aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2004-04-02 21:21:32 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2004-04-02 21:21:32 +0000
commit702c651c4ae90ac399264c07aded66df2c0efacf (patch)
treeb5584418f8597075292d0a9f3ccd6379155616e1 /vl.c
parent1154e441aa19ce3bf15fb0cabab2a5656321b43f (diff)
added -macaddr option
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@697 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c53
1 files changed, 42 insertions, 11 deletions
diff --git a/vl.c b/vl.c
index 24895508d0..cefe0e9ab4 100644
--- a/vl.c
+++ b/vl.c
@@ -1600,6 +1600,7 @@ void help(void)
"Network options:\n"
"-n script set network init script [default=%s]\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"
"\n"
"Linux boot specific:\n"
@@ -1655,6 +1656,7 @@ struct option long_options[] = {
{ "fdb", 1, NULL, 0, },
{ "no-code-copy", 0, NULL, 0 },
{ "nics", 1, NULL, 0 },
+ { "macaddr", 1, NULL, 0 },
{ NULL, 0, NULL, 0 },
};
@@ -1692,6 +1694,7 @@ int main(int argc, char **argv)
const char *kernel_filename, *kernel_cmdline;
DisplayState *ds = &display_state;
int cyls, heads, secs;
+ uint8_t macaddr[6];
#if !defined(CONFIG_SOFTMMU)
/* we never want that malloc() uses mmap() */
@@ -1717,17 +1720,13 @@ int main(int argc, char **argv)
cyls = heads = secs = 0;
nb_nics = 1;
- for(i = 0; i < MAX_NICS; i++) {
- NetDriverState *nd = &nd_table[i];
- nd->fd = -1;
- /* init virtual mac address */
- nd->macaddr[0] = 0x52;
- nd->macaddr[1] = 0x54;
- nd->macaddr[2] = 0x00;
- nd->macaddr[3] = 0x12;
- nd->macaddr[4] = 0x34;
- nd->macaddr[5] = 0x56 + i;
- }
+ /* default mac address of the first network interface */
+ macaddr[0] = 0x52;
+ macaddr[1] = 0x54;
+ macaddr[2] = 0x00;
+ macaddr[3] = 0x12;
+ macaddr[4] = 0x34;
+ macaddr[5] = 0x56;
for(;;) {
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);
}
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;
case 'h':
@@ -1912,6 +1932,17 @@ int main(int argc, char **argv)
#endif
/* 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();
/* init the memory */