Re: [libvirt] [PATCH 2/2] LXC: use lxcDomainSetMemoryFlags to do lxcDomainSetMaxMemory's work
-Original Message- From: Michal Privoznik [mailto:mpriv...@redhat.com] Sent: Thursday, July 24, 2014 5:00 PM To: Chen, Hanxiao/陈 晗霄; libvir-list@redhat.com Subject: Re: [libvirt] [PATCH 2/2] LXC: use lxcDomainSetMemoryFlags to do lxcDomainSetMaxMemory's work On 16.07.2014 11:51, Chen Hanxiao wrote: Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com --- 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. Will update commit message in v2. 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. Current lxcDomainSetMaxMemory did: inactive: affect domain config active: success but no change So we should fix that and will do in v2. Thanks, - Chen 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@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] LXC: use lxcDomainSetMemoryFlags to do lxcDomainSetMaxMemory's work
On 16.07.2014 11:51, Chen Hanxiao wrote: Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com --- 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@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] LXC: use lxcDomainSetMemoryFlags to do lxcDomainSetMaxMemory's work
Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com --- 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; -} - 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); +} + static int lxcDomainSetMemoryParameters(virDomainPtr dom, virTypedParameterPtr params, -- 1.9.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list