return &vq->host_notifier;
}
+void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name)
+{
+ if (vdev->bus_name) {
+ g_free(vdev->bus_name);
+ vdev->bus_name = NULL;
+ }
+
+ if (bus_name) {
+ vdev->bus_name = g_strdup(bus_name);
+ }
+}
+
static int virtio_device_init(DeviceState *qdev)
{
VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
return 0;
}
+static int virtio_device_exit(DeviceState *qdev)
+{
+ VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
+
+ if (vdev->bus_name) {
+ g_free(vdev->bus_name);
+ vdev->bus_name = NULL;
+ }
+ return 0;
+}
+
static void virtio_device_class_init(ObjectClass *klass, void *data)
{
/* Set the default value here. */
DeviceClass *dc = DEVICE_CLASS(klass);
dc->init = virtio_device_init;
+ dc->exit = virtio_device_exit;
dc->bus_type = TYPE_VIRTIO_BUS;
}
uint16_t device_id;
bool vm_running;
VMChangeStateEntry *vmstate;
+ char *bus_name;
};
typedef struct VirtioDeviceClass {
uint16_t device_id, size_t config_size);
void virtio_cleanup(VirtIODevice *vdev);
+/* Set the child bus name. */
+void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name);
+
VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
void (*handle_output)(VirtIODevice *,
VirtQueue *));