]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Update hostdevs device lists before connecting qemu monitor
authorWu Zongyong <cordius.wu@huawei.com>
Fri, 21 Sep 2018 02:33:53 +0000 (10:33 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Sat, 22 Sep 2018 11:22:36 +0000 (07:22 -0400)
In a following case:

    virsh start $domain
    service libvirtd stop
    <shutdown> 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 <cordius.wu@huawei.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_process.c

index 711db105be22356553325384564e18aa67a8ea8d..98a240a350ca7293eaebf4833725a7ae61a5fe8d 100644 (file)
@@ -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;