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@xxxxxxxxxx> --- 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 d05052a3d7..10ff8519c5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7764,6 +7764,7 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef, virDomainDiskDef *newDisk; virDomainGraphicsDef *newGraphics; virDomainNetDef *net; + virDomainMemoryDef *mem; virDomainDeviceDef oldDev = { .type = dev->type }; int pos; @@ -7826,6 +7827,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: @@ -7842,7 +7860,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