[PATCH 3/9] qemu_hotplug: validate address on memory device change

Michal Privoznik posted 9 patches 2 years, 5 months ago
Only 6 patches received!
[PATCH 3/9] qemu_hotplug: validate address on memory device change
Posted by Michal Privoznik 2 years, 5 months ago
As of v7.9.0-rc1~296 users have ability to adjust what portion of
virtio-mem is exposed to the guest. Then, as of v9.4.0-rc2~5 they
have ability to set address where the memory is mapped. But due
to a missing check it was possible to feed
virDomainUpdateDeviceFlags() API  with memory device XML that
changes the address. This is of course not possible and should be
forbidden. Add the missing check.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_hotplug.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 2e3c99760d..03a50191ef 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -7102,6 +7102,13 @@ qemuDomainChangeMemoryLiveValidateChange(const virDomainMemoryDef *oldDef,
         return false;
     }
 
+    if (oldDef->address != newDef->address) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("cannot modify memory address from '0x%1$llx' to '0x%2$llx'"),
+                       oldDef->address, newDef->address);
+        return false;
+    }
+
     return true;
 }
 
-- 
2.41.0