qemu: Don't skip detection of virtual cpu's on non KVM targets

This patch lifts the limit of calling thread detection code only on KVM
guests. With upstream qemu the thread mappings are reported also on
non-KVM machines.

QEMU adopted the thread_id information from the kvm branch.

To remain compatible with older upstream versions of qemu the check is
attempted but the failure to detect threads (or even run the monitor
command - on older versions without SMP support) is treated non-fatal
and the code reports one vCPU with pid of the hypervisor (in same
fashion this was done on non-KVM guests).
(cherry picked from commit c833526924d56e14f2d0133804cf209f5f47a228)
This commit is contained in:
Peter Krempa 2012-05-07 13:58:22 +02:00 committed by Cole Robinson
parent 6ef9ea9bbf
commit ecd9a50b76

View File

@ -1613,7 +1613,14 @@ qemuProcessDetectVcpuPIDs(struct qemud_driver *driver,
int ncpupids; int ncpupids;
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
if (vm->def->virtType != VIR_DOMAIN_VIRT_KVM) { qemuDomainObjEnterMonitorWithDriver(driver, vm);
/* failure to get the VCPU<-> PID mapping or to execute the query
* command will not be treated fatal as some versions of qemu don't
* support this command */
if ((ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids)) <= 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);
virResetLastError();
priv->nvcpupids = 1; priv->nvcpupids = 1;
if (VIR_ALLOC_N(priv->vcpupids, priv->nvcpupids) < 0) { if (VIR_ALLOC_N(priv->vcpupids, priv->nvcpupids) < 0) {
virReportOOMError(); virReportOOMError();
@ -1622,19 +1629,7 @@ qemuProcessDetectVcpuPIDs(struct qemud_driver *driver,
priv->vcpupids[0] = vm->pid; priv->vcpupids[0] = vm->pid;
return 0; return 0;
} }
/* What follows is now all KVM specific */
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if ((ncpupids = qemuMonitorGetCPUInfo(priv->mon, &cpupids)) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm); qemuDomainObjExitMonitorWithDriver(driver, vm);
return -1;
}
qemuDomainObjExitMonitorWithDriver(driver, vm);
/* Treat failure to get VCPU<->PID mapping as non-fatal */
if (ncpupids == 0)
return 0;
if (ncpupids != vm->def->vcpus) { if (ncpupids != vm->def->vcpus) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,