Re: how to change existing domain xml?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/24/2012 10:15 AM, p-man314@xxxxxxx wrote:
> Hi.
> 
> I'm trying to change network settings for a domain via libvirt (the
> driver is xenapi) with no success.
> 
> According to its sources, 'virsh edit' uses virDomainGetXMLDesc(),
> allows to edit the received xml and then use virDomainDefineXML(). In
> case of xenapi driver it leads to a new vm creation (with the same name
> and edited settings).

Correct, but not the full story.  Question - is your guest running or
inactive?  Remember, there are two types of guests: persistent and
transient; persistent guests can be offline (inactive) or running, while
transient is always running.

virDomainDefineXML() can only set the XML for an offline persistent
guest (if called on a transient guest, the guest is converted over to
persistent).  As a result, when you use that API (such as via 'virsh
edit'), you are only affecting the state of the guest for the next time
it is booted, not the current running guest.

> 
> Looking through the list of API functions I failed to find a function
> like virDomainUpdateXML() that would change configuration of existing
> domain.

The reason you can't do a whole-sale replacement of a running guest's
XML is that the running XML must match the current state of the running
guest.  However, there are many API that allow you to change a portion
of the running guest's XML; although 'virsh edit' cannot expose these
API, there are many other virsh commands that can do this piece-wise
editing.

For example, virDomainSetMemoryFlags takes a flags argument; if flags is
0, then you affect the current state of the guest (that is, a hot-plug
operation on any transient or running persistent guest, or the next boot
of an inactive persistent guest); if flags is VIR_DOMAIN_AFFECT_LIVE,
then you affect the running guest (and error out if the guest is
inactive); if flags is VIR_DOMAIN_AFFECT_CONFIG, you affect the next
boot only (and error out if the guest is transient); or you can pass
both flags at once.  This maps back to 'virsh setmem' which has
--current, --live, and --config as flag options.

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

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux