[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 1/1] hw/nvme: Add hotplug handler to nvme bus
From: |
Daniel Wagner |
Subject: |
[PATCH v1 1/1] hw/nvme: Add hotplug handler to nvme bus |
Date: |
Fri, 5 May 2023 14:12:16 +0200 |
Support attaching/detaching namespaces during runtime.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
hw/nvme/ctrl.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index ac24eeb5ed5a..7bddbc644cae 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -8314,6 +8314,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
}
qbus_init(&n->bus, sizeof(NvmeBus), TYPE_NVME_BUS, dev, dev->id);
+ qbus_set_bus_hotplug_handler(BUS(&n->bus));
if (nvme_init_subsys(n, errp)) {
return;
@@ -8540,10 +8541,22 @@ static const TypeInfo nvme_info = {
},
};
+static void nvme_bus_class_init(ObjectClass *oc, void *data)
+{
+ HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
+
+ hc->unplug = qdev_simple_device_unplug_cb;
+}
+
static const TypeInfo nvme_bus_info = {
.name = TYPE_NVME_BUS,
.parent = TYPE_BUS,
.instance_size = sizeof(NvmeBus),
+ .class_init = nvme_bus_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_HOTPLUG_HANDLER },
+ { }
+ }
};
static void nvme_register_types(void)
--
2.40.0