net.c (ca7eb1848bb06d9b75784d7760b83c7b0beb1102) net.c (a30ecde6e795682d1473c45acae66a60a76fca2f)
1/*
2 * QEMU System Emulator
3 *
4 * Copyright (c) 2003-2008 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 726 unchanged lines hidden (view full) ---

735 return i;
736 }
737
738 error_report("Unsupported NIC model: %s", nd->model);
739 return -1;
740}
741
742static int net_init_nic(const NetClientOptions *opts, const char *name,
1/*
2 * QEMU System Emulator
3 *
4 * Copyright (c) 2003-2008 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 726 unchanged lines hidden (view full) ---

735 return i;
736 }
737
738 error_report("Unsupported NIC model: %s", nd->model);
739 return -1;
740}
741
742static int net_init_nic(const NetClientOptions *opts, const char *name,
743 NetClientState *peer)
743 NetClientState *peer, Error **errp)
744{
744{
745 /* FIXME error_setg(errp, ...) on failure */
745 int idx;
746 NICInfo *nd;
747 const NetLegacyNicOptions *nic;
748
749 assert(opts->kind == NET_CLIENT_OPTIONS_KIND_NIC);
750 nic = opts->nic;
751
752 idx = nic_get_free_idx();

--- 51 unchanged lines hidden (view full) ---

804
805 return idx;
806}
807
808
809static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])(
810 const NetClientOptions *opts,
811 const char *name,
746 int idx;
747 NICInfo *nd;
748 const NetLegacyNicOptions *nic;
749
750 assert(opts->kind == NET_CLIENT_OPTIONS_KIND_NIC);
751 nic = opts->nic;
752
753 idx = nic_get_free_idx();

--- 51 unchanged lines hidden (view full) ---

805
806 return idx;
807}
808
809
810static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])(
811 const NetClientOptions *opts,
812 const char *name,
812 NetClientState *peer) = {
813 NetClientState *peer, Error **errp) = {
813 [NET_CLIENT_OPTIONS_KIND_NIC] = net_init_nic,
814#ifdef CONFIG_SLIRP
815 [NET_CLIENT_OPTIONS_KIND_USER] = net_init_slirp,
816#endif
817 [NET_CLIENT_OPTIONS_KIND_TAP] = net_init_tap,
818 [NET_CLIENT_OPTIONS_KIND_SOCKET] = net_init_socket,
819#ifdef CONFIG_VDE
820 [NET_CLIENT_OPTIONS_KIND_VDE] = net_init_vde,

--- 76 unchanged lines hidden (view full) ---

897 /* Do not add to a vlan if it's a -netdev or a nic with a netdev=
898 * parameter. */
899 if (!is_netdev &&
900 (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC ||
901 !opts->nic->has_netdev)) {
902 peer = net_hub_add_port(u.net->has_vlan ? u.net->vlan : 0, NULL);
903 }
904
814 [NET_CLIENT_OPTIONS_KIND_NIC] = net_init_nic,
815#ifdef CONFIG_SLIRP
816 [NET_CLIENT_OPTIONS_KIND_USER] = net_init_slirp,
817#endif
818 [NET_CLIENT_OPTIONS_KIND_TAP] = net_init_tap,
819 [NET_CLIENT_OPTIONS_KIND_SOCKET] = net_init_socket,
820#ifdef CONFIG_VDE
821 [NET_CLIENT_OPTIONS_KIND_VDE] = net_init_vde,

--- 76 unchanged lines hidden (view full) ---

898 /* Do not add to a vlan if it's a -netdev or a nic with a netdev=
899 * parameter. */
900 if (!is_netdev &&
901 (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC ||
902 !opts->nic->has_netdev)) {
903 peer = net_hub_add_port(u.net->has_vlan ? u.net->vlan : 0, NULL);
904 }
905
905 if (net_client_init_fun[opts->kind](opts, name, peer) < 0) {
906 /* TODO push error reporting into init() methods */
907 error_set(errp, QERR_DEVICE_INIT_FAILED,
908 NetClientOptionsKind_lookup[opts->kind]);
906 if (net_client_init_fun[opts->kind](opts, name, peer, errp) < 0) {
907 /* FIXME drop when all init functions store an Error */
908 if (errp && !*errp) {
909 error_set(errp, QERR_DEVICE_INIT_FAILED,
910 NetClientOptionsKind_lookup[opts->kind]);
911 }
909 return -1;
910 }
911 }
912 return 0;
913}
914
915
916static void net_visit(Visitor *v, int is_netdev, void **object, Error **errp)

--- 480 unchanged lines hidden ---
912 return -1;
913 }
914 }
915 return 0;
916}
917
918
919static void net_visit(Visitor *v, int is_netdev, void **object, Error **errp)

--- 480 unchanged lines hidden ---