For LVM storages using 'snapshot-as-volume-chain', it's necessary to
ensure that the size for the LV of the target snapshot volume is large
enough before doing a commit operation. Note that the change here also
affects file-based storages; previously resize would happen as part of
the commit operation automatically for them. This fixes the online
case.

Signed-off-by: Fiona Ebner <[email protected]>
---

Dependency bump from qemu-server to libpve-storage-perl needed!

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

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 09e7a19b..f99560a6 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -4414,6 +4414,15 @@ sub qemu_volume_snapshot_delete {
         # improve-me: if firstsnap > child : commit, if firstsnap < child do a 
stream.
         if (!$parentsnap) {
             print "delete first snapshot $snap\n";
+
+            my $snap_size = $snapshots->{$snap}->{'virtual-size'};
+            my $child_size = $snapshots->{$childsnap}->{'virtual-size'};
+            if (defined($child_size) && defined($snap_size) && $child_size > 
$snap_size) {
+                print
+                    "resize '$snap' ($snap_size bytes) to match '$childsnap' 
($child_size bytes)\n";
+                PVE::Storage::volume_resize($storecfg, $volid, $child_size, 
$running, $snap);
+            }
+
             PVE::QemuServer::VolumeChain::blockdev_commit(
                 $storecfg,
                 $vmid,
-- 
2.47.3




Reply via email to