Allow passing options to volume_has_feature
With the option valid_target_formats it's possible to let the caller specify possible formats for the target of an operation. [0]: If the option is not set, assume that every format is valid. In most cases the format of the the target and the format of the source will agree (and therefore assumption [0] is not actually assuming very much and ensures backwards compatability). But when cloning a volume on a storage using Plugin.pm's implementation (e.g. directory based storages), the result is always a qcow2 image. When cloning containers, the new option can be used to detect that qcow2 is not valid and hence the clone feature is not available. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
committed by
Fabian Grünbichler
parent
6c25dbd495
commit
e6f4eed435
@ -828,7 +828,7 @@ sub storage_can_replicate {
|
||||
}
|
||||
|
||||
sub volume_has_feature {
|
||||
my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
|
||||
my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running, $opts) = @_;
|
||||
|
||||
my $features = {
|
||||
snapshot => { current => { qcow2 => 1}, snap => { qcow2 => 1} },
|
||||
@ -841,6 +841,11 @@ sub volume_has_feature {
|
||||
current => {qcow2 => 1, raw => 1, vmdk => 1} },
|
||||
};
|
||||
|
||||
# clone_image creates a qcow2 volume
|
||||
return 0 if $feature eq 'clone' &&
|
||||
defined($opts->{valid_target_formats}) &&
|
||||
!(grep { $_ eq 'qcow2' } @{$opts->{valid_target_formats}});
|
||||
|
||||
my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) =
|
||||
$class->parse_volname($volname);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user