[PATCH v5 07/16] qemu: Wire up <memory/> offline update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux