[libvirt] [PATCH] qemu: Fix numatune nodeset reporting

Martin Kletzander mkletzan at redhat.com
Mon May 18 23:05:53 UTC 2015


Since af2a1f0587d88656f2c14265a63fbc11ecbd924e,
qemuDomainGetNumaParameters() returns invalid value for a running
guest.  The problem is that it is getting the information from cgroups,
but the parent cgroup is being left alone since the mentioned commit.
Since the running guest's XML is in sync with cgroups, there is no need
to look into cgroups (unless someone changes the configuration behind
libvirt's back).  Returning the info from the definition fixes a bug and
is also a cleanup.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1221047
Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/qemu/qemu_driver.c | 35 ++++++++++-------------------------
 1 file changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8c00cdc..0cc0a29 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10523,7 +10523,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
     char *nodeset = NULL;
     int ret = -1;
     virCapsPtr caps = NULL;
-    qemuDomainObjPrivatePtr priv;
+    virDomainDefPtr def = NULL;

     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG |
@@ -10537,8 +10537,6 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
     if (!(vm = qemuDomObjFromDomain(dom)))
         return -1;

-    priv = vm->privateData;
-
     if (virDomainGetNumaParametersEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;

@@ -10555,6 +10553,11 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
         goto cleanup;
     }

+    if (flags & VIR_DOMAIN_AFFECT_CONFIG)
+        def = persistentDef;
+    else
+        def = vm->def;
+
     for (i = 0; i < QEMU_NB_NUMA_PARAM && i < *nparams; i++) {
         virMemoryParameterPtr param = &params[i];

@@ -10564,35 +10567,17 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
                                         VIR_TYPED_PARAM_INT, 0) < 0)
                 goto cleanup;

-            if (flags & VIR_DOMAIN_AFFECT_CONFIG)
-                param->value.i = virDomainNumatuneGetMode(persistentDef->numa, -1);
-            else
-                param->value.i = virDomainNumatuneGetMode(vm->def->numa, -1);
+            param->value.i = virDomainNumatuneGetMode(def->numa, -1);
             break;

         case 1: /* fill numa nodeset here */
-            if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
-                nodeset = virDomainNumatuneFormatNodeset(persistentDef->numa,
-                                                         NULL, -1);
-                if (!nodeset)
-                    goto cleanup;
-            } else {
-                if (!virCgroupHasController(priv->cgroup,
-                                            VIR_CGROUP_CONTROLLER_CPUSET) ||
-                    virCgroupGetCpusetMems(priv->cgroup, &nodeset) < 0) {
-                    nodeset = virDomainNumatuneFormatNodeset(vm->def->numa,
-                                                             NULL, -1);
-                    if (!nodeset)
-                        goto cleanup;
-                }
-            }
-
-            if (virTypedParameterAssign(param, VIR_DOMAIN_NUMA_NODESET,
+            nodeset = virDomainNumatuneFormatNodeset(def->numa, NULL, -1);
+            if (!nodeset ||
+                virTypedParameterAssign(param, VIR_DOMAIN_NUMA_NODESET,
                                         VIR_TYPED_PARAM_STRING, nodeset) < 0)
                 goto cleanup;

             nodeset = NULL;
-
             break;

         /* coverity[dead_error_begin] */
-- 
2.4.0




More information about the libvir-list mailing list