Updating offline XML of <memory/> devices might come handy when
dealing with virtio-mem devices. But it's implemented to just
replace one virDomainMemoryDef with another so it can be used to
change almost anything.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_driver.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1dee792dfd..e6557ce997 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7765,6 +7765,7 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef,
virDomainDiskDef *newDisk;
virDomainGraphicsDef *newGraphics;
virDomainNetDef *net;
+ virDomainMemoryDef *mem;
virDomainDeviceDef oldDev = { .type = dev->type };
int pos;
@@ -7827,6 +7828,23 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef,
dev->data.net = NULL;
break;
+ case VIR_DOMAIN_DEVICE_MEMORY:
+ mem = virDomainMemoryFindByDeviceInfo(vmdef, &dev->data.memory->info,
&pos);
+ if (!mem) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("memory not
found"));
+ return -1;
+ }
+
+ oldDev.data.memory = mem;
+ if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev,
+ VIR_DOMAIN_DEVICE_ACTION_UPDATE,
+ false) < 0)
+ return -1;
+
+ virDomainMemoryDefFree(vmdef->mems[pos]);
+ vmdef->mems[pos] = g_steal_pointer(&dev->data.memory);
+ break;
+
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT:
case VIR_DOMAIN_DEVICE_SOUND:
@@ -7843,7 +7861,6 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef,
case VIR_DOMAIN_DEVICE_CONTROLLER:
case VIR_DOMAIN_DEVICE_REDIRDEV:
case VIR_DOMAIN_DEVICE_CHR:
- case VIR_DOMAIN_DEVICE_MEMORY:
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
--
2.32.0