From 5c896f8d9f8b7b61ee0a684a4f97549eeae6a423 Mon Sep 17 00:00:00 2001 From: damon_hu Date: Tue, 23 Jan 2024 06:48:32 +0000 Subject: [PATCH] acpi: pcihp: allow repeating hot-unplug requests While detach a device from booting guest, libvirt will return successful but actually still not detached. When detach again, qemu will return error and message is : unable to execute QEMU command 'device_del': Device virtio-disk1 is already in the process of unplug. This patch will allow repeating hot-unplug request to qemu. Signed-off-by: damon_hu --- hw/acpi/pcihp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index be0e846b34..6cd5a61f7b 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -430,6 +430,16 @@ 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; + /* if unplug was requested before OSPM is initialized, + * linux kernel will clear GPE0.sts[] bits during boot, which effectively + * hides unplug event. And than followup qmp_device_del() calls remain + * blocked by above flag permanently. + * Unblock qmp_device_del() by setting expire limit, so user can + * repeat unplug request later when OSPM has been booted. + */ + pdev->qdev.pending_deleted_expires_ms = + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); /* 1 msec */ + s->acpi_pcihp_pci_status[bsel].down |= (1U << slot); acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS); } -- Gitee