From: Derbyshev Dmitry <dderbyshev(a)virtuozzo.com>
Is necessary to call it from other contexts, such as qemuDomainGetStatsBalloon.
Signed-off-by: Derbyshev Dmitry <dderbyshev(a)virtuozzo.com>
---
src/qemu/qemu_driver.c | 55 ++++++++++++++++++++++++++++++++------------------
1 file changed, 35 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2089359..0b76177 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10957,32 +10957,22 @@ qemuDomainGetInterfaceParameters(virDomainPtr dom,
return ret;
}
+/* This functions assumes that job QEMU_JOB_QUERY is started by a caller */
+
static int
-qemuDomainMemoryStats(virDomainPtr dom,
- virDomainMemoryStatPtr stats,
- unsigned int nr_stats,
- unsigned int flags)
+qemuDomainMemoryStatsInternal(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainMemoryStatPtr stats,
+ unsigned int nr_stats)
+
{
- virQEMUDriverPtr driver = dom->conn->privateData;
- virDomainObjPtr vm;
int ret = -1;
long rss;
- virCheckFlags(0, -1);
-
- if (!(vm = qemuDomObjFromDomain(dom)))
- goto cleanup;
-
- if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0)
- goto cleanup;
-
- if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
- goto cleanup;
-
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
- goto endjob;
+ return -1;
}
if (vm->def->memballoon &&
@@ -10993,7 +10983,7 @@ qemuDomainMemoryStats(virDomainPtr dom,
ret = -1;
if (ret < 0 || ret >= nr_stats)
- goto endjob;
+ return ret;
} else {
ret = 0;
}
@@ -11007,7 +10997,32 @@ qemuDomainMemoryStats(virDomainPtr dom,
ret++;
}
- endjob:
+ return ret;
+}
+
+static int
+qemuDomainMemoryStats(virDomainPtr dom,
+ virDomainMemoryStatPtr stats,
+ unsigned int nr_stats,
+ unsigned int flags)
+{
+ virQEMUDriverPtr driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ int ret = -1;
+
+ virCheckFlags(0, -1);
+
+ if (!(vm = qemuDomObjFromDomain(dom)))
+ goto cleanup;
+
+ if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
+ goto cleanup;
+
+ ret = qemuDomainMemoryStatsInternal(driver, vm, stats, nr_stats);
+
qemuDomainObjEndJob(driver, vm);
cleanup:
--
1.9.5.msysgit.0