提交 8cf65dab 编写于 作者: P Peter Krempa

qemu: cpu hotplug: Fix error handling logic

The cpu hotplug helper functions used negative error handling in a part
of them, although some code that was added later didn't properly set the
error codes in some cases. This would cause improper error messages in
cases where we couldn't modify the numa cpu mask and a few other cases.

Fix the logic by converting it to the regularly used pattern.
上级 bb1d8d7a
......@@ -4721,10 +4721,6 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
vcpus++;
}
/* hotplug succeeded */
ret = 0;
/* After hotplugging the CPUs we need to re-detect threads corresponding
* to the virtual CPUs. Some older versions don't provide the thread ID
* or don't have the "info cpus" command (and they don't support multiple
......@@ -4732,12 +4728,12 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
* fatal */
if ((ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids)) <= 0) {
virResetLastError();
ret = 0;
goto exit_monitor;
}
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
ret = -1;
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
}
if (ncpupids != vcpus) {
virReportError(VIR_ERR_INTERNAL_ERROR,
......@@ -4745,7 +4741,6 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
"got %d, wanted %d"),
ncpupids, vcpus);
vcpus = oldvcpus;
ret = -1;
goto cleanup;
}
......@@ -4771,15 +4766,12 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
if (vm->def->cpumask) {
if (qemuDomainHotplugAddPin(vm->def->cpumask, i,
&vm->def->cputune.vcpupin,
&vm->def->cputune.nvcpupin) < 0) {
ret = -1;
&vm->def->cputune.nvcpupin) < 0)
goto cleanup;
}
if (qemuDomainHotplugPinThread(vm->def->cpumask, i, cpupids[i],
cgroup_vcpu) < 0) {
ret = -1;
cgroup_vcpu) < 0)
goto cleanup;
}
}
virCgroupFree(&cgroup_vcpu);
......@@ -4794,6 +4786,8 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
priv->vcpupids = cpupids;
cpupids = NULL;
ret = 0;
cleanup:
VIR_FREE(cpupids);
VIR_FREE(mem_mask);
......@@ -4841,8 +4835,6 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
vcpus--;
}
ret = 0;
/* After hotplugging the CPUs we need to re-detect threads corresponding
* to the virtual CPUs. Some older versions don't provide the thread ID
* or don't have the "info cpus" command (and they don't support multiple
......@@ -4850,19 +4842,17 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
* fatal */
if ((ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids)) <= 0) {
virResetLastError();
ret = 0;
goto exit_monitor;
}
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
ret = -1;
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
}
/* check if hotunplug has failed */
if (ncpupids == oldvcpus) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("qemu didn't unplug the vCPUs properly"));
vcpus = oldvcpus;
ret = -1;
goto cleanup;
}
......@@ -4872,7 +4862,6 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
"got %d, wanted %d"),
ncpupids, vcpus);
vcpus = oldvcpus;
ret = -1;
goto cleanup;
}
......@@ -4892,6 +4881,8 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
priv->vcpupids = cpupids;
cpupids = NULL;
ret = 0;
cleanup:
VIR_FREE(cpupids);
if (virDomainObjIsActive(vm) &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册