[pve-devel] [PATCH v3 qemu-server 1/2] Create get_scsi_devicetype and move it and its dependencies to QemuServer/Drive.pm
Fiona Ebner
f.ebner at proxmox.com
Thu Nov 16 11:15:03 CET 2023
Nit: Like can be seen from the "and" in the commit title, it's actually
two changes. Moving the dependencies first, and then introducing the new
helper in a second patch would be even better. But no big deal :)
Am 10.11.23 um 10:33 schrieb Hannes Duerr:
> +sub get_scsi_devicetype {
> + my ($drive, $storecfg, $machine_version) = @_;
> +
> + my $devicetype = 'hd';
> + my $path = '';
> + if (drive_is_cdrom($drive)) {
> + $devicetype = 'cd';
> + } else {
> + if ($drive->{file} =~ m|^/|) {
> + $path = $drive->{file};
> + if (my $info = path_is_scsi($path)) {
> + if ($info->{type} == 0 && $drive->{scsiblock}) {
> + $devicetype = 'block';
> + } elsif ($info->{type} == 1) { # tape
> + $devicetype = 'generic';
> + }
> + }
> + } elsif ($drive->{file} =~ m/local-lvm:/){
> + # special syntax cannot be parsed to path
> + $path = "local-lvm";
What if the storage is called differently ;)
Note, there also is a NEW_DISK_RE in API2/Qemu.pm you can use to compare
(needs to be moved to the Drive.pm module first - make it
our $NEW_DISK_RE = ...;
to be able to reference it from API2/Qemu.pm afterwards)
Why set the path to some fake value and not just return the device type
early?
More information about the pve-devel
mailing list