Die if the list of snapshots returned by `volume_snapshot_info` does
not contain the snapshot we are trying to delete.

Previously it was just assumed that the snapshot would be present,
leading to the entry in the list being autoviviefied by the following
lines of code. Hence, we tried to commit nonexistent snapshot states
here, as both `$parentsnap` and `$childsnap` would be undefined.

Signed-off-by: Shannon Sterz <s.st...@proxmox.com>
---
consider this more of a suggestion, but the autovivification here made
this bug somewhat more annoying to debug and i don't really see a reason
not to check that here (after all, what behaviour should be expected in
this case?)

 src/PVE/QemuServer.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 5a4f8120..ef8f2fc0 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -4418,6 +4418,9 @@ sub qemu_volume_snapshot_delete {

         my $path = PVE::Storage::path($storecfg, $volid);
         my $snapshots = PVE::Storage::volume_snapshot_info($storecfg, $volid);
+
+        die "could not find snapshot '$snap'\n" if 
!defined($snapshots->{$snap});
+
         my $parentsnap = $snapshots->{$snap}->{parent};
         my $childsnap = $snapshots->{$snap}->{child};
         my $machine_version = 
PVE::QemuServer::Machine::get_current_qemu_machine($vmid);
--
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to