[PATCH 1/9] lxc: rename vmdef to persistentDef

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

 



A few functions using virDomainLiveConfigHelperMethod use the generic
name 'vmdef' to point to the persistent definition.

Use persistentDef and/or persistentDefCopy to make its purpose obvious.
---
 src/lxc/lxc_driver.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index f0948ea..e854f35 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -806,7 +806,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
                              unsigned int flags)
 {
     virCapsPtr caps = NULL;
-    virDomainDefPtr vmdef = NULL;
+    virDomainDefPtr persistentDef = NULL;
     virDomainObjPtr vm = NULL;
     virLXCDomainObjPrivatePtr priv = NULL;
     virLXCDriverConfigPtr cfg = NULL;
@@ -847,7 +847,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
         goto cleanup;
 
     if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
-                                        vm, &flags, &vmdef) < 0)
+                                        vm, &flags, &persistentDef) < 0)
         goto endjob;
 
     if (flags & VIR_DOMAIN_AFFECT_LIVE &&
@@ -903,7 +903,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
         }                                                                       \
                                                                                 \
         if (flags & VIR_DOMAIN_AFFECT_CONFIG)                                   \
-            vmdef->mem.VALUE = VALUE;                                           \
+            persistentDef->mem.VALUE = VALUE;                                   \
     }
 
     /* Soft limit doesn't clash with the others */
@@ -924,7 +924,7 @@ lxcDomainSetMemoryParameters(virDomainPtr dom,
 #undef LXC_SET_MEM_PARAMETER
 
     if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
-        virDomainSaveConfig(cfg->configDir, driver->caps, vmdef) < 0)
+        virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0)
         goto endjob;
 
     ret = 0;
@@ -946,7 +946,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
                              unsigned int flags)
 {
     virCapsPtr caps = NULL;
-    virDomainDefPtr vmdef = NULL;
+    virDomainDefPtr persistentDef = NULL;
     virDomainObjPtr vm = NULL;
     virLXCDomainObjPrivatePtr priv = NULL;
     virLXCDriverPtr driver = dom->conn->privateData;
@@ -969,7 +969,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
     if (virDomainGetMemoryParametersEnsureACL(dom->conn, vm->def) < 0 ||
         !(caps = virLXCDriverGetCapabilities(driver, false)) ||
         virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
-                                        vm, &flags, &vmdef) < 0)
+                                        vm, &flags, &persistentDef) < 0)
         goto cleanup;
 
     if (flags & VIR_DOMAIN_AFFECT_LIVE &&
@@ -993,7 +993,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
         switch (i) {
         case 0: /* fill memory hard limit here */
             if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
-                val = vmdef->mem.hard_limit;
+                val = persistentDef->mem.hard_limit;
             } else if (virCgroupGetMemoryHardLimit(priv->cgroup, &val) < 0) {
                 goto cleanup;
             }
@@ -1003,7 +1003,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
             break;
         case 1: /* fill memory soft limit here */
             if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
-                val = vmdef->mem.soft_limit;
+                val = persistentDef->mem.soft_limit;
             } else if (virCgroupGetMemorySoftLimit(priv->cgroup, &val) < 0) {
                 goto cleanup;
             }
@@ -1013,7 +1013,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
             break;
         case 2: /* fill swap hard limit here */
             if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
-                val = vmdef->mem.swap_hard_limit;
+                val = persistentDef->mem.swap_hard_limit;
             } else if (virCgroupGetMemSwapHardLimit(priv->cgroup, &val) < 0) {
                 goto cleanup;
             }
@@ -1951,7 +1951,8 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
     virCapsPtr caps = NULL;
     size_t i;
     virDomainObjPtr vm = NULL;
-    virDomainDefPtr vmdef = NULL;
+    virDomainDefPtr persistentDefCopy = NULL;
+    virDomainDefPtr persistentDef = NULL;
     int ret = -1;
     int rc;
     virLXCDomainObjPrivatePtr priv;
@@ -1984,13 +1985,13 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
         goto cleanup;
 
     if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
-                                        vm, &flags, &vmdef) < 0)
+                                        vm, &flags, &persistentDef) < 0)
         goto endjob;
 
     if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
         /* Make a copy for updated domain. */
-        vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
-        if (!vmdef)
+        persistentDefCopy = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
+        if (!persistentDefCopy)
             goto endjob;
     }
 
@@ -2019,8 +2020,8 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
             }
 
             if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
-                vmdef->cputune.shares = params[i].value.ul;
-                vmdef->cputune.sharesSpecified = true;
+                persistentDefCopy->cputune.shares = params[i].value.ul;
+                persistentDefCopy->cputune.sharesSpecified = true;
             }
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)) {
             if (flags & VIR_DOMAIN_AFFECT_LIVE) {
@@ -2033,7 +2034,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
             }
 
             if (flags & VIR_DOMAIN_AFFECT_CONFIG)
-                vmdef->cputune.period = params[i].value.ul;
+                persistentDefCopy->cputune.period = params[i].value.ul;
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA)) {
             if (flags & VIR_DOMAIN_AFFECT_LIVE) {
                 rc = lxcSetVcpuBWLive(priv->cgroup, 0, params[i].value.l);
@@ -2045,7 +2046,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
             }
 
             if (flags & VIR_DOMAIN_AFFECT_CONFIG)
-                vmdef->cputune.quota = params[i].value.l;
+                persistentDefCopy->cputune.quota = params[i].value.l;
         }
     }
 
@@ -2054,12 +2055,12 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
 
 
     if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
-        rc = virDomainSaveConfig(cfg->configDir, driver->caps, vmdef);
+        rc = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDefCopy);
         if (rc < 0)
             goto endjob;
 
-        virDomainObjAssignDef(vm, vmdef, false, NULL);
-        vmdef = NULL;
+        virDomainObjAssignDef(vm, persistentDefCopy, false, NULL);
+        persistentDefCopy = NULL;
     }
 
     ret = 0;
@@ -2068,7 +2069,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
     virLXCDomainObjEndJob(driver, vm);
 
  cleanup:
-    virDomainDefFree(vmdef);
+    virDomainDefFree(persistentDefCopy);
     virDomainObjEndAPI(&vm);
     virObjectUnref(caps);
     virObjectUnref(cfg);
-- 
2.7.3

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