[libvirt] [PATCH v2 0/3] test_driver: re-implement testDomainSetMemoryFlags

Ilias Stamatis (3): test_driver: consider flags in testDomainSetMemoryFlags test_driver: testDomainSetMemory should forward the call with VIR_DOMAIN_AFFECT_LIVE test_driver: testDomainSetMaxMemory should simply forward the call src/test/test_driver.c | 75 +++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 23 deletions(-) -- 2.22.0

Update the current or max memory, on the persistent or live definition depending on the flags which are currently ignored. Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com> --- src/test/test_driver.c | 51 +++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c10344f6cd..90910060ed 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2473,24 +2473,59 @@ static int testDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, unsigned int flags) { - virDomainObjPtr privdom; + virDomainObjPtr vm; + virDomainDefPtr def; int ret = -1; - virCheckFlags(0, -1); + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG | + VIR_DOMAIN_MEM_MAXIMUM, -1); - if (!(privdom = testDomObjFromDomain(domain))) + if (!(vm = testDomObjFromDomain(domain))) return -1; - if (memory > virDomainDefGetMemoryTotal(privdom->def)) { - virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__); + if (!(def = virDomainObjGetOneDef(vm, flags))) goto cleanup; + + if (flags & VIR_DOMAIN_MEM_MAXIMUM) { + if (virDomainObjCheckActive(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot resize the maximum memory on an " + "active domain")); + goto cleanup; + } + + if (virDomainNumaGetNodeCount(def->numa) > 0) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("initial memory size of a domain with NUMA " + "nodes cannot be modified with this API")); + goto cleanup; + } + + if (def->mem.max_memory && def->mem.max_memory < memory) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot set initial memory size greater than " + "the maximum memory size")); + goto cleanup; + } + + virDomainDefSetMemoryTotal(def, memory); + + if (def->mem.cur_balloon > memory) + def->mem.cur_balloon = memory; + } else { + if (memory > virDomainDefGetMemoryTotal(def)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("cannot set memory higher than max memory")); + goto cleanup; + } + + def->mem.cur_balloon = memory; } - privdom->def->mem.cur_balloon = memory; ret = 0; - cleanup: - virDomainObjEndAPI(&privdom); + virDomainObjEndAPI(&vm); return ret; } -- 2.22.0

On Fri, Jul 12, 2019 at 07:55:33AM +0200, Ilias Stamatis wrote:
Update the current or max memory, on the persistent or live definition depending on the flags which are currently ignored.
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com> --- src/test/test_driver.c | 51 +++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c10344f6cd..90910060ed 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2473,24 +2473,59 @@ static int testDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, unsigned int flags) { - virDomainObjPtr privdom; + virDomainObjPtr vm; + virDomainDefPtr def; int ret = -1;
- virCheckFlags(0, -1); + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG | + VIR_DOMAIN_MEM_MAXIMUM, -1);
- if (!(privdom = testDomObjFromDomain(domain))) + if (!(vm = testDomObjFromDomain(domain))) return -1;
- if (memory > virDomainDefGetMemoryTotal(privdom->def)) { - virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__); + if (!(def = virDomainObjGetOneDef(vm, flags))) goto cleanup; + + if (flags & VIR_DOMAIN_MEM_MAXIMUM) { + if (virDomainObjCheckActive(vm)) {
^This should be virDomainObjIsActive(vm) right? With that: Reviewed-by: Erik Skultety <eskultet@redhat.com>

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com> --- src/test/test_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 90910060ed..6b39b78a93 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2532,7 +2532,7 @@ static int testDomainSetMemoryFlags(virDomainPtr domain, static int testDomainSetMemory(virDomainPtr domain, unsigned long memory) { - return testDomainSetMemoryFlags(domain, memory, 0); + return testDomainSetMemoryFlags(domain, memory, VIR_DOMAIN_AFFECT_LIVE); } static int -- 2.22.0

On Fri, Jul 12, 2019 at 07:55:34AM +0200, Ilias Stamatis wrote:
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com> --- Reviewed-by: Erik Skultety <eskultet@redhat.com>

Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com> --- src/test/test_driver.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6b39b78a93..8aea739387 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2454,20 +2454,6 @@ testDomainGetMaxMemory(virDomainPtr domain) return ret; } -static int testDomainSetMaxMemory(virDomainPtr domain, - unsigned long memory) -{ - virDomainObjPtr privdom; - - if (!(privdom = testDomObjFromDomain(domain))) - return -1; - - /* XXX validate not over host memory wrt to other domains */ - virDomainDefSetMemoryTotal(privdom->def, memory); - - virDomainObjEndAPI(&privdom); - return 0; -} static int testDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory, @@ -2535,6 +2521,14 @@ static int testDomainSetMemory(virDomainPtr domain, return testDomainSetMemoryFlags(domain, memory, VIR_DOMAIN_AFFECT_LIVE); } + +static int testDomainSetMaxMemory(virDomainPtr domain, + unsigned long memory) +{ + return testDomainSetMemoryFlags(domain, memory, VIR_DOMAIN_MEM_MAXIMUM); +} + + static int testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) { -- 2.22.0

On Fri, Jul 12, 2019 at 07:55:35AM +0200, Ilias Stamatis wrote:
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com> ---
This patch cannot be applied, was it formatted from a different branch? I only applied the diff, built and reviewed. Like I said in the other series, I could fix it, but I'd be forging a patch with your SoB, so you can resend with the change in 1/3. Anyhow, Reviewed-by: Erik Skultety <eskultet@redhat.com>

On Wed, Jul 24, 2019 at 02:53:23PM +0200, Erik Skultety wrote:
On Fri, Jul 12, 2019 at 07:55:35AM +0200, Ilias Stamatis wrote:
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com> ---
This patch cannot be applied, was it formatted from a different branch? I only applied the diff, built and reviewed. Like I said in the other series, I could fix it, but I'd be forging a patch with your SoB, so you can resend with the change in 1/3.
So, I don't know how exactly these patches were created, but git complains that the ancestor is invalid and refuses to apply the patch, even though the diff itself can be applied cleanly. Resetting the branch prior to any of your test driver patches I already merged, re-applying and then rebasing on top of the current master works like a charm. I'd prefer if 'git am -3' didn't complain if it can apply the patch without conflicts. Anyhow, consider this resolved, no need to resend. Erik
participants (2)
-
Erik Skultety
-
Ilias Stamatis