From 833c7174ce5145397d2b3405f6857ca607fed1f1 Mon Sep 17 00:00:00 2001 From: blueswir1 Date: Sun, 27 May 2007 19:36:43 +0000 Subject: Improved sanity checking to -net options git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2877 c046a42c-6fe2-441c-8c8c-71466251a162 --- vl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'vl.c') diff --git a/vl.c b/vl.c index d23af87a71..61c6c1a013 100644 --- a/vl.c +++ b/vl.c @@ -4197,6 +4197,7 @@ static int net_client_init(const char *str) } nd->vlan = vlan; nb_nics++; + vlan->nb_guest_devs++; ret = 0; } else if (!strcmp(device, "none")) { @@ -4209,6 +4210,7 @@ static int net_client_init(const char *str) if (get_param_value(buf, sizeof(buf), "hostname", p)) { pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf); } + vlan->nb_host_devs++; ret = net_slirp_init(vlan); } else #endif @@ -4219,6 +4221,7 @@ static int net_client_init(const char *str) fprintf(stderr, "tap: no interface name\n"); return -1; } + vlan->nb_host_devs++; ret = tap_win32_init(vlan, ifname); } else #else @@ -4238,6 +4241,7 @@ static int net_client_init(const char *str) if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) { pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT); } + vlan->nb_host_devs++; ret = net_tap_init(vlan, ifname, setup_script); } } else @@ -4259,6 +4263,7 @@ static int net_client_init(const char *str) fprintf(stderr, "Unknown socket options: %s\n", p); return -1; } + vlan->nb_host_devs++; } else { fprintf(stderr, "Unknown network device: %s\n", device); @@ -7131,6 +7136,7 @@ int main(int argc, char **argv) int usb_devices_index; int fds[2]; const char *pid_file = NULL; + VLANState *vlan; LIST_INIT (&vm_change_state_head); #ifndef _WIN32 @@ -7750,6 +7756,18 @@ int main(int argc, char **argv) if (net_client_init(net_clients[i]) < 0) exit(1); } + for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) { + if (vlan->nb_guest_devs == 0 && vlan->nb_host_devs == 0) + continue; + if (vlan->nb_guest_devs == 0) { + fprintf(stderr, "Invalid vlan (%d) with no nics\n", vlan->id); + exit(1); + } + if (vlan->nb_host_devs == 0) + fprintf(stderr, + "Warning: vlan %d is not connected to host network\n", + vlan->id); + } #ifdef TARGET_I386 if (boot_device == 'n') { -- cgit v1.2.3