[PATCH 3/9] Use virDomainObjGetDefs in lxcDomainSetSchedulerParametersFlags

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

 



On LXC domain startup we have already called virDomainObjSetDefTransient
to fill vm->newDef.

There is no need to call virDomainLiveConfigHelperMethod which has the
ability to fill newDef if it's NULL.
---
 src/lxc/lxc_driver.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 72a144b..363b0b0 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1945,6 +1945,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
     virCapsPtr caps = NULL;
     size_t i;
     virDomainObjPtr vm = NULL;
+    virDomainDefPtr def = NULL;
     virDomainDefPtr persistentDefCopy = NULL;
     virDomainDefPtr persistentDef = NULL;
     int ret = -1;
@@ -1978,18 +1979,17 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
     if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
         goto cleanup;
 
-    if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
-                                        vm, &flags, &persistentDef) < 0)
+    if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
         goto endjob;
 
-    if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+    if (persistentDef) {
         /* Make a copy for updated domain. */
         persistentDefCopy = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
         if (!persistentDefCopy)
             goto endjob;
     }
 
-    if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+    if (def) {
         if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
             virReportError(VIR_ERR_OPERATION_INVALID,
                            "%s", _("cgroup CPU controller is not mounted"));
@@ -2001,7 +2001,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
         virTypedParameterPtr param = &params[i];
 
         if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
-            if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+            if (def) {
                 unsigned long long val;
                 if (virCgroupSetCpuShares(priv->cgroup, params[i].value.ul) < 0)
                     goto endjob;
@@ -2009,37 +2009,37 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
                 if (virCgroupGetCpuShares(priv->cgroup, &val) < 0)
                     goto endjob;
 
-                vm->def->cputune.shares = val;
-                vm->def->cputune.sharesSpecified = true;
+                def->cputune.shares = val;
+                def->cputune.sharesSpecified = true;
             }
 
-            if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+            if (persistentDef) {
                 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) {
+            if (def) {
                 rc = lxcSetVcpuBWLive(priv->cgroup, params[i].value.ul, 0);
                 if (rc != 0)
                     goto endjob;
 
                 if (params[i].value.ul)
-                    vm->def->cputune.period = params[i].value.ul;
+                    def->cputune.period = params[i].value.ul;
             }
 
-            if (flags & VIR_DOMAIN_AFFECT_CONFIG)
+            if (persistentDef)
                 persistentDefCopy->cputune.period = params[i].value.ul;
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA)) {
-            if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+            if (def) {
                 rc = lxcSetVcpuBWLive(priv->cgroup, 0, params[i].value.l);
                 if (rc != 0)
                     goto endjob;
 
                 if (params[i].value.l)
-                    vm->def->cputune.quota = params[i].value.l;
+                    def->cputune.quota = params[i].value.l;
             }
 
-            if (flags & VIR_DOMAIN_AFFECT_CONFIG)
+            if (persistentDef)
                 persistentDefCopy->cputune.quota = params[i].value.l;
         }
     }
@@ -2048,7 +2048,7 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
         goto endjob;
 
 
-    if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+    if (persistentDef) {
         rc = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDefCopy);
         if (rc < 0)
             goto endjob;
-- 
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]