public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server 6/6] hotplug: remove iothread if adding drive device failed
Date: Thu, 10 Sep 2026 13:00:33 +0200	[thread overview]
Message-ID: <20260910110832.2822954-7-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260910110832.2822954-1-d.csapak@proxmox.com>

Otherwise it is left over after a failed attempt to add a drive with
iothreads.

Modify the relevant test that highlighted this problem.

The failure can be tested by disabling hotplug, e.g. for a i440fx guest
one can use the following commandline switches:

-global PIIX4_PM.acpi-root-pci-hotplug=off
-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off
-global pci-bridge.shpc=off

to disable hotplug on all pci bridges and the pci root bus.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PVE/QemuServer.pm                        | 11 ++++++++++-
 src/test/hotplug/disk-add-fail.conf.expected |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 34073ee8..8fade3fa 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -3906,6 +3906,8 @@ sub vm_deviceplug {
         if (my $err = $@) {
             eval { qemu_drivedel($vmid, $deviceid); };
             warn $@ if $@;
+            eval { qemu_iothread_del($vmid, $deviceid, $device) };
+            warn $@ if $@;
             die $err;
         }
     } elsif ($deviceid =~ m/^(virtioscsi|scsihw)(\d+)$/) {
@@ -3925,7 +3927,14 @@ sub vm_deviceplug {
         }
 
         qemu_deviceadd($vmid, $devicefull);
-        qemu_deviceaddverify($vmid, $deviceid);
+        eval { qemu_deviceaddverify($vmid, $deviceid) };
+        if (my $err = $@) {
+            if ($deviceid =~ m/^virtioscsi(\d+)$/ && $device->{iothread}) {
+                eval { qemu_iothread_del($vmid, $deviceid, $device) };
+                warn $@ if $@;
+            }
+            die $err;
+        }
     } elsif ($deviceid =~ m/^(scsi)(\d+)$/) {
         qemu_findorcreatescsihw($storecfg, $conf, $vmid, $device, $arch, $machine_type);
         qemu_driveadd($storecfg, $vmid, $device);
diff --git a/src/test/hotplug/disk-add-fail.conf.expected b/src/test/hotplug/disk-add-fail.conf.expected
index 8a36d951..28ec8e89 100644
--- a/src/test/hotplug/disk-add-fail.conf.expected
+++ b/src/test/hotplug/disk-add-fail.conf.expected
@@ -7,12 +7,12 @@ qmp blockdev-add {"detect-zeroes":"on","discard":"ignore","driver":"throttle","f
 hmp device_add driver=virtio-blk-pci,drive=drive-virtio1,id=virtio1,bus=pci.0,addr=0xb,iothread=iothread-virtio1,write-cache=on
 qmp blockdev-del {"node-name":"drive-virtio1"}
 qmp object-del {"id":"throttle-drive-virtio1"}
+qmp object-del {"id":"iothread-virtio1"}
 
 # hotplug errors
 virtio1: hotplug problem - error on hotplug device 'virtio1'
 
 # differences to a freshly started VM
-object iothread-virtio1: only present in running VM
 
 # resulting config
 bootdisk: scsi0
-- 
2.47.3





      parent reply	other threads:[~2026-09-10 11:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 11:00 [PATCH qemu-server 0/6] add hotplug tests and fix uncovered bugs Dominik Csapak
2026-09-10 11:00 ` [PATCH qemu-server 1/6] tests: hotplug: add initial hotplug test harness Dominik Csapak
2026-09-10 14:24   ` Fiona Ebner
2026-09-10 11:00 ` [PATCH qemu-server 2/6] tests: hotplug: add some test cases Dominik Csapak
2026-09-10 14:24   ` Fiona Ebner
2026-09-10 11:00 ` [PATCH qemu-server 3/6] tests: hotplug: add cases for known defects Dominik Csapak
2026-09-10 11:00 ` [PATCH qemu-server 4/6] tests: hotplug: add test case for adding scsi14 on qemu 11.1 Dominik Csapak
2026-09-10 11:00 ` [PATCH qemu-server 5/6] hotplug: fix vm_deviceplug call for 'tablet' and 'keyboard' on aarch64 Dominik Csapak
2026-09-10 11:00 ` Dominik Csapak [this message]

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=20260910110832.2822954-7-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal