[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 1/2] remove function during multi-function hot-ad
From: |
Cao jin |
Subject: |
[Qemu-devel] [PATCH v5 1/2] remove function during multi-function hot-add |
Date: |
Mon, 26 Oct 2015 11:29:17 +0800 |
In case user regret when hot-add multi-function, we should roll back,
device_del the function added but still not worked.
Signed-off-by: Cao jin <address@hidden>
---
hw/pci/pcie.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 6e28985..b1adeaf 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -261,13 +261,31 @@ void pcie_cap_slot_hotplug_cb(HotplugHandler
*hotplug_dev, DeviceState *dev,
PCI_EXP_HP_EV_PDC | PCI_EXP_HP_EV_ABP);
}
+static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)
+{
+ object_unparent(OBJECT(dev));
+}
+
void pcie_cap_slot_hot_unplug_request_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
uint8_t *exp_cap;
+ PCIDevice *pci_dev = PCI_DEVICE(dev);
+ PCIBus *bus = pci_dev->bus;
pcie_cap_slot_hotplug_common(PCI_DEVICE(hotplug_dev), dev, &exp_cap, errp);
+ /* In case user cancel the operation of multi-function hot-add,
+ * remove the function that is unexposed to guest individually,
+ * without interaction with guest.
+ */
+ if (PCI_FUNC(pci_dev->devfn) &&
+ !bus->devices[PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 0)]) {
+ pcie_unplug_device(bus, pci_dev, NULL);
+
+ return;
+ }
+
pcie_cap_slot_push_attention_button(PCI_DEVICE(hotplug_dev));
}
@@ -378,11 +396,6 @@ void pcie_cap_slot_reset(PCIDevice *dev)
hotplug_event_update_event_status(dev);
}
-static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)
-{
- object_unparent(OBJECT(dev));
-}
-
void pcie_cap_slot_write_config(PCIDevice *dev,
uint32_t addr, uint32_t val, int len)
{
--
2.1.0
- [Qemu-devel] [PATCH v5 0/2] PCI-e device multi-function hot-add support, Cao jin, 2015/10/25
- [Qemu-devel] [PATCH v5 1/2] remove function during multi-function hot-add,
Cao jin <=
- [Qemu-devel] [PATCH v5 2/2] enable multi-function hot-add, Cao jin, 2015/10/25
- Re: [Qemu-devel] [PATCH v5 2/2] enable multi-function hot-add, Michael S. Tsirkin, 2015/10/26
- Re: [Qemu-devel] [PATCH v5 2/2] enable multi-function hot-add, Cao jin, 2015/10/26
- Re: [Qemu-devel] [PATCH v5 2/2] enable multi-function hot-add, Michael S. Tsirkin, 2015/10/26
- Re: [Qemu-devel] [PATCH v5 2/2] enable multi-function hot-add, Cao jin, 2015/10/27
- Re: [Qemu-devel] [PATCH v5 2/2] enable multi-function hot-add, Michael S. Tsirkin, 2015/10/27
- Re: [Qemu-devel] [PATCH v5 2/2] enable multi-function hot-add, Cao jin, 2015/10/27