<html>
<head>
<meta content="text/html; charset=GB2312" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">ÓÚ 2014/1/21 1:17, Aline Manera дµÀ:<br>
</div>
<blockquote cite="mid:52DD5A33.3080900@linux.vnet.ibm.com"
type="cite">
<meta content="text/html; charset=GB2312"
http-equiv="Content-Type">
<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>
</font></blockquote>
<br>
Let libvirt to generate the MAC addresses are better. randomMAC()
does not gurantee that the MAC address generated is unique, so you
need to handle that in your code. If libvirt doesn't gurantee that
either, we can file a bug against libvirt.<br>
<br>
<blockquote cite="mid:52DD5A33.3080900@linux.vnet.ibm.com"
type="cite"><font face="DejaVu Sans Mono"> <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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Kimchi-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>