[oe-commits] [openembedded-core] 16/20: runqemu: Allow unique network interface MAC addresses

git at git.openembedded.org git at git.openembedded.org
Fri Sep 9 11:08:34 UTC 2016


rpurdie pushed a commit to branch master
in repository openembedded-core.

commit c01962bf88786dd84ad83cc1d315297607d29f7c
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Tue Sep 6 14:46:10 2016 +0100

    runqemu: Allow unique network interface MAC addresses
    
    Current qemu instances all share the same MAC address. This shouldn't be an
    issue as they are all on separate network interfaces, however on the slight
    chance this is causing problems, its easy enough to ensure we use unique
    MAC addresses based on the IP numbers we assign.
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/conf/machine/qemuarm64.conf | 2 +-
 meta/conf/machine/qemuppc.conf   | 2 +-
 scripts/runqemu                  | 5 +++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/meta/conf/machine/qemuarm64.conf b/meta/conf/machine/qemuarm64.conf
index df76ee6..da59c33 100644
--- a/meta/conf/machine/qemuarm64.conf
+++ b/meta/conf/machine/qemuarm64.conf
@@ -16,7 +16,7 @@ QB_MACHINE = "-machine virt"
 QB_CPU = "-cpu cortex-a57"
 QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,38400"
 QB_OPT_APPEND = "-show-cursor"
-QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no -device virtio-net-device,netdev=net0"
+QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no -device virtio-net-device,netdev=net0,mac=@MAC@"
 QB_SLIRP_OPT = "-netdev user,id=net0 -device virtio-net-device,netdev=net0"
 QB_ROOTFS_OPT = "-drive id=disk0,file=@ROOTFS@,if=none,format=raw -device virtio-blk-device,drive=disk0"
 QB_SERIAL_OPT = "-device virtio-serial-device -chardev null,id=virtcon -device virtconsole,chardev=virtcon"
diff --git a/meta/conf/machine/qemuppc.conf b/meta/conf/machine/qemuppc.conf
index 939c834..e4c8dac 100644
--- a/meta/conf/machine/qemuppc.conf
+++ b/meta/conf/machine/qemuppc.conf
@@ -17,4 +17,4 @@ QB_MACHINE = "-machine mac99"
 QB_CPU = "-cpu G4"
 QB_KERNEL_CMDLINE_APPEND = "console=ttyS0 console=tty"
 QB_OPT_APPEND = "-show-cursor -usb -usbdevice tablet"
-QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no -device virtio-net-pci,netdev=net0"
+QB_TAP_OPT = "-netdev tap,id=net0,ifname=@TAP@,script=no,downscript=no -device virtio-net-pci,netdev=net0,mac=@MAC@"
diff --git a/scripts/runqemu b/scripts/runqemu
index 91e72cb..c43db8c 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -736,11 +736,12 @@ class BaseConfig(object):
         if self.fstype == 'nfs':
             self.setup_nfs()
         self.kernel_cmdline_script += " ip=192.168.7.%s::192.168.7.%s:255.255.255.0" % (n2, n1)
+        mac = "52:54:00:12:34:%02x" % n2
         qb_tap_opt = self.get('QB_TAP_OPT')
         if qb_tap_opt:
-            qemu_tap_opt = qb_tap_opt.replace('@TAP@', tap)
+            qemu_tap_opt = qb_tap_opt.replace('@TAP@', tap).replace('@MAC@', mac)
         else:
-            qemu_tap_opt = "-net nic,model=virtio -net tap,vlan=0,ifname=%s,script=no,downscript=no" % self.tap
+            qemu_tap_opt = "-net nic,model=virtio,mac=%s -net tap,vlan=0,ifname=%s,script=no,downscript=no" % (mac, self.tap)
 
         if self.vhost_enabled:
             qemu_tap_opt += ',vhost=on'

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list