Require that snapshot-as-volume-chain qcow2 images are always used in
combination with '-blockdev', rather than '-drive'. With '-drive', the
'discard-no-unref' option is not set and the fragmentation can lead to
the same issue that for '-blockdev', was solved by commit a3a9a2ab
("fix #6543: use qcow2 'discard-no-unref' option when using
snapshot-as-volume-chain").

While it would be possible to set the flag for '-drive' too, the
snapshot-as-volume-chain feature already only works with machine type
>= 10.0, see commit 6b2b45fd ("snapshot create/delete: die early for
snapshot-as-volume-chain for pre-10.0 machine version") and it's only
tested for those. Avoid accidents and other unknown issues by being
strict and prohibiting usage without '-blockdev'.

Reported-by: Friedrich Weber <f.we...@proxmox.com>
Signed-off-by: Fiona Ebner <f.eb...@proxmox.com>
---
 src/PVE/QemuServer.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index e30b27cb..cfc54568 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -1335,6 +1335,13 @@ sub print_drive_commandline_full {
     my ($path, $format) =
         PVE::QemuServer::Drive::get_path_and_format($storecfg, $drive, 
$live_restore_name);
 
+    if ($scfg && $scfg->{'snapshot-as-volume-chain'} && $format && $format eq 
'qcow2') {
+        # the print_drive_commandline_full() function is only used if machine 
version is < 10.0
+        die "storage for '$drive->{file}' is configured for snapshots as a 
volume chain - this"
+            . " requires QEMU machine version >= 10.0. See"
+            . " https://pve.proxmox.com/wiki/QEMU_Machine_Version_Upgrade\n";;
+    }
+
     my $is_rbd = $path =~ m/^rbd:/;
 
     my $opts = '';
-- 
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