<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 01/20/2014 11:34 AM, Sheldon wrote:<br>
</div>
<blockquote cite="mid:52DD25E9.4070700@linux.vnet.ibm.com"
type="cite">when I create a interface, There is no mac attribute
in the xml.
<br>
After create successfully, libvirt will allocate a mac.
<br>
The problem is that, How can I get the mac.
<br>
<br>
Should the CREATE method always needs to return an interface info?
<br>
<br>
Here is some of create code.
<br>
<br>
def vmifaces_create(self, vm, params):
<br>
dom = self._get_vm(vm)
<br>
xml = """
<br>
<interface type='network'>
<br>
<source network='default'/>
<br>
</interface>
<br>
"""
<br>
<br>
dom.attachDeviceFlags(xml,
<br>
libvirt.VIR_DOMAIN_AFFECT_CURRENT)
<br>
<br>
# here I need to return the mac
<br>
return ????
<br>
<br>
<br>
<br>
The libvirt will create a xml like the follow? The problem is that
the a vm may have several interfaces.
<br>
xml = """
<br>
<interface type='network'>
<br>
<mac address='52:54:00:2a:53:8f'/>
<br>
<source network='default'/>
<br>
<model type='rtl8139'/>
<br>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03'
function='0x0'/>
<br>
</interface>
<br>
"""
<br>
<br>
<br>
</blockquote>
<br>
<font face="DejaVu Sans Mono">We can generate the mac and pass it to
libvirt:<br>
<br>
>>> import virtinst.util<br>
>>> print virtinst.util.randomMAC()<br>
00:16:3e:fd:b4:3a<br>
<br>
I don't if libvirt requires a mac starting with </font>"52:52:00"<br>
Maybe it is used to avoid generating duplicated mac addresses.<br>
</body>
</html>