While qemu would reject the configuration we can check whether it makes
sense to plug the device upfront.
/* memory hotplug requires NUMA to be enabled - we already checked
* that memory devices are present only when NUMA is */
+
+ if (def->nmems > def->mem.memory_slots) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("memory device count '%zu' exceeds slots count '%u'"),
+ def->nmems, def->mem.memory_slots);
+ goto error;
+ }
+
for (i = 0; i < def->nmems; i++) {
char *backStr;
char *dimmStr;
break;
case VIR_DOMAIN_DEVICE_MEMORY:
+ if (vmdef->nmems == vmdef->mem.memory_slots) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("no free memory device slot available"));
+ return -1;
+ }
+
if (virDomainMemoryInsert(vmdef, dev->data.memory) < 0)
return -1;
dev->data.memory = NULL;
int id;
int ret = -1;
+ if (vm->def->nmems == vm->def->mem.memory_slots) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("no free memory device slot available"));
+ goto cleanup;
+ }
+
if (virAsprintf(&mem->info.alias, "dimm%zu", vm->def->nmems) < 0)
goto cleanup;