Skip to contentSkip to conversation

failover: fix unplug pending detection

PATCH In review Laurent Vivier 5 participants 14 messages Oct 1, 2021 – Nov 18, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 failover: fix unplug pending detection

Failover needs to detect the end of the PCI unplug to start migration after the VFIO card has been unplugged.

To do that, a flag is set in pcie_cap_slot_unplug_request_cb() and reset in pcie_unplug_device().

But since

    17858a169508 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35")

we have switched to ACPI unplug and these functions are not called anymore and the flag not set. So failover migration is not able to detect if card is really unplugged and acts as it's done as soon as it's started. So it doesn't wait the end of the unplug to start the migration. We don't see any problem when we test that because ACPI unplug is faster than PCIe native hotplug and when the migration really starts the unplug operation is already done.

See c000a9bd06ea ("pci: mark device having guest unplug request pending")
a99c4da9fc2a ("pci: mark devices partially unplugged")

---

Notes:
v3: add some inlined comments to explain partially_hotplugged and
pending_deleted_event
v2: move partially_hotplugged to acpi_pcihp_eject_slot()

 hw/acpi/pcihp.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)
hw/acpi/pcihp.c +27 -3
index f610a25d2ef9..30405b5113d7 100644
@@ -222,9 +222,27 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slo
         PCIDevice *dev = PCI_DEVICE(qdev);
         if (PCI_SLOT(dev->devfn) == slot) {
             if (!acpi_pcihp_pc_no_hotplug(s, dev)) {
-                hotplug_ctrl = qdev_get_hotplug_handler(qdev);
-                hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abort);
-                object_unparent(OBJECT(qdev));
+                /*
+                 * partially_hotplugged is used by virtio-net failover:
+                 * failover has asked the guest OS to unplug the device
+                 * but we need to keep some references to the device
+                 * to be able to plug it back in case of failure so
+                 * we don't execute hotplug_handler_unplug().
+                 */
+                if (dev->partially_hotplugged) {
+                    /*
+                     * pending_deleted_event is set to true when
+                     * virtio-net failover asks to unplug the device,
+                     * and set to false here when the operation is done
+                     * This is used by the migration loop to detect the
+                     * end of the operation and really start the migration.
+                     */
+                    qdev->pending_deleted_event = false;
+                } else {
+                    hotplug_ctrl = qdev_get_hotplug_handler(qdev);
+                    hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abort);
+                    object_unparent(OBJECT(qdev));
+                }
             }
         }
     }
@@ -396,6 +414,12 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
         return;
     }
 
+    /*
+     * pending_deleted_event is used by virtio-net failover to detect the
+     * end of the unplug operation, the flag is set to false in
+     * acpi_pcihp_eject_slot() when the operation is completed.
+     */
+    pdev->qdev.pending_deleted_event = true;
     s->acpi_pcihp_pci_status[bsel].down |= (1U << slot);
     acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
 }
Signature · 1 line
2.31.1
#1 lore raw

hw/acpi/pcihp.c void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, · line 422

Quoted 12 lines · Laurent Vivier

Failover needs to detect the end of the PCI unplug to start migration after the VFIO card has been unplugged.

To do that, a flag is set in pcie_cap_slot_unplug_request_cb() and reset in pcie_unplug_device().

hw/acpi/pcihp.c +6 -0
+    /*
+     * pending_deleted_event is used by virtio-net failover to detect the
+     * end of the unplug operation, the flag is set to false in
+     * acpi_pcihp_eject_slot() when the operation is completed.
+     */
+    pdev->qdev.pending_deleted_event = true;

This has the side effect of blocking a second 'device_del' command.

So, in case the first time didn't work (for example due to the guest not listening because grub just doesn't do that), you can try a second time once the linux kernel is up'n'running.

I suspect this patch will break that (didn't actually test though).

While being at it I'll throw in a link to a bunch of slightly related pcie hotplug patches:
https://gitlab.com/kraxel/qemu/-/commits/sirius/pcie-hotplug

I'll be offline next week, so not posting that series for discussion yet, will probably do that when I'm back, but you might want have a look nevertheless.

take care,
Gerd

#2 lore raw
Quoted 14 lines · Gerd Hoffmann

hw/acpi/pcihp.c void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, · line 422

Quoted 12 lines · Laurent Vivier

Failover needs to detect the end of the PCI unplug to start migration after the VFIO card has been unplugged.

To do that, a flag is set in pcie_cap_slot_unplug_request_cb() and reset in pcie_unplug_device().

hw/acpi/pcihp.c +6 -0
+    /*
+     * pending_deleted_event is used by virtio-net failover to detect the
+     * end of the unplug operation, the flag is set to false in
+     * acpi_pcihp_eject_slot() when the operation is completed.
+     */
+    pdev->qdev.pending_deleted_event = true;
Quoted 7 lines

This has the side effect of blocking a second 'device_del' command.

So, in case the first time didn't work (for example due to the guest not listening because grub just doesn't do that), you can try a second time once the linux kernel is up'n'running.

I suspect this patch will break that (didn't actually test though).

That's important because OpenStack will definitely trigger multiple device_del commands in a row if they don't get a success from an initial one.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
author Reviewed-by Stefan Hajnoczi
#3 lore raw
In reply to Gerd Hoffmann
Quoted 7 lines · Gerd Hoffmann
Quoted 5 lines · Laurent Vivier

Failover needs to detect the end of the PCI unplug to start migration after the VFIO card has been unplugged.

To do that, a flag is set in pcie_cap_slot_unplug_request_cb() and reset in pcie_unplug_device().

Quoted 8 lines

hw/acpi/pcihp.c void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, · line 422

Quoted 6 lines
hw/acpi/pcihp.c +6 -0
+    /*
+     * pending_deleted_event is used by virtio-net failover to detect the
+     * end of the unplug operation, the flag is set to false in
+     * acpi_pcihp_eject_slot() when the operation is completed.
+     */
+    pdev->qdev.pending_deleted_event = true;

This has the side effect of blocking a second 'device_del' command.

This problem is not introduced by this patch as it only adds the code we already have in PCIe Native hotplug to ACPI hotplug (but see below).

Quoted 5 lines

So, in case the first time didn't work (for example due to the guest not listening because grub just doesn't do that), you can try a second time once the linux kernel is up'n'running.

I suspect this patch will break that (didn't actually test though).

I think the solution to this problem is to not check for pending_deleted_event value in qmp_device_del().

But this has been explicitly added by:

commit cce8944cc9efab47d4bf29cfffb3470371c3541b

Author: Julia Suvorova <[email protected]>
Date:   Thu Feb 20 17:55:56 2020 +0100

qdev-monitor: Forbid repeated device_del

Device unplug can be done asynchronously. Thus, sending the second device_del before the previous unplug is complete may lead to unexpected results. On PCIe devices, this cancels the hot-unplug process.

Message-Id: <[email protected]>

So do you mean ACPI differs from PCIe Native hotplug in this case?

Thanks,
Laurent

#4 lore raw

Hi,

Quoted 12 lines
Quoted 5 lines

So, in case the first time didn't work (for example due to the guest not listening because grub just doesn't do that), you can try a second time once the linux kernel is up'n'running.

I suspect this patch will break that (didn't actually test though).

I think the solution to this problem is to not check for pending_deleted_event value in qmp_device_del().

But this has been explicitly added by:

commit cce8944cc9efab47d4bf29cfffb3470371c3541b

Quoted 8 lines
Author: Julia Suvorova <[email protected]>
Date:   Thu Feb 20 17:55:56 2020 +0100

qdev-monitor: Forbid repeated device_del

[ ... ]

So do you mean ACPI differs from PCIe Native hotplug in this case?

Yes.

It's one of the issues I'm trying to address with the

https://gitlab.com/kraxel/qemu/-/commits/sirius/pcie-hotplug

series. See this commit:

https://gitlab.com/kraxel/qemu/-/commit/675d9257d794c9d59ea7c80f48fe176a2aa3f8ba

So, yes, I think acpi and pcie hotplug should show consistent behavior here. And I think we need some way to recover in case the guest didn't respond to an unplug event. Just allowing to send device_del multiple times looks like a sensible approach to me, and given OpenStack already does that it looks like the most sensible way forward.

take care,
Gerd

#5 lore raw
Quoted 26 lines · On Fri, Oct 1, 2021 at 18:19 Gerd Hoffmann <[email protected]> wrote:

Hi,

Quoted 1 line
Quoted 1 line

So, in case the first time didn't work (for example due to the guest

not

Quoted 11 lines
Quoted 4 lines

listening because grub just doesn't do that), you can try a second time once the linux kernel is up'n'running.

I suspect this patch will break that (didn't actually test though).

I think the solution to this problem is to not check for pending_deleted_event value in qmp_device_del().

But this has been explicitly added by:

commit cce8944cc9efab47d4bf29cfffb3470371c3541b

Quoted 8 lines
Author: Julia Suvorova <[email protected]>
Date:   Thu Feb 20 17:55:56 2020 +0100

qdev-monitor: Forbid repeated device_del

[ ... ]

So do you mean ACPI differs from PCIe Native hotplug in this case?

Yes.

Quoted 8 lines

It's one of the issues I'm trying to address with the

https://gitlab.com/kraxel/qemu/-/commits/sirius/pcie-hotplug

series. See this commit:

https://gitlab.com/kraxel/qemu/-/commit/675d9257d794c9d59ea7c80f48fe176a2aa3f8ba

I think the scope of this patch is limited to making the acpi hotplug path identical to PCIE native path wrt failover. If there are issues with the existing approach, it should be looked into separately using subsequent patches.

<https://gitlab.com/kraxel/qemu/-/commit/675d9257d794c9d59ea7c80f48fe176a2aa3f8ba>

Quoted 11 lines

So, yes, I think acpi and pcie hotplug should show consistent behavior here. And I think we need some way to recover in case the guest didn't respond to an unplug event. Just allowing to send device_del multiple times looks like a sensible approach to me, and given OpenStack already does that it looks like the most sensible way forward.

take care,
Gerd

#6 lore raw
In reply to Gerd Hoffmann
Quoted 25 lines · Gerd Hoffmann

Hi,

Quoted 12 lines
Quoted 5 lines

So, in case the first time didn't work (for example due to the guest not listening because grub just doesn't do that), you can try a second time once the linux kernel is up'n'running.

I suspect this patch will break that (didn't actually test though).

I think the solution to this problem is to not check for pending_deleted_event value in qmp_device_del().

But this has been explicitly added by:

commit cce8944cc9efab47d4bf29cfffb3470371c3541b

Quoted 8 lines
Author: Julia Suvorova <[email protected]>
Date:   Thu Feb 20 17:55:56 2020 +0100

qdev-monitor: Forbid repeated device_del

[ ... ]

So do you mean ACPI differs from PCIe Native hotplug in this case?

Yes.

Quoted 8 lines

It's one of the issues I'm trying to address with the

https://gitlab.com/kraxel/qemu/-/commits/sirius/pcie-hotplug

series. See this commit:

https://gitlab.com/kraxel/qemu/-/commit/675d9257d794c9d59ea7c80f48fe176a2aa3f8ba

I think the scope of this patch is limited to making the acpi hotplug path identical to PCIE native path wrt failover. If there are issues with the existing approach, it should be looked into separately using subsequent patches.

Quoted 10 lines

So, yes, I think acpi and pcie hotplug should show consistent behavior here. And I think we need some way to recover in case the guest didn't respond to an unplug event. Just allowing to send device_del multiple times looks like a sensible approach to me, and given OpenStack already does that it looks like the most sensible way forward.

take care,
Gerd

#7 lore raw
In reply to Laurent Vivier
Quoted 16 lines · Laurent Vivier

Failover needs to detect the end of the PCI unplug to start migration after the VFIO card has been unplugged.

To do that, a flag is set in pcie_cap_slot_unplug_request_cb() and reset in pcie_unplug_device().

But since

    17858a169508 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35")

we have switched to ACPI unplug and these functions are not called anymore and the flag not set. So failover migration is not able to detect if card is really unplugged and acts as it's done as soon as it's started. So it doesn't wait the end of the unplug to start the migration. We don't see any problem when we test that because ACPI unplug is faster than PCIe native hotplug and when the migration really starts the unplug operation is already done.

Quoted 5 lines

See c000a9bd06ea ("pci: mark device having guest unplug request pending")
a99c4da9fc2a ("pci: mark devices partially unplugged")

Laurent, are you thinking of addressing Gerd's comment?

Quoted 60 lines

---

Notes:
v3: add some inlined comments to explain partially_hotplugged and
pending_deleted_event
v2: move partially_hotplugged to acpi_pcihp_eject_slot()

 hw/acpi/pcihp.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)
hw/acpi/pcihp.c +27 -3
index f610a25d2ef9..30405b5113d7 100644
@@ -222,9 +222,27 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slo
         PCIDevice *dev = PCI_DEVICE(qdev);
         if (PCI_SLOT(dev->devfn) == slot) {
             if (!acpi_pcihp_pc_no_hotplug(s, dev)) {
-                hotplug_ctrl = qdev_get_hotplug_handler(qdev);
-                hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abort);
-                object_unparent(OBJECT(qdev));
+                /*
+                 * partially_hotplugged is used by virtio-net failover:
+                 * failover has asked the guest OS to unplug the device
+                 * but we need to keep some references to the device
+                 * to be able to plug it back in case of failure so
+                 * we don't execute hotplug_handler_unplug().
+                 */
+                if (dev->partially_hotplugged) {
+                    /*
+                     * pending_deleted_event is set to true when
+                     * virtio-net failover asks to unplug the device,
+                     * and set to false here when the operation is done
+                     * This is used by the migration loop to detect the
+                     * end of the operation and really start the migration.
+                     */
+                    qdev->pending_deleted_event = false;
+                } else {
+                    hotplug_ctrl = qdev_get_hotplug_handler(qdev);
+                    hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abort);
+                    object_unparent(OBJECT(qdev));
+                }
             }
         }
     }
@@ -396,6 +414,12 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
         return;
     }
 
+    /*
+     * pending_deleted_event is used by virtio-net failover to detect the
+     * end of the unplug operation, the flag is set to false in
+     * acpi_pcihp_eject_slot() when the operation is completed.
+     */
+    pdev->qdev.pending_deleted_event = true;
     s->acpi_pcihp_pci_status[bsel].down |= (1U << slot);
     acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
 }
Signature · 1 line
2.31.1
#8 lore raw
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Laurent Vivier

Failover needs to detect the end of the PCI unplug to start migration after the VFIO card has been unplugged.

To do that, a flag is set in pcie_cap_slot_unplug_request_cb() and reset in pcie_unplug_device().

But since

     17858a169508 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35")

we have switched to ACPI unplug and these functions are not called anymore and the flag not set. So failover migration is not able to detect if card is really unplugged and acts as it's done as soon as it's started. So it doesn't wait the end of the unplug to start the migration. We don't see any problem when we test that because ACPI unplug is faster than PCIe native hotplug and when the migration really starts the unplug operation is already done.

Quoted 7 lines
Quoted 5 lines

See c000a9bd06ea ("pci: mark device having guest unplug request pending")
a99c4da9fc2a ("pci: mark devices partially unplugged")

Laurent, are you thinking of addressing Gerd's comment?

No, because as said by Ani, it's not the scope of this patch. The patch only aligns ACPI to PCIe Native to be able to manage failover.

The problem reported by Gerd and Daniel has been introduced by another patch, globally.

Except if you think it's really required I will not send a new version.

Thanks,
Laurent

#9 lore raw
Quoted 27 lines · Laurent Vivier
Quoted 26 lines · Michael S. Tsirkin
Quoted 24 lines · Laurent Vivier

Failover needs to detect the end of the PCI unplug to start migration after the VFIO card has been unplugged.

To do that, a flag is set in pcie_cap_slot_unplug_request_cb() and reset in
pcie_unplug_device().

But since

     17858a169508 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on

Q35")
we have switched to ACPI unplug and these functions are not called anymore and the flag not set. So failover migration is not able to detect if card is really unplugged and acts as it's done as soon as it's started. So it doesn't wait the end of the unplug to start the migration. We don't see any
problem when we test that because ACPI unplug is faster than PCIe native hotplug and when the migration really starts the unplug operation is already done.

See c000a9bd06ea ("pci: mark device having guest unplug request pending")
a99c4da9fc2a ("pci: mark devices partially unplugged")

Quoted 8 lines
Quoted 1 line

Laurent, are you thinking of addressing Gerd's comment?

No, because as said by Ani, it's not the scope of this patch. The patch only aligns ACPI to PCIe Native to be able to manage failover.

The problem reported by Gerd and Daniel has been introduced by another patch, globally.

but I thought Julia's fix commit cce8944cc9efab47d4bf29cfffb3470371c3541b addressed this for native pcie and since it is at a high enough level, it should catch the acpi hotplug path equally as well.

#10 lore raw
In reply to Laurent Vivier

Hi,

I don't understand if there are some issues to address to have this patch merged?

Thanks,
Laurent

Quoted 80 lines · Laurent Vivier

Failover needs to detect the end of the PCI unplug to start migration after the VFIO card has been unplugged.

To do that, a flag is set in pcie_cap_slot_unplug_request_cb() and reset in pcie_unplug_device().

But since

     17858a169508 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35")

we have switched to ACPI unplug and these functions are not called anymore and the flag not set. So failover migration is not able to detect if card is really unplugged and acts as it's done as soon as it's started. So it doesn't wait the end of the unplug to start the migration. We don't see any problem when we test that because ACPI unplug is faster than PCIe native hotplug and when the migration really starts the unplug operation is already done.

See c000a9bd06ea ("pci: mark device having guest unplug request pending")
a99c4da9fc2a ("pci: mark devices partially unplugged")

---

Notes:
v3: add some inlined comments to explain partially_hotplugged and
pending_deleted_event
v2: move partially_hotplugged to acpi_pcihp_eject_slot()

  hw/acpi/pcihp.c | 30 +++++++++++++++++++++++++++---
  1 file changed, 27 insertions(+), 3 deletions(-)
hw/acpi/pcihp.c +27 -3
index f610a25d2ef9..30405b5113d7 100644
@@ -222,9 +222,27 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slo
          PCIDevice *dev = PCI_DEVICE(qdev);
          if (PCI_SLOT(dev->devfn) == slot) {
              if (!acpi_pcihp_pc_no_hotplug(s, dev)) {
-                hotplug_ctrl = qdev_get_hotplug_handler(qdev);
-                hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abort);
-                object_unparent(OBJECT(qdev));
+                /*
+                 * partially_hotplugged is used by virtio-net failover:
+                 * failover has asked the guest OS to unplug the device
+                 * but we need to keep some references to the device
+                 * to be able to plug it back in case of failure so
+                 * we don't execute hotplug_handler_unplug().
+                 */
+                if (dev->partially_hotplugged) {
+                    /*
+                     * pending_deleted_event is set to true when
+                     * virtio-net failover asks to unplug the device,
+                     * and set to false here when the operation is done
+                     * This is used by the migration loop to detect the
+                     * end of the operation and really start the migration.
+                     */
+                    qdev->pending_deleted_event = false;
+                } else {
+                    hotplug_ctrl = qdev_get_hotplug_handler(qdev);
+                    hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abort);
+                    object_unparent(OBJECT(qdev));
+                }
              }
          }
      }
@@ -396,6 +414,12 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
          return;
      }
 
+    /*
+     * pending_deleted_event is used by virtio-net failover to detect the
+     * end of the unplug operation, the flag is set to false in
+     * acpi_pcihp_eject_slot() when the operation is completed.
+     */
+    pdev->qdev.pending_deleted_event = true;
      s->acpi_pcihp_pci_status[bsel].down |= (1U << slot);
      acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
  }
#11 lore raw
Quoted 3 lines · Laurent Vivier

Hi,

I don't understand if there are some issues

Gerd did identify some issues, you felt they aren't related to the patch and need to be addressed separately.

Gerd posted patches that are supposed to address them since. "try improve native hotplug for pcie root ports" Could you please either
- test and report that your series depend on Gerd's one to now work without the issues. preferably by reposting a patch that applies on top.
- test and report that the functionality is still partially broken but explain in the commit log that this is not due to the patch itself, and not made worse.

in both cases please CC reviewers: Daniel, Gerd.

Thanks!

Quoted 86 lines

to address to have this patch merged?

Thanks,
Laurent

Quoted 79 lines · Laurent Vivier

Failover needs to detect the end of the PCI unplug to start migration after the VFIO card has been unplugged.

To do that, a flag is set in pcie_cap_slot_unplug_request_cb() and reset in pcie_unplug_device().

But since

     17858a169508 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35")

we have switched to ACPI unplug and these functions are not called anymore and the flag not set. So failover migration is not able to detect if card is really unplugged and acts as it's done as soon as it's started. So it doesn't wait the end of the unplug to start the migration. We don't see any problem when we test that because ACPI unplug is faster than PCIe native hotplug and when the migration really starts the unplug operation is already done.

See c000a9bd06ea ("pci: mark device having guest unplug request pending")
a99c4da9fc2a ("pci: mark devices partially unplugged")

---

Notes:
v3: add some inlined comments to explain partially_hotplugged and
pending_deleted_event
v2: move partially_hotplugged to acpi_pcihp_eject_slot()

  hw/acpi/pcihp.c | 30 +++++++++++++++++++++++++++---
  1 file changed, 27 insertions(+), 3 deletions(-)
hw/acpi/pcihp.c +27 -3
index f610a25d2ef9..30405b5113d7 100644
@@ -222,9 +222,27 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slo
          PCIDevice *dev = PCI_DEVICE(qdev);
          if (PCI_SLOT(dev->devfn) == slot) {
              if (!acpi_pcihp_pc_no_hotplug(s, dev)) {
-                hotplug_ctrl = qdev_get_hotplug_handler(qdev);
-                hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abort);
-                object_unparent(OBJECT(qdev));
+                /*
+                 * partially_hotplugged is used by virtio-net failover:
+                 * failover has asked the guest OS to unplug the device
+                 * but we need to keep some references to the device
+                 * to be able to plug it back in case of failure so
+                 * we don't execute hotplug_handler_unplug().
+                 */
+                if (dev->partially_hotplugged) {
+                    /*
+                     * pending_deleted_event is set to true when
+                     * virtio-net failover asks to unplug the device,
+                     * and set to false here when the operation is done
+                     * This is used by the migration loop to detect the
+                     * end of the operation and really start the migration.
+                     */
+                    qdev->pending_deleted_event = false;
+                } else {
+                    hotplug_ctrl = qdev_get_hotplug_handler(qdev);
+                    hotplug_handler_unplug(hotplug_ctrl, qdev, &error_abort);
+                    object_unparent(OBJECT(qdev));
+                }
              }
          }
      }
@@ -396,6 +414,12 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
          return;
      }
+    /*
+     * pending_deleted_event is used by virtio-net failover to detect the
+     * end of the unplug operation, the flag is set to false in
+     * acpi_pcihp_eject_slot() when the operation is completed.
+     */
+    pdev->qdev.pending_deleted_event = true;
      s->acpi_pcihp_pci_status[bsel].down |= (1U << slot);
      acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
  }
 
#12 lore raw
Quoted 18 lines · Michael S. Tsirkin
Quoted 3 lines · Laurent Vivier

Hi,

I don't understand if there are some issues

Gerd did identify some issues, you felt they aren't related to the patch and need to be addressed separately.

Gerd posted patches that are supposed to address them since. "try improve native hotplug for pcie root ports" Could you please either
- test and report that your series depend on Gerd's one to now work without the issues. preferably by reposting a patch that applies on top.
- test and report that the functionality is still partially broken but explain in the commit log that this is not due to the patch itself, and not made worse.

Quoted 2 lines

in both cases please CC reviewers: Daniel, Gerd.

I'm writing a test in tests/qtest that tests virtio-net failover, and I've added a test that checks the migration doesn't start while the card is not unplugged.

I've run the test on top of current qemu master (where Gerd's series is merged) and the problem still exists.

I will re-send this fix and the test in the same series.

Thanks,
Laurent

#13 lore raw
Quoted 20 lines · Laurent Vivier
Quoted 18 lines · Michael S. Tsirkin
Quoted 3 lines · Laurent Vivier

Hi,

I don't understand if there are some issues

Gerd did identify some issues, you felt they aren't related to the patch and need to be addressed separately.

Gerd posted patches that are supposed to address them since. "try improve native hotplug for pcie root ports" Could you please either
- test and report that your series depend on Gerd's one to now work without the issues. preferably by reposting a patch that applies on top.
- test and report that the functionality is still partially broken but explain in the commit log that this is not due to the patch itself, and not made worse.

Quoted 8 lines
Quoted 2 lines

in both cases please CC reviewers: Daniel, Gerd.

I'm writing a test in tests/qtest that tests virtio-net failover, and I've added a test that checks the migration doesn't start while the card is not unplugged.

I've run the test on top of current qemu master (where Gerd's series is merged) and the problem still exists.

btw, for the records, we have decided to continue to use acpi hotplug as default and not revert to native for 6.2. So regardless of what Gerd's patches does, we need to address issues around acpi hotplug if it exists, for failover.

Quoted 6 lines

I will re-send this fix and the test in the same series.

Thanks,
Laurent