qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Juan Quintela" <quintela@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Jens Freimann" <jfreimann@redhat.com>
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	[thread overview]
Message-ID: <20210820142002.152994-6-lvivier@redhat.com> (raw)
In-Reply-To: <20210820142002.152994-1-lvivier@redhat.com>

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



  parent reply	other threads:[~2021-08-20 14:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 14:19 [RFC PATCH v2 0/8] virtio-net failover cleanup and new features Laurent Vivier
2021-08-20 14:19 ` [RFC PATCH v2 1/8] qdev: add an Error parameter to the DeviceListener hide_device() function Laurent Vivier
2021-08-25 15:05   ` Juan Quintela
2021-08-20 14:19 ` [RFC PATCH v2 2/8] qdev/qbus: remove failover specific code Laurent Vivier
2021-08-25 15:07   ` Juan Quintela
2021-08-20 14:19 ` [RFC PATCH v2 3/8] failover: virtio-net: remove failover_primary_hidden flag Laurent Vivier
2021-08-25 15:09   ` Juan Quintela
2021-08-20 14:19 ` [RFC PATCH v2 4/8] failover: pci: move failover hotplug/unplug code into pci subsystem Laurent Vivier
2021-08-20 14:19 ` Laurent Vivier [this message]
2021-08-20 14:20 ` [RFC PATCH v2 6/8] failover: pci: unregister ROM on unplug Laurent Vivier
2021-08-25 15:12   ` Juan Quintela
2021-08-20 14:20 ` [RFC PATCH v2 7/8] pci: automatically unplug a PCI card before migration Laurent Vivier
2021-08-20 14:20 ` [RFC PATCH v2 8/8] failover: qemu-opts: manage hidden device list Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210820142002.152994-6-lvivier@redhat.com \
    --to=lvivier@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jfreimann@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).