# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import os
+import random
import sys
# Generate libvirt XML. Would be nice to use virt-install here, but
if not virtio:
network_model = "e1000"
+ # Give the network a fixed MAC address, otherwise libvirt will
+ # generate a random one on every guest restart.
+ network_mac = "52:54:00:%02x:%02x:%02x" % (random.randint (0, 0xff),
+ random.randint (0, 0xff),
+ random.randint (0, 0xff))
+
# XXX Quoting, and we should use a real XML generator.
xml = """
<domain type='kvm'>
<on_crash>restart</on_crash>
<devices>
<interface type='bridge'>
+ <mac address='%s'/>
<source bridge='br0'/>
<model type='%s'/>
</interface>
<video>
<model type='cirrus' vram='9216' heads='1'/>
</video>
-""" % (vm_name, memory, memory, vcpus, network_model)
+""" % (vm_name, memory, memory, vcpus, network_mac, network_model)
# virtio-scsi or IDE disk:
if virtio: