As of now, the cur_ballon is set to actual memory if not specified by the user. When the user specified memory is not aligned the cur_balloon alone ends up unaligned. For qemu in function qemuDomainAttachMemory(), the cur_balloon wouldn't add up to the actual memory as the cur_ballon was not aligned. So, there is need for explicit setmem post attach-device for such guests. The decision as to whether to align the cur_balloon memory or not is not possible if we set it to actual memory by default in post-parse. Move the default cur_balloon assignment to their respective drivers during domain start wherever possible. For qemu align the cur_balloon too iow assign the aligned actual memory when not specified by the user. Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx> --- src/conf/domain_conf.c | 3 +-- src/libxl/libxl_conf.c | 2 ++ src/lxc/lxc_process.c | 3 +++ src/openvz/openvz_driver.c | 13 +++++++------ src/phyp/phyp_driver.c | 10 +++------- src/qemu/qemu_domain.c | 3 +++ src/uml/uml_conf.c | 3 +++ src/vbox/vbox_common.c | 3 +++ src/vmx/vmx.c | 3 +++ src/vz/vz_sdk.c | 3 +++ src/xenconfig/xen_common.c | 3 +++ src/xenconfig/xen_sxpr.c | 4 ++++ 12 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2f5c0ed..68338f4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3527,8 +3527,7 @@ virDomainDefPostParseMemory(virDomainDefPtr def, return -1; } - if (def->mem.cur_balloon > virDomainDefGetMemoryActual(def) || - def->mem.cur_balloon == 0) + if (def->mem.cur_balloon > virDomainDefGetMemoryActual(def)) def->mem.cur_balloon = virDomainDefGetMemoryActual(def); if ((def->mem.max_memory || def->mem.memory_slots) && diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 4eed5ca..6b6e764 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -665,6 +665,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, } b_info->sched_params.weight = 1000; b_info->max_memkb = virDomainDefGetMemoryInitial(def); + if (!def->mem.cur_balloon) + def->mem.cur_balloon = virDomainDefGetMemoryInitial(def); b_info->target_memkb = def->mem.cur_balloon; if (hvm) { char bootorder[VIR_DOMAIN_BOOT_LAST + 1]; diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 57e3880..201ee61 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1257,6 +1257,9 @@ int virLXCProcessStart(virConnectPtr conn, vm->def->resource = res; } + if (!vm->def->mem.cur_balloon) + vm->def->mem.cur_balloon = virDomainDefGetMemoryActual(vm->def); + if (virAsprintf(&logfile, "%s/%s.log", cfg->logDir, vm->def->name) < 0) goto cleanup; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index b8c0f50..8a56d94 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1043,12 +1043,13 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla } } - if (vm->def->mem.cur_balloon > 0) { - if (openvzDomainSetMemoryInternal(vm, vm->def->mem.cur_balloon) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not set memory size")); - goto cleanup; - } + if (!vm->def->mem.cur_balloon) + vm->def->mem.cur_balloon = virDomainDefGetMemoryActual(vm->def); + + if (openvzDomainSetMemoryInternal(vm, vm->def->mem.cur_balloon) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not set memory size")); + goto cleanup; } dom = virGetDomain(conn, vm->def->name, vm->def->uuid); diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 14264c0..1fc7b34 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3491,13 +3491,6 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def) int exit_status = 0; virBuffer buf = VIR_BUFFER_INITIALIZER; - if (!def->mem.cur_balloon) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Field <currentMemory> on the domain XML file is " - "missing or has invalid value")); - goto cleanup; - } - if (!virDomainDefGetMemoryInitial(def)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Field <memory> on the domain XML file is missing or " @@ -3505,6 +3498,9 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def) goto cleanup; } + if (!def->mem.cur_balloon) + def->mem.cur_balloon = virDomainDefGetMemoryActual(def); + if (def->ndisks < 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Domain XML must contain at least one <disk> element.")); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 40e1f18..9d92d99 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3567,6 +3567,9 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def) } } + if (!def->mem.cur_balloon) + def->mem.cur_balloon = virDomainDefGetMemoryActual(def); + return 0; } diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index afc0375..c53bc65 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -399,6 +399,9 @@ virCommandPtr umlBuildCommandLine(virConnectPtr conn, virCommandAddEnvPassCommon(cmd); + if (!vm->def->mem.cur_balloon) + vm->def->mem.cur_balloon = virDomainDefGetMemoryActual(vm->def); + //virCommandAddArgPair(cmd, "con0", "fd:0,fd:1"); virCommandAddArgFormat(cmd, "mem=%lluK", vm->def->mem.cur_balloon); virCommandAddArgPair(cmd, "umid", vm->def->name); diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 9369367..38bf35e 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1886,6 +1886,9 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags goto cleanup; } + if (!def->mem.cur_balloon) + def->mem.cur_balloon = virDomainDefGetMemoryActual(def); + rc = gVBoxAPI.UIMachine.SetMemorySize(machine, VIR_DIV_UP(def->mem.cur_balloon, 1024)); if (NS_FAILED(rc)) { diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 7c3c10a..8f4d66a 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3157,6 +3157,9 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe virBufferAsprintf(&buffer, "memsize = \"%llu\"\n", max_balloon / 1024); /* Scale from kilobytes to megabytes */ + if (!def->mem.cur_balloon) + def->mem.cur_balloon = virDomainDefGetMemoryActual(def); + /* def:mem.cur_balloon -> vmx:sched.mem.max */ if (def->mem.cur_balloon < max_balloon) { virBufferAsprintf(&buffer, "sched.mem.max = \"%llu\"\n", diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 1fced3f..131f6bb 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -3475,6 +3475,9 @@ prlsdkDoApplyConfig(virConnectPtr conn, bool needBoot = true; char *mask = NULL; + if (!def->mem.cur_ballon) + def->mem.cur_ballon = virDomainDefGetMemoryActual(def); + if (prlsdkCheckUnsupportedParams(sdkdom, def) < 0) return -1; diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 0890c73..ba6dffa 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -1306,6 +1306,9 @@ xenFormatMem(virConfPtr conf, virDomainDefPtr def) VIR_DIV_UP(virDomainDefGetMemoryActual(def), 1024)) < 0) return -1; + if (!def->mem.cur_balloon) + def->mem.cur_balloon = virDomainDefGetMemoryActual(def); + if (xenConfigSetInt(conf, "memory", VIR_DIV_UP(def->mem.cur_balloon, 1024)) < 0) return -1; diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index 7fc9c9d..63b79a0 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -2219,6 +2219,10 @@ xenFormatSxpr(virConnectPtr conn, virBufferAddLit(&buf, "(vm "); virBufferEscapeSexpr(&buf, "(name '%s')", def->name); + + if (!def->mem.cur_balloon) + def->mem.cur_balloon = virDomainDefGetMemoryActual(def); + virBufferAsprintf(&buf, "(memory %llu)(maxmem %llu)", VIR_DIV_UP(def->mem.cur_balloon, 1024), VIR_DIV_UP(virDomainDefGetMemoryActual(def), 1024)); -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list