public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server] fix #6562: fix blockdev_replace for dir-based storages
Date: Thu, 24 Jul 2025 14:10:42 +0200	[thread overview]
Message-ID: <20250724121042.473947-1-f.gruenbichler@proxmox.com> (raw)

avoid calling qemu_blockdev_options on a volid+snapshot that is potentially
already invalid if it has been removed/renamed by the storage layer. instead,
generate the node name of the old node that we want to replace/remove directly,
since nothing besides the name is used in this code path anyway..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
gave this a quick spin with both dir and lvm based storages, seems to work as
expected..

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

diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm
index 28453b48..4cbcf2a4 100644
--- a/src/PVE/QemuServer/Blockdev.pm
+++ b/src/PVE/QemuServer/Blockdev.pm
@@ -881,19 +881,11 @@ sub blockdev_replace {
     print "blockdev replace $src_snap by $target_snap\n";
 
     my $volid = $drive->{file};
+    my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);
 
-    my $src_file_blockdev = generate_file_blockdev(
-        $storecfg,
-        $drive,
-        $machine_version,
-        { 'snapshot-name' => $src_snap },
-    );
-    my $src_fmt_blockdev = generate_format_blockdev(
-        $storecfg,
-        $drive,
-        $src_file_blockdev,
-        { 'snapshot-name' => $src_snap },
-    );
+    my $src_name_options = $src_snap eq 'current' ? {} : {'snapshot-name' => $src_snap };
+    my $src_file_blockdev_name = get_node_name('file', $drive_id, $volid, $src_name_options);
+    my $src_fmt_blockdev_name = get_node_name('fmt', $drive_id, $volid, $src_name_options);
 
     my $target_file_blockdev = generate_file_blockdev(
         $storecfg,
@@ -910,7 +902,6 @@ sub blockdev_replace {
 
     if ($target_snap eq 'current' || $src_snap eq 'current') {
         #rename from|to current
-        my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);
 
         #add backing to target
         if ($parent_snap) {
@@ -955,8 +946,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_file_blockdev->{'node-name'}) };
-    eval { mon_cmd($vmid, 'blockdev-del', 'node-name' => $src_fmt_blockdev->{'node-name'}) };
+    eval { mon_cmd($vmid, 'blockdev-del', 'node-name' => $src_file_blockdev_name) };
+    eval { mon_cmd($vmid, 'blockdev-del', 'node-name' => $src_fmt_blockdev_name) };
 }
 
 sub blockdev_commit {
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

             reply	other threads:[~2025-07-24 12:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24 12:10 Fabian Grünbichler [this message]
2025-07-24 14:45 ` [pve-devel] applied: " Fiona Ebner

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=20250724121042.473947-1-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@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