[PATCH 5/9] qemuSnapshotForEachQcow2: Handle also NVRAM image for internal snapshots

Peter Krempa posted 9 patches 6 days, 4 hours ago
[PATCH 5/9] qemuSnapshotForEachQcow2: Handle also NVRAM image for internal snapshots
Posted by Peter Krempa 6 days, 4 hours ago
The live VM snapshot code already does handle the NVRAM image when it's
in use, so we should also handle it when modifying/creating the
snapshots via qemu-img when inactive.

Add the handling to qemuSnapshotForEachQcow2 which is used for all
inactive operations.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_snapshot.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index f560cf270c..4a17935627 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -347,6 +347,26 @@ qemuSnapshotForEachQcow2(virDomainDef *def,
         }
     }

+    if (def->os.loader && def->os.loader->nvram) {
+        virStorageSource *nvram = def->os.loader->nvram;
+
+        if (virStorageSourceIsLocalStorage(nvram) &&
+            nvram->format == VIR_STORAGE_FILE_QCOW2) {
+            if (qemuSnapshotForEachQcow2One(nvram, op, snap->def->name) < 0) {
+                if (create) {
+                    nrollback = def->ndisks;
+                    virErrorPreserveLast(&orig_err);
+                    goto rollback;
+                } else {
+                    VIR_WARN("failed 'qemu-img snapshot %s' action on NVRAM image",
+                             op);
+                    skipped = true;
+                    virResetLastError();
+                }
+            }
+        }
+    }
+
     return skipped ? 1 : 0;

  rollback:
-- 
2.47.0