[libvirt-users] Configuration file question

David Mitchell mitchell at ucar.edu
Mon Dec 10 15:28:46 UTC 2012


On Dec 8, 2012, at 10:56 PM, Eric Blake wrote:

> On 12/08/2012 10:36 AM, David Mitchell wrote:
>> 
>> On Dec 8, 2012, at 7:56 AM, Eric Blake wrote:
>> 
>>> On 12/07/2012 04:32 PM, David Mitchell wrote:
>>>> Where are the configuration files for libvirt and/or virsh actually stored?
>>> 
>>> That's an implementation detail, and might change in the future.  You
>>> shouldn't need to care where they are stored, and instead access the
>>> data via the API (such as virDomainGetXMLDesc and virDomainDefine) or
>>> API wrappers (such as virsh dumpxml/define).  That said:
>> 
>> In my case I'm trying to sync the configuration files between two physical servers. To that end I have a drbd partition which I mirror. I have /etc/libvirt softlinked into that partition. I could easily link /var/lib/libvirt into that partition as well but without understanding what it's for I'm not sure of all the ramifications. 
>> 
> 
> Don't.  Mirroring the contents of /etc/libvirt or /var/libvirt is going
> behind libvirt's back, and risks data inconsistencies if the libvirtd on
> one machine sees data in an incomplete state as written by a libvirtd on
> another machine.

Being a DRBD partition the mirror would only ever be visible to one physical server at a time. My expectation is that libvirt won't be running at all on the backup server at all unless libvirt has been stopped on the primary.

> 
> The _only_ two safe ways to share configuration between multiple
> machines is to share the output of 'virsh dumpxml' and then to 'virsh
> define' it on the destination; or to use only transient objects in the
> first place (VDSM does the latter).  (Well, you don't have to use virsh
> - you can use any language binding that eventually boils down to the
> same underlying C API that virsh is using).

I can certainly work on getting all the management stuff done this way but it seems worrisome to me to say that the config files can't be safely copied from one server to another. Is this really the case even if I stop the libvirt service first? Does this imply that if I want to move my installation to new hardware that I can't just copy the config files? Or am I reading too much into this?

I think I can probably manage to have some kind of script which can help ensure that my servers are in sync using only the libvirt API and ignoring the config files. I think I am still a little unclear on exactly how transient transient is. In my mind only the persistent and defined objects would actually have their configuration saved in a file and persist across reboots. It's surprising to me that so-called transient objects are also saved in config files and can persist across reboots.

-David Mitchell

> 
>> For clean stops and starts I do plan on using the API to save or destroy the running domains, etc and that should keep the /var/lib/ and /etc/configurations consistent if I understand their purpose. I'm a little worried about what will happen during unclean stops though.
> 
> _Always_ use the API, rather than attempting to read implementation
> detail files behind libvirt's back.
> 
>>> # edit the persistent definition, which will touch /etc
>>> virsh net-edit default
>>> # stop the running instance with the old definition from /var
>>> virsh net-destroy default
>>> # restart, which will repopulate /var with your changes
>>> virsh net-start default
>> 
>> I will give that a try. The problem I'm having is that the /var configuration is being used even after a reboot instead of the /etc/ configuration. 
> 
> You'd have to provide more details as to why you think the runtime
> configuration is surviving a reboot; are you sure you are properly using
> the API to set the persistent definition?
> 
> -- 
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
> 

-----------------------------------------------------------------
| David Mitchell (mitchell at ucar.edu)       Network Engineer IV  |
| Tel: (303) 497-1845                      National Center for  |
| FAX: (303) 497-1818                      Atmospheric Research |
-----------------------------------------------------------------







More information about the libvirt-users mailing list