Re: [libvirt] [PATCH v2] LXC: add support for --config in setmem command

2014-07-10 Thread Ján Tomko
On 07/08/2014 10:32 AM, Chen Hanxiao wrote:
 In lxc, we could not use setmem command
 with --config options.
 This patch will add support for this.
 
 Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
 ---
 v2: use virDomainSetMemoryFlagsEnsureACL
 remove redundant domain running check
 
  src/lxc/lxc_driver.c | 48 +---
  1 file changed, 37 insertions(+), 11 deletions(-)
 
 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
 index b47ac5e..93f496b 100644
 --- a/src/lxc/lxc_driver.c
 +++ b/src/lxc/lxc_driver.c
 @@ -711,18 +711,33 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, 
 unsigned long newmax)
  return ret;
  }
  
 -static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem)
 +static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
 +   unsigned int flags)
  {
  virDomainObjPtr vm;
 +virDomainDefPtr persistentDef = NULL;
 +virCapsPtr caps = NULL;
  int ret = -1;
  virLXCDomainObjPrivatePtr priv;
 +virLXCDriverPtr driver = dom-conn-privateData;
 +virLXCDriverConfigPtr cfg = NULL;
 +
 +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
 +  VIR_DOMAIN_AFFECT_CONFIG, -1);
  
  if (!(vm = lxcDomObjFromDomain(dom)))
  goto cleanup;
  
  priv = vm-privateData;
  
 -if (virDomainSetMemoryEnsureACL(dom-conn, vm-def)  0)
 +if (virDomainSetMemoryFlagsEnsureACL(dom-conn, vm-def, flags)  0)
 +goto cleanup;
 +
 +if (!(caps = virLXCDriverGetCapabilities(driver, false)))
 +goto cleanup;
 +
 +if (virDomainLiveConfigHelperMethod(caps, driver-xmlopt, vm, flags,
 +persistentDef)  0)
  goto cleanup;
  

  if (newmem  vm-def-mem.max_balloon) {

This check should only be done for AFFECT_LIVE.
For AFFECT_CONFIG it needs to be checked against the max_balloon value from
the persistent definition.

Jan



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] LXC: add support for --config in setmem command

2014-07-10 Thread chenhanx...@cn.fujitsu.com


 -Original Message-
 From: Ján Tomko [mailto:jto...@redhat.com]
 Sent: Thursday, July 10, 2014 9:40 PM
 
  -if (virDomainSetMemoryEnsureACL(dom-conn, vm-def)  0)
  +if (virDomainSetMemoryFlagsEnsureACL(dom-conn, vm-def, flags)  0)
  +goto cleanup;
  +
  +if (!(caps = virLXCDriverGetCapabilities(driver, false)))
  +goto cleanup;
  +
  +if (virDomainLiveConfigHelperMethod(caps, driver-xmlopt, vm, flags,
  +persistentDef)  0)
   goto cleanup;
 
 
   if (newmem  vm-def-mem.max_balloon) {
 
 This check should only be done for AFFECT_LIVE.
 For AFFECT_CONFIG it needs to be checked against the max_balloon value from
 the persistent definition.
 
Oops, my fault.
Thanks for your comments

- Chen


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list