static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)

{

    VirtIODevice *vdev = VIRTIO_DEVICE(n);

    NetClientState *nc = qemu_get_queue(n->nic);

    int queues = n->multiqueue ? n->max_queues : 1;



    if (!get_vhost_net(nc->peer)) {

        return;

    }



    if ((virtio_net_started(n, status) && !nc->peer->link_down) ==

        !!n->vhost_started) {

        return;

    }

    if (!n->vhost_started) {

        int r, i;



        if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) {

            return;

        }



        /* Any packets outstanding? Purge them to avoid touching rings

         * when vhost is running.

         */

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

            NetClientState *qnc = qemu_get_subqueue(n->nic, i);



            /* Purge both directions: TX and RX. */

            qemu_net_queue_purge(qnc->peer->incoming_queue, qnc);

            qemu_net_queue_purge(qnc->incoming_queue, qnc->peer);

        }



        n->vhost_started = 1;

        r = vhost_net_start(vdev, n->nic->ncs, queues);

        if (r < 0) {

            error_report("unable to start vhost net: %d: "

                         "falling back on userspace virtio", -r);

            n->vhost_started = 0;

        }

    } else {

        vhost_net_stop(vdev, n->nic->ncs, queues);

        n->vhost_started = 0;

    }

}

static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)

{

    VirtIODevice *vdev = VIRTIO_DEVICE(n);

    NetClientState *nc = qemu_get_queue(n->nic);

    int queues = n->multiqueue ? n->max_queues : 1;



    if (!get_vhost_net(nc->peer)) {

        return;

    }



    if ((virtio_net_started(n, status) && !nc->peer->link_down) ==

        !!n->vhost_started) {

        return;

    }

    if (!n->vhost_started) {

        int r, i;



        if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) {

            return;

        }



        





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

            NetClientState *qnc = qemu_get_subqueue(n->nic, i);



            

            qemu_net_queue_purge(qnc->peer->incoming_queue, qnc);

            qemu_net_queue_purge(qnc->incoming_queue, qnc->peer);

        }



        n->vhost_started = 1;

        r = vhost_net_start(vdev, n->nic->ncs, queues);

        if (r < 0) {

            error_report("unable to start vhost net: %d: "

                         "falling back on userspace virtio", -r);

            n->vhost_started = 0;

        }

    } else {

        vhost_net_stop(vdev, n->nic->ncs, queues);

        n->vhost_started = 0;

    }

}

        if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) {
static void FUNC_0(VirtIONet *VAR_0, uint8_t VAR_1)

{

    VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0);

    NetClientState *nc = qemu_get_queue(VAR_0->nic);

    int VAR_2 = VAR_0->multiqueue ? VAR_0->max_queues : 1;



    if (!get_vhost_net(nc->peer)) {

        return;

    }



    if ((virtio_net_started(VAR_0, VAR_1) && !nc->peer->link_down) ==

        !!VAR_0->vhost_started) {

        return;

    }

    if (!VAR_0->vhost_started) {

        int VAR_3, VAR_4;



        if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) {

            return;

        }



        





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

            NetClientState *qnc = qemu_get_subqueue(VAR_0->nic, VAR_4);



            

            qemu_net_queue_purge(qnc->peer->incoming_queue, qnc);

            qemu_net_queue_purge(qnc->incoming_queue, qnc->peer);

        }



        VAR_0->vhost_started = 1;

        VAR_3 = vhost_net_start(vdev, VAR_0->nic->ncs, VAR_2);

        if (VAR_3 < 0) {

            error_report("unable to start vhost net: %d: "

                         "falling back on userspace virtio", -VAR_3);

            VAR_0->vhost_started = 0;

        }

    } else {

        vhost_net_stop(vdev, VAR_0->nic->ncs, VAR_2);

        VAR_0->vhost_started = 0;

    }

}

static void FUNC_0(VirtIONet *VAR_0, uint8_t VAR_1)
{ VirtIODevice *vdev = VIRTIO_DEVICE(VAR_0); NetClientState *nc = qemu_get_queue(VAR_0->nic); int VAR_2 = VAR_0->multiqueue ? VAR_0->max_queues : 1; if (!get_vhost_net(nc->peer)) { return; } if ((virtio_net_started(VAR_0, VAR_1) && !nc->peer->link_down) ==
!!VAR_0->vhost_started) { return; } if (!VAR_0->vhost_started) { int VAR_3, VAR_4; if (!vhost_net_query(get_vhost_net(nc->peer), vdev)) { return; } for (VAR_4 = 0;  VAR_4 < VAR_2; VAR_4++) { NetClientState *qnc = qemu_get_subqueue(VAR_0->nic, VAR_4); qemu_net_queue_purge(qnc->peer->incoming_queue, qnc); qemu_net_queue_purge(qnc->incoming_queue, qnc->peer); } VAR_0->vhost_started = 1; VAR_3 = vhost_net_start(vdev, VAR_0->nic->ncs, VAR_2); if (VAR_3 < 0) { error_report("unable to start vhost net: %d: "
"falling back on userspace virtio", -VAR_3); VAR_0->vhost_started = 0; } } else { vhost_net_stop(vdev, VAR_0->nic->ncs, VAR_2); VAR_0->vhost_started = 0; } }