[libvirt PATCH] qemu_snapshot: external: don't error out when updating metadata

Pavel Hrdina posted 1 patch 1 year, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1057de723e990f20803e5f5055a4788f6e672962.1679914011.git.phrdina@redhat.com
src/qemu/qemu_snapshot.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[libvirt PATCH] qemu_snapshot: external: don't error out when updating metadata
Posted by Pavel Hrdina 1 year, 1 month ago
Attaching disk into running VM the offilne definition may not be
updated and we will end up with that disk existing only in live
definition. Creating snapshot with this state saves both live and
offline definition into snapshot metadata.

When we are deleting an external snapshot we are updating these
definitions in the snapshot metadata so we should just skip over
non-existing disks instead of reporting error.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2174700

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/qemu/qemu_snapshot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 14353c6f0d..e36d6288ac 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -2464,8 +2464,8 @@ qemuSnapshotUpdateDisksSingle(virDomainMomentObj *snap,
 {
     virDomainDiskDef *disk = NULL;
 
-    if (!(disk = qemuDomainDiskByName(def, snapDisk->name)))
-        return -1;
+    if (!(disk = virDomainDiskByName(def, snapDisk->name, true)))
+        return 0;
 
     if (virDomainSnapshotIsExternal(snap)) {
         virDomainDiskDef *parentDisk = NULL;
-- 
2.39.2
Re: [libvirt PATCH] qemu_snapshot: external: don't error out when updating metadata
Posted by Ján Tomko 1 year, 1 month ago
On a Monday in 2023, Pavel Hrdina wrote:
>Attaching disk into running VM the offilne definition may not be
>updated and we will end up with that disk existing only in live
>definition. Creating snapshot with this state saves both live and
>offline definition into snapshot metadata.
>
>When we are deleting an external snapshot we are updating these
>definitions in the snapshot metadata so we should just skip over
>non-existing disks instead of reporting error.
>
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2174700
>
>Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>---
> src/qemu/qemu_snapshot.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano