qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH for-next v2 05/22] virtio: Allow NULL VirtioDeviceCl


From: Andreas Färber
Subject: [Qemu-devel] [PATCH for-next v2 05/22] virtio: Allow NULL VirtioDeviceClass::init hook
Date: Thu, 1 Aug 2013 04:17:26 +0200

This is a temporary measure to allow mixing VirtioDeviceClass::init with
DeviceClass::realize.

Clean up variable naming in preparation for QOM realize.

Signed-off-by: Andreas Färber <address@hidden>
---
 hw/virtio/virtio.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 09f62c6..c00c224 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1139,13 +1139,15 @@ void virtio_device_set_child_bus_name(VirtIODevice 
*vdev, char *bus_name)
     }
 }
 
-static int virtio_device_init(DeviceState *qdev)
+static int virtio_device_init(DeviceState *dev)
 {
-    VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
-    VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(qdev);
-    assert(k->init != NULL);
-    if (k->init(vdev) < 0) {
-        return -1;
+    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
+
+    if (vdc->init != NULL) {
+        if (vdc->init(vdev) < 0) {
+            return -1;
+        }
     }
     virtio_bus_plug_device(vdev);
     return 0;
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]