plugin: add method to get qemu blockdevice options for volume
This is in preparation to switch qemu-server from using '-drive' to the modern '-blockdev' in the QEMU commandline options as well as for the qemu-storage-daemon, which only supports '-blockdev'. The plugins know best what driver and options are needed to access an image, so a dedicated plugin method returning the necessary parameters for '-blockdev' is the most straight-forward. There intentionally is only handling for absolute paths in the default plugin implementation. Any plugin requiring more needs to implement the method itself. With PVE 9 being a major release and most popular plugins not using special protocols like 'rbd://', this seems acceptable. For NBD, etc. qemu-server should construct the blockdev object. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
committed by
Fabian Grünbichler
parent
823707a7ac
commit
073c5677c7
@ -719,6 +719,23 @@ sub abs_filesystem_path {
|
||||
return $path;
|
||||
}
|
||||
|
||||
# see the documentation for the plugin method
|
||||
sub qemu_blockdev_options {
|
||||
my ($cfg, $volid) = @_;
|
||||
|
||||
my ($storeid, $volname) = parse_volume_id($volid);
|
||||
|
||||
my $scfg = storage_config($cfg, $storeid);
|
||||
|
||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
||||
|
||||
my ($vtype) = $plugin->parse_volname($volname);
|
||||
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);
|
||||
}
|
||||
|
||||
# used as last resort to adapt volnames when migrating
|
||||
my $volname_for_storage = sub {
|
||||
my ($cfg, $storeid, $name, $vmid, $format) = @_;
|
||||
|
||||
Reference in New Issue
Block a user