[libvirt] mac address question of a vm

Eric Blake eblake at redhat.com
Fri Mar 21 13:04:01 UTC 2014


On 03/21/2014 02:31 AM, yue wrote:
> hi,all

[Can you configure your mailer to wrap long lines?]

> if a vm had mac before, now i delete the mac in its xml then start it, how libvirt get its mac? new one or find the old one, how to find?

Libvirt generates a new random MAC address if you omit one from the XML;
to see what libvirt generated, you can use virDomainGetXMLDesc() (or
'virsh dumpxml') to see what got inserted into the xml.

> where is the place that stores the mac?  and where is the code that get the mac and how  set it for vm?

src/conf/domain_conf.h contains the field that stores the MAC in memory
as parsed from XML, and what gets formatted back into XML on a dump.
Code for generating a MAC is in src/util/virmacaddr.c
(virMacAddrGenerate), so figure out who calls that.  Code for passing on
a MAC address to the qemu command line is in src/qemu/qemu_command.c
(look for virMacAddrFormat calls).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140321/497090da/attachment-0001.sig>


More information about the libvir-list mailing list