* [pve-devel] [PATCH qemu-server] fix #6562: fix blockdev_replace for dir-based storages
@ 2025-07-24 12:10 Fabian Grünbichler
2025-07-24 14:45 ` [pve-devel] applied: " Fiona Ebner
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Grünbichler @ 2025-07-24 12:10 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH qemu-server] fix #6562: fix blockdev_replace for dir-based storages
2025-07-24 12:10 [pve-devel] [PATCH qemu-server] fix #6562: fix blockdev_replace for dir-based storages Fabian Grünbichler
@ 2025-07-24 14:45 ` Fiona Ebner
0 siblings, 0 replies; 2+ messages in thread
From: Fiona Ebner @ 2025-07-24 14:45 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Grünbichler
Am 24.07.25 um 2:10 PM schrieb Fabian Grünbichler:
> 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>
Applied, with 'make tidy' squashed in, thanks!
[1/1] fix #6562: fix blockdev_replace for dir-based storages
commit: 6898a72b54358863835de16372f1eabc035de915
> @@ -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) };
Also made a follow-up here to fix the pre-existing wrong deletion
ordering. Nodes that are further up in the chain need to be removed
first. It's just that nodes that are not added via blockdev-add are
automatically dropped and I suppose that's the case for the file node
here, so it probably doesn't matter in practice.
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-24 14:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-24 12:10 [pve-devel] [PATCH qemu-server] fix #6562: fix blockdev_replace for dir-based storages Fabian Grünbichler
2025-07-24 14:45 ` [pve-devel] applied: " Fiona Ebner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.