[pve-devel] [RFC storage 1/3] plugin: add method to get qemu blockdevice options for volume

DERUMIER, Alexandre alexandre.derumier at groupe-cyllene.com
Fri May 23 11:34:37 CEST 2025


>>I intentionally do not handle CD-ROMs, qemu-server should be
>>concerned
>>with doing that. There is a comment about this ;)

I mean, could it better to have something like this ? :


sub qemu_blockdev_options {
    my ($cfg, $volid, $snapname) = @_;

    my ($storeid, $volname) = parse_volume_id($volid, 1);

    if($storeid) {
        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';

        die "QEMU blockdevice - 'snapname' argument is not supported
for vtype '$vtype'"
            if $snapname && $vtype ne 'images';
    } elsif ($volid =~ m|^/|) {
        my $st = File::stat::stat($volid);
        my $driver = (S_ISCHR($st->mode) || S_ISBLK($st->mode)) ?
'host_device' : 'file';
        return { driver => $driver, filename => $volid };
    }

    return $plugin->qemu_blockdev_options($scfg, $storeid, $volname,
$snapname);
}


More information about the pve-devel mailing list