After a cpu hotplug the qemu driver did not refresh information about
virtual procesors used by qemu and their corresponding threads. This
patch forces a re-detection as is done on start of QEMU.
This ensures that correct informations are reported by the
virDomainGetVcpus API and "virsh vcpuinfo".
---
src/qemu/qemu_driver.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7b1d1b6..fcaf0d2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3343,6 +3343,8 @@ static int qemudDomainHotplugVcpus(struct qemud_driver *driver,
int ret = -1;
int oldvcpus = vm->def->vcpus;
int vcpus = oldvcpus;
+ pid_t *cpupids = NULL;
+ int ncpupids;
qemuDomainObjEnterMonitor(driver, vm);
@@ -3373,8 +3375,30 @@ static int qemudDomainHotplugVcpus(struct qemud_driver *driver,
}
}
+ /* after hotplugging the cpu we need to re-detect threads for the virtual
+ * cpus */
+ if ((ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids)) < 0)
+ goto cleanup;
+
ret = 0;
+ /* Treat failure to get VCPU<->PID mapping as non-fatal */
+ if (ncpupids == 0)
+ goto cleanup;
+
+ if (ncpupids != vcpus) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ _("got wrong number of vCPU pids from QEMU monitor. "
+ "got %d, wanted %d"),
+ ncpupids, vcpus);
+ VIR_FREE(cpupids);
+ ret = -1;
+ goto cleanup;
+ }
+
+ priv->nvcpupids = ncpupids;
+ priv->vcpupids = cpupids;
+
cleanup:
qemuDomainObjExitMonitor(driver, vm);
vm->def->vcpus = vcpus;
--
1.7.3.4