提交 04597f8f 编写于 作者: J Jim Fehlig

libxl: Set def->vcpus after successfully modifying live vcpu count

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: NJim Fehlig <jfehlig@suse.com>
上级 33be48d7
...@@ -2101,6 +2101,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, ...@@ -2101,6 +2101,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
" with libxenlight"), vm->def->id); " with libxenlight"), vm->def->id);
goto endjob; goto endjob;
} }
vm->def->vcpus = nvcpus;
break; break;
case VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG: case VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG:
...@@ -2110,14 +2111,25 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, ...@@ -2110,14 +2111,25 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
" with libxenlight"), vm->def->id); " with libxenlight"), vm->def->id);
goto endjob; goto endjob;
} }
vm->def->vcpus = nvcpus;
def->vcpus = nvcpus; def->vcpus = nvcpus;
break; break;
} }
ret = 0; ret = 0;
if (flags & VIR_DOMAIN_VCPU_CONFIG) if (flags & VIR_DOMAIN_VCPU_LIVE) {
ret = virDomainSaveConfig(cfg->configDir, def); 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: endjob:
if (!libxlDomainObjEndJob(driver, vm)) if (!libxlDomainObjEndJob(driver, vm))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册