aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio/virtio.c
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2014-09-30 14:10:38 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2014-09-30 11:09:59 +0200
commitc8075caf19b000b975349f8976958cedf7d2613a (patch)
tree0d55002a87bb3bd8f63f38357347c52d3e3a6f54 /hw/virtio/virtio.c
parent8f3d60e568f53cb3ccdedd917f8e49cdb304973b (diff)
virtio: add a wrapper for virtio-backend initialization
For better code sharing, add a helper function that handles reference counting of the virtio backend for virtio proxy devices. Cc: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/virtio/virtio.c')
-rw-r--r--hw/virtio/virtio.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 5c981801f3..2c236bf271 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1123,6 +1123,17 @@ static void virtio_vmstate_change(void *opaque, int running, RunState state)
}
}
+void virtio_instance_init_common(Object *proxy_obj, void *data,
+ size_t vdev_size, const char *vdev_name)
+{
+ DeviceState *vdev = data;
+
+ object_initialize(vdev, vdev_size, vdev_name);
+ object_property_add_child(proxy_obj, "virtio-backend", OBJECT(vdev), NULL);
+ object_unref(OBJECT(vdev));
+ qdev_alias_all_properties(vdev, proxy_obj);
+}
+
void virtio_init(VirtIODevice *vdev, const char *name,
uint16_t device_id, size_t config_size)
{