[Kimchi-devel] [RFC]: help, how to get the mac after create a VM interface.

Christy Perez christy at linux.vnet.ibm.com
Wed Jan 22 17:45:24 UTC 2014


libvirt always adds the new interface to the end of the group. I did a
little experimenting to make sure. So, you could just parse the
interfaces and pull the MAC from the last one returned. It's not very
elegant, though.


On Mon, 2014-01-20 at 21:34 +0800, Sheldon wrote:
> when I create a interface, There is no mac attribute in the xml.
> After create successfully, libvirt will allocate a mac.
> The problem is that, How can I get the mac.
> 
> Should the CREATE method always needs to return an interface info?
> 
> Here is some of create code.
> 
> def vmifaces_create(self, vm, params):
> dom = self._get_vm(vm)
> xml = """
> <interface type='network'>
> <source network='default'/>
> </interface>
> """
> 
> dom.attachDeviceFlags(xml,
> libvirt.VIR_DOMAIN_AFFECT_CURRENT)
> 
> # here I need to return the mac
> return ????
> 
> 
> 
> The libvirt will create a xml like the follow? The problem is that the a 
> vm may have several interfaces.
> xml = """
> <interface type='network'>
> <mac address='52:54:00:2a:53:8f'/>
> <source network='default'/>
> <model type='rtl8139'/>
> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
> </interface>
> """
> 
> 





More information about the Kimchi-devel mailing list