From: Peter Krempa Date: Tue, 28 Apr 2015 14:23:05 +0000 (+0200) Subject: qemu: conf: Reject memory device if it would exceed configured max size X-Git-Tag: v1.2.15-rc2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=406944e476729ce740da126d767b073e23c1af4d;p=thirdparty%2Flibvirt.git qemu: conf: Reject memory device if it would exceed configured max size If the added memory device would exceed the maximum memory size, reject it. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1216046 --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fc48ed5a5f..7e4f0af25d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21661,6 +21661,17 @@ virDomainDefCompatibleDevice(virDomainDefPtr def, return -1; } + if (dev->type == VIR_DOMAIN_DEVICE_MEMORY) { + unsigned long long sz = dev->data.memory->size; + + if ((virDomainDefGetMemoryActual(def) + sz) > def->mem.max_memory) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Attaching memory device with size '%llu' would " + "exceed domain's maxMemory config"), sz); + return -1; + } + } + return 0; }