[PATCH v2 07/10] qemu: update name on reverting from snapshot

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Tue Nov 3 12:00:05 UTC 2020


If domain name is changed since snapshot we need to update it to current in
config taken from snapshot.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy at virtuozzo.com>
---
 src/qemu/qemu_snapshot.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index a6241ab..c9f2be0 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -1924,6 +1924,11 @@ qemuSnapshotRevert(virDomainObjPtr vm,
                                   driver->xmlopt, priv->qemuCaps, true);
         if (!config)
             goto endjob;
+
+        if (STRNEQ(config->name, vm->def->name)) {
+            VIR_FREE(config->name);
+            config->name = g_strdup(vm->def->name);
+        }
     }
 
     if (snap->def->inactiveDom) {
@@ -1931,6 +1936,11 @@ qemuSnapshotRevert(virDomainObjPtr vm,
                                           driver->xmlopt, priv->qemuCaps, true);
         if (!inactiveConfig)
             goto endjob;
+
+        if (STRNEQ(inactiveConfig->name, vm->def->name)) {
+            VIR_FREE(inactiveConfig->name);
+            inactiveConfig->name = g_strdup(vm->def->name);
+        }
     } else {
         /* Inactive domain definition is missing:
          * - either this is an old active snapshot and we need to copy the
-- 
1.8.3.1




More information about the libvir-list mailing list