Plugins can guard based on the machine version to be able to switch drivers or options in a safe way without the risk of breaking older versions.
Signed-off-by: Fiona Ebner <f.eb...@proxmox.com> --- src/PVE/Storage.pm | 4 ++-- src/PVE/Storage/ISCSIDirectPlugin.pm | 2 +- src/PVE/Storage/Plugin.pm | 12 ++++++++++-- src/PVE/Storage/RBDPlugin.pm | 2 +- src/PVE/Storage/ZFSPlugin.pm | 2 +- src/PVE/Storage/ZFSPoolPlugin.pm | 2 +- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm index 4920bd6..5afff26 100755 --- a/src/PVE/Storage.pm +++ b/src/PVE/Storage.pm @@ -721,7 +721,7 @@ sub abs_filesystem_path { # see the documentation for the plugin method sub qemu_blockdev_options { - my ($cfg, $volid, $options) = @_; + my ($cfg, $volid, $machine_version, $options) = @_; my ($storeid, $volname) = parse_volume_id($volid); @@ -733,7 +733,7 @@ sub qemu_blockdev_options { die "cannot use volume of type '$vtype' as a QEMU blockdevice\n" if $vtype ne 'images' && $vtype ne 'iso' && $vtype ne 'import'; - return $plugin->qemu_blockdev_options($scfg, $storeid, $volname, $options); + return $plugin->qemu_blockdev_options($scfg, $storeid, $volname, $machine_version, $options); } # used as last resort to adapt volnames when migrating diff --git a/src/PVE/Storage/ISCSIDirectPlugin.pm b/src/PVE/Storage/ISCSIDirectPlugin.pm index e0f8a62..62e9026 100644 --- a/src/PVE/Storage/ISCSIDirectPlugin.pm +++ b/src/PVE/Storage/ISCSIDirectPlugin.pm @@ -111,7 +111,7 @@ sub path { } sub qemu_blockdev_options { - my ($class, $scfg, $storeid, $volname, $options) = @_; + my ($class, $scfg, $storeid, $volname, $machine_version, $options) = @_; die "volume snapshot is not possible on iscsi device\n" if $options->{'snapshot-name'}; diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index 52652b2..cfe89dd 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -1965,7 +1965,8 @@ sub rename_volume { =head3 qemu_blockdev_options - $blockdev = $plugin->qemu_blockdev_options($scfg, $storeid, $volname, $options) + $blockdev = + $plugin->qemu_blockdev_options($scfg, $storeid, $volname, $machine_version, $options) Returns a hash reference with the basic options needed to open the volume via QEMU's C<-blockdev> API. This at least requires a C<< $blockdev->{driver} >> and a reference to the image, e.g. @@ -1992,6 +1993,13 @@ Arguments: =item C<$volume>: The volume name. +=item C<$machine_version>: The QEMU machine version for which the block device will be used. If you +want to change drivers or change driver options, you should use this as a guard, so that only +machines with a new enough version will use the new driver or options. Machines with an older +version should still get the old driver and options. The version is a string +C<${major}.${minor}+pve${pve_version}>. The pve version is used for certain downstream changes to +machine models and should be (mostly) irrelevant for third-party plugins. + =item C<$options>: A hash reference with additional options. =over @@ -2019,7 +2027,7 @@ volume itself. =cut sub qemu_blockdev_options { - my ($class, $scfg, $storeid, $volname, $options) = @_; + my ($class, $scfg, $storeid, $volname, $machine_version, $options) = @_; my $blockdev = {}; diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm index 800af68..31cbf8f 100644 --- a/src/PVE/Storage/RBDPlugin.pm +++ b/src/PVE/Storage/RBDPlugin.pm @@ -524,7 +524,7 @@ sub path { } sub qemu_blockdev_options { - my ($class, $scfg, $storeid, $volname, $options) = @_; + my ($class, $scfg, $storeid, $volname, $machine_version, $options) = @_; my $cmd_option = PVE::CephConfig::ceph_connect_option($scfg, $storeid); my ($name) = ($class->parse_volname($volname))[1]; diff --git a/src/PVE/Storage/ZFSPlugin.pm b/src/PVE/Storage/ZFSPlugin.pm index 940d4f0..eed39cd 100644 --- a/src/PVE/Storage/ZFSPlugin.pm +++ b/src/PVE/Storage/ZFSPlugin.pm @@ -248,7 +248,7 @@ sub path { } sub qemu_blockdev_options { - my ($class, $scfg, $storeid, $volname, $options) = @_; + my ($class, $scfg, $storeid, $volname, $machine_version, $options) = @_; die "direct access to snapshots not implemented\n" if $options->{'snapshot-name'}; diff --git a/src/PVE/Storage/ZFSPoolPlugin.pm b/src/PVE/Storage/ZFSPoolPlugin.pm index d5552ab..979cf2c 100644 --- a/src/PVE/Storage/ZFSPoolPlugin.pm +++ b/src/PVE/Storage/ZFSPoolPlugin.pm @@ -163,7 +163,7 @@ sub path { } sub qemu_blockdev_options { - my ($class, $scfg, $storeid, $volname, $options) = @_; + my ($class, $scfg, $storeid, $volname, $machine_version, $options) = @_; my $format = ($class->parse_volname($volname))[6]; -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel