>> +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(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org