提交 a190744a 编写于 作者: P Peter Krempa

qemu: cpu hotplug: Set vcpu state directly in the new structure

Avoid using virDomainDefSetVcpus when we can set it directly in the
structure.
上级 9bf284da
......@@ -4764,6 +4764,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
unsigned int vcpu)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainVcpuInfoPtr vcpuinfo;
int ret = -1;
int rc;
int oldvcpus = virDomainDefGetVcpus(vm->def);
......@@ -4773,6 +4774,15 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
char *mem_mask = NULL;
virDomainNumatuneMemMode mem_mode;
if (!(vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu)))
return -1;
if (vcpuinfo->online) {
virReportError(VIR_ERR_INVALID_ARG,
_("vCPU '%u' is already online"), vcpu);
return -1;
}
qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorSetCPU(priv->mon, vcpu, true);
......@@ -4788,7 +4798,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
if (rc < 0)
goto cleanup;
ignore_value(virDomainDefSetVcpus(vm->def, oldvcpus + 1));
vcpuinfo->online = true;
if (ncpupids < 0)
goto cleanup;
......@@ -4864,12 +4874,22 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
unsigned int vcpu)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainVcpuInfoPtr vcpuinfo;
int ret = -1;
int rc;
int oldvcpus = virDomainDefGetVcpus(vm->def);
pid_t *cpupids = NULL;
int ncpupids = 0;
if (!(vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu)))
return -1;
if (!vcpuinfo->online) {
virReportError(VIR_ERR_INVALID_ARG,
_("vCPU '%u' is already offline"), vcpu);
return -1;
}
qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorSetCPU(priv->mon, vcpu, false);
......@@ -4893,7 +4913,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
goto cleanup;
}
ignore_value(virDomainDefSetVcpus(vm->def, oldvcpus - 1));
vcpuinfo->online = false;
if (qemuDomainDelCgroupForThread(priv->cgroup,
VIR_CGROUP_THREAD_VCPU, vcpu) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册