* [pve-devel] [PATCH qemuserver 1/3] introduce DriveDevice module
[not found] <20250627100242.1478523-1-alexandre.derumier@groupe-cyllene.com>
@ 2025-06-27 10:02 ` Alexandre Derumier via pve-devel
2025-06-27 10:02 ` [pve-devel] [PATCH qemuserver 2/3] add print_drivedevice_controller && print_drivedevice_iothread Alexandre Derumier via pve-devel
2025-06-27 10:02 ` [pve-devel] [PATCH qemuserver 3/3] hotplug: drive controller : use print_drivedevice_iothread && print_drivedevice_controller Alexandre Derumier via pve-devel
2 siblings, 0 replies; 3+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-06-27 10:02 UTC (permalink / raw)
To: pve-devel; +Cc: Alexandre Derumier
[-- Attachment #1: Type: message/rfc822, Size: 15496 bytes --]
From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemuserver 1/3] introduce DriveDevice module
Date: Fri, 27 Jun 2025 12:02:40 +0200
Message-ID: <20250627100242.1478523-2-alexandre.derumier@groupe-cyllene.com>
and move print_drivedevice_full
Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
src/PVE/QemuServer.pm | 144 +-------------------------
src/PVE/QemuServer/DriveDevice.pm | 163 ++++++++++++++++++++++++++++++
src/PVE/QemuServer/Makefile | 1 +
3 files changed, 165 insertions(+), 143 deletions(-)
create mode 100644 src/PVE/QemuServer/DriveDevice.pm
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 70e51e97..f6f8cc58 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -72,6 +72,7 @@ use PVE::QemuServer::Drive qw(
print_drive
storage_allows_io_uring_default
);
+use PVE::QemuServer::DriveDevice qw(print_drivedevice_full scsihw_infos);
use PVE::QemuServer::Machine;
use PVE::QemuServer::Memory qw(get_current_memory);
use PVE::QemuServer::MetaInfo;
@@ -1196,127 +1197,6 @@ sub print_keyboarddevice_full {
return "usb-kbd,id=keyboard,bus=ehci.0,port=2";
}
-sub print_drivedevice_full {
- my ($storecfg, $conf, $vmid, $drive, $bridges, $arch, $machine_type) = @_;
-
- my $device = '';
- my $maxdev = 0;
-
- my $machine_version = extract_version($machine_type, kvm_user_version());
-
- my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);
- if ($drive->{interface} eq 'virtio') {
- my $pciaddr = print_pci_addr("$drive_id", $bridges, $arch);
- $device = 'virtio-blk-pci';
- # for the switch to -blockdev, there is no blockdev for 'none'
- if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') {
- $device .= ",drive=drive-$drive_id";
- }
- $device .= ",id=${drive_id}${pciaddr}";
- $device .= ",iothread=iothread-$drive_id" if $drive->{iothread};
- } elsif ($drive->{interface} eq 'scsi') {
-
- my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive);
- my $unit = $drive->{index} % $maxdev;
-
- my $device_type =
- PVE::QemuServer::Drive::get_scsi_device_type($drive, $storecfg, $machine_version);
-
- if (!$conf->{scsihw} || $conf->{scsihw} =~ m/^lsi/ || $conf->{scsihw} eq 'pvscsi') {
- $device = "scsi-$device_type,bus=$controller_prefix$controller.0,scsi-id=$unit";
- } else {
- $device = "scsi-$device_type,bus=$controller_prefix$controller.0,channel=0,scsi-id=0"
- . ",lun=$drive->{index}";
- }
- # for the switch to -blockdev, there is no blockdev for 'none'
- if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') {
- $device .= ",drive=drive-$drive_id";
- }
- $device .= ",id=$drive_id";
-
- if ($drive->{ssd} && ($device_type eq 'block' || $device_type eq 'hd')) {
- $device .= ",rotation_rate=1";
- }
- $device .= ",wwn=$drive->{wwn}" if $drive->{wwn};
-
- # only scsi-hd and scsi-cd support passing vendor and product information
- if ($device_type eq 'hd' || $device_type 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);
- my $unit = $drive->{index} % $maxdev;
-
- # machine type q35 only supports unit=0 for IDE rather than 2 units. This wasn't handled
- # correctly before, so e.g. index=2 was mapped to controller=1,unit=0 rather than
- # controller=2,unit=0. Note that odd indices never worked, as they would be mapped to
- # unit=1, so to keep backwards compat for migration, it suffices to keep even ones as they
- # were before. Move odd ones up by 2 where they don't clash.
- if (PVE::QemuServer::Machine::machine_type_is_q35($conf) && $drive->{interface} eq 'ide') {
- $controller += 2 * ($unit % 2);
- $unit = 0;
- }
-
- my $device_type = ($drive->{media} && $drive->{media} eq 'cdrom') ? "cd" : "hd";
-
- $device = "ide-$device_type";
- if ($drive->{interface} eq 'ide') {
- $device .= ",bus=ide.$controller,unit=$unit";
- } else {
- $device .= ",bus=ahci$controller.$unit";
- }
- if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') {
- $device .= ",drive=drive-$drive_id";
- }
- $device .= ",id=$drive_id";
-
- if ($device_type eq 'hd') {
- if (my $model = $drive->{model}) {
- $model = URI::Escape::uri_unescape($model);
- $device .= ",model=$model";
- }
- if ($drive->{ssd}) {
- $device .= ",rotation_rate=1";
- }
- }
- $device .= ",wwn=$drive->{wwn}" if $drive->{wwn};
- } elsif ($drive->{interface} eq 'usb') {
- die "implement me";
- # -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
- } else {
- die "unsupported interface type";
- }
-
- $device .= ",bootindex=$drive->{bootindex}" if $drive->{bootindex};
-
- if (my $serial = $drive->{serial}) {
- $serial = URI::Escape::uri_unescape($serial);
- $device .= ",serial=$serial";
- }
-
- if (min_version($machine_version, 10, 0)) { # for the switch to -blockdev
- if (!drive_is_cdrom($drive)) {
- my $write_cache = 'on';
- if (my $cache = $drive->{cache}) {
- $write_cache = 'off' if $cache eq 'writethrough' || $cache eq 'directsync';
- }
- $device .= ",write-cache=$write_cache";
- }
- for my $o (qw(rerror werror)) {
- $device .= ",$o=$drive->{$o}" if defined($drive->{$o});
- }
- }
-
- return $device;
-}
-
sub print_drive_commandline_full {
my ($storecfg, $vmid, $drive, $live_restore_name) = @_;
@@ -7995,28 +7875,6 @@ sub vm_iothreads_list {
return $iothreads;
}
-sub scsihw_infos {
- my ($conf, $drive) = @_;
-
- my $maxdev = 0;
-
- if (!$conf->{scsihw} || ($conf->{scsihw} =~ m/^lsi/)) {
- $maxdev = 7;
- } elsif ($conf->{scsihw} && ($conf->{scsihw} eq 'virtio-scsi-single')) {
- $maxdev = 1;
- } else {
- $maxdev = 256;
- }
-
- my $controller = int($drive->{index} / $maxdev);
- my $controller_prefix =
- ($conf->{scsihw} && $conf->{scsihw} eq 'virtio-scsi-single')
- ? "virtioscsi"
- : "scsihw";
-
- return ($maxdev, $controller, $controller_prefix);
-}
-
sub resolve_dst_disk_format {
my ($storecfg, $storeid, $src_volid, $format) = @_;
diff --git a/src/PVE/QemuServer/DriveDevice.pm b/src/PVE/QemuServer/DriveDevice.pm
new file mode 100644
index 00000000..764afc93
--- /dev/null
+++ b/src/PVE/QemuServer/DriveDevice.pm
@@ -0,0 +1,163 @@
+package PVE::QemuServer::DriveDevice;
+
+use strict;
+use warnings;
+
+use URI::Escape;
+
+use PVE::QemuServer::Drive qw (drive_is_cdrom);
+use PVE::QemuServer::Helpers qw(kvm_user_version min_version);
+use PVE::QemuServer::Machine;
+use PVE::QemuServer::PCI qw(print_pci_addr);
+
+use base qw(Exporter);
+
+our @EXPORT_OK = qw(
+ print_drivedevice_full
+ scsihw_infos
+);
+
+sub scsihw_infos {
+ my ($conf, $drive) = @_;
+
+ my $maxdev = 0;
+
+ if (!$conf->{scsihw} || ($conf->{scsihw} =~ m/^lsi/)) {
+ $maxdev = 7;
+ } elsif ($conf->{scsihw} && ($conf->{scsihw} eq 'virtio-scsi-single')) {
+ $maxdev = 1;
+ } else {
+ $maxdev = 256;
+ }
+
+ my $controller = int($drive->{index} / $maxdev);
+ my $controller_prefix =
+ ($conf->{scsihw} && $conf->{scsihw} eq 'virtio-scsi-single')
+ ? "virtioscsi"
+ : "scsihw";
+
+ return ($maxdev, $controller, $controller_prefix);
+}
+
+sub print_drivedevice_full {
+ my ($storecfg, $conf, $vmid, $drive, $bridges, $arch, $machine_type) = @_;
+
+ my $device = '';
+ my $maxdev = 0;
+
+ my $machine_version = PVE::QemuServer::Machine::extract_version($machine_type, kvm_user_version());
+
+ my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);
+ if ($drive->{interface} eq 'virtio') {
+ my $pciaddr = print_pci_addr("$drive_id", $bridges, $arch);
+ $device = 'virtio-blk-pci';
+ # for the switch to -blockdev, there is no blockdev for 'none'
+ if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') {
+ $device .= ",drive=drive-$drive_id";
+ }
+ $device .= ",id=${drive_id}${pciaddr}";
+ $device .= ",iothread=iothread-$drive_id" if $drive->{iothread};
+ } elsif ($drive->{interface} eq 'scsi') {
+
+ my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive);
+ my $unit = $drive->{index} % $maxdev;
+
+ my $device_type =
+ PVE::QemuServer::Drive::get_scsi_device_type($drive, $storecfg, $machine_version);
+
+ if (!$conf->{scsihw} || $conf->{scsihw} =~ m/^lsi/ || $conf->{scsihw} eq 'pvscsi') {
+ $device = "scsi-$device_type,bus=$controller_prefix$controller.0,scsi-id=$unit";
+ } else {
+ $device = "scsi-$device_type,bus=$controller_prefix$controller.0,channel=0,scsi-id=0"
+ . ",lun=$drive->{index}";
+ }
+ # for the switch to -blockdev, there is no blockdev for 'none'
+ if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') {
+ $device .= ",drive=drive-$drive_id";
+ }
+ $device .= ",id=$drive_id";
+
+ if ($drive->{ssd} && ($device_type eq 'block' || $device_type eq 'hd')) {
+ $device .= ",rotation_rate=1";
+ }
+ $device .= ",wwn=$drive->{wwn}" if $drive->{wwn};
+
+ # only scsi-hd and scsi-cd support passing vendor and product information
+ if ($device_type eq 'hd' || $device_type 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);
+ my $unit = $drive->{index} % $maxdev;
+
+ # machine type q35 only supports unit=0 for IDE rather than 2 units. This wasn't handled
+ # correctly before, so e.g. index=2 was mapped to controller=1,unit=0 rather than
+ # controller=2,unit=0. Note that odd indices never worked, as they would be mapped to
+ # unit=1, so to keep backwards compat for migration, it suffices to keep even ones as they
+ # were before. Move odd ones up by 2 where they don't clash.
+ if (PVE::QemuServer::Machine::machine_type_is_q35($conf) && $drive->{interface} eq 'ide') {
+ $controller += 2 * ($unit % 2);
+ $unit = 0;
+ }
+
+ my $device_type = ($drive->{media} && $drive->{media} eq 'cdrom') ? "cd" : "hd";
+
+ $device = "ide-$device_type";
+ if ($drive->{interface} eq 'ide') {
+ $device .= ",bus=ide.$controller,unit=$unit";
+ } else {
+ $device .= ",bus=ahci$controller.$unit";
+ }
+ if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') {
+ $device .= ",drive=drive-$drive_id";
+ }
+ $device .= ",id=$drive_id";
+
+ if ($device_type eq 'hd') {
+ if (my $model = $drive->{model}) {
+ $model = URI::Escape::uri_unescape($model);
+ $device .= ",model=$model";
+ }
+ if ($drive->{ssd}) {
+ $device .= ",rotation_rate=1";
+ }
+ }
+ $device .= ",wwn=$drive->{wwn}" if $drive->{wwn};
+ } elsif ($drive->{interface} eq 'usb') {
+ die "implement me";
+ # -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
+ } else {
+ die "unsupported interface type";
+ }
+
+ $device .= ",bootindex=$drive->{bootindex}" if $drive->{bootindex};
+
+ if (my $serial = $drive->{serial}) {
+ $serial = URI::Escape::uri_unescape($serial);
+ $device .= ",serial=$serial";
+ }
+
+ if (min_version($machine_version, 10, 0)) { # for the switch to -blockdev
+ if (!drive_is_cdrom($drive)) {
+ my $write_cache = 'on';
+ if (my $cache = $drive->{cache}) {
+ $write_cache = 'off' if $cache eq 'writethrough' || $cache eq 'directsync';
+ }
+ $device .= ",write-cache=$write_cache";
+ }
+ for my $o (qw(rerror werror)) {
+ $device .= ",$o=$drive->{$o}" if defined($drive->{$o});
+ }
+ }
+
+ return $device;
+}
+
+1;
diff --git a/src/PVE/QemuServer/Makefile b/src/PVE/QemuServer/Makefile
index ca30a0ad..150f2229 100644
--- a/src/PVE/QemuServer/Makefile
+++ b/src/PVE/QemuServer/Makefile
@@ -9,6 +9,7 @@ SOURCES=Agent.pm \
Cloudinit.pm \
CPUConfig.pm \
Drive.pm \
+ DriveDevice.pm \
Helpers.pm \
ImportDisk.pm \
Machine.pm \
--
2.39.5
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH qemuserver 2/3] add print_drivedevice_controller && print_drivedevice_iothread
[not found] <20250627100242.1478523-1-alexandre.derumier@groupe-cyllene.com>
2025-06-27 10:02 ` [pve-devel] [PATCH qemuserver 1/3] introduce DriveDevice module Alexandre Derumier via pve-devel
@ 2025-06-27 10:02 ` Alexandre Derumier via pve-devel
2025-06-27 10:02 ` [pve-devel] [PATCH qemuserver 3/3] hotplug: drive controller : use print_drivedevice_iothread && print_drivedevice_controller Alexandre Derumier via pve-devel
2 siblings, 0 replies; 3+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-06-27 10:02 UTC (permalink / raw)
To: pve-devel; +Cc: Alexandre Derumier
[-- Attachment #1: Type: message/rfc822, Size: 10158 bytes --]
From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemuserver 2/3] add print_drivedevice_controller && print_drivedevice_iothread
Date: Fri, 27 Jun 2025 12:02:41 +0200
Message-ID: <20250627100242.1478523-3-alexandre.derumier@groupe-cyllene.com>
Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
src/PVE/QemuServer.pm | 60 +++-----------------------
src/PVE/QemuServer/DriveDevice.pm | 70 +++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+), 54 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index f6f8cc58..dca206b4 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -72,7 +72,7 @@ use PVE::QemuServer::Drive qw(
print_drive
storage_allows_io_uring_default
);
-use PVE::QemuServer::DriveDevice qw(print_drivedevice_full scsihw_infos);
+use PVE::QemuServer::DriveDevice qw(print_drivedevice_controller print_drivedevice_full print_drivedevice_iothread scsihw_infos);
use PVE::QemuServer::Machine;
use PVE::QemuServer::Memory qw(get_current_memory);
use PVE::QemuServer::MetaInfo;
@@ -3442,8 +3442,7 @@ sub config_to_command {
push @$devices, '-watchdog-action', $wdopts->{action} if $wdopts->{action};
}
- my $scsicontroller = {};
- my $ahcicontroller = {};
+ my $used_controller = {};
my $scsihw = defined($conf->{scsihw}) ? $conf->{scsihw} : $defaults->{scsihw};
# Add iscsi initiator name if available
@@ -3465,58 +3464,11 @@ sub config_to_command {
$drive->{bootindex} = $bootorder->{$ds} if $bootorder->{$ds};
- if ($drive->{interface} eq 'virtio') {
- push @$cmd, '-object', "iothread,id=iothread-$ds" if $drive->{iothread};
- }
-
- if ($drive->{interface} eq 'scsi') {
-
- my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive);
-
- die
- "scsi$drive->{index}: machine version 4.1~pve2 or higher is required to use more than 14 SCSI disks\n"
- if $drive->{index} > 13 && !&$version_guard(4, 1, 2);
-
- my $pciaddr = print_pci_addr("$controller_prefix$controller", $bridges, $arch);
- my $scsihw_type =
- $scsihw =~ m/^virtio-scsi-single/ ? "virtio-scsi-pci" : $scsihw;
-
- my $iothread = '';
- if (
- $conf->{scsihw}
- && $conf->{scsihw} eq "virtio-scsi-single"
- && $drive->{iothread}
- ) {
- $iothread .= ",iothread=iothread-$controller_prefix$controller";
- push @$cmd, '-object', "iothread,id=iothread-$controller_prefix$controller";
- } elsif ($drive->{iothread}) {
- log_warn(
- "iothread is only valid with virtio disk or virtio-scsi-single controller, ignoring\n"
- );
- }
-
- my $queues = '';
- if (
- $conf->{scsihw}
- && $conf->{scsihw} eq "virtio-scsi-single"
- && $drive->{queues}
- ) {
- $queues = ",num_queues=$drive->{queues}";
- }
+ my $iothread = print_drivedevice_iothread($conf, $drive);
+ push @$cmd, '-object', $iothread if $iothread;
- push @$devices, '-device',
- "$scsihw_type,id=$controller_prefix$controller$pciaddr$iothread$queues"
- if !$scsicontroller->{$controller};
- $scsicontroller->{$controller} = 1;
- }
-
- if ($drive->{interface} eq 'sata') {
- my $controller = int($drive->{index} / $PVE::QemuServer::Drive::MAX_SATA_DISKS);
- my $pciaddr = print_pci_addr("ahci$controller", $bridges, $arch);
- push @$devices, '-device', "ahci,id=ahci$controller,multifunction=on$pciaddr"
- if !$ahcicontroller->{$controller};
- $ahcicontroller->{$controller} = 1;
- }
+ my $controller = print_drivedevice_controller($conf, $drive, $iothread, $scsihw, $arch, $bridges, $used_controller);
+ push @$devices, '-device', $controller if $controller;
my $live_restore = $live_restore_backing->{$ds};
my $live_blockdev_name = undef;
diff --git a/src/PVE/QemuServer/DriveDevice.pm b/src/PVE/QemuServer/DriveDevice.pm
index 764afc93..1e875cb9 100644
--- a/src/PVE/QemuServer/DriveDevice.pm
+++ b/src/PVE/QemuServer/DriveDevice.pm
@@ -14,6 +14,8 @@ use base qw(Exporter);
our @EXPORT_OK = qw(
print_drivedevice_full
+ print_drivedevice_controller
+ print_drivedevice_iothread
scsihw_infos
);
@@ -160,4 +162,72 @@ sub print_drivedevice_full {
return $device;
}
+sub print_drivedevice_controller {
+ my ($conf, $drive, $iothread_enabled, $scsihw, $arch, $bridges, $used_controller) = @_;
+
+ if ($drive->{interface} eq 'scsi') {
+
+ my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive);
+ return if $used_controller->{scsi}->{$controller};
+
+ my $pciaddr = print_pci_addr("$controller_prefix$controller", $bridges, $arch);
+ my $scsihw_type =
+ $scsihw =~ m/^virtio-scsi-single/ ? "virtio-scsi-pci" : $scsihw;
+
+
+ my $iothread = $iothread_enabled ? ",iothread=iothread-$controller_prefix$controller" : "";
+
+ my $queues = '';
+ if (
+ $conf->{scsihw}
+ && $conf->{scsihw} eq "virtio-scsi-single"
+ && $drive->{queues}
+ ) {
+ $queues = ",num_queues=$drive->{queues}";
+ }
+
+
+ $used_controller->{scsi}->{$controller} = 1;
+ return "$scsihw_type,id=$controller_prefix$controller$pciaddr$iothread$queues";
+ }
+
+ if ($drive->{interface} eq 'sata') {
+ my $controller = int($drive->{index} / $PVE::QemuServer::Drive::MAX_SATA_DISKS);
+ return if $used_controller->{ahci}->{$controller};
+
+ my $pciaddr = print_pci_addr("ahci$controller", $bridges, $arch);
+
+ $used_controller->{ahci}->{$controller} = 1;
+ return "ahci,id=ahci$controller,multifunction=on$pciaddr";
+
+ }
+}
+
+sub print_drivedevice_iothread {
+ my ($conf, $drive) = @_;
+
+ my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);
+
+ if ($drive->{interface} eq 'virtio') {
+ return "iothread,id=iothread-$drive_id" if $drive->{iothread};
+ }
+
+ if ($drive->{interface} eq 'scsi') {
+
+ my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive);
+
+ if (
+ $conf->{scsihw}
+ && $conf->{scsihw} eq "virtio-scsi-single"
+ && $drive->{iothread}
+ ) {
+ return "iothread,id=iothread-$controller_prefix$controller";
+ } elsif ($drive->{iothread}) {
+ log_warn(
+ "iothread is only valid with virtio disk or virtio-scsi-single controller, ignoring\n"
+ );
+ }
+ }
+}
+
1;
--
2.39.5
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH qemuserver 3/3] hotplug: drive controller : use print_drivedevice_iothread && print_drivedevice_controller
[not found] <20250627100242.1478523-1-alexandre.derumier@groupe-cyllene.com>
2025-06-27 10:02 ` [pve-devel] [PATCH qemuserver 1/3] introduce DriveDevice module Alexandre Derumier via pve-devel
2025-06-27 10:02 ` [pve-devel] [PATCH qemuserver 2/3] add print_drivedevice_controller && print_drivedevice_iothread Alexandre Derumier via pve-devel
@ 2025-06-27 10:02 ` Alexandre Derumier via pve-devel
2 siblings, 0 replies; 3+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-06-27 10:02 UTC (permalink / raw)
To: pve-devel; +Cc: Alexandre Derumier
[-- Attachment #1: Type: message/rfc822, Size: 5141 bytes --]
From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemuserver 3/3] hotplug: drive controller : use print_drivedevice_iothread && print_drivedevice_controller
Date: Fri, 27 Jun 2025 12:02:42 +0200
Message-ID: <20250627100242.1478523-4-alexandre.derumier@groupe-cyllene.com>
Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
src/PVE/QemuServer.pm | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index dca206b4..a5b5ad33 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -3748,21 +3748,11 @@ sub vm_deviceplug {
}
} elsif ($deviceid =~ m/^(virtioscsi|scsihw)(\d+)$/) {
my $scsihw = defined($conf->{scsihw}) ? $conf->{scsihw} : "lsi";
- my $pciaddr = print_pci_addr($deviceid, undef, $arch);
- my $scsihw_type = $scsihw eq 'virtio-scsi-single' ? "virtio-scsi-pci" : $scsihw;
-
- my $devicefull = "$scsihw_type,id=$deviceid$pciaddr";
-
- if ($deviceid =~ m/^virtioscsi(\d+)$/ && $device->{iothread}) {
- qemu_iothread_add($vmid, $deviceid, $device);
- $devicefull .= ",iothread=iothread-$deviceid";
- }
+ my $iothread = print_drivedevice_iothread($conf, $device);
+ my $controller = print_drivedevice_controller($conf, $device, $iothread, $scsihw, $arch);
- if ($deviceid =~ m/^virtioscsi(\d+)$/ && $device->{queues}) {
- $devicefull .= ",num_queues=$device->{queues}";
- }
-
- qemu_deviceadd($vmid, $devicefull);
+ qemu_iothread_add($vmid, $deviceid, $device) if $iothread;
+ qemu_deviceadd($vmid, $controller);
qemu_deviceaddverify($vmid, $deviceid);
} elsif ($deviceid =~ m/^(scsi)(\d+)$/) {
qemu_findorcreatescsihw($storecfg, $conf, $vmid, $device, $arch, $machine_type);
--
2.39.5
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-27 10:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20250627100242.1478523-1-alexandre.derumier@groupe-cyllene.com>
2025-06-27 10:02 ` [pve-devel] [PATCH qemuserver 1/3] introduce DriveDevice module Alexandre Derumier via pve-devel
2025-06-27 10:02 ` [pve-devel] [PATCH qemuserver 2/3] add print_drivedevice_controller && print_drivedevice_iothread Alexandre Derumier via pve-devel
2025-06-27 10:02 ` [pve-devel] [PATCH qemuserver 3/3] hotplug: drive controller : use print_drivedevice_iothread && print_drivedevice_controller Alexandre Derumier via pve-devel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox