blockdev: blockdev replace: delete format block node first

Nodes need to be deleted from top to bottom. For example:

> ./qemu-img create /tmp/disk.qcow2 -f qcow2 1G
> ./qemu-system-x86_64 --qmp stdio \
> <<EOF
> {"execute": "qmp_capabilities"}
> {"execute": "blockdev-add", "arguments": { "driver": "file", "node-name": "file-node", "filename": "/tmp/disk.qcow2" }}
> {"execute": "blockdev-add", "arguments": { "driver": "qcow2", "node-name": "fmt-node", "file": "file-node" }}
> {"execute": "blockdev-del", "arguments": { "node-name": "file-node" }}
> {"execute": "blockdev-del", "arguments": { "node-name": "fmt-node" }}
> EOF

produces

> {"error": {"class": "GenericError", "desc": "Block device file-node is in use"}}

while it works with first detaching the format node and then the file
node.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2025-07-24 16:36:02 +02:00
parent 6898a72b54
commit 32102c06be

View File

@ -947,8 +947,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_name) };
eval { mon_cmd($vmid, 'blockdev-del', 'node-name' => $src_fmt_blockdev_name) };
eval { mon_cmd($vmid, 'blockdev-del', 'node-name' => $src_file_blockdev_name) };
}
sub blockdev_commit {