[pve-devel] [PATCH qemu-server v2 3/3] blockdev: delete/replace: re-use detach() helper

Fiona Ebner f.ebner at proxmox.com
Tue Aug 12 13:56:31 CEST 2025


Re-using the detach() helper has the side effect of avoiding logging
errors to syslog for automatically removed child nodes. This should be
the case for all file nodes here. None are explicitly added via
blockdev-add and thus QEMU already auto-removes them.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---

Changes in v2:
* use eval+warn around new detach() call sites, as failure should not
  be critical there.

 src/PVE/QemuServer/Blockdev.pm | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm
index 04eeed3c..f5798cbf 100644
--- a/src/PVE/QemuServer/Blockdev.pm
+++ b/src/PVE/QemuServer/Blockdev.pm
@@ -873,9 +873,8 @@ sub blockdev_external_snapshot {
 sub blockdev_delete {
     my ($storecfg, $vmid, $drive, $file_blockdev, $fmt_blockdev, $snap) = @_;
 
-    #add eval as reopen is auto removing the old nodename automatically only if it was created at vm start in command line argument
-    eval { mon_cmd($vmid, 'blockdev-del', 'node-name' => $fmt_blockdev->{'node-name'}) };
-    eval { mon_cmd($vmid, 'blockdev-del', 'node-name' => $file_blockdev->{'node-name'}) };
+    eval { detach($vmid, $fmt_blockdev->{'node-name'}); };
+    warn "detaching block node for $file_blockdev->{filename} failed - $@" if $@;
 
     #delete the file (don't use vdisk_free as we don't want to delete all snapshot chain)
     print "delete old $file_blockdev->{filename}\n";
@@ -982,9 +981,8 @@ sub blockdev_replace {
     }
 
     # delete old file|fmt nodes
-    # add eval as reopen is auto removing the old nodename automatically only if it was created at vm start in command line argument
-    eval { mon_cmd($vmid, 'blockdev-del', 'node-name' => $src_fmt_blockdev_name) };
-    eval { mon_cmd($vmid, 'blockdev-del', 'node-name' => $src_file_blockdev_name) };
+    eval { detach($vmid, $src_fmt_blockdev_name); };
+    warn "detaching block node for $src_snap failed - $@" if $@;
 }
 
 sub blockdev_commit {
-- 
2.47.2





More information about the pve-devel mailing list