aboutsummaryrefslogtreecommitdiff
path: root/kvm/kvm
diff options
context:
space:
mode:
Diffstat (limited to 'kvm/kvm')
-rwxr-xr-xkvm/kvm16
1 files changed, 14 insertions, 2 deletions
diff --git a/kvm/kvm b/kvm/kvm
index 73c351525..b5e315309 100755
--- a/kvm/kvm
+++ b/kvm/kvm
@@ -1,7 +1,7 @@
#!/usr/bin/python
import sys, os, time, re
-import optparse
+import optparse, commands
optparser = optparse.OptionParser()
@@ -140,7 +140,19 @@ if options.debugger:
qemu_args += ('-s',)
if not options.notap:
- qemu_args += ('-net', 'nic' ,'-net', 'tap,script=/etc/kvm/qemu-ifup',)
+ mac = None
+ for line in commands.getoutput('ip link show eth0').splitlines():
+ m = re.match(r'.*link/ether (..:..:..:..:..:..).*', line)
+ if m:
+ mac = m.group(1)
+ if not mac:
+ raise Exception, 'Unable to determine eth0 mac address'
+ mac_components = mac.split(':')
+ mac_components[0] = 'a0'
+ mac = ':'.join(mac_components)
+
+ qemu_args += ('-net', 'nic,macaddr=%s' % (mac,),
+ '-net', 'tap,script=/etc/kvm/qemu-ifup',)
if options.vnc is not None:
qemu_args += ('-vnc', str(options.vnc))