qemu_driver: validate mem->model on MEMORY_DEVICE_SIZE_CHANGE event

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>
This commit is contained in:
Michal Privoznik 2023-08-01 12:57:04 +02:00
parent 29df55e74d
commit a03b6cedfd

View 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