<html>
  <head>
    <meta content="text/html; charset=GB2312" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 01/20/2014 10:43 PM, Shu Ming wrote:<br>
    </div>
    <blockquote cite="mid:52DDC2B8.4090903@linux.vnet.ibm.com"
      type="cite">
      <meta content="text/html; charset=GB2312"
        http-equiv="Content-Type">
      <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>
          &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>
        </font></blockquote>
      <br>
      Let libvirt to generate the MAC addresses are better.&nbsp;&nbsp;
      randomMAC() does not gurantee that the MAC address generated is
      unique,&nbsp; so you need to handle that in your code. If libvirt
      doesn't gurantee that either,&nbsp; we can file a bug against libvirt.<br>
      <br>
    </blockquote>
    <br>
    Ok. But if we let libvirt generates the MAC we come back to the
    original problem mentioned by Sheldon.<br>
    How do we get the MAC to return to kimchi API?<br>
    <br>
    <blockquote cite="mid:52DDC2B8.4090903@linux.vnet.ibm.com"
      type="cite">
      <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 moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<a moz-do-not-send="true" 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>
    </blockquote>
    <br>
  </body>
</html>