From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWlRl-0006QS-5q for qemu-devel@nongnu.org; Wed, 24 Sep 2014 08:13:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWlRe-0004EQ-W2 for qemu-devel@nongnu.org; Wed, 24 Sep 2014 08:13:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45935) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWlRe-0004D0-PK for qemu-devel@nongnu.org; Wed, 24 Sep 2014 08:13:18 -0400 Message-ID: <5422B54F.20602@redhat.com> Date: Wed, 24 Sep 2014 14:13:03 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1411559299-19042-1-git-send-email-imammedo@redhat.com> <1411559299-19042-23-git-send-email-imammedo@redhat.com> In-Reply-To: <1411559299-19042-23-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 22/30] scsi: convert pvscsi HBA to hotplug hander API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov , qemu-devel@nongnu.org Cc: dmitry@daynix.com, borntraeger@de.ibm.com, mst@redhat.com, agraf@suse.de, cornelia.huck@de.ibm.com, kraxel@redhat.com, amit.shah@redhat.com, rth@twiddle.net Il 24/09/2014 13:48, Igor Mammedov ha scritto: > Signed-off-by: Igor Mammedov > --- > not tested since it's broken, i.e. QEMU hangs in BIOS > with pvscsi device present on CLI > --- > hw/scsi/vmw_pvscsi.c | 24 ++++++++++++++++-------- > 1 file changed, 16 insertions(+), 8 deletions(-) > > diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c > index 5734d19..10586c4 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 > @@ -1187,6 +1188,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 +1201,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 +1210,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 > Reviewed-by: Paolo Bonzini