void virtio_init(VirtIODevice *vdev, const char *name,

                 uint16_t device_id, size_t config_size)

{

    BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));

    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);

    int i;

    int nvectors = k->query_nvectors ? k->query_nvectors(qbus->parent) : 0;



    if (nvectors) {

        vdev->vector_queues =

            g_malloc0(sizeof(*vdev->vector_queues) * nvectors);

    }



    vdev->device_id = device_id;

    vdev->status = 0;

    vdev->isr = 0;

    vdev->queue_sel = 0;

    vdev->config_vector = VIRTIO_NO_VECTOR;

    vdev->vq = g_malloc0(sizeof(VirtQueue) * VIRTIO_QUEUE_MAX);

    vdev->vm_running = runstate_is_running();


    for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {

        vdev->vq[i].vector = VIRTIO_NO_VECTOR;

        vdev->vq[i].vdev = vdev;

        vdev->vq[i].queue_index = i;

    }



    vdev->name = name;

    vdev->config_len = config_size;

    if (vdev->config_len) {

        vdev->config = g_malloc0(config_size);

    } else {

        vdev->config = NULL;

    }

    vdev->vmstate = qemu_add_vm_change_state_handler(virtio_vmstate_change,

                                                     vdev);

    vdev->device_endian = virtio_default_endian();

    vdev->use_guest_notifier_mask = true;

}
void virtio_init(VirtIODevice *vdev, const char *name,

                 uint16_t device_id, size_t config_size)

{

    BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));

    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);

    int i;

    int nvectors = k->query_nvectors ? k->query_nvectors(qbus->parent) : 0;



    if (nvectors) {

        vdev->vector_queues =

            g_malloc0(sizeof(*vdev->vector_queues) * nvectors);

    }



    vdev->device_id = device_id;

    vdev->status = 0;

    vdev->isr = 0;

    vdev->queue_sel = 0;

    vdev->config_vector = VIRTIO_NO_VECTOR;

    vdev->vq = g_malloc0(sizeof(VirtQueue) * VIRTIO_QUEUE_MAX);

    vdev->vm_running = runstate_is_running();


    for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {

        vdev->vq[i].vector = VIRTIO_NO_VECTOR;

        vdev->vq[i].vdev = vdev;

        vdev->vq[i].queue_index = i;

    }



    vdev->name = name;

    vdev->config_len = config_size;

    if (vdev->config_len) {

        vdev->config = g_malloc0(config_size);

    } else {

        vdev->config = NULL;

    }

    vdev->vmstate = qemu_add_vm_change_state_handler(virtio_vmstate_change,

                                                     vdev);

    vdev->device_endian = virtio_default_endian();

    vdev->use_guest_notifier_mask = true;

}
void FUNC_0(VirtIODevice *VAR_0, const char *VAR_1,

                 uint16_t VAR_2, size_t VAR_3)

{

    BusState *qbus = qdev_get_parent_bus(DEVICE(VAR_0));

    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);

    int VAR_4;

    int VAR_5 = k->query_nvectors ? k->query_nvectors(qbus->parent) : 0;



    if (VAR_5) {

        VAR_0->vector_queues =

            g_malloc0(sizeof(*VAR_0->vector_queues) * VAR_5);

    }



    VAR_0->VAR_2 = VAR_2;

    VAR_0->status = 0;

    VAR_0->isr = 0;

    VAR_0->queue_sel = 0;

    VAR_0->config_vector = VIRTIO_NO_VECTOR;

    VAR_0->vq = g_malloc0(sizeof(VirtQueue) * VIRTIO_QUEUE_MAX);

    VAR_0->vm_running = runstate_is_running();


    for (VAR_4 = 0; VAR_4 < VIRTIO_QUEUE_MAX; VAR_4++) {

        VAR_0->vq[VAR_4].vector = VIRTIO_NO_VECTOR;

        VAR_0->vq[VAR_4].VAR_0 = VAR_0;

        VAR_0->vq[VAR_4].queue_index = VAR_4;

    }



    VAR_0->VAR_1 = VAR_1;

    VAR_0->config_len = VAR_3;

    if (VAR_0->config_len) {

        VAR_0->config = g_malloc0(VAR_3);

    } else {

        VAR_0->config = NULL;

    }

    VAR_0->vmstate = qemu_add_vm_change_state_handler(virtio_vmstate_change,

                                                     VAR_0);

    VAR_0->device_endian = virtio_default_endian();

    VAR_0->use_guest_notifier_mask = true;

}
void FUNC_0(VirtIODevice *VAR_0, const char *VAR_1,
uint16_t VAR_2, size_t VAR_3)
{ BusState *qbus = qdev_get_parent_bus(DEVICE(VAR_0)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); int VAR_4; int VAR_5 = k->query_nvectors ? k->query_nvectors(qbus->parent) : 0; if (VAR_5) { VAR_0->vector_queues =
g_malloc0(sizeof(*VAR_0->vector_queues) * VAR_5); } VAR_0->VAR_2 = VAR_2; VAR_0->status = 0; VAR_0->isr = 0; VAR_0->queue_sel = 0; VAR_0->config_vector = VIRTIO_NO_VECTOR; VAR_0->vq = g_malloc0(sizeof(VirtQueue) * VIRTIO_QUEUE_MAX); VAR_0->vm_running = runstate_is_running(); for (VAR_4 = 0; VAR_4 < VIRTIO_QUEUE_MAX; VAR_4++) { VAR_0->vq[VAR_4].vector = VIRTIO_NO_VECTOR; VAR_0->vq[VAR_4].VAR_0 = VAR_0; VAR_0->vq[VAR_4].queue_index = VAR_4; } VAR_0->VAR_1 = VAR_1; VAR_0->config_len = VAR_3; if (VAR_0->config_len) { VAR_0->config = g_malloc0(VAR_3); } else { VAR_0->config = NULL; } VAR_0->vmstate = qemu_add_vm_change_state_handler(virtio_vmstate_change,
VAR_0); VAR_0->device_endian = virtio_default_endian(); VAR_0->use_guest_notifier_mask = true; }