[libvirt] [PATCH 2/3] maxmem: implement virDomainSetMaxMemory API of the qemu driver

Eric Blake eblake at redhat.com
Mon Apr 11 19:25:32 UTC 2011


>>> +static int qemudDomainSetMaxMemory(virDomainPtr dom, unsigned long memory) {
>>> +    return qemudDomainSetMemoryFlags(dom, memory,
>>> +                                     VIR_DOMAIN_MEM_MAXIMUM | VIR_DOMAIN_MEM_LIVE);
>>
>> Hmm.  Given the above implementation, this will _always_ fail.  Then
>> again, the failure message will be nicer (the function used to fail with
>> "not implemented", now it fails with "cannot resize memory on an active
>> domain"), so I guess it's okay to provide this stub.  And given the
>> documentation in libvirt.c, this is accurate (that documentation
>> explicitly stated that it only works on live domains).
>>
>> But the real clincher is how xen behaves.  I just tested, and my RHEL 5
>> machine with xen:/// was able to change persistent max memory of an
>> inactive domain, so the documentation in libvirt.c is wrong.  I then
> 
>   Hum, how did you test this ? This sounds weird to me, maybe the xen
> code really improved, but basically the max memory information was used
> by the hypervisor (micro) kernel to allocate things like size of page
> tablesetc. for the gues and well that could not be changed dynamically,
> once the guest was started say with a max_memory of 4G you would not
> be able to "live" change the max_memory to 16GB and grow the guest
> memory to more than 4G.

I tested as follows.  Note that libvirt was able to see that xen
"claimed" to have a larger max memory, but that I did not actually try
to balloon the guest to the larger memory, so it could be that the
balloon attempt would still fail, in which case we could argue that xen
has a bug for allowing the setmaxmem to "succeed" on an active domain.

I tested with libvirt 0.8.2 built for RHEL 5.6:

# virsh list --all
 Id Name         State
-------------------------
  0 Domain-0     running
  - dom          shut off
# virsh dumpxml dom | grep emory
  <memory>524288</memory>
  <currentMemory>524288</currentMemory>
# virsh setmaxmem dom 600000 && echo $?
0
# virsh dumpxml dom | grep emory
  <memory>599040</memory>
  <currentMemory>524288</currentMemory>
# virsh start dom
Domain dom started
# virsh setmaxmem dom 580000 && echo $?
# virsh dumpxml dom | grep emory
  <memory>579584</memory>
  <currentMemory>524288</currentMemory>
# virsh shutdown dom
# # wait for shutdown to complete
# virsh dumpxml dom | grep emory
  <memory>599040</memory>
  <currentMemory>524288</currentMemory>

Thus, setmaxmem was able to affect config-only and live-only (at least
in reported numbers), but not config|live, and certainly did not match
the former documentation of being a live-only operation.

-- 
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/20110411/4c302188/attachment-0001.sig>


More information about the libvir-list mailing list