On 16.07.2014 11:51, Chen Hanxiao wrote:
Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx> --- src/lxc/lxc_driver.c | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index be6ee19..9f974eb 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -680,37 +680,6 @@ lxcDomainGetMaxMemory(virDomainPtr dom) return ret; } -static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) -{ - virDomainObjPtr vm; - int ret = -1; - - if (!(vm = lxcDomObjFromDomain(dom))) - goto cleanup; - - if (virDomainSetMaxMemoryEnsureACL(dom->conn, vm->def) < 0) - goto cleanup; - - if (newmax < vm->def->mem.cur_balloon) { - if (!virDomainObjIsActive(vm)) { - vm->def->mem.cur_balloon = newmax; - } else { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("Cannot set max memory lower than current" - " memory for an active domain")); - goto cleanup; - } - } - - vm->def->mem.max_balloon = newmax; - ret = 0; - - cleanup: - if (vm) - virObjectUnlock(vm); - return ret; -} -
A-ha! This is what I was looking for in 1/2. Okay, but I'd rather note this fact in 1/2 commit message to make it more obvious.
static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, unsigned int flags) { @@ -809,6 +778,11 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) return lxcDomainSetMemoryFlags(dom, newmem, VIR_DOMAIN_AFFECT_LIVE); } +static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long memory) +{ + return lxcDomainSetMemoryFlags(dom, memory, VIR_DOMAIN_MEM_MAXIMUM); +} +
So previously, calling virDomainSetMaxMemory() on an inactive LXC domain would succeed. Now, after the change, due to problem with _CURRENT, _LIVE and _CONFIG this will basically return success, but without any effect on the domain config. And that's wrong.
static int lxcDomainSetMemoryParameters(virDomainPtr dom, virTypedParameterPtr params,
Moreover, I think these two patches can be joined into one. Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list