On Wed, Feb 25, 2015 at 11:22:00AM +0100, Peter Krempa wrote:
Commit 60f7303c151cccdbe214b9f9ac59ecaf95cbf24b introduced the error
message but it's unclear whether the persistent config or the live
config tripped the message. Later the LXC driver copied the same code.
Separate the message which will also clarify the code.
---
Notes:
Version 2:
- reworded error message
src/lxc/lxc_driver.c | 22 +++++++++++++---------
src/qemu/qemu_driver.c | 24 ++++++++++++++----------
2 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 3adb21d..fea9599 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -742,18 +742,22 @@ static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long
newmem,
goto cleanup;
}
} else {
- unsigned long oldmax = 0;
-
- if (flags & VIR_DOMAIN_AFFECT_LIVE)
- oldmax = vm->def->mem.max_balloon;
- if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- if (!oldmax || oldmax > persistentDef->mem.max_balloon)
- oldmax = persistentDef->mem.max_balloon;
+ if (flags & VIR_DOMAIN_AFFECT_LIVE &&
+ newmem > vm->def->mem.max_balloon) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("new memory value '%lu' cannot be greater than
"
+ "the maximum value '%llu' for the live
instance"),
I sense disturbance in the force that this might clash in the future
with "something" ;) Either remove "maximum" completely or change it
to
"memory" or something. Use neither "maximum" nor "current"
in the
commit message to make devs' users' lives easier. ACK with that
changed.
<rant>
I must say I totally hate how the hot-plug turned out WRT naming.
Still hoping we can do something with it.
</rant>
+ newmem, vm->def->mem.max_balloon);
+ goto cleanup;
}
- if (newmem > oldmax) {
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
+ newmem > persistentDef->mem.max_balloon) {
virReportError(VIR_ERR_INVALID_ARG,
- "%s", _("Cannot set memory higher than max
memory"));
+ _("new memory value '%lu' cannot be greater than
"
+ "the maximum value '%llu' for the persistent
"
+ "configuration"),
+ newmem, persistentDef->mem.max_balloon);
goto cleanup;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 27cb3bf..bf19de8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2326,18 +2326,22 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned
long newmem,
} else {
/* resize the current memory */
- unsigned long oldmax = 0;
-
- if (flags & VIR_DOMAIN_AFFECT_LIVE)
- oldmax = vm->def->mem.max_balloon;
- if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
- if (!oldmax || oldmax > persistentDef->mem.max_balloon)
- oldmax = persistentDef->mem.max_balloon;
+ if (flags & VIR_DOMAIN_AFFECT_LIVE &&
+ newmem > vm->def->mem.max_balloon) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("new memory value '%lu' cannot be greater than
"
+ "the maximum value '%llu' for the live
instance"),
+ newmem, vm->def->mem.max_balloon);
+ goto endjob;
}
- if (newmem > oldmax) {
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("cannot set memory higher than max memory"));
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
+ newmem > persistentDef->mem.max_balloon) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("new memory value '%lu' cannot be greater than
"
+ "the maximum value '%llu' for the persistent
"
+ "configuration"),
+ newmem, persistentDef->mem.max_balloon);
goto endjob;
}
--
2.2.2
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list