[pve-devel] [PATCH qemu-server 12/14] qemu_img convert : add external snapshot support
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri May 9 12:30:10 CEST 2025
the commit title is a bit weird, this actually adapts the qemu_img_convert helper
to the new volume_has_feature values, supporting external snapshots is a side effect
of that..
> Alexandre Derumier via pve-devel <pve-devel at lists.proxmox.com> hat am 22.04.2025 13:51 CEST geschrieben:
> for external snapshot, we simply use snap volname as src.
> don't use internal snapshot option in the command line.
>
> Signed-off-by: Alexandre Derumier <alexandre.derumier at groupe-cyllene.com>
> ---
> PVE/QemuServer.pm | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 12d60cad..5cce7094 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -7906,11 +7906,11 @@ sub qemu_img_convert {
> my $dst_format = checked_volume_format($storecfg, $dst_volid);
> my $dst_path = PVE::Storage::path($storecfg, $dst_volid);
> my $dst_is_iscsi = ($dst_path =~ m|^iscsi://|);
> + my $snapshot_type = PVE::Storage::volume_has_feature($storecfg, 'snapshot', $src_volid);
>
> my $cmd = [];
> push @$cmd, '/usr/bin/qemu-img', 'convert', '-p', '-n';
> - push @$cmd, '-l', "snapshot.name=$snapname"
> - if $snapname && $src_format && $src_format eq "qcow2";
> + push @$cmd, '-l', "snapshot.name=$snapname" if $snapname && $snapshot_type == 2;
this breaks backwards compatibility with external plugins that override volume_has_features, and
thus still return '1' while using internal qcow2 snapshots.. I think we need to detect that and
fallback here? or we need to differentiate all four cases:
1: plugin not changed, fallback to format-based decision
2: storage snapshot, no need to pass snapshot name to qemu-img
3: qcow2-internal snapshot, need to pass snapshot name to qemu-img
4: qcow2-external snapshot, no need to pass snapshot name to qemu-img
?
at that point, it might make more sense to actually name those values:
1: plugin not changed, 'legacy' snapshot support
'storage': same semantics as '1', but plugin was updated/doesn't override volume_has_features
'file-internal': same as 3 above
'file-external': same as 4 above
? or if we want to keep volume_has_features the same, we could introduce a new helper that
returns the snapshot type?
> push @$cmd, '-t', 'none' if $dst_scfg->{type} eq 'zfspool';
> push @$cmd, '-T', $cachemode if defined($cachemode);
> push @$cmd, '-r', "${bwlimit}K" if defined($bwlimit);
> --
> 2.39.5
More information about the pve-devel
mailing list