[libvirt] [PATCH] qemuProcess: update hostdevs before connectting qemu monitor

Wu Zongyong cordius.wu at huawei.com
Fri Sep 21 02:33:53 UTC 2018


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
                qemuHostdevReAttachDomainDevices
                    qemuHostdevReAttachPCIDevices
                        virHostdevReAttachPCIDevices

qemuHostdevUpdateActiveDomainDevices won't be called because the monitor
channel is closed. So host devices in $domain will not be added to either
activePCIHostdevs list or inactivePCIHostdev list. And therefore,
virHostdevReAttachPCIDevices just neglects these host PCI devices which
are bound to stub drivers and don't rebind them to host drivers.

This patch fixs that by moving qemuHostdevUpdateActiveDomainDevices before
qemuConnectMonitor.

Signed-off-by: Wu Zongyong <cordius.wu at huawei.com>
---
 src/qemu/qemu_process.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f9a01da..d187271 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;
-- 
1.9.1




More information about the libvir-list mailing list