plugin: add machine version to qemu_blockdev_options() interface
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.ebner@proxmox.com>
This commit is contained in:
committed by
Fabian Grünbichler
parent
2d874037f3
commit
6c07619abd
@ -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
|
||||
|
||||
@ -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'};
|
||||
|
||||
@ -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 = {};
|
||||
|
||||
|
||||
@ -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];
|
||||
|
||||
@ -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'};
|
||||
|
||||
@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user