summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2007-05-27 19:36:43 +0000
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2007-05-27 19:36:43 +0000
commit833c7174ce5145397d2b3405f6857ca607fed1f1 (patch)
tree98e297a268e6b91421d030b6614535542acf3386 /vl.c
parent1b2e93c175a947653326efce9a6f36791d458691 (diff)
downloadqemu-833c7174ce5145397d2b3405f6857ca607fed1f1.tar.gz
Improved sanity checking to -net options
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2877 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c18
1 files changed, 18 insertions, 0 deletions
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') {