[PATCH 5/8] qemu: update name on reverting from snapshot

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Tue Mar 3 08:19:19 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_driver.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 288067dd67..875b665cdf 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16326,6 +16326,11 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
                                   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) {
@@ -16333,6 +16338,11 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
                                           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
-- 
2.23.0





More information about the libvir-list mailing list