qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Yuri Benditovich <yuri.benditovich@daynix.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Subject: [PULL 13/22] pci: do not respond config requests after PCI device eject
Date: Thu, 3 Aug 2023 18:21:26 -0400	[thread overview]
Message-ID: <348e354417b64c484877354ee7cc66f29fa6c7df.1691101215.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1691101215.git.mst@redhat.com>

From: Yuri Benditovich <yuri.benditovich@daynix.com>

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2224964

In migration with VF failover, Windows guest and ACPI hot
unplug we do not need to satisfy config requests, otherwise
the guest immediately detects the device and brings up its
driver. Many network VF's are stuck on the guest PCI bus after
the migration.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Message-Id: <20230728084049.191454-1-yuri.benditovich@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci/pci_host.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c
index 7af8afdcbe..a18aa0a8d4 100644
--- a/hw/pci/pci_host.c
+++ b/hw/pci/pci_host.c
@@ -62,6 +62,17 @@ static void pci_adjust_config_limit(PCIBus *bus, uint32_t *limit)
     }
 }
 
+static bool is_pci_dev_ejected(PCIDevice *pci_dev)
+{
+    /*
+     * device unplug was requested and the guest acked it,
+     * so we stop responding config accesses even if the
+     * device is not deleted (failover flow)
+     */
+    return pci_dev && pci_dev->partially_hotplugged &&
+           !pci_dev->qdev.pending_deleted_event;
+}
+
 void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr,
                                   uint32_t limit, uint32_t val, uint32_t len)
 {
@@ -75,7 +86,7 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr,
      * allowing direct removal of unexposed functions.
      */
     if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) ||
-        !pci_dev->has_power) {
+        !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) {
         return;
     }
 
@@ -100,7 +111,7 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr,
      * allowing direct removal of unexposed functions.
      */
     if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) ||
-        !pci_dev->has_power) {
+        !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) {
         return ~0x0;
     }
 
-- 
MST



  parent reply	other threads:[~2023-08-03 22:23 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 22:20 [PULL 00/22] pc,pci,virtio,crypto: bugfixes Michael S. Tsirkin
2023-08-03 22:20 ` [PULL 01/22] hw/virtio-iommu: Fix potential OOB access in virtio_iommu_handle_command() Michael S. Tsirkin
2023-08-03 22:20 ` [PULL 02/22] hw/pci-bridge/cxl_upstream.c: Use g_new0() in build_cdat_table() Michael S. Tsirkin
2023-08-03 22:20 ` [PULL 03/22] virtio-iommu: Standardize granule extraction and formatting Michael S. Tsirkin
2023-08-03 22:20 ` [PULL 04/22] hw/virtio: Add a protection against duplicate vu_scmi_stop calls Michael S. Tsirkin
2023-08-03 22:20 ` [PULL 05/22] tests: acpi: x86: whitelist expected blobs Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 06/22] x86: acpi: workaround Windows not handling name references in Package properly Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 07/22] tests: acpi: x86: update expected blobs Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 08/22] tests: acpi: whitelist " Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 09/22] acpi: x86: remove _ADR on host bridges Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 10/22] tests: acpi: update expected blobs Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 11/22] hw/virtio: qmp: add RING_RESET to 'info virtio-status' Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 12/22] virtio: Fix packed virtqueue used_idx mask Michael S. Tsirkin
2023-08-03 22:21 ` Michael S. Tsirkin [this message]
2023-08-04  4:37   ` [PULL 13/22] pci: do not respond config requests after PCI device eject Michael Tokarev
2023-08-03 22:21 ` [PULL 14/22] vhost: fix the fd leak Michael S. Tsirkin
2023-08-04  4:36   ` Michael Tokarev
2023-08-04  4:56     ` Michael Tokarev
2023-08-03 22:21 ` [PULL 15/22] hw/i386/intel_iommu: Fix trivial endianness problems Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 16/22] hw/i386/intel_iommu: Fix endianness problems related to VTD_IR_TableEntry Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 17/22] hw/i386/intel_iommu: Fix struct VTDInvDescIEC on big endian hosts Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 18/22] hw/i386/intel_iommu: Fix index calculation in vtd_interrupt_remap_msi() Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 19/22] hw/i386/x86-iommu: Fix endianness issue in x86_iommu_irq_to_msi_message() Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 20/22] include/hw/i386/x86-iommu: Fix struct X86IOMMU_MSIMessage for big endian hosts Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 21/22] virtio-crypto: verify src&dst buffer length for sym request Michael S. Tsirkin
2023-08-03 22:21 ` [PULL 22/22] cryptodev: Handle unexpected request to avoid crash Michael S. Tsirkin
2023-08-04  4:35   ` Michael Tokarev
2023-08-04  6:10     ` zhenwei pi
2023-08-04  6:35       ` Michael Tokarev
2023-08-04  4:12 ` [PULL 00/22] pc,pci,virtio,crypto: bugfixes Richard Henderson

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=348e354417b64c484877354ee7cc66f29fa6c7df.1691101215.git.mst@redhat.com \
    --to=mst@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=yuri.benditovich@daynix.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).