]> xenbits.xensource.com Git - people/aperard/libvirt.git/commitdiff
qemu: Relax check for memory device coldplug
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 30 Nov 2023 12:26:14 +0000 (13:26 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 5 Dec 2023 15:36:53 +0000 (16:36 +0100)
When cold plugging a memory device we check whether there's
enough free memory slots to accommodate new module. Well, this
checks makes sense only for those memory devices that are plugged
into DIMM slots (DIMM and NVDIMM models). Other memory device
models, like VIRTIO_MEM, VIRTIO_PMEM or SGX_EPC are attached into
PCI bus, or no bus at all.

Resolves: https://issues.redhat.com/browse/RHEL-15480
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_driver.c

index cad52b7150fe1a9828769b57aac51f54edcc19ed..64afae6450dbf2192c7da545f0cdbc2ccfdb0bfa 100644 (file)
@@ -6631,9 +6631,23 @@ static int
 qemuDomainAttachMemoryConfig(virDomainDef *vmdef,
                              virDomainMemoryDef **mem)
 {
-    if (vmdef->nmems == vmdef->mem.memory_slots) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("no free memory device slot available"));
+    switch ((*mem)->model) {
+    case VIR_DOMAIN_MEMORY_MODEL_DIMM:
+    case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
+        if (vmdef->nmems == vmdef->mem.memory_slots) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("no free memory device slot available"));
+            return -1;
+        }
+        break;
+
+    case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM:
+    case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM:
+    case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC:
+        break;
+    case VIR_DOMAIN_MEMORY_MODEL_NONE:
+    case VIR_DOMAIN_MEMORY_MODEL_LAST:
+        virReportEnumRangeError(virDomainMemoryModel, (*mem)->model);
         return -1;
     }