* [pve-devel] [PATCH v6 qemu-server 1/4] Move path_is_scsi to QemuServer/Drive.pm
2023-12-06 7:47 [pve-devel] [PATCH v6 qemu-server 0/4] fix #4957: add vendor and product information passthrough for SCSI-Disks Hannes Duerr
@ 2023-12-06 7:47 ` Hannes Duerr
2023-12-06 7:47 ` [pve-devel] [PATCH v6 qemu-server 2/4] Move NEW_DISK_RE " Hannes Duerr
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Hannes Duerr @ 2023-12-06 7:47 UTC (permalink / raw)
To: pve-devel
Prepare for introduction of new helper
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
---
PVE/QemuServer.pm | 62 +---------------------------------------
PVE/QemuServer/Drive.pm | 63 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 61 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 2063e66..7e69924 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -53,7 +53,7 @@ use PVE::QemuServer::Helpers qw(config_aware_timeout min_version windows_version
use PVE::QemuServer::Cloudinit;
use PVE::QemuServer::CGroup;
use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options);
-use PVE::QemuServer::Drive qw(is_valid_drivename drive_is_cloudinit drive_is_cdrom drive_is_read_only parse_drive print_drive);
+use PVE::QemuServer::Drive qw(is_valid_drivename drive_is_cloudinit drive_is_cdrom drive_is_read_only parse_drive print_drive path_is_scsi);
use PVE::QemuServer::Machine;
use PVE::QemuServer::Memory qw(get_current_memory);
use PVE::QemuServer::Monitor qw(mon_cmd);
@@ -1365,66 +1365,6 @@ sub assert_clipboard_config {
}
}
-sub scsi_inquiry {
- my($fh, $noerr) = @_;
-
- my $SG_IO = 0x2285;
- my $SG_GET_VERSION_NUM = 0x2282;
-
- my $versionbuf = "\x00" x 8;
- my $ret = ioctl($fh, $SG_GET_VERSION_NUM, $versionbuf);
- if (!$ret) {
- die "scsi ioctl SG_GET_VERSION_NUM failoed - $!\n" if !$noerr;
- return;
- }
- my $version = unpack("I", $versionbuf);
- if ($version < 30000) {
- die "scsi generic interface too old\n" if !$noerr;
- return;
- }
-
- my $buf = "\x00" x 36;
- my $sensebuf = "\x00" x 8;
- my $cmd = pack("C x3 C x1", 0x12, 36);
-
- # see /usr/include/scsi/sg.h
- my $sg_io_hdr_t = "i i C C s I P P P I I i P C C C C S S i I I";
-
- my $packet = pack(
- $sg_io_hdr_t, ord('S'), -3, length($cmd), length($sensebuf), 0, length($buf), $buf, $cmd, $sensebuf, 6000
- );
-
- $ret = ioctl($fh, $SG_IO, $packet);
- if (!$ret) {
- die "scsi ioctl SG_IO failed - $!\n" if !$noerr;
- return;
- }
-
- my @res = unpack($sg_io_hdr_t, $packet);
- if ($res[17] || $res[18]) {
- die "scsi ioctl SG_IO status error - $!\n" if !$noerr;
- return;
- }
-
- my $res = {};
- $res->@{qw(type removable vendor product revision)} = unpack("C C x6 A8 A16 A4", $buf);
-
- $res->{removable} = $res->{removable} & 128 ? 1 : 0;
- $res->{type} &= 0x1F;
-
- return $res;
-}
-
-sub path_is_scsi {
- my ($path) = @_;
-
- my $fh = IO::File->new("+<$path") || return;
- my $res = scsi_inquiry($fh, 1);
- close($fh);
-
- return $res;
-}
-
sub print_tabletdevice_full {
my ($conf, $arch) = @_;
diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm
index e24ba12..f3fbaaa 100644
--- a/PVE/QemuServer/Drive.pm
+++ b/PVE/QemuServer/Drive.pm
@@ -5,6 +5,8 @@ use warnings;
use Storable qw(dclone);
+use IO::File;
+
use PVE::Storage;
use PVE::JSONSchema qw(get_standard_option);
@@ -17,6 +19,7 @@ drive_is_cdrom
drive_is_read_only
parse_drive
print_drive
+path_is_scsi
);
our $QEMU_FORMAT_RE = qr/raw|cow|qcow|qcow2|qed|vmdk|cloop/;
@@ -760,4 +763,64 @@ sub resolve_first_disk {
return;
}
+sub scsi_inquiry {
+ my($fh, $noerr) = @_;
+
+ my $SG_IO = 0x2285;
+ my $SG_GET_VERSION_NUM = 0x2282;
+
+ my $versionbuf = "\x00" x 8;
+ my $ret = ioctl($fh, $SG_GET_VERSION_NUM, $versionbuf);
+ if (!$ret) {
+ die "scsi ioctl SG_GET_VERSION_NUM failoed - $!\n" if !$noerr;
+ return;
+ }
+ my $version = unpack("I", $versionbuf);
+ if ($version < 30000) {
+ die "scsi generic interface too old\n" if !$noerr;
+ return;
+ }
+
+ my $buf = "\x00" x 36;
+ my $sensebuf = "\x00" x 8;
+ my $cmd = pack("C x3 C x1", 0x12, 36);
+
+ # see /usr/include/scsi/sg.h
+ my $sg_io_hdr_t = "i i C C s I P P P I I i P C C C C S S i I I";
+
+ my $packet = pack(
+ $sg_io_hdr_t, ord('S'), -3, length($cmd), length($sensebuf), 0, length($buf), $buf, $cmd, $sensebuf, 6000
+ );
+
+ $ret = ioctl($fh, $SG_IO, $packet);
+ if (!$ret) {
+ die "scsi ioctl SG_IO failed - $!\n" if !$noerr;
+ return;
+ }
+
+ my @res = unpack($sg_io_hdr_t, $packet);
+ if ($res[17] || $res[18]) {
+ die "scsi ioctl SG_IO status error - $!\n" if !$noerr;
+ return;
+ }
+
+ my $res = {};
+ $res->@{qw(type removable vendor product revision)} = unpack("C C x6 A8 A16 A4", $buf);
+
+ $res->{removable} = $res->{removable} & 128 ? 1 : 0;
+ $res->{type} &= 0x1F;
+
+ return $res;
+}
+
+sub path_is_scsi {
+ my ($path) = @_;
+
+ my $fh = IO::File->new("+<$path") || return;
+ my $res = scsi_inquiry($fh, 1);
+ close($fh);
+
+ return $res;
+}
+
1;
--
2.39.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] [PATCH v6 qemu-server 2/4] Move NEW_DISK_RE to QemuServer/Drive.pm
2023-12-06 7:47 [pve-devel] [PATCH v6 qemu-server 0/4] fix #4957: add vendor and product information passthrough for SCSI-Disks Hannes Duerr
2023-12-06 7:47 ` [pve-devel] [PATCH v6 qemu-server 1/4] Move path_is_scsi to QemuServer/Drive.pm Hannes Duerr
@ 2023-12-06 7:47 ` Hannes Duerr
2023-12-06 7:47 ` [pve-devel] [PATCH v6 qemu-server 3/4] drive: Create get_scsi_devicetype Hannes Duerr
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Hannes Duerr @ 2023-12-06 7:47 UTC (permalink / raw)
To: pve-devel
Prepare for introduction of new helper
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
---
PVE/API2/Qemu.pm | 10 ++++------
PVE/QemuServer/Drive.pm | 1 +
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index f26adf5..9e3cfb5 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -86,8 +86,6 @@ my $foreach_volume_with_alloc = sub {
}
};
-my $NEW_DISK_RE = qr!^(([^/:\s]+):)?(\d+(\.\d+)?)$!;
-
my $check_drive_param = sub {
my ($param, $storecfg, $extra_checks) = @_;
@@ -98,7 +96,7 @@ my $check_drive_param = sub {
raise_param_exc({ $opt => "unable to parse drive options" }) if !$drive;
if ($drive->{'import-from'}) {
- if ($drive->{file} !~ $NEW_DISK_RE || $3 != 0) {
+ if ($drive->{file} !~ $PVE::QemuServer::Drive::NEW_DISK_RE || $3 != 0) {
raise_param_exc({
$opt => "'import-from' requires special syntax - ".
"use <storage ID>:0,import-from=<source>",
@@ -142,7 +140,7 @@ my $check_storage_access = sub {
# nothing to check
} elsif ($isCDROM && ($volid eq 'cdrom')) {
$rpcenv->check($authuser, "/", ['Sys.Console']);
- } elsif (!$isCDROM && ($volid =~ $NEW_DISK_RE)) {
+ } elsif (!$isCDROM && ($volid =~ $PVE::QemuServer::Drive::NEW_DISK_RE)) {
my ($storeid, $size) = ($2 || $default_storage, $3);
die "no storage ID specified (and no default storage)\n" if !$storeid;
$rpcenv->check($authuser, "/storage/$storeid", ['Datastore.AllocateSpace']);
@@ -365,7 +363,7 @@ my $create_disks = sub {
delete $disk->{format}; # no longer needed
$res->{$ds} = PVE::QemuServer::print_drive($disk);
print "$ds: successfully created disk '$res->{$ds}'\n";
- } elsif ($volid =~ $NEW_DISK_RE) {
+ } elsif ($volid =~ $PVE::QemuServer::Drive::NEW_DISK_RE) {
my ($storeid, $size) = ($2 || $default_storage, $3);
die "no storage ID specified (and no default storage)\n" if !$storeid;
@@ -1633,7 +1631,7 @@ my $update_vm_api = sub {
return if defined($volname) && $volname eq 'cloudinit';
my $format;
- if ($volid =~ $NEW_DISK_RE) {
+ if ($volid =~ $PVE::QemuServer::Drive::NEW_DISK_RE) {
$storeid = $2;
$format = $drive->{format} || PVE::Storage::storage_default_format($storecfg, $storeid);
} else {
diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm
index f3fbaaa..3a27a6e 100644
--- a/PVE/QemuServer/Drive.pm
+++ b/PVE/QemuServer/Drive.pm
@@ -36,6 +36,7 @@ my $MAX_SCSI_DISKS = 31;
my $MAX_VIRTIO_DISKS = 16;
our $MAX_SATA_DISKS = 6;
our $MAX_UNUSED_DISKS = 256;
+our $NEW_DISK_RE = qr!^(([^/:\s]+):)?(\d+(\.\d+)?)$!;
our $drivedesc_hash;
# Schema when disk allocation is possible.
--
2.39.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] [PATCH v6 qemu-server 3/4] drive: Create get_scsi_devicetype
2023-12-06 7:47 [pve-devel] [PATCH v6 qemu-server 0/4] fix #4957: add vendor and product information passthrough for SCSI-Disks Hannes Duerr
2023-12-06 7:47 ` [pve-devel] [PATCH v6 qemu-server 1/4] Move path_is_scsi to QemuServer/Drive.pm Hannes Duerr
2023-12-06 7:47 ` [pve-devel] [PATCH v6 qemu-server 2/4] Move NEW_DISK_RE " Hannes Duerr
@ 2023-12-06 7:47 ` Hannes Duerr
2023-12-06 7:47 ` [pve-devel] [PATCH v6 qemu-server 4/4] fix #4957: add vendor and product information passthrough for SCSI-Disks Hannes Duerr
2024-01-05 16:00 ` [pve-devel] partially-applied: [PATCH v6 qemu-server 0/4] " Fiona Ebner
4 siblings, 0 replies; 7+ messages in thread
From: Hannes Duerr @ 2023-12-06 7:47 UTC (permalink / raw)
To: pve-devel
Encapsulation of the functionality for determining the scsi device type
in a new function for reusability in QemuServer/Drive.pm
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
---
PVE/QemuServer.pm | 29 ++++-------------------------
PVE/QemuServer/Drive.pm | 35 ++++++++++++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7e69924..b3e651e 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -53,7 +53,7 @@ use PVE::QemuServer::Helpers qw(config_aware_timeout min_version windows_version
use PVE::QemuServer::Cloudinit;
use PVE::QemuServer::CGroup;
use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options);
-use PVE::QemuServer::Drive qw(is_valid_drivename drive_is_cloudinit drive_is_cdrom drive_is_read_only parse_drive print_drive path_is_scsi);
+use PVE::QemuServer::Drive qw(is_valid_drivename drive_is_cloudinit drive_is_cdrom drive_is_read_only parse_drive print_drive);
use PVE::QemuServer::Machine;
use PVE::QemuServer::Memory qw(get_current_memory);
use PVE::QemuServer::Monitor qw(mon_cmd);
@@ -1409,31 +1409,10 @@ sub print_drivedevice_full {
my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive);
my $unit = $drive->{index} % $maxdev;
- 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';
- }
- }
- } else {
- $path = PVE::Storage::path($storecfg, $drive->{file});
- }
- # for compatibility only, we prefer scsi-hd (#2408, #2355, #2380)
- my $version = extract_version($machine_type, kvm_user_version());
- if ($path =~ m/^iscsi\:\/\// &&
- !min_version($version, 4, 1)) {
- $devicetype = 'generic';
- }
- }
+ my $machine_version = extract_version($machine_type, kvm_user_version());
+ my $devicetype = PVE::QemuServer::Drive::get_scsi_devicetype(
+ $drive, $storecfg, $machine_version);
if (!$conf->{scsihw} || $conf->{scsihw} =~ m/^lsi/ || $conf->{scsihw} eq 'pvscsi') {
$device = "scsi-$devicetype,bus=$controller_prefix$controller.0,scsi-id=$unit";
diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm
index 3a27a6e..5747356 100644
--- a/PVE/QemuServer/Drive.pm
+++ b/PVE/QemuServer/Drive.pm
@@ -17,9 +17,9 @@ is_valid_drivename
drive_is_cloudinit
drive_is_cdrom
drive_is_read_only
+get_scsi_devicetype
parse_drive
print_drive
-path_is_scsi
);
our $QEMU_FORMAT_RE = qr/raw|cow|qcow|qcow2|qed|vmdk|cloop/;
@@ -824,4 +824,37 @@ sub path_is_scsi {
return $res;
}
+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} =~ $NEW_DISK_RE){
+ # special syntax cannot be parsed to path
+ return $devicetype;
+ } else {
+ $path = PVE::Storage::path($storecfg, $drive->{file});
+ }
+
+ # for compatibility only, we prefer scsi-hd (#2408, #2355, #2380)
+ if ($path =~ m/^iscsi\:\/\// &&
+ !PVE::QemuServer::Helpers::min_version($machine_version, 4, 1)) {
+ $devicetype = 'generic';
+ }
+ }
+
+ return $devicetype;
+}
1;
--
2.39.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] [PATCH v6 qemu-server 4/4] fix #4957: add vendor and product information passthrough for SCSI-Disks
2023-12-06 7:47 [pve-devel] [PATCH v6 qemu-server 0/4] fix #4957: add vendor and product information passthrough for SCSI-Disks Hannes Duerr
` (2 preceding siblings ...)
2023-12-06 7:47 ` [pve-devel] [PATCH v6 qemu-server 3/4] drive: Create get_scsi_devicetype Hannes Duerr
@ 2023-12-06 7:47 ` Hannes Duerr
2024-01-05 16:00 ` Fiona Ebner
2024-01-05 16:00 ` [pve-devel] partially-applied: [PATCH v6 qemu-server 0/4] " Fiona Ebner
4 siblings, 1 reply; 7+ messages in thread
From: Hannes Duerr @ 2023-12-06 7:47 UTC (permalink / raw)
To: pve-devel
adds vendor and product information for SCSI devices to the json schema
and checks in the VM create/update API call if it is possible to add
these to QEMU as a device option
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
---
PVE/API2/Qemu.pm | 38 ++++++++++++++++++++++++++++++++++++++
PVE/QemuServer.pm | 13 ++++++++++++-
PVE/QemuServer/Drive.pm | 24 ++++++++++++++++++++++++
3 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 9e3cfb5..e0fbb3c 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -696,6 +696,33 @@ my $check_vm_modify_config_perm = sub {
return 1;
};
+sub assert_scsi_feature_compatibility {
+ my ($opt, $conf, $storecfg, $drive_attributes) = @_;
+
+ my $drive = PVE::QemuServer::Drive::parse_drive($opt, $drive_attributes);
+
+ my $machine_type = PVE::QemuServer::get_vm_machine($conf, undef, $conf->{arch});
+ my $machine_version = PVE::QemuServer::extract_version(
+ $machine_type, PVE::QemuServer::kvm_user_version());
+ my $drivetype = PVE::QemuServer::Drive::get_scsi_devicetype(
+ $drive, $storecfg, $machine_version);
+
+ if ($drivetype ne 'hd' && $drivetype ne 'cd') {
+ if ($drive->{product}) {
+ raise_param_exc({
+ product => "Passing of product information is only supported for".
+ "'scsi-hd' and 'scsi-cd' devices (e.g. not pass-through)."
+ });
+ }
+ if ($drive->{vendor}) {
+ raise_param_exc({
+ vendor => "Passing of vendor information is only supported for".
+ "'scsi-hd' and 'scsi-cd' devices (e.g. not pass-through)."
+ });
+ }
+ }
+}
+
__PACKAGE__->register_method({
name => 'vmlist',
path => '',
@@ -1013,6 +1040,12 @@ __PACKAGE__->register_method({
my $conf = $param;
my $arch = PVE::QemuServer::get_vm_arch($conf);
+ for my $opt (sort keys $param->%*) {
+ next if $opt !~ m/^scsi\d+$/;
+ assert_scsi_feature_compatibility(
+ $opt, $conf, $storecfg, $param->{$opt});
+ }
+
$conf->{meta} = PVE::QemuServer::new_meta_info_string();
my $vollist = [];
@@ -1833,6 +1866,11 @@ my $update_vm_api = sub {
PVE::QemuServer::vmconfig_register_unused_drive($storecfg, $vmid, $conf, PVE::QemuServer::parse_drive($opt, $conf->{pending}->{$opt}))
if defined($conf->{pending}->{$opt});
+ if ($opt =~ m/^scsi\d+$/) {
+ assert_scsi_feature_compatibility(
+ $opt, $conf, $storecfg, $param->{$opt});
+ }
+
my (undef, $created_opts) = $create_disks->(
$rpcenv,
$authuser,
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index b3e651e..3a4c30d 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1218,7 +1218,8 @@ sub kvm_user_version {
return $kvm_user_version->{$binary};
}
-my sub extract_version {
+
+our sub extract_version {
my ($machine_type, $version) = @_;
$version = kvm_user_version() if !defined($version);
return PVE::QemuServer::Machine::extract_version($machine_type, $version)
@@ -1427,6 +1428,16 @@ sub print_drivedevice_full {
}
$device .= ",wwn=$drive->{wwn}" if $drive->{wwn};
+ # only scsi-hd and scsi-cd support passing vendor and product information
+ if ($devicetype eq 'hd' || $devicetype eq 'cd') {
+ if (my $vendor = $drive->{vendor}) {
+ $device .= ",vendor=$vendor";
+ }
+ if (my $product = $drive->{product}) {
+ $device .= ",product=$product";
+ }
+ }
+
} elsif ($drive->{interface} eq 'ide' || $drive->{interface} eq 'sata') {
my $maxdev = ($drive->{interface} eq 'sata') ? $PVE::QemuServer::Drive::MAX_SATA_DISKS : 2;
my $controller = int($drive->{index} / $maxdev);
diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm
index 5747356..82d117e 100644
--- a/PVE/QemuServer/Drive.pm
+++ b/PVE/QemuServer/Drive.pm
@@ -163,6 +163,26 @@ my %iothread_fmt = ( iothread => {
optional => 1,
});
+my %product_fmt = (
+ product => {
+ type => 'string',
+ pattern => '[A-Za-z0-9\-_\s]{,40}',
+ format_description => 'product',
+ description => "The drive's product name, up to 40 bytes long.",
+ optional => 1,
+ },
+);
+
+my %vendor_fmt = (
+ vendor => {
+ type => 'string',
+ pattern => '[A-Za-z0-9\-_\s]{,40}',
+ format_description => 'vendor',
+ description => "The drive's vendor name, up to 40 bytes long.",
+ optional => 1,
+ },
+);
+
my %model_fmt = (
model => {
type => 'string',
@@ -280,10 +300,12 @@ PVE::JSONSchema::register_standard_option("pve-qm-ide", $idedesc);
my $scsi_fmt = {
%drivedesc_base,
%iothread_fmt,
+ %product_fmt,
%queues_fmt,
%readonly_fmt,
%scsiblock_fmt,
%ssd_fmt,
+ %vendor_fmt,
%wwn_fmt,
};
my $scsidesc = {
@@ -404,10 +426,12 @@ my $alldrive_fmt = {
%drivedesc_base,
%iothread_fmt,
%model_fmt,
+ %product_fmt,
%queues_fmt,
%readonly_fmt,
%scsiblock_fmt,
%ssd_fmt,
+ %vendor_fmt,
%wwn_fmt,
%tpmversion_fmt,
%efitype_fmt,
--
2.39.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [pve-devel] [PATCH v6 qemu-server 4/4] fix #4957: add vendor and product information passthrough for SCSI-Disks
2023-12-06 7:47 ` [pve-devel] [PATCH v6 qemu-server 4/4] fix #4957: add vendor and product information passthrough for SCSI-Disks Hannes Duerr
@ 2024-01-05 16:00 ` Fiona Ebner
0 siblings, 0 replies; 7+ messages in thread
From: Fiona Ebner @ 2024-01-05 16:00 UTC (permalink / raw)
To: Proxmox VE development discussion, Hannes Duerr
Am 06.12.23 um 08:47 schrieb Hannes Duerr:
> adds vendor and product information for SCSI devices to the json schema
> and checks in the VM create/update API call if it is possible to add
> these to QEMU as a device option
>
> Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
> ---
> PVE/API2/Qemu.pm | 38 ++++++++++++++++++++++++++++++++++++++
> PVE/QemuServer.pm | 13 ++++++++++++-
> PVE/QemuServer/Drive.pm | 24 ++++++++++++++++++++++++
> 3 files changed, 74 insertions(+), 1 deletion(-)
>
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 9e3cfb5..e0fbb3c 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -696,6 +696,33 @@ my $check_vm_modify_config_perm = sub {
> return 1;
> };
>
> +sub assert_scsi_feature_compatibility {
> + my ($opt, $conf, $storecfg, $drive_attributes) = @_;
> +
> + my $drive = PVE::QemuServer::Drive::parse_drive($opt, $drive_attributes);
> +
> + my $machine_type = PVE::QemuServer::get_vm_machine($conf, undef, $conf->{arch});
> + my $machine_version = PVE::QemuServer::extract_version(
> + $machine_type, PVE::QemuServer::kvm_user_version());
Is there a specific reason you don't use
PVE::QemuServer::Machine::extract_version() here?
Would avoid the need to make the helper below public:
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index b3e651e..3a4c30d 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -1218,7 +1218,8 @@ sub kvm_user_version {
> return $kvm_user_version->{$binary};
>
> }
> -my sub extract_version {
> +
> +our sub extract_version {
> my ($machine_type, $version) = @_;
> $version = kvm_user_version() if !defined($version);
> return PVE::QemuServer::Machine::extract_version($machine_type, $version)
i.e. here. Note for the future: there's no need to add 'our' for a sub.
Things I noticed while testing:
1. Currently the new properties are directly applied to the config, but
not actually hotplugged. You'll need to skip them in vmconfig_update_disk().
2. udevadm info seems to only show the first eight characters for
ID_VENDOR and first sixteen characters for ID_MODEL. Can you check if
that is a limitation there or if more is simply not supported? If the
latter, we should limit the sizes in the schema accordingly.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] partially-applied: [PATCH v6 qemu-server 0/4] fix #4957: add vendor and product information passthrough for SCSI-Disks
2023-12-06 7:47 [pve-devel] [PATCH v6 qemu-server 0/4] fix #4957: add vendor and product information passthrough for SCSI-Disks Hannes Duerr
` (3 preceding siblings ...)
2023-12-06 7:47 ` [pve-devel] [PATCH v6 qemu-server 4/4] fix #4957: add vendor and product information passthrough for SCSI-Disks Hannes Duerr
@ 2024-01-05 16:00 ` Fiona Ebner
4 siblings, 0 replies; 7+ messages in thread
From: Fiona Ebner @ 2024-01-05 16:00 UTC (permalink / raw)
To: Proxmox VE development discussion, Hannes Duerr
Am 06.12.23 um 08:47 schrieb Hannes Duerr:
>
> Hannes Duerr (4):
> Move path_is_scsi to QemuServer/Drive.pm
> Move NEW_DISK_RE to QemuServer/Drive.pm
> drive: Create get_scsi_devicetype
applied the preparatory patches, thanks!
> fix #4957: add vendor and product information passthrough for
> SCSI-Disks
>
^ permalink raw reply [flat|nested] 7+ messages in thread