From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWlcR-0008Kn-Rv for qemu-devel@nongnu.org; Wed, 24 Sep 2014 08:24:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWlcL-0007Af-JL for qemu-devel@nongnu.org; Wed, 24 Sep 2014 08:24:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25719) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWlcL-0007AA-BG for qemu-devel@nongnu.org; Wed, 24 Sep 2014 08:24:21 -0400 Message-ID: <5422B7E5.5010301@redhat.com> Date: Wed, 24 Sep 2014 14:24:05 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1411559299-19042-1-git-send-email-imammedo@redhat.com> <1411559299-19042-17-git-send-email-imammedo@redhat.com> In-Reply-To: <1411559299-19042-17-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 16/30] virtio-serial: convert to hotplug-handler 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 > --- > hw/char/virtio-serial-bus.c | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c > index 3931085..c6870f1 100644 > --- a/hw/char/virtio-serial-bus.c > +++ b/hw/char/virtio-serial-bus.c > @@ -904,6 +904,12 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp) > } > > port->elem.out_num = 0; > +} > + > +static void virtser_port_device_plug(HotplugHandler *hotplug_dev, > + DeviceState *dev, Error **errp) > +{ > + VirtIOSerialPort *port = VIRTIO_SERIAL_PORT(dev); > > QTAILQ_INSERT_TAIL(&port->vser->ports, port, next); > port->ivq = port->vser->ivqs[port->id]; > @@ -912,7 +918,7 @@ static void virtser_port_device_realize(DeviceState *dev, Error **errp) > add_port(port->vser, port->id); > > /* Send an update to the guest about this new port added */ > - virtio_notify_config(vdev); > + virtio_notify_config(VIRTIO_DEVICE(hotplug_dev)); > } > > static void virtser_port_device_unrealize(DeviceState *dev, Error **errp) > @@ -935,7 +941,6 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp) > { > VirtIODevice *vdev = VIRTIO_DEVICE(dev); > VirtIOSerial *vser = VIRTIO_SERIAL(dev); > - BusState *bus; > uint32_t i, max_supported_ports; > > if (!vser->serial.max_virtserial_ports) { > @@ -957,8 +962,7 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp) > /* Spawn a new virtio-serial bus on which the ports will ride as devices */ > qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS, > dev, vdev->bus_name); > - bus = BUS(&vser->bus); > - bus->allow_hotplug = 1; > + qbus_set_hotplug_handler(BUS(&vser->bus), DEVICE(vser), errp); > vser->bus.vser = vser; > QTAILQ_INIT(&vser->ports); > > @@ -1021,7 +1025,6 @@ static void virtio_serial_port_class_init(ObjectClass *klass, void *data) > k->bus_type = TYPE_VIRTIO_SERIAL_BUS; > k->realize = virtser_port_device_realize; > k->unrealize = virtser_port_device_unrealize; > - k->unplug = qdev_simple_unplug_cb; > k->props = virtser_props; > } > > @@ -1064,6 +1067,7 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); > + HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass); > > QLIST_INIT(&vserdevices.devices); > > @@ -1077,6 +1081,8 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data) > vdc->reset = vser_reset; > vdc->save = virtio_serial_save_device; > vdc->load = virtio_serial_load_device; > + hc->plug = virtser_port_device_plug; > + hc->unplug = qdev_simple_device_unplug_cb; > } > > static const TypeInfo virtio_device_info = { > @@ -1084,6 +1090,10 @@ static const TypeInfo virtio_device_info = { > .parent = TYPE_VIRTIO_DEVICE, > .instance_size = sizeof(VirtIOSerial), > .class_init = virtio_serial_class_init, > + .interfaces = (InterfaceInfo[]) { > + { TYPE_HOTPLUG_HANDLER }, > + { } > + } > }; > > static void virtio_serial_register_types(void) > Reviewed-by: Paolo Bonzini