[libvirt] [PATCH] RFC: virsh setmem: configure inactive domains' memory size

Eric Blake eblake at redhat.com
Thu Feb 24 21:43:03 UTC 2011


On 02/24/2011 03:25 AM, Taku Izumi wrote:
> 
> Currently "virsh setmem" is not allowed to use against inactive domains.
> By applying this patch, we can change the memory size of inactive domains
> by "virsh setmem".
> 
> 
> -    if (virDomainSetMemory(dom, kilobytes) != 0) {
> -        ret = FALSE;
> +    if (virDomainIsActive(dom) == 1) {
> +        if (virDomainSetMemory(dom, kilobytes) == 0)

This is slightly racy - in between the time that you probe if the domain
is active and actually request to set memory, the domain may have gone
inactive (or vice versa, in between the time you see that it is inactive
and start modifying the xml, it may have become active).

I think the better fix here would be to add a new API,
virDomainSetMemoryFlags, similar to virDomainUpdateDeviceFlags, where
the flags can request whether you want to affect running, persistent, or
both configurations all from a single API.  Falling back to XML editing
when the new API is not present is reasonable, but not an excuse for not
providing the right interface to begin with.

So, I'm debating whether to apply this now or whether to add the better
API first; anyone else want to chime in?

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list