[PATCH 4/6] qemu: Save numad advice into qemuDomainObjPrivate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks to that we don't need to drag the pointer everywhere and future
code will get cleaner.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/qemu/qemu_cgroup.c  | 18 +++++++-----------
 src/qemu/qemu_cgroup.h  |  9 +++------
 src/qemu/qemu_domain.c  |  1 +
 src/qemu/qemu_domain.h  |  1 +
 src/qemu/qemu_process.c | 21 ++++++++++-----------
 5 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index ed5416b..a0370bc 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -608,8 +608,7 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,


 int
-qemuSetupCpusetMems(virDomainObjPtr vm,
-                    virBitmapPtr nodemask)
+qemuSetupCpusetMems(virDomainObjPtr vm)
 {
     virCgroupPtr cgroup_temp = NULL;
     qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -624,7 +623,7 @@ qemuSetupCpusetMems(virDomainObjPtr vm,
         return 0;

     if (virDomainNumatuneMaybeFormatNodeset(vm->def->numatune,
-                                            nodemask,
+                                            priv->autoNodeset,
                                             &mem_mask, -1) < 0)
         goto cleanup;

@@ -644,7 +643,6 @@ qemuSetupCpusetMems(virDomainObjPtr vm,

 static int
 qemuSetupCpusetCgroup(virDomainObjPtr vm,
-                      virBitmapPtr nodemask,
                       virCapsPtr caps)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -659,7 +657,7 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm,

         if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
             virBitmapPtr cpumap;
-            if (!(cpumap = virCapabilitiesGetCpusForNodemask(caps, nodemask)))
+            if (!(cpumap = virCapabilitiesGetCpusForNodemask(caps, priv->autoNodeset)))
                 goto cleanup;
             cpu_mask = virBitmapFormat(cpumap);
             virBitmapFree(cpumap);
@@ -823,8 +821,7 @@ qemuConnectCgroup(virQEMUDriverPtr driver,

 int
 qemuSetupCgroup(virQEMUDriverPtr driver,
-                virDomainObjPtr vm,
-                virBitmapPtr nodemask)
+                virDomainObjPtr vm)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virCapsPtr caps = NULL;
@@ -857,7 +854,7 @@ qemuSetupCgroup(virQEMUDriverPtr driver,
     if (qemuSetupCpuCgroup(driver, vm) < 0)
         goto cleanup;

-    if (qemuSetupCpusetCgroup(vm, nodemask, caps) < 0)
+    if (qemuSetupCpusetCgroup(vm, caps) < 0)
         goto cleanup;

     ret = 0;
@@ -1042,8 +1039,7 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm)

 int
 qemuSetupCgroupForEmulator(virQEMUDriverPtr driver,
-                           virDomainObjPtr vm,
-                           virBitmapPtr nodemask)
+                           virDomainObjPtr vm)
 {
     virBitmapPtr cpumask = NULL;
     virBitmapPtr cpumap = NULL;
@@ -1079,7 +1075,7 @@ qemuSetupCgroupForEmulator(virQEMUDriverPtr driver,
         goto cleanup;

     if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
-        if (!(cpumap = qemuPrepareCpumap(driver, nodemask)))
+        if (!(cpumap = qemuPrepareCpumap(driver, priv->autoNodeset)))
             goto cleanup;
         cpumask = cpumap;
     } else if (def->cputune.emulatorpin) {
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
index 72c28f7..df7e3a1 100644
--- a/src/qemu/qemu_cgroup.h
+++ b/src/qemu/qemu_cgroup.h
@@ -45,10 +45,8 @@ int qemuTeardownHostdevCgroup(virDomainObjPtr vm,
 int qemuConnectCgroup(virQEMUDriverPtr driver,
                       virDomainObjPtr vm);
 int qemuSetupCgroup(virQEMUDriverPtr driver,
-                    virDomainObjPtr vm,
-                    virBitmapPtr nodemask);
-int qemuSetupCpusetMems(virDomainObjPtr vm,
-                        virBitmapPtr nodemask);
+                    virDomainObjPtr vm);
+int qemuSetupCpusetMems(virDomainObjPtr vm);
 int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
                           unsigned long long period,
                           long long quota);
@@ -64,8 +62,7 @@ int qemuSetupCgroupIOThreadsPin(virCgroupPtr cgroup,
 int qemuSetupCgroupForVcpu(virDomainObjPtr vm);
 int qemuSetupCgroupForIOThreads(virDomainObjPtr vm);
 int qemuSetupCgroupForEmulator(virQEMUDriverPtr driver,
-                               virDomainObjPtr vm,
-                               virBitmapPtr nodemask);
+                               virDomainObjPtr vm);
 int qemuRemoveCgroup(virQEMUDriverPtr driver, virDomainObjPtr vm);
 int qemuAddToCgroup(virDomainObjPtr vm);

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 220304f..8dd427a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -451,6 +451,7 @@ qemuDomainObjPrivateFree(void *data)
         qemuAgentClose(priv->agent);
     }
     VIR_FREE(priv->cleanupCallbacks);
+    virBitmapFree(priv->autoNodeset);
     VIR_FREE(priv);
 }

diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index efabd82..ce5eba3 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -187,6 +187,7 @@ struct _qemuDomainObjPrivate {
     char **qemuDevices; /* NULL-terminated list of devices aliases known to QEMU */

     bool hookRun;  /* true if there was a hook run over this domain */
+    virBitmapPtr autoNodeset;
 };

 typedef enum {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9781e44..d683918 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2377,12 +2377,12 @@ qemuPrepareCpumap(virQEMUDriverPtr driver,
  */
 static int
 qemuProcessInitCpuAffinity(virQEMUDriverPtr driver,
-                           virDomainObjPtr vm,
-                           virBitmapPtr nodemask)
+                           virDomainObjPtr vm)
 {
     int ret = -1;
     virBitmapPtr cpumap = NULL;
     virBitmapPtr cpumapToSet = NULL;
+    qemuDomainObjPrivatePtr priv = vm->privateData;

     if (!vm->pid) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -2390,7 +2390,7 @@ qemuProcessInitCpuAffinity(virQEMUDriverPtr driver,
         return -1;
     }

-    if (!(cpumap = qemuPrepareCpumap(driver, nodemask)))
+    if (!(cpumap = qemuPrepareCpumap(driver, priv->autoNodeset)))
         return -1;

     if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
@@ -3041,13 +3041,13 @@ struct qemuProcessHookData {
     virConnectPtr conn;
     virDomainObjPtr vm;
     virQEMUDriverPtr driver;
-    virBitmapPtr nodemask;
     virQEMUDriverConfigPtr cfg;
 };

 static int qemuProcessHook(void *data)
 {
     struct qemuProcessHookData *h = data;
+    qemuDomainObjPrivatePtr priv = h->vm->privateData;
     int ret = -1;
     int fd;
     virBitmapPtr nodeset = NULL;
@@ -3084,7 +3084,7 @@ static int qemuProcessHook(void *data)

     mode = virDomainNumatuneGetMode(h->vm->def->numatune, -1);
     nodeset = virDomainNumatuneGetNodeset(h->vm->def->numatune,
-                                          h->nodemask, -1);
+                                          priv->autoNodeset, -1);

     if (virNumaSetupMemoryPolicy(mode, nodeset) < 0)
         goto cleanup;
@@ -4426,7 +4426,7 @@ int qemuProcessStart(virConnectPtr conn,
         if (virBitmapParse(nodeset, 0, &nodemask, VIR_DOMAIN_CPUMASK_LEN) < 0)
             goto cleanup;
     }
-    hookData.nodemask = nodemask;
+    priv->autoNodeset = nodemask;

     /* "volume" type disk's source must be translated before
      * cgroup and security setting.
@@ -4630,13 +4630,13 @@ int qemuProcessStart(virConnectPtr conn,
     }

     VIR_DEBUG("Setting up domain cgroup (if required)");
-    if (qemuSetupCgroup(driver, vm, nodemask) < 0)
+    if (qemuSetupCgroup(driver, vm) < 0)
         goto cleanup;

     /* This must be done after cgroup placement to avoid resetting CPU
      * affinity */
     if (!vm->def->cputune.emulatorpin &&
-        qemuProcessInitCpuAffinity(driver, vm, nodemask) < 0)
+        qemuProcessInitCpuAffinity(driver, vm) < 0)
         goto cleanup;

     VIR_DEBUG("Setting domain security labels");
@@ -4683,7 +4683,7 @@ int qemuProcessStart(virConnectPtr conn,
         goto cleanup;

     VIR_DEBUG("Setting cgroup for emulator (if required)");
-    if (qemuSetupCgroupForEmulator(driver, vm, nodemask) < 0)
+    if (qemuSetupCgroupForEmulator(driver, vm) < 0)
         goto cleanup;

     VIR_DEBUG("Setting affinity of emulator threads");
@@ -4710,7 +4710,7 @@ int qemuProcessStart(virConnectPtr conn,
         goto cleanup;

     VIR_DEBUG("Setting up post-init cgroup restrictions");
-    if (qemuSetupCpusetMems(vm, nodemask) < 0)
+    if (qemuSetupCpusetMems(vm) < 0)
         goto cleanup;

     VIR_DEBUG("Detecting VCPU PIDs");
@@ -4848,7 +4848,6 @@ int qemuProcessStart(virConnectPtr conn,
      * if we failed to initialize the now running VM. kill it off and
      * pretend we never started it */
     VIR_FREE(nodeset);
-    virBitmapFree(nodemask);
     virCommandFree(cmd);
     VIR_FORCE_CLOSE(logfile);
     if (priv->mon)
-- 
2.2.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]