]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_driver: validate mem->model on MEMORY_DEVICE_SIZE_CHANGE event
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 1 Aug 2023 10:57:04 +0000 (12:57 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 24 Aug 2023 10:39:21 +0000 (12:39 +0200)
When guest acknowledges change in size of virtio-mem (portion
that's exposed to the guest), QEMU emits
MEMORY_DEVICE_SIZE_CHANGE event. We process it in
processMemoryDeviceSizeChange(). So far, QEMU emits the even only
for virtio-mem (as that's the only memory device model that
allows live changes to its size). Nevertheless, if this ever
changes, validate the memory model upon processing the event as
the rest of the code blindly expects virtio-mem model.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c

index f8039160f415b6a19382ae7b3589105382a86a52..f0eda71c4f941dc9bfc84db07e3303b447668c54 100644 (file)
@@ -3998,6 +3998,13 @@ processMemoryDeviceSizeChange(virQEMUDriver *driver,
         goto endjob;
     }
 
+    if (mem->model != VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM) {
+        VIR_DEBUG("Received MEMORY_DEVICE_SIZE_CHANGE event for unexpected memory model (%s), expected %s",
+                  virDomainMemoryModelTypeToString(mem->model),
+                  virDomainMemoryModelTypeToString(VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM));
+        goto endjob;
+    }
+
     /* If this looks weird it's because it is. The balloon size
      * as reported by QEMU does not include any of @currentsize.
      * It really contains just the balloon size. But in domain