Improved sanity checking to -net options
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2877 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
1b2e93c175
commit
833c7174ce
18
vl.c
18
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') {
|
||||
|
Loading…
Reference in New Issue
Block a user