struct vhost_net *vhost_net_init(NetClientState *backend, int devfd,

                                 bool force)

{

    int r;

    struct vhost_net *net = g_malloc(sizeof *net);

    if (!backend) {

        fprintf(stderr, "vhost-net requires backend to be setup\n");

        goto fail;

    }

    r = vhost_net_get_fd(backend);

    if (r < 0) {

        goto fail;

    }

    net->nc = backend;

    net->dev.backend_features = tap_has_vnet_hdr(backend) ? 0 :

        (1 << VHOST_NET_F_VIRTIO_NET_HDR);

    net->backend = r;



    net->dev.nvqs = 2;

    net->dev.vqs = net->vqs;



    r = vhost_dev_init(&net->dev, devfd, "/dev/vhost-net", force);

    if (r < 0) {

        goto fail;

    }

    if (!tap_has_vnet_hdr_len(backend,

                              sizeof(struct virtio_net_hdr_mrg_rxbuf))) {

        net->dev.features &= ~(1 << VIRTIO_NET_F_MRG_RXBUF);

    }

    if (~net->dev.features & net->dev.backend_features) {

        fprintf(stderr, "vhost lacks feature mask %" PRIu64 " for backend\n",

                (uint64_t)(~net->dev.features & net->dev.backend_features));

        vhost_dev_cleanup(&net->dev);

        goto fail;

    }



    /* Set sane init value. Override when guest acks. */

    vhost_net_ack_features(net, 0);

    return net;

fail:

    g_free(net);

    return NULL;

}

struct vhost_net *vhost_net_init(NetClientState *backend, int devfd,

                                 bool force)

{

    int r;

    struct vhost_net *net = g_malloc(sizeof *net);

    if (!backend) {

        fprintf(stderr, "vhost-net requires backend to be setup\n");

        goto fail;

    }

    r = vhost_net_get_fd(backend);

    if (r < 0) {

        goto fail;

    }

    net->nc = backend;

    net->dev.backend_features = tap_has_vnet_hdr(backend) ? 0 :

        (1 << VHOST_NET_F_VIRTIO_NET_HDR);

    net->backend = r;



    net->dev.nvqs = 2;

    net->dev.vqs = net->vqs;



    r = vhost_dev_init(&net->dev, devfd, "/dev/vhost-net", force);

    if (r < 0) {

        goto fail;

    }

    if (!tap_has_vnet_hdr_len(backend,

                              sizeof(struct virtio_net_hdr_mrg_rxbuf))) {

        net->dev.features &= ~(1 << VIRTIO_NET_F_MRG_RXBUF);

    }

    if (~net->dev.features & net->dev.backend_features) {

        fprintf(stderr, "vhost lacks feature mask %" PRIu64 " for backend\n",

                (uint64_t)(~net->dev.features & net->dev.backend_features));

        vhost_dev_cleanup(&net->dev);

        goto fail;

    }



    

    vhost_net_ack_features(net, 0);

    return net;

fail:

    g_free(net);

    return NULL;

}

struct vhost_net *FUNC_0(NetClientState *VAR_0, int VAR_1,

                                 bool VAR_2)

{

    int VAR_3;

    struct vhost_net *VAR_4 = g_malloc(sizeof *VAR_4);

    if (!VAR_0) {

        fprintf(stderr, "vhost-VAR_4 requires VAR_0 to be setup\n");

        goto fail;

    }

    VAR_3 = vhost_net_get_fd(VAR_0);

    if (VAR_3 < 0) {

        goto fail;

    }

    VAR_4->nc = VAR_0;

    VAR_4->dev.backend_features = tap_has_vnet_hdr(VAR_0) ? 0 :

        (1 << VHOST_NET_F_VIRTIO_NET_HDR);

    VAR_4->VAR_0 = VAR_3;



    VAR_4->dev.nvqs = 2;

    VAR_4->dev.vqs = VAR_4->vqs;



    VAR_3 = vhost_dev_init(&VAR_4->dev, VAR_1, "/dev/vhost-VAR_4", VAR_2);

    if (VAR_3 < 0) {

        goto fail;

    }

    if (!tap_has_vnet_hdr_len(VAR_0,

                              sizeof(struct virtio_net_hdr_mrg_rxbuf))) {

        VAR_4->dev.features &= ~(1 << VIRTIO_NET_F_MRG_RXBUF);

    }

    if (~VAR_4->dev.features & VAR_4->dev.backend_features) {

        fprintf(stderr, "vhost lacks feature mask %" PRIu64 " for VAR_0\n",

                (uint64_t)(~VAR_4->dev.features & VAR_4->dev.backend_features));

        vhost_dev_cleanup(&VAR_4->dev);

        goto fail;

    }



    

    vhost_net_ack_features(VAR_4, 0);

    return VAR_4;

fail:

    g_free(VAR_4);

    return NULL;

}

struct vhost_net *FUNC_0(NetClientState *VAR_0, int VAR_1,
bool VAR_2)
{ int VAR_3; struct vhost_net *VAR_4 = g_malloc(sizeof *VAR_4); if (!VAR_0) { fprintf(stderr, "vhost-VAR_4 requires VAR_0 to be setup\n"); goto fail; } VAR_3 = vhost_net_get_fd(VAR_0); if (VAR_3 < 0) { goto fail; } VAR_4->nc = VAR_0; VAR_4->dev.backend_features = tap_has_vnet_hdr(VAR_0) ? 0 :
(1 << VHOST_NET_F_VIRTIO_NET_HDR); VAR_4->VAR_0 = VAR_3; VAR_4->dev.nvqs = 2; VAR_4->dev.vqs = VAR_4->vqs; VAR_3 = vhost_dev_init(&VAR_4->dev, VAR_1, "/dev/vhost-VAR_4", VAR_2); if (VAR_3 < 0) { goto fail; } if (!tap_has_vnet_hdr_len(VAR_0,
sizeof(struct virtio_net_hdr_mrg_rxbuf))) { VAR_4->dev.features &= ~(1 << VIRTIO_NET_F_MRG_RXBUF); } if (~VAR_4->dev.features & VAR_4->dev.backend_features) { fprintf(stderr, "vhost lacks feature mask %" PRIu64 " for VAR_0\n",
(uint64_t)(~VAR_4->dev.features & VAR_4->dev.backend_features)); vhost_dev_cleanup(&VAR_4->dev); goto fail; } vhost_net_ack_features(VAR_4, 0); return VAR_4; fail:
g_free(VAR_4); return NULL; }