From e7cf7c0056f8fe7dc4487d3465a4ba27e9289190 Mon Sep 17 00:00:00 2001 From: Fiona Ebner Date: Tue, 12 Aug 2025 13:56:31 +0200 Subject: [PATCH] blockdev: delete/replace: re-use detach() helper 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 Link: https://lore.proxmox.com/all/20250812115652.79330-4-f.ebner@proxmox.com --- 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 {