From f5df98aae43973bd85a3e183d5383024a5630c94 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Tue, 17 May 2016 00:36:49 +0300 Subject: [PATCH] lxc: use job functions in lxcDomainSetMemoryFlags Large balloon operation can be time consuming. Use the recently added job functions and unlock the virDomainObj while ballooning. Signed-off-by: Katerina Koukiou --- src/lxc/lxc_driver.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 1e21ee436b..863c799884 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -725,19 +725,22 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, if (virDomainSetMemoryFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (!(caps = virLXCDriverGetCapabilities(driver, false))) + if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) goto cleanup; + if (!(caps = virLXCDriverGetCapabilities(driver, false))) + goto endjob; + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) - goto cleanup; + goto endjob; if (flags & VIR_DOMAIN_MEM_MAXIMUM) { if (flags & VIR_DOMAIN_AFFECT_LIVE) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Cannot resize the max memory " "on an active domain")); - goto cleanup; + goto endjob; } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { @@ -746,7 +749,7 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, persistentDef->mem.cur_balloon = newmem; if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0) - goto cleanup; + goto endjob; } } else { unsigned long oldmax = 0; @@ -761,31 +764,35 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, if (newmem > oldmax) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("Cannot set memory higher than max memory")); - goto cleanup; + goto endjob; } if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (virCgroupSetMemory(priv->cgroup, newmem) < 0) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("Failed to set memory for domain")); - goto cleanup; + goto endjob; } vm->def->mem.cur_balloon = newmem; if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) - goto cleanup; + goto endjob; } if (flags & VIR_DOMAIN_AFFECT_CONFIG) { persistentDef->mem.cur_balloon = newmem; if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0) - goto cleanup; + goto endjob; } } ret = 0; + endjob: + if (!virLXCDomainObjEndJob(driver, vm)) + vm = NULL; + cleanup: if (vm) virObjectUnlock(vm); -- GitLab