Patchwork [v3,039/197] virtio-serial-port

login
register
mail settings
Submitter Anthony Liguori
Date Dec. 12, 2011, 8:18 p.m.
Message ID <1323721273-32404-40-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/130904/
State New
Headers show

Comments

Anthony Liguori - Dec. 12, 2011, 8:18 p.m.
---
 hw/virtio-serial-bus.c |   17 ++++++++++++++++-
 hw/virtio-serial.h     |   12 ++++++++++++
 2 files changed, 28 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index b9c8ca7..a459e31 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -829,7 +829,7 @@  void virtio_serial_port_qdev_register(VirtIOSerialPortInfo *info)
     info->qdev.bus_info = &virtser_bus_info;
     info->qdev.exit = virtser_port_qdev_exit;
     info->qdev.unplug = qdev_simple_unplug_cb;
-    qdev_register(&info->qdev);
+    qdev_register_subclass(&info->qdev, TYPE_VIRTIO_SERIAL_PORT);
 }
 
 VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
@@ -925,3 +925,18 @@  void virtio_serial_exit(VirtIODevice *vdev)
 
     virtio_cleanup(vdev);
 }
+
+static TypeInfo virtio_serial_port_type_info = {
+    .name = TYPE_VIRTIO_SERIAL_PORT,
+    .parent = TYPE_DEVICE,
+    .instance_size = sizeof(VirtIOSerialPort),
+    .abstract = true,
+    .class_size = sizeof(VirtIOSerialPortClass),
+};
+
+static void virtio_serial_register_devices(void)
+{
+    type_register_static(&virtio_serial_port_type_info);
+}
+
+device_init(virtio_serial_register_devices);
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index ab13803..86fae8d 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -62,6 +62,18 @@  struct virtio_serial_conf {
 
 /* == In-qemu interface == */
 
+#define TYPE_VIRTIO_SERIAL_PORT "virtio-serial-port"
+#define VIRTIO_SERIAL_PORT(obj) \
+     OBJECT_CHECK(VirtIOSerialPort, (obj), TYPE_VIRTIO_SERIAL_PORT)
+#define VIRTIO_SERIAL_PORT_CLASS(klass) \
+     OBJECT_CLASS_CHECK(VirtIOSerialPortClass, (klass), TYPE_VIRTIO_SERIAL_PORT)
+#define VIRTIO_SERIAL_PORT_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(VirtIOSerialPortClass, (obj), TYPE_VIRTIO_SERIAL_PORT)
+
+typedef struct VirtIOSerialPortClass {
+    DeviceClass parent_class;
+} VirtIOSerialPortClass;
+
 typedef struct VirtIOSerial VirtIOSerial;
 typedef struct VirtIOSerialBus VirtIOSerialBus;
 typedef struct VirtIOSerialPort VirtIOSerialPort;