replace volume_support_qemu_snapshot with volume_qemu_snapshot

This also changes the return values, since their meanings are rather
weird from the storage point of view. For instance, "internal" meant
it is *not* the storage which does the snapshot, while "external"
meant a mixture of storage and qemu-server side actions. `undef` meant
the storage does it all...

┌────────────┬───────────┐
│ previous   │ new       │
├────────────┼───────────┤
│ "internal" │ "qemu"    │
│ "external" │ "mixed"   │
│ undef      │ "storage" │
└────────────┴───────────┘

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2025-07-16 15:16:24 +02:00
parent 3941068c25
commit 41c6e4bf7a
6 changed files with 37 additions and 21 deletions

View File

@ -2370,7 +2370,7 @@ sub rename_snapshot {
);
}
sub volume_support_qemu_snapshot {
sub volume_qemu_snapshot_method {
my ($cfg, $volid) = @_;
my ($storeid, $volname) = parse_volume_id($volid, 1);
@ -2380,7 +2380,7 @@ sub volume_support_qemu_snapshot {
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
return $plugin->volume_support_qemu_snapshot($storeid, $scfg, $volname);
return $plugin->volume_qemu_snapshot_method($storeid, $scfg, $volname);
}
return undef;
}

View File

@ -315,14 +315,13 @@ sub get_import_metadata {
};
}
sub volume_support_qemu_snapshot {
sub volume_qemu_snapshot_method {
my ($class, $storeid, $scfg, $volname) = @_;
my $format = ($class->parse_volname($volname))[6];
return if $format ne 'qcow2';
return 'storage' if $format ne 'qcow2';
my $type = $scfg->{'external-snapshots'} ? 'external' : 'internal';
return $type;
return $scfg->{'external-snapshots'} ? 'mixed' : 'qemu';
}
1;

View File

@ -1301,11 +1301,12 @@ sub rename_snapshot {
lvrename($scfg, $source_snap_volname, $target_snap_volname);
}
sub volume_support_qemu_snapshot {
sub volume_qemu_snapshot_method {
my ($class, $storeid, $scfg, $volname) = @_;
my $format = ($class->parse_volname($volname))[6];
return 'external' if $format eq 'qcow2';
return 'mixed' if $format eq 'qcow2';
return 'storage';
}
1;

View File

@ -2428,9 +2428,9 @@ sub new_backup_provider {
=pod
=head3 volume_support_qemu_snapshot
=head3 volume_qemu_snapshot_method
$blockdev = $plugin->volume_support_qemu_snapshot($storeid, $scfg, $volname)
$blockdev = $plugin->volume_qemu_snapshot_method($storeid, $scfg, $volname)
Returns a string with the type of snapshot that qemu can do for a specific volume
@ -2439,11 +2439,12 @@ Returns a string with the type of snapshot that qemu can do for a specific volum
undef : don't support qemu snapshot
=cut
sub volume_support_qemu_snapshot {
sub volume_qemu_snapshot_method {
my ($class, $storeid, $scfg, $volname) = @_;
my $format = ($class->parse_volname($volname))[6];
return 'internal' if $format eq 'qcow2';
return 'qemu' if $format eq 'qcow2';
return 'storage';
}
sub config_aware_base_mkdir {

View File

@ -1063,10 +1063,11 @@ sub rename_snapshot {
die "rename_snapshot is not implemented for $class";
}
sub volume_support_qemu_snapshot {
sub volume_qemu_snapshot_method {
my ($class, $storeid, $scfg, $volname) = @_;
return 'internal' if !$scfg->{krbd};
return 'qemu' if !$scfg->{krbd};
return 'storage';
}
1;