Patchwork [RFC,V9,10/12] virtio-blk-s390 : switch to the new API.

login
register
mail settings
Submitter fred.konrad@greensocs.com
Date Jan. 3, 2013, 2:52 p.m.
Message ID <1357224744-14443-11-git-send-email-fred.konrad@greensocs.com>
Download mbox | patch
Permalink /patch/209268/
State New
Headers show

Comments

fred.konrad@greensocs.com - Jan. 3, 2013, 2:52 p.m.
From: KONRAD Frederic <fred.konrad@greensocs.com>

Here the virtio-blk-s390 is modified for the new API. The device
virtio-blk-s390 extends virtio-s390-device as before. It creates and
connects a virtio-blk during the init. The properties are not modified.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
 hw/s390-virtio-bus.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

Patch

diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 4e8471b..a2ccdc0 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -165,14 +165,20 @@  static int s390_virtio_net_init(VirtIOS390Device *dev)
 
 static int s390_virtio_blk_init(VirtIOS390Device *dev)
 {
-    VirtIODevice *vdev;
-
-    vdev = virtio_blk_init((DeviceState *)dev, &dev->blk);
-    if (!vdev) {
+    DeviceState *vdev = DEVICE(dev->vdev);
+    virtio_blk_set_conf(vdev, &(dev->blk));
+    qdev_set_parent_bus(vdev, BUS(dev->bus));
+    if (qdev_init(vdev) < 0) {
         return -1;
     }
+    return s390_virtio_device_init(dev, VIRTIO_DEVICE(vdev));
+}
 
-    return s390_virtio_device_init(dev, vdev);
+static void s390_virtio_blk_instance_init(Object *obj)
+{
+    VirtIOS390Device *dev = VIRTIO_S390_DEVICE(obj);
+    dev->vdev = VIRTIO_DEVICE(object_new("virtio-blk"));
+    object_property_add_child(obj, "virtio-backend", OBJECT(dev->vdev), NULL);
 }
 
 static int s390_virtio_serial_init(VirtIOS390Device *dev)
@@ -436,6 +442,7 @@  static TypeInfo s390_virtio_blk = {
     .name          = "virtio-blk-s390",
     .parent        = TYPE_VIRTIO_S390_DEVICE,
     .instance_size = sizeof(VirtIOS390Device),
+    .instance_init = s390_virtio_blk_instance_init,
     .class_init    = s390_virtio_blk_class_init,
 };