From: Dominik Csapak <d.csapak@proxmox.com>
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 [thread overview]
Message-ID: <20261030101134.2090350-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261030101134.2090350-1-d.csapak@proxmox.com>
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-<id>' 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 <d.csapak@proxmox.com>
---
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
next prev parent reply other threads:[~2026-10-30 10:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 10:04 [PATCH qemu-server v5 0/4] hotplug: improve and fix cleanup/error handling Dominik Csapak
2026-10-30 10:04 ` [PATCH qemu-server v5 1/4] hotplug: scsi: only keep controller if a disk on it is still present Dominik Csapak
2026-10-30 10:04 ` Dominik Csapak [this message]
2026-10-30 10:04 ` [PATCH qemu-server v5 3/4] hotplug: factor out cleanup of disk devices Dominik Csapak
2026-10-30 10:04 ` [PATCH qemu-server v5 4/4] hotplug: clean up disk devices/objects if adding them failed Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261030101134.2090350-3-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox