From: Wu Zongyong Date: Fri, 21 Sep 2018 02:33:53 +0000 (+0800) Subject: qemu: Update hostdevs device lists before connecting qemu monitor X-Git-Tag: v4.8.0-rc1~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f754b26cb2bc1fdc2574aef218cb9f5699ad624;p=thirdparty%2Flibvirt.git qemu: Update hostdevs device lists before connecting qemu monitor In a following case: virsh start $domain service libvirtd stop the guest from within the $domain service libvirtd start Notice that PCI devices which have been assigned to the $domain will still be bound to stub drivers instead rebound to host drivers. In that case the call stack is like below: libvirtd start qemuProcessReconnect qemuProcessStop (because $domain was shutdown without libvirtd event to process that) qemuHostdevReAttachDomainDevices qemuHostdevReAttachPCIDevices virHostdevReAttachPCIDevices However, because qemuHostdevUpdateActiveDomainDevices was called after the qemuConnectMonitor, the setup of the tracking of each host device in the $domain on either the activePCIHostdevs list or inactivePCIHostdev list will not occur in an orderly manner. Therefore, virHostdevReAttachPCIDevices just neglects these host PCI devices which are bound to stub drivers and doesn't rebind them to host drivers. This patch fixs that by moving qemuHostdevUpdateActiveDomainDevices before qemuConnectMonitor during libvirtd reconnection processing. Signed-off-by: Wu Zongyong Reviewed-by: John Ferlan --- diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 711db105be..98a240a350 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7783,6 +7783,9 @@ qemuProcessReconnect(void *opaque) * allowReboot in status XML and we need to initialize it. */ qemuProcessPrepareAllowReboot(obj); + if (qemuHostdevUpdateActiveDomainDevices(driver, obj->def) < 0) + goto error; + if (priv->qemuCaps && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) retry = false; @@ -7794,9 +7797,6 @@ qemuProcessReconnect(void *opaque) if (qemuConnectMonitor(driver, obj, QEMU_ASYNC_JOB_NONE, retry, NULL) < 0) goto error; - if (qemuHostdevUpdateActiveDomainDevices(driver, obj->def) < 0) - goto error; - priv->machineName = qemuDomainGetMachineName(obj); if (!priv->machineName) goto error;