]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainMemoryDefCheckConflict: Check dimm & nvdimm models too
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 2 Nov 2023 15:06:00 +0000 (16:06 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 24 Nov 2023 11:37:38 +0000 (12:37 +0100)
So far we check whether virtio-mem and/or virtio-pmem memory
devices do not overlap with each other. But we allow specifying
address where dimm and nvdimm memory devices are mapped too. And
there are left out from this collision check. Not anymore.

This leaves just sgx model out, but that's expected since it
can't have any address (see virDomainMemoryDefValidate()).

Resolves: https://issues.redhat.com/browse/RHEL-4452
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/conf/domain_validate.c

index b4ffef919ad908270d4fa09b7b90e64760f27a06..5d9602666e8e133625a4d29f0c8bbaeb31db1c19 100644 (file)
@@ -2234,6 +2234,10 @@ virDomainMemoryDefCheckConflict(const virDomainMemoryDef *mem,
         break;
     case VIR_DOMAIN_MEMORY_MODEL_DIMM:
     case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
+        if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM) {
+            thisStart = mem->info.addr.dimm.base;
+        }
+        break;
     case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC:
     case VIR_DOMAIN_MEMORY_MODEL_NONE:
     case VIR_DOMAIN_MEMORY_MODEL_LAST:
@@ -2271,13 +2275,17 @@ virDomainMemoryDefCheckConflict(const virDomainMemoryDef *mem,
 
         switch (other->model) {
         case VIR_DOMAIN_MEMORY_MODEL_NONE:
-        case VIR_DOMAIN_MEMORY_MODEL_DIMM:
-        case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
         case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC:
         case VIR_DOMAIN_MEMORY_MODEL_LAST:
             continue;
             break;
 
+        case VIR_DOMAIN_MEMORY_MODEL_DIMM:
+        case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
+            if (other->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM) {
+                otherStart = other->info.addr.dimm.base;
+            }
+            break;
         case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM:
             otherStart = other->target.virtio_pmem.address;
             break;