Selectable MAC address
PATCH 1/1 Selectable MAC address
Hi! Here's a small patch which enables MAC adddress selection for the NE2000 network interface (it's a diff against the current CVS version). If you invoke 'qemu' with, say,
$ qemu -M 12:34:56:78:9A:BC -nics 3
, then the MAC of the first interface will be 12:34:56:78:9A:BC, the one of the second interface will be 12:34:56:78:9A:BD and so on
Carlos
Index: vl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.c,v
retrieving revision 1.52
vl.c +34 -1
@@ -1730,7 +1730,7 @@ }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:M:" , long_options, &long_index);if (c ==-1 )break ;switch (c) {
@@ -1840,6 +1840,39 @@case 'h' :help ();break ; + +case 'M' : + { +int mac[6 ]; +char *octet = optarg; + +/* Get base MAC address */ + optarg =strchr (optarg,':' ); +for (i =0 ; i <6 && optarg; ++i) { + *optarg ='\0' ; + ++optarg; + mac[i] =strtol (octet,NULL ,16 ); + + octet = optarg; + optarg =strchr (optarg,':' ); + } + mac[i] =strtol (octet,NULL ,16 ); + +/* Apply base MAC to al interfaces */ +for (i =0 ; i <MAX_NICS ; i++) { +NetDriverState *nd = &nd_table[i]; + nd->fd =-1 ; +/* init virtual mac address */ + nd->macaddr[0 ] = mac[0 ]; + nd->macaddr[1 ] = mac[1 ]; + nd->macaddr[2 ] = mac[2 ]; + nd->macaddr[3 ] = mac[3 ]; + nd->macaddr[4 ] = mac[4 ]; + nd->macaddr[5 ] = mac[5 ] + i; + } + } +break ; +case 'm' : ram_size =atoi (optarg) *1024 *1024 ;if (ram_size <=0 )