On 20.02.2014 16:34, Daniel P. Berrange wrote:
The virCgroupXXX APIs' return value must be checked for
being less than 0, not equal to 0.

An VIR_ERR_OPERATION_INVALID error must also be raised
when the VM is not running to prevent a crash on NULL
priv->cgroup field.

Signed-off-by: Daniel P. Berrange <[email protected]>
---
  src/lxc/lxc_driver.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 50910df..10e0fbb 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -5410,13 +5410,16 @@ lxcDomainMemoryStats(virDomainPtr dom,
      if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0)
          goto cleanup;

-    if (!virCgroupGetMemSwapUsage(priv->cgroup, &swap_usage))
+    if (!virDomainObjIsActive(vm)) {
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("domain is not active"));
          goto cleanup;
+    }

-    if (!virCgroupGetMemoryUsage(priv->cgroup, &mem_usage))
+    if (virCgroupGetMemSwapUsage(priv->cgroup, &swap_usage) < 0)
          goto cleanup;

-    if (!virDomainObjIsActive(vm))
+    if (virCgroupGetMemoryUsage(priv->cgroup, &mem_usage) < 0)
          goto cleanup;

      ret = 0;


ACK

Michal

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to