[libvirt-users] which is the config file for a vm ?

Michal Privoznik mprivozn at redhat.com
Tue Mar 1 16:27:33 UTC 2016


On 01.03.2016 14:57, Lentes, Bernd wrote:
> Hi, 
> 
> i have a weird problem. I have a vm (KVM) which seems to run fine. I believe the respective config file for this vm is /etc/libvirt/qemu/MausDB.xml. This is it:
> 
> =========================================================
> <domain type='kvm'>
>   <name>MausDB</name>
>   <uuid>d4c7956c-b57f-967a-0454-99835a3a740b</uuid>
>   <memory unit='KiB'>2353792</memory>
>   <currentMemory unit='KiB'>2353792</currentMemory>
>   <vcpu placement='static'>2</vcpu>
>   <os>
>     <type arch='x86_64' machine='pc-i440fx-1.4'>hvm</type>
>     <boot dev='hd'/>
>   </os>
>   <features>
>     <acpi/>
>     <apic/>
>     <pae/>
>   </features>
>   <clock offset='utc'/>
>   <on_poweroff>destroy</on_poweroff>
>   <on_reboot>restart</on_reboot>
>   <on_crash>destroy</on_crash>
>   <devices>
>     <emulator>/usr/bin/qemu-kvm</emulator>
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw'/>
>       <source file='/var/lib/kvm/images/MausDB/disk0.raw'/>
>       <target dev='vda' bus='virtio'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
>     </disk>
>     <disk type='file' device='cdrom'>
>       <driver name='qemu' type='raw'/>
>       <target dev='hda' bus='ide'/>
>       <readonly/>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </disk>
>     <controller type='usb' index='0'>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
>     </controller>
>     <controller type='pci' index='0' model='pci-root'/>
>     <controller type='ide' index='0'>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
>     </controller>
>     <interface type='bridge'>
>       <mac address='52:54:00:37:92:03'/>
>       <source bridge='br0'/>
>       <model type='virtio'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
>     </interface>
>     <input type='mouse' bus='ps2'/>
>     <input type='keyboard' bus='ps2'/>
>     <graphics type='vnc' port='-1' autoport='yes'/>
>     <video>
>       <model type='cirrus' vram='9216' heads='1'/>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
>     </video>
>     <memballoon model='virtio'>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
>     </memballoon>
>   </devices>
> </domain>
> =============================================================
> 
> As you see, the vm has one NIC. Its MAC-Address is: '52:54:00:37:92:03'.
> I also see that MAC when i edit the config via virsh.
> 
> But when i boot that vm, it has a nic with another MAC: '52:54:00:37:92:B2' ??? lspci shows me just one nic in the vm.
> This MAC-Address is also visible in the Virtual Machine Manager.
> Pictures you find here: https://hmgubox.helmholtz-muenchen.de:8001/d/51feb02c02/ 
> I thought the xml-file in /etc/libvirt/qemu ist the only responsable one. It is that one which is configured when i issue a 'edit domain' in virsh. Or ?

Yes, it's the only location where libvirt keeps inactive domain
configurations. However, in some cases domain configuration can be fed
in from a different source, e.g. when restoring from a file. Moreover,
if the file is managed by libvirt (so called managed save), doing 'virsh
start' will run domain from there rather than from a fresh config kept
under /etc/libvirt/qemu. You can check whether domain has a managed save
by inspecting 'virsh dominfo' output.
Or if you restore a domain from previously saved state use 'virsh
save-image-edit' to check MAC address.

> Where does the VMM stores the configuration of the domains ?

Nowhere. It relies on libvirt.

> I found another xml: /var/run/libvirt/qemu/MausDB.xml . Inside it there is the MAC the booted vm has. What is the purpose of this xml ?

It's purpose is to keep runtime configuration, libvirt's internal state
of domain, so that when libvirtd is restarted it can reload the internal
state from there.

And as Andrea already pointed out, you should never ever go behind
libvirt's back and hand edit those files. Use libvirt APIs for that
(from this POV virsh is considered as API too).

Michal




More information about the libvirt-users mailing list