[PATCH 17/24] numa: conf: Tweak parameters of virDomainNumatuneSet

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

 



As virDomainNumatuneSet now doesn't allocate the virDomainNuma object
any longer it's not necessary to pass the pointer to a pointer to store
the object as it will not change any longer.

While touching the parameter definitions I've also changed the name of
the parameter to "numa".
---
 src/conf/numa_conf.c   | 28 +++++++++++++---------------
 src/conf/numa_conf.h   |  2 +-
 src/lxc/lxc_native.c   |  2 +-
 src/qemu/qemu_driver.c |  4 ++--
 4 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
index 70a38d6..1b8232e 100644
--- a/src/conf/numa_conf.c
+++ b/src/conf/numa_conf.c
@@ -245,7 +245,7 @@ virDomainNumatuneParseXML(virDomainNumaPtr *numatunePtr,
         VIR_FREE(tmp);
     }

-    if (virDomainNumatuneSet(numatunePtr,
+    if (virDomainNumatuneSet(*numatunePtr,
                              placement_static,
                              placement,
                              mode,
@@ -438,20 +438,19 @@ virDomainNumatuneMaybeFormatNodeset(virDomainNumaPtr numatune,
 }

 int
-virDomainNumatuneSet(virDomainNumaPtr *numatunePtr,
+virDomainNumatuneSet(virDomainNumaPtr numa,
                      bool placement_static,
                      int placement,
                      int mode,
                      virBitmapPtr nodeset)
 {
     int ret = -1;
-    virDomainNumaPtr numatune = *numatunePtr;

     /* No need to do anything in this case */
     if (mode == -1 && placement == -1 && !nodeset)
         return 0;

-    if (!numatune->memory.specified) {
+    if (!numa->memory.specified) {
         if (mode == -1)
             mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
         if (placement == -1)
@@ -476,26 +475,25 @@ virDomainNumatuneSet(virDomainNumaPtr *numatunePtr,
     }

     if (mode != -1)
-        numatune->memory.mode = mode;
+        numa->memory.mode = mode;

     if (nodeset) {
-        virBitmapFree(numatune->memory.nodeset);
-        numatune->memory.nodeset = virBitmapNewCopy(nodeset);
-        if (!numatune->memory.nodeset)
+        virBitmapFree(numa->memory.nodeset);
+        if (!(numa->memory.nodeset = virBitmapNewCopy(nodeset)))
             goto cleanup;
         if (placement == -1)
             placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC;
     }

     if (placement == VIR_DOMAIN_NUMATUNE_PLACEMENT_DEFAULT) {
-        if (numatune->memory.nodeset || placement_static)
+        if (numa->memory.nodeset || placement_static)
             placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC;
         else
             placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO;
     }

     if (placement == VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC &&
-        !numatune->memory.nodeset) {
+        !numa->memory.nodeset) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("nodeset for NUMA memory tuning must be set "
                          "if 'placement' is 'static'"));
@@ -504,15 +502,15 @@ virDomainNumatuneSet(virDomainNumaPtr *numatunePtr,

     /* setting nodeset when placement auto is invalid */
     if (placement == VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO &&
-        numatune->memory.nodeset) {
-        virBitmapFree(numatune->memory.nodeset);
-        numatune->memory.nodeset = NULL;
+        numa->memory.nodeset) {
+        virBitmapFree(numa->memory.nodeset);
+        numa->memory.nodeset = NULL;
     }

     if (placement != -1)
-        numatune->memory.placement = placement;
+        numa->memory.placement = placement;

-    numatune->memory.specified = true;
+    numa->memory.specified = true;

     ret = 0;

diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h
index e69489d..790f3bf 100644
--- a/src/conf/numa_conf.h
+++ b/src/conf/numa_conf.h
@@ -101,7 +101,7 @@ int virDomainNumatuneMaybeFormatNodeset(virDomainNumaPtr numatune,
 /*
  * Setters
  */
-int virDomainNumatuneSet(virDomainNumaPtr *numatunePtr,
+int virDomainNumatuneSet(virDomainNumaPtr numa,
                          bool placement_static,
                          int placement,
                          int mode,
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 99613af..abf07ce 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -847,7 +847,7 @@ lxcSetCpusetTune(virDomainDefPtr def, virConfPtr properties)
         value->str) {
         if (virBitmapParse(value->str, 0, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0)
             return -1;
-        if (virDomainNumatuneSet(&def->numa,
+        if (virDomainNumatuneSet(def->numa,
                                  def->placement_mode ==
                                  VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
                                  VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1c2ace9..0706303 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9543,7 +9543,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
             qemuDomainSetNumaParamsLive(vm, nodeset) < 0)
             goto endjob;

-        if (virDomainNumatuneSet(&vm->def->numa,
+        if (virDomainNumatuneSet(vm->def->numa,
                                  vm->def->placement_mode ==
                                  VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
                                  -1, mode, nodeset) < 0)
@@ -9554,7 +9554,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
     }

     if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
-        if (virDomainNumatuneSet(&persistentDef->numa,
+        if (virDomainNumatuneSet(persistentDef->numa,
                                  persistentDef->placement_mode ==
                                  VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
                                  -1, mode, nodeset) < 0)
-- 
2.2.2

--
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]