qemu-devel
[Top][All Lists]
Advanced

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

[RFC PATCH v2 5/8] failover: hide the PCI device if the virtio-net devic


From: Laurent Vivier
Subject: [RFC PATCH v2 5/8] failover: hide the PCI device if the virtio-net device is not present
Date: Fri, 20 Aug 2021 16:19:59 +0200

We can plug either the virtio-net device first or the PCI device
first.

If we plug the PCI device first, QEMU checks the failover_pair_id
but doesn't hide the device if the virtio-net device is not present.

This is a problem because if the virtio-net device is not plugged
and the machine is migrated the VFIO device doesn't prevent anymore
the migration and the machine is migrated with the VFIO device.

And of course, on destination the guest reboots because VFIO device
cannot be migrated.

We can fix the problem by hiding the PCI device with a failover_pair_id
device that is not present. In this case, if the machine is migrated the
VFIO device is not migrated, and if the virtio-net device is plugged, the
PCI device is plugged and can be migrated using the failover mechanism.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/pci/pci.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index f849945e2819..dd5e95216abf 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2244,10 +2244,11 @@ static bool pci_dev_hide_device(DeviceListener 
*listener,
         d =  qdev_find_recursive(sysbus_get_default(), opt);
         if (d == NULL) {
             /*
-             * if the the virtio-net device is not plugged it can be
-             * plugged later, and this device will be added to the failover
+             * PCI device has a pair id, but the virtio-net device is not
+             * plugged: hide it, it will be plugged later when the virtio-net
+             * device will be plugged
              */
-            return false;
+            return true;
         }
 
         if (runstate_check(RUN_STATE_PRELAUNCH)) {
-- 
2.31.1




reply via email to

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