<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>
      &lt;interface type='network'&gt;
      <br>
      &lt;source network='default'/&gt;
      <br>
      &lt;/interface&gt;
      <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>
      &lt;interface type='network'&gt;
      <br>
      &lt;mac address='52:54:00:2a:53:8f'/&gt;
      <br>
      &lt;source network='default'/&gt;
      <br>
      &lt;model type='rtl8139'/&gt;
      <br>
      &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x03'
      function='0x0'/&gt;
      <br>
      &lt;/interface&gt;
      <br>
      """
      <br>
      <br>
      <br>
    </blockquote>
    <br>
    <font face="DejaVu Sans Mono">We can generate the mac and pass it to
      libvirt:<br>
      <br>
      &gt;&gt;&gt; import virtinst.util<br>
      &gt;&gt;&gt; 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>