[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 27/36] scsi: convert pvscsi HBA to hotplug handle
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH v2 27/36] scsi: convert pvscsi HBA to hotplug handler API |
Date: |
Fri, 26 Sep 2014 09:28:32 +0000 |
Signed-off-by: Igor Mammedov <address@hidden>
---
not tested since it's broken, i.e. QEMU hangs in BIOS
with pvscsi device present on CLI
v2:
* enforce pvscsi specific hotplug-handler
---
hw/scsi/vmw_pvscsi.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index 5734d19..d3a92fb 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -524,17 +524,20 @@ pvscsi_send_msg(PVSCSIState *s, SCSIDevice *dev, uint32_t
msg_type)
}
static void
-pvscsi_hotplug(SCSIBus *bus, SCSIDevice *dev)
+pvscsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp)
{
- PVSCSIState *s = container_of(bus, PVSCSIState, bus);
- pvscsi_send_msg(s, dev, PVSCSI_MSG_DEV_ADDED);
+ PVSCSIState *s = PVSCSI(hotplug_dev);
+
+ pvscsi_send_msg(s, SCSI_DEVICE(dev), PVSCSI_MSG_DEV_ADDED);
}
static void
-pvscsi_hot_unplug(SCSIBus *bus, SCSIDevice *dev)
+pvscsi_hot_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp)
{
- PVSCSIState *s = container_of(bus, PVSCSIState, bus);
- pvscsi_send_msg(s, dev, PVSCSI_MSG_DEV_REMOVED);
+ PVSCSIState *s = PVSCSI(hotplug_dev);
+
+ pvscsi_send_msg(s, SCSI_DEVICE(dev), PVSCSI_MSG_DEV_REMOVED);
+ qdev_simple_device_unplug_cb(hotplug_dev, dev, errp);
}
static void
@@ -1057,8 +1060,6 @@ static const struct SCSIBusInfo pvscsi_scsi_info = {
.get_sg_list = pvscsi_get_sg_list,
.complete = pvscsi_command_complete,
.cancel = pvscsi_request_cancelled,
- .hotplug = pvscsi_hotplug,
- .hot_unplug = pvscsi_hot_unplug,
};
static int
@@ -1092,6 +1093,8 @@ pvscsi_init(PCIDevice *pci_dev)
scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(pci_dev),
&pvscsi_scsi_info, NULL);
+ /* override default SCSI bus hotplug-handler, with pvscsi's one */
+ qbus_set_hotplug_handler(BUS(&s->bus), DEVICE(s), &error_abort);
pvscsi_reset_state(s);
return 0;
@@ -1187,6 +1190,7 @@ static void pvscsi_class_init(ObjectClass *klass, void
*data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+ HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
k->init = pvscsi_init;
k->exit = pvscsi_uninit;
@@ -1199,6 +1203,8 @@ static void pvscsi_class_init(ObjectClass *klass, void
*data)
dc->props = pvscsi_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
k->config_write = pvscsi_write_config;
+ hc->unplug = pvscsi_hot_unplug;
+ hc->plug = pvscsi_hotplug;
}
static const TypeInfo pvscsi_info = {
@@ -1206,6 +1212,10 @@ static const TypeInfo pvscsi_info = {
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PVSCSIState),
.class_init = pvscsi_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_HOTPLUG_HANDLER },
+ { }
+ }
};
static void
--
1.8.3.1
- [Qemu-devel] [PATCH v2 33/36] usb: convert usb-ccid to hotplug handler API, (continued)
- [Qemu-devel] [PATCH v2 33/36] usb: convert usb-ccid to hotplug handler API, Igor Mammedov, 2014/09/26
- [Qemu-devel] [PATCH v2 32/36] usb-storage: drop not needed "allow_hotplug = 0", Igor Mammedov, 2014/09/26
- [Qemu-devel] [PATCH v2 34/36] usb: convert usb devices to hotplug handler API, Igor Mammedov, 2014/09/26
- [Qemu-devel] [PATCH v2 11/36] test: usb: usb-uas hotplug test, Igor Mammedov, 2014/09/26
- [Qemu-devel] [PATCH v2 36/36] qdev: HotplugHandler: add support for unplugging BUS-less devices, Igor Mammedov, 2014/09/26
- [Qemu-devel] [PATCH v2 35/36] qdev: drop legacy hotplug fields/methods, Igor Mammedov, 2014/09/26
- [Qemu-devel] [PATCH v2 19/36] target-i386: ICC bus: drop BusState.allow_hotplug, Igor Mammedov, 2014/09/26
- [Qemu-devel] [PATCH v2 28/36] scsi: convert virtio-scsi HBA to hotplug handler API, Igor Mammedov, 2014/09/26
- [Qemu-devel] [PATCH v2 30/36] usb-bot: mark device as non hotpluggable, Igor Mammedov, 2014/09/26
- [Qemu-devel] [PATCH v2 27/36] scsi: convert pvscsi HBA to hotplug handler API,
Igor Mammedov <=
- [Qemu-devel] [PATCH v2 29/36] scsi: cleanup not used anymore SCSIBusInfo{hotplug, hot_unplug} fields, Igor Mammedov, 2014/09/26
- Re: [Qemu-devel] [PATCH v2 00/36] complete conversion to hotplug-handler API, Cornelia Huck, 2014/09/26
- Re: [Qemu-devel] [PATCH v2 00/36] complete conversion to hotplug-handler API, Paolo Bonzini, 2014/09/26
- Re: [Qemu-devel] [PATCH v2 00/36] complete conversion to hotplug-handler API, Gerd Hoffmann, 2014/09/29
- Re: [Qemu-devel] [PATCH v2 00/36] complete conversion to hotplug-handler API, Michael S. Tsirkin, 2014/09/29