mirror of
https://github.com/libvirt/libvirt.git
synced 2026-09-03 20:53:04 -05:00
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: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user