Commit 833c7174ce5145397d2b3405f6857ca607fed1f1
1 parent
1b2e93c1
Improved sanity checking to -net options
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2877 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
19 additions
and
0 deletions
vl.c
... | ... | @@ -4197,6 +4197,7 @@ static int net_client_init(const char *str) |
4197 | 4197 | } |
4198 | 4198 | nd->vlan = vlan; |
4199 | 4199 | nb_nics++; |
4200 | + vlan->nb_guest_devs++; | |
4200 | 4201 | ret = 0; |
4201 | 4202 | } else |
4202 | 4203 | if (!strcmp(device, "none")) { |
... | ... | @@ -4209,6 +4210,7 @@ static int net_client_init(const char *str) |
4209 | 4210 | if (get_param_value(buf, sizeof(buf), "hostname", p)) { |
4210 | 4211 | pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf); |
4211 | 4212 | } |
4213 | + vlan->nb_host_devs++; | |
4212 | 4214 | ret = net_slirp_init(vlan); |
4213 | 4215 | } else |
4214 | 4216 | #endif |
... | ... | @@ -4219,6 +4221,7 @@ static int net_client_init(const char *str) |
4219 | 4221 | fprintf(stderr, "tap: no interface name\n"); |
4220 | 4222 | return -1; |
4221 | 4223 | } |
4224 | + vlan->nb_host_devs++; | |
4222 | 4225 | ret = tap_win32_init(vlan, ifname); |
4223 | 4226 | } else |
4224 | 4227 | #else |
... | ... | @@ -4238,6 +4241,7 @@ static int net_client_init(const char *str) |
4238 | 4241 | if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) { |
4239 | 4242 | pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT); |
4240 | 4243 | } |
4244 | + vlan->nb_host_devs++; | |
4241 | 4245 | ret = net_tap_init(vlan, ifname, setup_script); |
4242 | 4246 | } |
4243 | 4247 | } else |
... | ... | @@ -4259,6 +4263,7 @@ static int net_client_init(const char *str) |
4259 | 4263 | fprintf(stderr, "Unknown socket options: %s\n", p); |
4260 | 4264 | return -1; |
4261 | 4265 | } |
4266 | + vlan->nb_host_devs++; | |
4262 | 4267 | } else |
4263 | 4268 | { |
4264 | 4269 | fprintf(stderr, "Unknown network device: %s\n", device); |
... | ... | @@ -7131,6 +7136,7 @@ int main(int argc, char **argv) |
7131 | 7136 | int usb_devices_index; |
7132 | 7137 | int fds[2]; |
7133 | 7138 | const char *pid_file = NULL; |
7139 | + VLANState *vlan; | |
7134 | 7140 | |
7135 | 7141 | LIST_INIT (&vm_change_state_head); |
7136 | 7142 | #ifndef _WIN32 |
... | ... | @@ -7750,6 +7756,18 @@ int main(int argc, char **argv) |
7750 | 7756 | if (net_client_init(net_clients[i]) < 0) |
7751 | 7757 | exit(1); |
7752 | 7758 | } |
7759 | + for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) { | |
7760 | + if (vlan->nb_guest_devs == 0 && vlan->nb_host_devs == 0) | |
7761 | + continue; | |
7762 | + if (vlan->nb_guest_devs == 0) { | |
7763 | + fprintf(stderr, "Invalid vlan (%d) with no nics\n", vlan->id); | |
7764 | + exit(1); | |
7765 | + } | |
7766 | + if (vlan->nb_host_devs == 0) | |
7767 | + fprintf(stderr, | |
7768 | + "Warning: vlan %d is not connected to host network\n", | |
7769 | + vlan->id); | |
7770 | + } | |
7753 | 7771 | |
7754 | 7772 | #ifdef TARGET_I386 |
7755 | 7773 | if (boot_device == 'n') { | ... | ... |