[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 26/47] virtio-serial: Convert to hotplug-handler API
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PULL 26/47] virtio-serial: Convert to hotplug-handler API |
Date: |
Wed, 15 Oct 2014 05:09:00 +0200 |
From: Igor Mammedov <address@hidden>
Signed-off-by: Igor Mammedov <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
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)
--
1.8.4.5
- [Qemu-devel] [PULL 22/47] qdev: Add wrapper to set BUS as HotplugHandler, (continued)
- [Qemu-devel] [PULL 22/47] qdev: Add wrapper to set BUS as HotplugHandler, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 24/47] target-i386: ICC bus: Drop BusState::allow_hotplug, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 25/47] virtio-pci: Drop BusState::allow_hotplug, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 27/47] virtio-mmio: Drop useless bus->allow_hotplug = 0, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 29/47] s390x: Convert s390-virtio to hotplug handler API, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 31/47] scsi: Set SCSI BUS itself as default HotplugHandler, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 30/47] s390x: Convert virtio-ccw to hotplug handler API, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 34/47] scsi: Cleanup not used anymore SCSIBusInfo{hotplug, hot_unplug} fields, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 32/47] scsi: Convert pvscsi HBA to hotplug handler API, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 28/47] s390x: Drop not used allow_hotplug in event-facility, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 26/47] virtio-serial: Convert to hotplug-handler API,
Andreas Färber <=
- [Qemu-devel] [PULL 33/47] scsi: Convert virtio-scsi HBA to hotplug handler API, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 36/47] usb-bot: Drop not needed "allow_hotplug = 0", Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 37/47] usb-storage: Drop not needed "allow_hotplug = 0", Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 43/47] qdev: Add description field in PropertyInfo struct, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 38/47] usb: Convert usb-ccid to hotplug handler API, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 35/47] usb-bot: Mark device as non hotpluggable, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 39/47] usb: Convert usb devices to hotplug handler API, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 42/47] qdev: device_del: Search for to be unplugged device in 'peripheral' container, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 41/47] qdev: HotplugHandler: Add support for unplugging BUS-less devices, Andreas Färber, 2014/10/14
- [Qemu-devel] [PULL 45/47] qdev: Set the object property's description to the qdev property's., Andreas Färber, 2014/10/14