]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxl: Set def->vcpus after successfully modifying live vcpu count
authorJim Fehlig <jfehlig@suse.com>
Mon, 29 Jun 2015 16:46:36 +0000 (10:46 -0600)
committerJim Fehlig <jfehlig@suse.com>
Tue, 30 Jun 2015 17:02:30 +0000 (11:02 -0600)
def->vcpus was never updated after successfully changing the live
vcpu count of a domain. Subsequent queries for vcpu info would
return incorrect results.  E.g.:

virsh vcpucount test
maximum      config         4
maximum      live           4
current      config         4
current      live           4

virsh setvcpus test 2

virsh vcpucount test
maximum      config         4
maximum      live           4
current      config         4
current      live           4

After patch, live current config is reported correctly:

virsh vcpucount test
maximum      config         4
maximum      live           4
current      config         4
current      live           2

While fixing this, noticed that the live config was not saved
to cfg->stateDir via virDomainSaveStatus. Save the live config
and change error handling of virDomainSave{Config,Status} to
log a message via VIR_WARN, instead of failing the entire
DomainSetVcpusFlags operation.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
src/libxl/libxl_driver.c

index bf871de23f1641a0a8fa3a35d3520d681b25629b..149ef704966c134f16aefb796993e3bddd8db9e2 100644 (file)
@@ -2101,6 +2101,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
                              " with libxenlight"), vm->def->id);
             goto endjob;
         }
+        vm->def->vcpus = nvcpus;
         break;
 
     case VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG:
@@ -2110,14 +2111,25 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
                              " with libxenlight"), vm->def->id);
             goto endjob;
         }
+        vm->def->vcpus = nvcpus;
         def->vcpus = nvcpus;
         break;
     }
 
     ret = 0;
 
-    if (flags & VIR_DOMAIN_VCPU_CONFIG)
-        ret = virDomainSaveConfig(cfg->configDir, def);
+    if (flags & VIR_DOMAIN_VCPU_LIVE) {
+        if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) {
+            VIR_WARN("Unable to save status on vm %s after changing vcpus",
+                     vm->def->name);
+        }
+    }
+    if (flags & VIR_DOMAIN_VCPU_CONFIG) {
+        if (virDomainSaveConfig(cfg->configDir, def) < 0) {
+            VIR_WARN("Unable to save configuration of vm %s after changing vcpus",
+                     vm->def->name);
+        }
+    }
 
  endjob:
     if (!libxlDomainObjEndJob(driver, vm))