int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)

{

    int i, r;



    hdev->started = true;



    r = vhost_dev_set_features(hdev, hdev->log_enabled);

    if (r < 0) {

        goto fail_features;

    }

    r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_MEM_TABLE, hdev->mem);

    if (r < 0) {

        r = -errno;

        goto fail_mem;

    }

    for (i = 0; i < hdev->nvqs; ++i) {

        r = vhost_virtqueue_start(hdev,

                                  vdev,

                                  hdev->vqs + i,

                                  hdev->vq_index + i);

        if (r < 0) {

            goto fail_vq;

        }

    }



    if (hdev->log_enabled) {

        hdev->log_size = vhost_get_log_size(hdev);

        hdev->log = hdev->log_size ?

            g_malloc0(hdev->log_size * sizeof *hdev->log) : NULL;

        r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_LOG_BASE, hdev->log);

        if (r < 0) {

            r = -errno;

            goto fail_log;

        }

    }



    return 0;

fail_log:

fail_vq:

    while (--i >= 0) {

        vhost_virtqueue_stop(hdev,

                             vdev,

                             hdev->vqs + i,

                             hdev->vq_index + i);

    }

    i = hdev->nvqs;

fail_mem:

fail_features:



    hdev->started = false;

    return r;

}

int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)

{

    int i, r;



    hdev->started = true;



    r = vhost_dev_set_features(hdev, hdev->log_enabled);

    if (r < 0) {

        goto fail_features;

    }

    r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_MEM_TABLE, hdev->mem);

    if (r < 0) {

        r = -errno;

        goto fail_mem;

    }

    for (i = 0; i < hdev->nvqs; ++i) {

        r = vhost_virtqueue_start(hdev,

                                  vdev,

                                  hdev->vqs + i,

                                  hdev->vq_index + i);

        if (r < 0) {

            goto fail_vq;

        }

    }



    if (hdev->log_enabled) {

        hdev->log_size = vhost_get_log_size(hdev);

        hdev->log = hdev->log_size ?

            g_malloc0(hdev->log_size * sizeof *hdev->log) : NULL;

        r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_LOG_BASE, hdev->log);

        if (r < 0) {

            r = -errno;

            goto fail_log;

        }

    }



    return 0;

fail_log:

fail_vq:

    while (--i >= 0) {

        vhost_virtqueue_stop(hdev,

                             vdev,

                             hdev->vqs + i,

                             hdev->vq_index + i);

    }

    i = hdev->nvqs;

fail_mem:

fail_features:



    hdev->started = false;

    return r;

}

        r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_LOG_BASE, hdev->log);
int FUNC_0(struct vhost_dev *VAR_0, VirtIODevice *VAR_1)

{

    int VAR_2, VAR_3;



    VAR_0->started = true;



    VAR_3 = vhost_dev_set_features(VAR_0, VAR_0->log_enabled);

    if (VAR_3 < 0) {

        goto fail_features;

    }

    VAR_3 = VAR_0->vhost_ops->vhost_call(VAR_0, VHOST_SET_MEM_TABLE, VAR_0->mem);

    if (VAR_3 < 0) {

        VAR_3 = -errno;

        goto fail_mem;

    }

    for (VAR_2 = 0; VAR_2 < VAR_0->nvqs; ++VAR_2) {

        VAR_3 = vhost_virtqueue_start(VAR_0,

                                  VAR_1,

                                  VAR_0->vqs + VAR_2,

                                  VAR_0->vq_index + VAR_2);

        if (VAR_3 < 0) {

            goto fail_vq;

        }

    }



    if (VAR_0->log_enabled) {

        VAR_0->log_size = vhost_get_log_size(VAR_0);

        VAR_0->log = VAR_0->log_size ?

            g_malloc0(VAR_0->log_size * sizeof *VAR_0->log) : NULL;

        VAR_3 = VAR_0->vhost_ops->vhost_call(VAR_0, VHOST_SET_LOG_BASE, VAR_0->log);

        if (VAR_3 < 0) {

            VAR_3 = -errno;

            goto fail_log;

        }

    }



    return 0;

fail_log:

fail_vq:

    while (--VAR_2 >= 0) {

        vhost_virtqueue_stop(VAR_0,

                             VAR_1,

                             VAR_0->vqs + VAR_2,

                             VAR_0->vq_index + VAR_2);

    }

    VAR_2 = VAR_0->nvqs;

fail_mem:

fail_features:



    VAR_0->started = false;

    return VAR_3;

}

int FUNC_0(struct vhost_dev *VAR_0, VirtIODevice *VAR_1)
{ int VAR_2, VAR_3; VAR_0->started = true; VAR_3 = vhost_dev_set_features(VAR_0, VAR_0->log_enabled); if (VAR_3 < 0) { goto fail_features; } VAR_3 = VAR_0->vhost_ops->vhost_call(VAR_0, VHOST_SET_MEM_TABLE, VAR_0->mem); if (VAR_3 < 0) { VAR_3 = -errno; goto fail_mem; } for (VAR_2 = 0; VAR_2 < VAR_0->nvqs; ++VAR_2) { VAR_3 = vhost_virtqueue_start(VAR_0,
VAR_1,
VAR_0->vqs + VAR_2,
VAR_0->vq_index + VAR_2); if (VAR_3 < 0) { goto fail_vq; } } if (VAR_0->log_enabled) { VAR_0->log_size = vhost_get_log_size(VAR_0); VAR_0->log = VAR_0->log_size ?
g_malloc0(VAR_0->log_size * sizeof *VAR_0->log) : NULL; VAR_3 = VAR_0->vhost_ops->vhost_call(VAR_0, VHOST_SET_LOG_BASE, VAR_0->log); if (VAR_3 < 0) { VAR_3 = -errno; goto fail_log; } } return 0; fail_log:
fail_vq:
while (--VAR_2 >= 0) { vhost_virtqueue_stop(VAR_0,
VAR_1,
VAR_0->vqs + VAR_2,
VAR_0->vq_index + VAR_2); } VAR_2 = VAR_0->nvqs; fail_mem:
fail_features:
VAR_0->started = false; return VAR_3; }