[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 28/36] scsi: convert virtio-scsi HBA to hotplug h
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH v2 28/36] scsi: convert virtio-scsi HBA to hotplug handler API |
Date: |
Fri, 26 Sep 2014 09:28:33 +0000 |
Signed-off-by: Igor Mammedov <address@hidden>
---
v2:
* enforce virtio-scsi specific hotplug-handler
---
hw/scsi/virtio-scsi.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 86aba88..a08e253 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -649,26 +649,29 @@ static void virtio_scsi_change(SCSIBus *bus, SCSIDevice
*dev, SCSISense sense)
}
}
-static void virtio_scsi_hotplug(SCSIBus *bus, SCSIDevice *dev)
+static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
+ Error **errp)
{
- VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
- VirtIODevice *vdev = VIRTIO_DEVICE(s);
+ VirtIODevice *vdev = VIRTIO_DEVICE(hotplug_dev);
if ((vdev->guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) {
- virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_TRANSPORT_RESET,
+ virtio_scsi_push_event(VIRTIO_SCSI(hotplug_dev), SCSI_DEVICE(dev),
+ VIRTIO_SCSI_T_TRANSPORT_RESET,
VIRTIO_SCSI_EVT_RESET_RESCAN);
}
}
-static void virtio_scsi_hot_unplug(SCSIBus *bus, SCSIDevice *dev)
+static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState
*dev,
+ Error **errp)
{
- VirtIOSCSI *s = container_of(bus, VirtIOSCSI, bus);
- VirtIODevice *vdev = VIRTIO_DEVICE(s);
+ VirtIODevice *vdev = VIRTIO_DEVICE(hotplug_dev);
if ((vdev->guest_features >> VIRTIO_SCSI_F_HOTPLUG) & 1) {
- virtio_scsi_push_event(s, dev, VIRTIO_SCSI_T_TRANSPORT_RESET,
+ virtio_scsi_push_event(VIRTIO_SCSI(hotplug_dev), SCSI_DEVICE(dev),
+ VIRTIO_SCSI_T_TRANSPORT_RESET,
VIRTIO_SCSI_EVT_RESET_REMOVED);
}
+ qdev_simple_device_unplug_cb(hotplug_dev, dev, errp);
}
static struct SCSIBusInfo virtio_scsi_scsi_info = {
@@ -680,8 +683,6 @@ static struct SCSIBusInfo virtio_scsi_scsi_info = {
.complete = virtio_scsi_command_complete,
.cancel = virtio_scsi_request_cancelled,
.change = virtio_scsi_change,
- .hotplug = virtio_scsi_hotplug,
- .hot_unplug = virtio_scsi_hot_unplug,
.parse_cdb = virtio_scsi_parse_cdb,
.get_sg_list = virtio_scsi_get_sg_list,
.save_request = virtio_scsi_save_request,
@@ -736,6 +737,8 @@ static void virtio_scsi_device_realize(DeviceState *dev,
Error **errp)
scsi_bus_new(&s->bus, sizeof(s->bus), dev,
&virtio_scsi_scsi_info, vdev->bus_name);
+ /* override default SCSI bus hotplug-handler, with virtio-scsi's one */
+ qbus_set_hotplug_handler(BUS(&s->bus), dev, &error_abort);
if (!dev->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
@@ -785,6 +788,7 @@ static void virtio_scsi_class_init(ObjectClass *klass, void
*data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+ HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
dc->props = virtio_scsi_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
@@ -793,6 +797,8 @@ static void virtio_scsi_class_init(ObjectClass *klass, void
*data)
vdc->set_config = virtio_scsi_set_config;
vdc->get_features = virtio_scsi_get_features;
vdc->reset = virtio_scsi_reset;
+ hc->plug = virtio_scsi_hotplug;
+ hc->unplug = virtio_scsi_hotunplug;
}
static const TypeInfo virtio_scsi_common_info = {
@@ -808,6 +814,10 @@ static const TypeInfo virtio_scsi_info = {
.parent = TYPE_VIRTIO_SCSI_COMMON,
.instance_size = sizeof(VirtIOSCSI),
.class_init = virtio_scsi_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_HOTPLUG_HANDLER },
+ { }
+ }
};
static void virtio_register_types(void)
--
1.8.3.1
- [Qemu-devel] [PATCH v2 26/36] scsi: set SCSI BUS itself as default HotplugHandler, (continued)
- [Qemu-devel] [PATCH v2 26/36] scsi: set SCSI BUS itself as default HotplugHandler, Igor Mammedov, 2014/09/26
- [Qemu-devel] [PATCH v2 31/36] usb-bot: drop not needed "allow_hotplug = 0", Igor Mammedov, 2014/09/26
- [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 <=
- [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, 2014/09/26
- [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