int net_client_init(QemuOpts *opts, int is_netdev, Error **errp)

{

    const char *name;

    const char *type;

    int i;



    type = qemu_opt_get(opts, "type");

    if (!type) {

        error_set(errp, QERR_MISSING_PARAMETER, "type");

        return -1;

    }



    if (is_netdev) {

        if (strcmp(type, "tap") != 0 &&

#ifdef CONFIG_NET_BRIDGE

            strcmp(type, "bridge") != 0 &&

#endif

#ifdef CONFIG_SLIRP

            strcmp(type, "user") != 0 &&

#endif

#ifdef CONFIG_VDE

            strcmp(type, "vde") != 0 &&

#endif

            strcmp(type, "socket") != 0) {

            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",

                      "a netdev backend type");

            return -1;

        }



        if (qemu_opt_get(opts, "vlan")) {

            error_set(errp, QERR_INVALID_PARAMETER, "vlan");

            return -1;

        }

        if (qemu_opt_get(opts, "name")) {

            error_set(errp, QERR_INVALID_PARAMETER, "name");

            return -1;

        }

        if (!qemu_opts_id(opts)) {

            error_set(errp, QERR_MISSING_PARAMETER, "id");

            return -1;

        }

    }



    name = qemu_opts_id(opts);

    if (!name) {

        name = qemu_opt_get(opts, "name");

    }



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

        if (net_client_types[i].type != NULL &&

            !strcmp(net_client_types[i].type, type)) {

            Error *local_err = NULL;

            VLANState *vlan = NULL;

            int ret;



            qemu_opts_validate(opts, &net_client_types[i].desc[0], &local_err);

            if (error_is_set(&local_err)) {

                error_propagate(errp, local_err);

                return -1;

            }



            /* Do not add to a vlan if it's a -netdev or a nic with a

             * netdev= parameter. */

            if (!(is_netdev ||

                  (strcmp(type, "nic") == 0 && qemu_opt_get(opts, "netdev")))) {

                vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);

            }



            ret = 0;

            if (net_client_types[i].init) {

                ret = net_client_types[i].init(opts, name, vlan);

                if (ret < 0) {

                    /* TODO push error reporting into init() methods */

                    error_set(errp, QERR_DEVICE_INIT_FAILED, type);

                    return -1;

                }

            }

            return ret;

        }

    }



    error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",

              "a network client type");

    return -1;

}

int net_client_init(QemuOpts *opts, int is_netdev, Error **errp)

{

    const char *name;

    const char *type;

    int i;



    type = qemu_opt_get(opts, "type");

    if (!type) {

        error_set(errp, QERR_MISSING_PARAMETER, "type");

        return -1;

    }



    if (is_netdev) {

        if (strcmp(type, "tap") != 0 &&

#ifdef CONFIG_NET_BRIDGE

            strcmp(type, "bridge") != 0 &&

#endif

#ifdef CONFIG_SLIRP

            strcmp(type, "user") != 0 &&

#endif

#ifdef CONFIG_VDE

            strcmp(type, "vde") != 0 &&

#endif

            strcmp(type, "socket") != 0) {

            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",

                      "a netdev backend type");

            return -1;

        }



        if (qemu_opt_get(opts, "vlan")) {

            error_set(errp, QERR_INVALID_PARAMETER, "vlan");

            return -1;

        }

        if (qemu_opt_get(opts, "name")) {

            error_set(errp, QERR_INVALID_PARAMETER, "name");

            return -1;

        }

        if (!qemu_opts_id(opts)) {

            error_set(errp, QERR_MISSING_PARAMETER, "id");

            return -1;

        }

    }



    name = qemu_opts_id(opts);

    if (!name) {

        name = qemu_opt_get(opts, "name");

    }



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

        if (net_client_types[i].type != NULL &&

            !strcmp(net_client_types[i].type, type)) {

            Error *local_err = NULL;

            VLANState *vlan = NULL;

            int ret;



            qemu_opts_validate(opts, &net_client_types[i].desc[0], &local_err);

            if (error_is_set(&local_err)) {

                error_propagate(errp, local_err);

                return -1;

            }



            



            if (!(is_netdev ||

                  (strcmp(type, "nic") == 0 && qemu_opt_get(opts, "netdev")))) {

                vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);

            }



            ret = 0;

            if (net_client_types[i].init) {

                ret = net_client_types[i].init(opts, name, vlan);

                if (ret < 0) {

                    

                    error_set(errp, QERR_DEVICE_INIT_FAILED, type);

                    return -1;

                }

            }

            return ret;

        }

    }



    error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",

              "a network client type");

    return -1;

}

    const char *type; #endif #ifdef CONFIG_NET_BRIDGE int net_client_init(QemuOpts *opts, int is_netdev, Error **errp)     const char *type;     int i;     type = qemu_opt_get(opts, "type");     if (!type) {         error_set(errp, QERR_MISSING_PARAMETER, "type");         return -1;         if (strcmp(type, "tap") != 0 && #ifdef CONFIG_NET_BRIDGE             strcmp(type, "bridge") != 0 && #endif             strcmp(type, "user") != 0 &&             strcmp(type, "vde") != 0 &&             strcmp(type, "socket") != 0) {         if (qemu_opt_get(opts, "vlan")) {             error_set(errp, QERR_INVALID_PARAMETER, "vlan");             return -1;         if (qemu_opt_get(opts, "name")) {             error_set(errp, QERR_INVALID_PARAMETER, "name");             return -1;         if (!qemu_opts_id(opts)) {             error_set(errp, QERR_MISSING_PARAMETER, "id");     name = qemu_opts_id(opts);     if (!name) {         name = qemu_opt_get(opts, "name");     for (i = 0; i < NET_CLIENT_OPTIONS_KIND_MAX; i++) {         if (net_client_types[i].type != NULL &&             !strcmp(net_client_types[i].type, type)) {             Error *local_err = NULL;             VLANState *vlan = NULL;             int ret;             qemu_opts_validate(opts, &net_client_types[i].desc[0], &local_err);             if (error_is_set(&local_err)) {                 error_propagate(errp, local_err);                 return -1;             if (!(is_netdev ||                   (strcmp(type, "nic") == 0 && qemu_opt_get(opts, "netdev")))) {                 vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);             ret = 0;             if (net_client_types[i].init) {                 ret = net_client_types[i].init(opts, name, vlan);                 if (ret < 0) {                     error_set(errp, QERR_DEVICE_INIT_FAILED, type);                     return -1;             return ret;     error_set(errp, QERR_INVALID_PARAMETER_VALUE, "type",               "a network client type");     return -1;
int FUNC_0(QemuOpts *VAR_0, int VAR_1, Error **VAR_2)

{

    const char *VAR_3;

    const char *VAR_4;

    int VAR_5;



    VAR_4 = qemu_opt_get(VAR_0, "VAR_4");

    if (!VAR_4) {

        error_set(VAR_2, QERR_MISSING_PARAMETER, "VAR_4");

        return -1;

    }



    if (VAR_1) {

        if (strcmp(VAR_4, "tap") != 0 &&

#ifdef CONFIG_NET_BRIDGE

            strcmp(VAR_4, "bridge") != 0 &&

#endif

#ifdef CONFIG_SLIRP

            strcmp(VAR_4, "user") != 0 &&

#endif

#ifdef CONFIG_VDE

            strcmp(VAR_4, "vde") != 0 &&

#endif

            strcmp(VAR_4, "socket") != 0) {

            error_set(VAR_2, QERR_INVALID_PARAMETER_VALUE, "VAR_4",

                      "a netdev backend VAR_4");

            return -1;

        }



        if (qemu_opt_get(VAR_0, "vlan")) {

            error_set(VAR_2, QERR_INVALID_PARAMETER, "vlan");

            return -1;

        }

        if (qemu_opt_get(VAR_0, "VAR_3")) {

            error_set(VAR_2, QERR_INVALID_PARAMETER, "VAR_3");

            return -1;

        }

        if (!qemu_opts_id(VAR_0)) {

            error_set(VAR_2, QERR_MISSING_PARAMETER, "id");

            return -1;

        }

    }



    VAR_3 = qemu_opts_id(VAR_0);

    if (!VAR_3) {

        VAR_3 = qemu_opt_get(VAR_0, "VAR_3");

    }



    for (VAR_5 = 0; VAR_5 < NET_CLIENT_OPTIONS_KIND_MAX; VAR_5++) {

        if (net_client_types[VAR_5].VAR_4 != NULL &&

            !strcmp(net_client_types[VAR_5].VAR_4, VAR_4)) {

            Error *local_err = NULL;

            VLANState *vlan = NULL;

            int ret;



            qemu_opts_validate(VAR_0, &net_client_types[VAR_5].desc[0], &local_err);

            if (error_is_set(&local_err)) {

                error_propagate(VAR_2, local_err);

                return -1;

            }



            



            if (!(VAR_1 ||

                  (strcmp(VAR_4, "nic") == 0 && qemu_opt_get(VAR_0, "netdev")))) {

                vlan = qemu_find_vlan(qemu_opt_get_number(VAR_0, "vlan", 0), 1);

            }



            ret = 0;

            if (net_client_types[VAR_5].init) {

                ret = net_client_types[VAR_5].init(VAR_0, VAR_3, vlan);

                if (ret < 0) {

                    

                    error_set(VAR_2, QERR_DEVICE_INIT_FAILED, VAR_4);

                    return -1;

                }

            }

            return ret;

        }

    }



    error_set(VAR_2, QERR_INVALID_PARAMETER_VALUE, "VAR_4",

              "a network client VAR_4");

    return -1;

}

int FUNC_0(QemuOpts *VAR_0, int VAR_1, Error **VAR_2)
{ const char *VAR_3; const char *VAR_4; int VAR_5; VAR_4 = qemu_opt_get(VAR_0, "VAR_4"); if (!VAR_4) { error_set(VAR_2, QERR_MISSING_PARAMETER, "VAR_4"); return -1; } if (VAR_1) { if (strcmp(VAR_4, "tap") != 0 &&
#ifdef CONFIG_NET_BRIDGE
strcmp(VAR_4, "bridge") != 0 &&
#endif
#ifdef CONFIG_SLIRP
strcmp(VAR_4, "user") != 0 &&
#endif
#ifdef CONFIG_VDE
strcmp(VAR_4, "vde") != 0 &&
#endif
strcmp(VAR_4, "socket") != 0) { error_set(VAR_2, QERR_INVALID_PARAMETER_VALUE, "VAR_4",
"a netdev backend VAR_4"); return -1; } if (qemu_opt_get(VAR_0, "vlan")) { error_set(VAR_2, QERR_INVALID_PARAMETER, "vlan"); return -1; } if (qemu_opt_get(VAR_0, "VAR_3")) { error_set(VAR_2, QERR_INVALID_PARAMETER, "VAR_3"); return -1; } if (!qemu_opts_id(VAR_0)) { error_set(VAR_2, QERR_MISSING_PARAMETER, "id"); return -1; } } VAR_3 = qemu_opts_id(VAR_0); if (!VAR_3) { VAR_3 = qemu_opt_get(VAR_0, "VAR_3"); } for (VAR_5 = 0; VAR_5 < NET_CLIENT_OPTIONS_KIND_MAX; VAR_5++) { if (net_client_types[VAR_5].VAR_4 != NULL &&
!strcmp(net_client_types[VAR_5].VAR_4, VAR_4)) { Error *local_err = NULL; VLANState *vlan = NULL; int ret; qemu_opts_validate(VAR_0, &net_client_types[VAR_5].desc[0], &local_err); if (error_is_set(&local_err)) { error_propagate(VAR_2, local_err); return -1; } if (!(VAR_1 ||
(strcmp(VAR_4, "nic") == 0 && qemu_opt_get(VAR_0, "netdev")))) { vlan = qemu_find_vlan(qemu_opt_get_number(VAR_0, "vlan", 0), 1); } ret = 0; if (net_client_types[VAR_5].init) { ret = net_client_types[VAR_5].init(VAR_0, VAR_3, vlan); if (ret < 0) { error_set(VAR_2, QERR_DEVICE_INIT_FAILED, VAR_4); return -1; } } return ret; } } error_set(VAR_2, QERR_INVALID_PARAMETER_VALUE, "VAR_4",
"a network client VAR_4"); return -1; }