提交 355f5ab9 编写于 作者: P Peter Krempa

qemu: hotplug: Don't save status XML when monitor is closed

In the vcpu hotplug code if exit from the monitor failed we would still
attempt to save the status XML. When the daemon is terminated the
monitor socket is closed. In such case, the written status XML would not
contain the monitor path and thus be invalid.

Avoid this issue by only saving status XML on success of the monitor
command.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1439452
上级 f24dc5e2
...@@ -5386,6 +5386,7 @@ qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver, ...@@ -5386,6 +5386,7 @@ qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver,
static int static int
qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
virQEMUDriverConfigPtr cfg,
virDomainObjPtr vm, virDomainObjPtr vm,
unsigned int vcpu) unsigned int vcpu)
{ {
...@@ -5427,6 +5428,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, ...@@ -5427,6 +5428,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
if (qemuDomainRemoveVcpu(driver, vm, vcpu) < 0) if (qemuDomainRemoveVcpu(driver, vm, vcpu) < 0)
goto cleanup; goto cleanup;
qemuDomainVcpuPersistOrder(vm->def);
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
goto cleanup;
ret = 0; ret = 0;
cleanup: cleanup:
...@@ -5437,6 +5443,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, ...@@ -5437,6 +5443,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
static int static int
qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
virQEMUDriverConfigPtr cfg,
virDomainObjPtr vm, virDomainObjPtr vm,
unsigned int vcpu) unsigned int vcpu)
{ {
...@@ -5497,6 +5504,11 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, ...@@ -5497,6 +5504,11 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
if (qemuDomainValidateVcpuInfo(vm) < 0) if (qemuDomainValidateVcpuInfo(vm) < 0)
goto cleanup; goto cleanup;
qemuDomainVcpuPersistOrder(vm->def);
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
goto cleanup;
ret = 0; ret = 0;
cleanup: cleanup:
...@@ -5611,7 +5623,6 @@ qemuDomainSetVcpusLive(virQEMUDriverPtr driver, ...@@ -5611,7 +5623,6 @@ qemuDomainSetVcpusLive(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
qemuCgroupEmulatorAllNodesDataPtr emulatorCgroup = NULL; qemuCgroupEmulatorAllNodesDataPtr emulatorCgroup = NULL;
ssize_t nextvcpu = -1; ssize_t nextvcpu = -1;
int rc = 0;
int ret = -1; int ret = -1;
if (qemuCgroupEmulatorAllNodesAllow(priv->cgroup, &emulatorCgroup) < 0) if (qemuCgroupEmulatorAllNodesAllow(priv->cgroup, &emulatorCgroup) < 0)
...@@ -5619,27 +5630,19 @@ qemuDomainSetVcpusLive(virQEMUDriverPtr driver, ...@@ -5619,27 +5630,19 @@ qemuDomainSetVcpusLive(virQEMUDriverPtr driver,
if (enable) { if (enable) {
while ((nextvcpu = virBitmapNextSetBit(vcpumap, nextvcpu)) != -1) { while ((nextvcpu = virBitmapNextSetBit(vcpumap, nextvcpu)) != -1) {
if ((rc = qemuDomainHotplugAddVcpu(driver, vm, nextvcpu)) < 0) if (qemuDomainHotplugAddVcpu(driver, cfg, vm, nextvcpu) < 0)
break; goto cleanup;
} }
} else { } else {
for (nextvcpu = virDomainDefGetVcpusMax(vm->def) - 1; nextvcpu >= 0; nextvcpu--) { for (nextvcpu = virDomainDefGetVcpusMax(vm->def) - 1; nextvcpu >= 0; nextvcpu--) {
if (!virBitmapIsBitSet(vcpumap, nextvcpu)) if (!virBitmapIsBitSet(vcpumap, nextvcpu))
continue; continue;
if ((rc = qemuDomainHotplugDelVcpu(driver, vm, nextvcpu)) < 0) if (qemuDomainHotplugDelVcpu(driver, cfg, vm, nextvcpu) < 0)
break; goto cleanup;
} }
} }
qemuDomainVcpuPersistOrder(vm->def);
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
goto cleanup;
if (rc < 0)
goto cleanup;
ret = 0; ret = 0;
cleanup: cleanup:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册