mirror of https://github.com/xemu-project/xemu.git
added -macaddr option
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@697 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
1154e441aa
commit
702c651c4a
53
vl.c
53
vl.c
|
@ -1600,6 +1600,7 @@ void help(void)
|
||||||
"Network options:\n"
|
"Network options:\n"
|
||||||
"-n script set network init script [default=%s]\n"
|
"-n script set network init script [default=%s]\n"
|
||||||
"-nics n simulate 'n' network interfaces [default=1]\n"
|
"-nics n simulate 'n' network interfaces [default=1]\n"
|
||||||
|
"-macaddr addr set the mac address of the first interface\n"
|
||||||
"-tun-fd fd0[,...] use these fds as already opened tap/tun interfaces\n"
|
"-tun-fd fd0[,...] use these fds as already opened tap/tun interfaces\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Linux boot specific:\n"
|
"Linux boot specific:\n"
|
||||||
|
@ -1655,6 +1656,7 @@ struct option long_options[] = {
|
||||||
{ "fdb", 1, NULL, 0, },
|
{ "fdb", 1, NULL, 0, },
|
||||||
{ "no-code-copy", 0, NULL, 0 },
|
{ "no-code-copy", 0, NULL, 0 },
|
||||||
{ "nics", 1, NULL, 0 },
|
{ "nics", 1, NULL, 0 },
|
||||||
|
{ "macaddr", 1, NULL, 0 },
|
||||||
{ NULL, 0, NULL, 0 },
|
{ NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1692,6 +1694,7 @@ int main(int argc, char **argv)
|
||||||
const char *kernel_filename, *kernel_cmdline;
|
const char *kernel_filename, *kernel_cmdline;
|
||||||
DisplayState *ds = &display_state;
|
DisplayState *ds = &display_state;
|
||||||
int cyls, heads, secs;
|
int cyls, heads, secs;
|
||||||
|
uint8_t macaddr[6];
|
||||||
|
|
||||||
#if !defined(CONFIG_SOFTMMU)
|
#if !defined(CONFIG_SOFTMMU)
|
||||||
/* we never want that malloc() uses mmap() */
|
/* we never want that malloc() uses mmap() */
|
||||||
|
@ -1717,17 +1720,13 @@ int main(int argc, char **argv)
|
||||||
cyls = heads = secs = 0;
|
cyls = heads = secs = 0;
|
||||||
|
|
||||||
nb_nics = 1;
|
nb_nics = 1;
|
||||||
for(i = 0; i < MAX_NICS; i++) {
|
/* default mac address of the first network interface */
|
||||||
NetDriverState *nd = &nd_table[i];
|
macaddr[0] = 0x52;
|
||||||
nd->fd = -1;
|
macaddr[1] = 0x54;
|
||||||
/* init virtual mac address */
|
macaddr[2] = 0x00;
|
||||||
nd->macaddr[0] = 0x52;
|
macaddr[3] = 0x12;
|
||||||
nd->macaddr[1] = 0x54;
|
macaddr[4] = 0x34;
|
||||||
nd->macaddr[2] = 0x00;
|
macaddr[5] = 0x56;
|
||||||
nd->macaddr[3] = 0x12;
|
|
||||||
nd->macaddr[4] = 0x34;
|
|
||||||
nd->macaddr[5] = 0x56 + i;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
c = getopt_long_only(argc, argv, "hm:d:n:sp:L:", long_options, &long_index);
|
c = getopt_long_only(argc, argv, "hm:d:n:sp:L:", long_options, &long_index);
|
||||||
|
@ -1835,6 +1834,27 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 17:
|
||||||
|
{
|
||||||
|
const char *p;
|
||||||
|
int i;
|
||||||
|
p = optarg;
|
||||||
|
for(i = 0; i < 6; i++) {
|
||||||
|
macaddr[i] = strtol(p, (char **)&p, 16);
|
||||||
|
if (i == 5) {
|
||||||
|
if (*p != '\0')
|
||||||
|
goto macaddr_error;
|
||||||
|
} else {
|
||||||
|
if (*p != ':') {
|
||||||
|
macaddr_error:
|
||||||
|
fprintf(stderr, "qemu: invalid syntax for ethernet address\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -1912,6 +1932,17 @@ int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* init host network redirectors */
|
/* init host network redirectors */
|
||||||
|
for(i = 0; i < MAX_NICS; i++) {
|
||||||
|
NetDriverState *nd = &nd_table[i];
|
||||||
|
nd->fd = -1;
|
||||||
|
/* init virtual mac address */
|
||||||
|
nd->macaddr[0] = macaddr[0];
|
||||||
|
nd->macaddr[1] = macaddr[1];
|
||||||
|
nd->macaddr[2] = macaddr[2];
|
||||||
|
nd->macaddr[3] = macaddr[3];
|
||||||
|
nd->macaddr[4] = macaddr[4];
|
||||||
|
nd->macaddr[5] = macaddr[5] + i;
|
||||||
|
}
|
||||||
net_init();
|
net_init();
|
||||||
|
|
||||||
/* init the memory */
|
/* init the memory */
|
||||||
|
|
Loading…
Reference in New Issue