On 12/11/2015 07:26 AM, Andrei Perietanu wrote:
> I am trying to change a domain configuration from a python script. More
> specific, I want to edit the VNC settings. You can't do this using the
> libvirt API so you have to edit the domain configuration:
Umm, the libvirt API _is_ how you edit the domain configuration.
> Fo exmple, to disable VNC for a domain 'test1':
> vmXml = vm.XMLDesc(0)
> root = ET.fromstring(vmXml)
> devices = root.find('./devices')
> graphics = devices.find('graphics')
> xml = ET.tostring(root)
> with open('path_to/test1.xml', 'w') as f:
Writing to path_to/test1.xml is not necessary (it's merely a convenient
way for you to have a point-in-time snapshot of what the domain XML
was); what you are really looking for is to write the XML back to
> So the question really is: where is the domain configuration stored? Am I
> editing the write file, or am I missing something?
The official copy is stored in memory, so the only supported way to
manipulate it is via libvirt API. Libvirt happens to copy its memory
into files located under /etc/libvirt for persistence reasons, but
modifying those files behind libvirt's back is not a good idea - in
fact, those files start with the disclaimer:
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made
virsh edit domain
or other application using the libvirt API.
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you receive this in error please contact the sender and delete the material from any computer immediately. It is the policy of Klas Limited to disavow the sending of offensive material and should you consider that the material contained in the message is offensive you should contact the sender immediately and also your I.T. Manager.
Klas Telecom Inc., a Virginia Corporation with offices at 1101 30th St. NW, Washington, DC 20007.
Klas Limited (Company Number 163303) trading as Klas Telecom, an Irish Limited Liability Company, with its registered office at Fourth Floor, One Kilmainham Square, Inchicore Road, Kilmainham, Dublin 8, Ireland.