From deaeb480c5d5d0e03148d201998233b6116ac652 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 13 Oct 2021 16:28:20 +0200 Subject: [PATCH] qemuDomainHotplugAddVcpu: Remove legacy hotplug branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Report an error if the new hotplug is not supported and remove the alternate code paths. The modern cpu-hotplug code was introduced in qemu-2.7. We keep the capability so that proper errors are reported in case a platform doesn't support hotplug. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_hotplug.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a7b432b6f5..328b06245f 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6488,25 +6488,24 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver, virDomainVcpuDef *vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu); qemuDomainVcpuPrivate *vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpuinfo); unsigned int nvcpus = vcpupriv->vcpus; - bool newhotplug = qemuDomainSupportsNewVcpuHotplug(vm); int rc; int oldvcpus = virDomainDefGetVcpus(vm->def); size_t i; - if (newhotplug) { - vcpupriv->alias = g_strdup_printf("vcpu%u", vcpu); - - if (!(vcpuprops = qemuBuildHotpluggableCPUProps(vcpuinfo))) - return -1; + if (!qemuDomainSupportsNewVcpuHotplug(vm)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cpu hotplug is not supported")); + return -1; } + vcpupriv->alias = g_strdup_printf("vcpu%u", vcpu); + + if (!(vcpuprops = qemuBuildHotpluggableCPUProps(vcpuinfo))) + return -1; + qemuDomainObjEnterMonitor(driver, vm); - if (newhotplug) { - rc = qemuMonitorAddDeviceProps(qemuDomainGetMonitor(vm), &vcpuprops); - } else { - rc = qemuMonitorSetCPU(qemuDomainGetMonitor(vm), vcpu, true); - } + rc = qemuMonitorAddDeviceProps(qemuDomainGetMonitor(vm), &vcpuprops); if (qemuDomainObjExitMonitor(driver, vm) < 0) return -1; @@ -6517,8 +6516,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver, return -1; /* start outputting of the new XML element to allow keeping unpluggability */ - if (newhotplug) - vm->def->individualvcpus = true; + vm->def->individualvcpus = true; if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE, false) < 0) return -1;