[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 49/61] virtio-serial-s390 : switch to the new API.
From: |
fred . konrad |
Subject: |
[Qemu-devel] [PATCH 49/61] virtio-serial-s390 : switch to the new API. |
Date: |
Mon, 7 Jan 2013 19:41:02 +0100 |
From: KONRAD Frederic <address@hidden>
Here the virtio-serial-s390 is modified for the new API. The device
virtio-serial-s390 extends virtio-s390-device as before. It creates and
connects a virtio-serial during the init. The properties are not
modified.
Signed-off-by: KONRAD Frederic <address@hidden>
---
hw/s390-virtio-bus.c | 31 +++++++++++++++++++++----------
hw/s390-virtio-bus.h | 10 +++++++++-
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index f3e1f07..52978b3 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -189,27 +189,37 @@ static void s390_virtio_blk_instance_init(Object *obj)
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
}
-static int s390_virtio_serial_init(VirtIOS390Device *dev)
+static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
{
+ VirtIOSerialS390 *dev = VIRTIO_SERIAL_S390(s390_dev);
+ DeviceState *vdev = DEVICE(&dev->vdev);
+ DeviceState *qdev = DEVICE(s390_dev);
VirtIOS390Bus *bus;
- VirtIODevice *vdev;
int r;
- bus = DO_UPCAST(VirtIOS390Bus, bus, dev->qdev.parent_bus);
+ bus = DO_UPCAST(VirtIOS390Bus, bus, qdev->parent_bus);
- vdev = virtio_serial_init((DeviceState *)dev, &dev->serial);
- if (!vdev) {
+ virtio_serial_set_conf(vdev, &(dev->serial));
+ qdev_set_parent_bus(vdev, BUS(s390_dev->bus));
+ if (qdev_init(vdev) < 0) {
return -1;
}
- r = s390_virtio_device_init(dev, vdev);
+ r = s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
if (!r) {
- bus->console = dev;
+ bus->console = s390_dev;
}
return r;
}
+static void s390_virtio_serial_instance_init(Object *obj)
+{
+ VirtIOSerialS390 *dev = VIRTIO_SERIAL_S390(obj);
+ object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_SERIAL);
+ object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+}
+
static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev)
{
VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(s390_dev);
@@ -486,7 +496,7 @@ static TypeInfo s390_virtio_blk = {
};
static Property s390_virtio_serial_properties[] = {
- DEFINE_PROP_UINT32("max_ports", VirtIOS390Device,
+ DEFINE_PROP_UINT32("max_ports", VirtIOSerialS390,
serial.max_virtserial_ports, 31),
DEFINE_PROP_END_OF_LIST(),
};
@@ -501,9 +511,10 @@ static void s390_virtio_serial_class_init(ObjectClass
*klass, void *data)
}
static TypeInfo s390_virtio_serial = {
- .name = "virtio-serial-s390",
+ .name = TYPE_VIRTIO_SERIAL_S390,
.parent = TYPE_VIRTIO_S390_DEVICE,
- .instance_size = sizeof(VirtIOS390Device),
+ .instance_size = sizeof(VirtIOSerialS390),
+ .instance_init = s390_virtio_serial_instance_init,
.class_init = s390_virtio_serial_class_init,
};
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index 3eb9b69..c9ca5a1 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -86,7 +86,6 @@ struct VirtIOS390Device {
uint8_t feat_len;
VirtIODevice *vdev;
uint32_t host_features;
- virtio_serial_conf serial;
VirtioBusState *bus;
};
@@ -160,5 +159,14 @@ typedef struct VirtIORNGS390 {
VirtIORNGConf rng;
} VirtIORNGS390;
+#define TYPE_VIRTIO_SERIAL_S390 "virtio-serial-s390"
+#define VIRTIO_SERIAL_S390(obj) \
+ OBJECT_CHECK(VirtIOSerialS390, (obj), TYPE_VIRTIO_SERIAL_S390)
+
+typedef struct VirtIOSerialS390 {
+ VirtIOS390Device parent_obj;
+ VirtIOSerial vdev;
+ virtio_serial_conf serial;
+} VirtIOSerialS390;
#endif
--
1.7.11.7
- Re: [Qemu-devel] [PATCH 19/61] virtio-net : cleanup : use QOM cast., (continued)
- [Qemu-devel] [PATCH 30/61] virtio-scsi : cleanup : init and exit functions., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 33/61] virtio-balloon : add the virtio-balloon device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 34/61] virtio-balloon-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 32/61] virtio-balloon : show the VirtIOBalloon structure., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 36/61] virtio-balloon : cleanup : QOM casts., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 35/61] virtio-balloon : cleanup : init and exit function., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 40/61] virtio-rng : add virtio-rng device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 41/61] virtio-rng-s390 : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 43/61] virtio-rng.c : cleanup : init and exit functions., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 49/61] virtio-serial-s390 : switch to the new API.,
fred . konrad <=
- [Qemu-devel] [PATCH 48/61] virtio-serial-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 50/61] virtio-serial : cleanup : init and exit functions., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 42/61] virtio-rng-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 47/61] virtio-serial : add the virtio-serial device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 61/61] virtio : cleanup : init and exit function., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 51/61] virtio-serial : cleanup : use QOM casts., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 56/61] virtio-9p : cleanup : QOM casts., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 59/61] s390-virtio-bus : cleanup, fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 57/61] virtio : remove the function pointer., fred . konrad, 2013/01/07