From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 4BB191FF0B7 for ; Fri, 30 Oct 2026 11:11:49 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 4E1B621609; Fri, 30 Oct 2026 11:11:40 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v5 2/4] hotplug: remove iothread with virtio-scsi controller together Date: Fri, 30 Oct 2026 11:04:41 +0100 Message-ID: <20261030101134.2090350-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261030101134.2090350-1-d.csapak@proxmox.com> References: <20261030101134.2090350-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.345 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: MBMOQVF4CPC7EXH7FXMDTJXCAKKXJ5KT X-Message-ID-Hash: MBMOQVF4CPC7EXH7FXMDTJXCAKKXJ5KT X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: With virtio-scsi-single, the iothread is used by the controller 'virtioscsiN' and not by the disk 'scsiN', but it was removed when unplugging the disk (which was done after removal of the controller). Remove the iothread together with the controller instead, and decide whether to remove it by checking the iothreads that actually exist instead of the config. This way, the controller can be unplugged without having the config of its disk, which is necessary for cleaning up after a failed hotplug in a following commit. Since an 'iothread-' object is only used by the device with that id, it is safe to remove it once the device is gone. Note that this now executes an additional qmp command for disks that don't have an iothread in the config, but since this is not called that often (once per disk config change) it should be ok. Signed-off-by: Dominik Csapak --- src/PVE/QemuServer.pm | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index 6ac3c685..38a4e4f8 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -3972,25 +3972,20 @@ sub vm_deviceunplug { qemu_devicedel($vmid, $deviceid); qemu_devicedelverify($vmid, $deviceid); } elsif ($deviceid =~ m/^(virtio)(\d+)$/) { - my $device = parse_drive($deviceid, $conf->{$deviceid}); - qemu_devicedel($vmid, $deviceid); qemu_devicedelverify($vmid, $deviceid); qemu_drivedel($vmid, $deviceid); - qemu_iothread_del($vmid, $deviceid, $device); + qemu_iothread_del($vmid, $deviceid); } elsif ($deviceid =~ m/^(virtioscsi|scsihw)(\d+)$/) { qemu_devicedel($vmid, $deviceid); qemu_devicedelverify($vmid, $deviceid, 15); + qemu_iothread_del($vmid, $deviceid) if $deviceid =~ m/^virtioscsi\d+$/; } elsif ($deviceid =~ m/^(scsi)(\d+)$/) { - my $device = parse_drive($deviceid, $conf->{$deviceid}); - qemu_devicedel($vmid, $deviceid); qemu_devicedelverify($vmid, $deviceid); qemu_drivedel($vmid, $deviceid); + # the iothread of a virtio-scsi-single disk belongs to its controller and is removed there qemu_deletescsihw($conf, $vmid, $deviceid); - - qemu_iothread_del($vmid, "virtioscsi$device->{index}", $device) - if $conf->{scsihw} && ($conf->{scsihw} eq 'virtio-scsi-single'); } elsif ($deviceid =~ m/^(net)(\d+)$/) { qemu_devicedel($vmid, $deviceid); qemu_devicedelverify($vmid, $deviceid); @@ -4031,12 +4026,10 @@ sub qemu_iothread_add { } sub qemu_iothread_del { - my ($vmid, $deviceid, $device) = @_; + my ($vmid, $deviceid) = @_; - if ($device->{iothread}) { - my $iothreads = vm_iothreads_list($vmid); - qemu_objectdel($vmid, "iothread-$deviceid") if $iothreads->{"iothread-$deviceid"}; - } + my $iothreads = vm_iothreads_list($vmid); + qemu_objectdel($vmid, "iothread-$deviceid") if $iothreads->{"iothread-$deviceid"}; } sub qemu_driveadd { -- 2.47.3