plugin: add get_formats() method and use it instead of default_format()
The LVM plugin can only use qcow2 format when the 'snapshot-as-volume-chain' configuration option is set. The format information is currently only recorded statically in the plugin data. This causes issues, for example, restoring a guest volume that uses qcow2 as a format hint on an LVM storage without the option set will fail, because the plugin data indicates that qcow2 is supported. Introduce a dedicated method, so that plugins can indicate what actually is supported according to the storage configuration. The implementation for LVM is done in a separate commit. Remove the now unused default_format() function from Plugin.pm. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> [WB: docs: add missing params, drop =pod line, use !! for bools] Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
committed by
Wolfgang Bumiller
parent
cd7c8e0ce6
commit
e9e24973fd
@ -857,10 +857,11 @@ my $volname_for_storage = sub {
|
||||
|
||||
my $scfg = storage_config($cfg, $storeid);
|
||||
|
||||
my (undef, $valid_formats) = PVE::Storage::Plugin::default_format($scfg);
|
||||
my $format_is_valid = grep { $_ eq $format } @$valid_formats;
|
||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
||||
|
||||
my $formats = $plugin->get_formats($scfg, $storeid);
|
||||
die "unsupported format '$format' for storage type $scfg->{type}\n"
|
||||
if !$format_is_valid;
|
||||
if !$formats->{valid}->{$format};
|
||||
|
||||
(my $name_without_extension = $name) =~ s/\.$format$//;
|
||||
|
||||
@ -1184,14 +1185,12 @@ sub vdisk_alloc {
|
||||
|
||||
$vmid = parse_vmid($vmid);
|
||||
|
||||
my $defformat = PVE::Storage::Plugin::default_format($scfg);
|
||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
||||
|
||||
$fmt = $defformat if !$fmt;
|
||||
$fmt = $plugin->get_formats($scfg, $storeid)->{default} if !$fmt;
|
||||
|
||||
activate_storage($cfg, $storeid);
|
||||
|
||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
||||
|
||||
# lock shared storage
|
||||
return $plugin->cluster_lock_storage(
|
||||
$storeid,
|
||||
@ -1673,8 +1672,12 @@ sub storage_default_format {
|
||||
my ($cfg, $storeid) = @_;
|
||||
|
||||
my $scfg = storage_config($cfg, $storeid);
|
||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
||||
|
||||
return PVE::Storage::Plugin::default_format($scfg);
|
||||
my $formats = $plugin->get_formats($scfg, $storeid);
|
||||
|
||||
return
|
||||
wantarray ? ($formats->{default}, [sort keys $formats->{valid}->%*]) : $formats->{default};
|
||||
}
|
||||
|
||||
sub vgroup_is_used {
|
||||
|
||||
Reference in New Issue
Block a user