提交 a0be049f 编写于 作者: P Peter Krempa 提交者: Cole Robinson

qemu: Refactor qemuDomainSetVcpusFlags

This patch changes a switch statement into ifs when handling live vs.
configuration modifications getting rid of redundant code in case when
both live and persistent configuration gets changed.
(cherry picked from commit e99ad93d)
上级 48b9eb2d
...@@ -3455,8 +3455,12 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, ...@@ -3455,8 +3455,12 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
goto endjob; goto endjob;
} }
switch (flags) { if (flags & VIR_DOMAIN_AFFECT_LIVE) {
case VIR_DOMAIN_AFFECT_CONFIG: if (qemudDomainHotplugVcpus(driver, vm, nvcpus) < 0)
goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (maximum) { if (maximum) {
persistentDef->maxvcpus = nvcpus; persistentDef->maxvcpus = nvcpus;
if (nvcpus < persistentDef->vcpus) if (nvcpus < persistentDef->vcpus)
...@@ -3464,24 +3468,12 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, ...@@ -3464,24 +3468,12 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
} else { } else {
persistentDef->vcpus = nvcpus; persistentDef->vcpus = nvcpus;
} }
ret = 0;
break;
case VIR_DOMAIN_AFFECT_LIVE:
ret = qemudDomainHotplugVcpus(driver, vm, nvcpus);
break;
case VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG: if (virDomainSaveConfig(driver->configDir, persistentDef) < 0)
ret = qemudDomainHotplugVcpus(driver, vm, nvcpus); goto endjob;
if (ret == 0) {
persistentDef->vcpus = nvcpus;
}
break;
} }
/* Save the persistent config to disk */ ret = 0;
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
ret = virDomainSaveConfig(driver->configDir, persistentDef);
endjob: endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) if (qemuDomainObjEndJob(driver, vm) == 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册