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.gruenbich...@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 via email to