qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v12 11/15] vfio: modify vfio_pci_hot_reset to suppor


From: Chen Hanxiao
Subject: [Qemu-devel] [PATCH v12 11/15] vfio: modify vfio_pci_hot_reset to support bus reset
Date: Thu, 16 Jul 2015 12:00:49 +0800

From: Chen Fan <address@hidden>

the vfio_pci_hot_reset differentiate the single and multi in-used
devices for reset. but in multi case, when some dependent devices
are not assigned to VM, the devices can not be recovered by driver.

Signed-off-by: Chen Fan <address@hidden>
Signed-off-by: Chen Hanxiao <address@hidden>
---
 hw/vfio/pci.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index bab72a4..c52456b 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3287,6 +3287,7 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool 
single)
         PCIHostDeviceAddress host;
         VFIOPCIDevice *tmp;
         VFIODevice *vbasedev_iter;
+        bool found;
 
         host.domain = devices[i].segment;
         host.bus = devices[i].bus;
@@ -3316,6 +3317,7 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool 
single)
             goto out;
         }
 
+        found = false;
         /* Prep dependent devices for reset and clear our marker. */
         QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
             if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) {
@@ -3327,12 +3329,23 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool 
single)
                     ret = -EINVAL;
                     goto out_single;
                 }
+                found = true;
                 vfio_pci_pre_reset(tmp);
                 tmp->vbasedev.needs_reset = false;
                 multi = true;
                 break;
             }
         }
+
+        /*
+         * If the dependent device is not assigned to VM, we should
+         * not call hot bus reset, otherwise, the dependent device
+         * can not be used in the future.
+         */
+        if (!single && !found) {
+            ret = -EINVAL;
+            goto out_single;
+        }
     }
 
     if (!single && !multi) {
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]