with Q35 using ACPI PCI hotplug by default, user's request to unplug device is ignored when it's issued before guest OS has been booted. And any additional attempt to request device hot-unplug afterwards results in following error:
"Device XYZ is already in the process of unplug" arguably it can be considered as a regression introduced by [2], before which it was possible to issue unplug request multiple times. Allowing pending delete expire brings ACPI PCI hotplug on par with native PCIe unplug behavior [1] which in its turn refers back to ACPI PCI hotplug ability to repeat unplug requests. PS: >From ACPI point of view, unplug request sets PCI hotplug status bit in GPE0 block. However depending on OSPM, status bits may be retained (Windows) or cleared (Linux) during guest's ACPI subsystem initialization, and as result Linux guest looses plug/unplug event (no SCI generated) if plug/unplug has happend before guest OS initialized GPE registers handling. I couldn't find any restrictions wrt OPM clearing GPE status bits ACPI spec. Hence a fallback approach is to let user repeat unplug request later at the time when guest OS has booted. 1) 18416c62e3 ("pcie: expire pending delete") 2) Fixes: cce8944cc9ef ("qdev-monitor: Forbid repeated device_del") Signed-off-by: Igor Mammedov <imamm...@redhat.com> --- CC: m...@redhat.com CC: anisi...@redhat.com CC: jus...@redhat.com CC: kra...@redhat.com --- hw/acpi/pcihp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index dcfb779a7a..cd4f9fee0a 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -357,6 +357,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, * acpi_pcihp_eject_slot() when the operation is completed. */ pdev->qdev.pending_deleted_event = true; + pdev->qdev.pending_deleted_expires_ms = + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 5000; /* 5 secs */ s->acpi_pcihp_pci_status[bsel].down |= (1U << slot); acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS); } -- 2.39.1