diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 89f444b967667494f51b33632d3eddb212f8b6eb..ae8fb5a501e2564ef080c12739eb3e47a3e1cb3f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28923,6 +28923,13 @@ virDomainDefCompatibleDevice(virDomainDefPtr def, if (dev->type == VIR_DOMAIN_DEVICE_MEMORY) { unsigned long long sz = dev->data.memory->size; + if (!virDomainDefHasMemoryHotplug(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("cannot use/hotplug a memory device when domain " + "'maxMemory' is not defined")); + return -1; + } + if ((virDomainDefGetMemoryTotal(def) + sz) > def->mem.max_memory) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Attaching memory device with size '%llu' would "