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;
|
nd->vlan = vlan;
|
||||||
nb_nics++;
|
nb_nics++;
|
||||||
|
vlan->nb_guest_devs++;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else
|
} else
|
||||||
if (!strcmp(device, "none")) {
|
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)) {
|
if (get_param_value(buf, sizeof(buf), "hostname", p)) {
|
||||||
pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf);
|
pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf);
|
||||||
}
|
}
|
||||||
|
vlan->nb_host_devs++;
|
||||||
ret = net_slirp_init(vlan);
|
ret = net_slirp_init(vlan);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@ -4219,6 +4221,7 @@ static int net_client_init(const char *str)
|
|||||||
fprintf(stderr, "tap: no interface name\n");
|
fprintf(stderr, "tap: no interface name\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
vlan->nb_host_devs++;
|
||||||
ret = tap_win32_init(vlan, ifname);
|
ret = tap_win32_init(vlan, ifname);
|
||||||
} else
|
} else
|
||||||
#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) {
|
if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) {
|
||||||
pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT);
|
pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT);
|
||||||
}
|
}
|
||||||
|
vlan->nb_host_devs++;
|
||||||
ret = net_tap_init(vlan, ifname, setup_script);
|
ret = net_tap_init(vlan, ifname, setup_script);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -4259,6 +4263,7 @@ static int net_client_init(const char *str)
|
|||||||
fprintf(stderr, "Unknown socket options: %s\n", p);
|
fprintf(stderr, "Unknown socket options: %s\n", p);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
vlan->nb_host_devs++;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unknown network device: %s\n", device);
|
fprintf(stderr, "Unknown network device: %s\n", device);
|
||||||
@ -7131,6 +7136,7 @@ int main(int argc, char **argv)
|
|||||||
int usb_devices_index;
|
int usb_devices_index;
|
||||||
int fds[2];
|
int fds[2];
|
||||||
const char *pid_file = NULL;
|
const char *pid_file = NULL;
|
||||||
|
VLANState *vlan;
|
||||||
|
|
||||||
LIST_INIT (&vm_change_state_head);
|
LIST_INIT (&vm_change_state_head);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
@ -7750,6 +7756,18 @@ int main(int argc, char **argv)
|
|||||||
if (net_client_init(net_clients[i]) < 0)
|
if (net_client_init(net_clients[i]) < 0)
|
||||||
exit(1);
|
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
|
#ifdef TARGET_I386
|
||||||
if (boot_device == 'n') {
|
if (boot_device == 'n') {
|
||||||
|
1
vl.h
1
vl.h
@ -389,6 +389,7 @@ typedef struct VLANState {
|
|||||||
int id;
|
int id;
|
||||||
VLANClientState *first_client;
|
VLANClientState *first_client;
|
||||||
struct VLANState *next;
|
struct VLANState *next;
|
||||||
|
unsigned int nb_guest_devs, nb_host_devs;
|
||||||
} VLANState;
|
} VLANState;
|
||||||
|
|
||||||
VLANState *qemu_find_vlan(int id);
|
VLANState *qemu_find_vlan(int id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user