diff --git a/sys/man/1/vmx b/sys/man/1/vmx index 9f8b8ac57..656a114cf 100644 --- a/sys/man/1/vmx +++ b/sys/man/1/vmx @@ -100,6 +100,8 @@ Alternatively, a dial string such as \fLudp!\fIhost\fL!\fIport\fR can be used. It can also be prefixed by \fLfile!\fR to interpret the argument as a file instead and it can be prefixed by \fLhdr!\fR to enable headers matching the binary .IR snoopy (8) format. +The MAC address can be specified with the \fLea:\fInnnnnnnnnnnn\fL!\fR prefix, +otherwise a random address is used. .PP A .B -d diff --git a/sys/src/cmd/vmx/virtio.c b/sys/src/cmd/vmx/virtio.c index 1dd1b5537..4e18fa7bd 100644 --- a/sys/src/cmd/vmx/virtio.c +++ b/sys/src/cmd/vmx/virtio.c @@ -4,6 +4,9 @@ #include "dat.h" #include "fns.h" +#include /* parseether() */ +#include /* genrandom() */ + typedef struct VIODev VIODev; typedef struct VIOQueue VIOQueue; typedef struct VIOBuf VIOBuf; @@ -633,10 +636,11 @@ mkvionet(char *net) { int fd, cfd; VIODev *d; - int i; + char *ea; int flags; enum { VNETFILE = 1 }; + ea = nil; flags = 0; for(;;){ if(strncmp(net, "hdr!", 4) == 0){ @@ -645,6 +649,12 @@ mkvionet(char *net) }else if(strncmp(net, "file!", 5) == 0){ net += 5; flags |= VNETFILE; + }else if(strncmp(net, "ea:", 3) == 0){ + net = strchr(ea = net+3, '!'); + if(net++ == nil){ + werrstr("missing: !"); + return -1; + } }else break; } @@ -665,9 +675,10 @@ mkvionet(char *net) mkvioqueue(d, 1024, viowakeup); mkvioqueue(d, 1024, viowakeup); mkvioqueue(d, 32, vionetcmd); - for(i = 0; i < 6; i++) - d->net.mac[i] = rand(); - d->net.mac[0] = d->net.mac[0] & ~1 | 2; + if(ea == nil || parseether(d->net.mac, ea)){ + genrandom(d->net.mac, 6); + d->net.mac[0] = d->net.mac[0] & ~1 | 2; + } d->net.flags = flags; d->devfeat = 1<<5|1<<16|1<<17|1<<18|1<<20; d->io = vionetio; diff --git a/sys/src/cmd/vmx/vmx.c b/sys/src/cmd/vmx/vmx.c index aeeeb9676..c4484966e 100644 --- a/sys/src/cmd/vmx/vmx.c +++ b/sys/src/cmd/vmx/vmx.c @@ -87,7 +87,6 @@ vmxsetup(void) rc = read(ctlfd, name, sizeof(name) - 1); if(rc < 0) sysfatal("read: %r"); name[rc] = 0; - srand(atoi(name)); if(segname == nil){ segname = smprint("vm.%s", name); segrclose = ORCLOSE;