Re: [PATCH qemu-server v3 16/18] blockdev: switch blockdev_commit() to use QMP peer

Lukas Sichert
2026-04-24T12:39:31Z

On 2026-04-23 11:36, Fiona Ebner <f.ebner@proxmox.com> wrote:

> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
> src/PVE/QemuServer.pm | 2 +-
> src/PVE/QemuServer/VolumeChain.pm | 19 ++++++-------------
> 2 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
> index 9c6e2cdb..53c40eef 100644
> --- a/src/PVE/QemuServer.pm
> +++ b/src/PVE/QemuServer.pm
> @@ -4434,7 +4434,7 @@ sub qemu_volume_snapshot_delete {
> print "delete first snapshot $snap\n";
> PVE::QemuServer::VolumeChain::blockdev_commit(
> $storecfg,
> - $vmid,
> + vm_qmp_peer($vmid),
> $machine_version,
> $attached_deviceid,
> $drive,
> diff --git a/src/PVE/QemuServer/VolumeChain.pm b/src/PVE/QemuServer/VolumeChain.pm
> index dad39479..91e78495 100644
> --- a/src/PVE/QemuServer/VolumeChain.pm
> +++ b/src/PVE/QemuServer/VolumeChain.pm
> @@ -192,7 +192,7 @@ sub blockdev_replace {
> }
>
> sub blockdev_commit {
> - my ($storecfg, $vmid, $machine_version, $deviceid, $drive, $src_snap, $target_snap) = @_;
> + my ($storecfg, $qmp_peer, $machine_version, $deviceid, $drive, $src_snap, $target_snap) = @_;
>
> my $volid = $drive->{file};
> my $target_was_read_only;
> @@ -229,7 +229,7 @@ sub blockdev_commit {
> print "reopening internal read-only block node for '$target_snap' as writable\n";
> $target_fmt_blockdev->{'read-only'} = JSON::false;
> $target_file_blockdev->{'read-only'} = JSON::false;
> - mon_cmd($vmid, 'blockdev-reopen', options => [$target_fmt_blockdev]);
> + qmp_cmd($qmp_peer, 'blockdev-reopen', options => [$target_fmt_blockdev]);
> # For the guest, the drive is still read-only, because the top throttle node is.
> }
>
> @@ -241,7 +241,7 @@ sub blockdev_commit {
> $opts->{'base-node'} = $target_fmt_blockdev->{'node-name'};
> $opts->{'top-node'} = $src_fmt_blockdev->{'node-name'};
>
> - mon_cmd($vmid, "block-commit", %$opts);
> + qmp_cmd($qmp_peer, "block-commit", %$opts);
> $jobs->{$job_id} = {};
>
> # If the 'current' state is committed to its backing snapshot, the job will not complete
> @@ -255,17 +255,10 @@ sub blockdev_commit {
> # 'block-commit' will complete automatically.
> my $complete = $src_snap && $src_snap ne 'current' ? 'auto' : 'complete';
>
> - PVE::QemuServer::BlockJob::monitor(
> - vm_qmp_peer($vmid), undef, $jobs, $complete, 0, 'commit',
> - );
> + PVE::QemuServer::BlockJob::monitor($qmp_peer, undef, $jobs, $complete, 0, 'commit');
Similar to [1], but not as obvious. 'vm_qmp_peer' just got added in this
series.
>
> blockdev_delete(
> - $storecfg,
> - vm_qmp_peer($vmid),
> - $drive,
> - $src_file_blockdev,
> - $src_fmt_blockdev,
> - $src_snap,
> + $storecfg, $qmp_peer, $drive, $src_file_blockdev, $src_fmt_blockdev, $src_snap,
> );
> };
Same as above.
> my $err = $@;
> @@ -276,7 +269,7 @@ sub blockdev_commit {
> print "re-applying read-only flag for internal block node for '$target_snap'\n";
> $target_fmt_blockdev->{'read-only'} = JSON::true;
> $target_file_blockdev->{'read-only'} = JSON::true;
> - eval { mon_cmd($vmid, 'blockdev-reopen', options => [$target_fmt_blockdev]); };
> + eval { qmp_cmd($qmp_peer, 'blockdev-reopen', options => [$target_fmt_blockdev]); };
> print "failed to re-apply read-only flag - $@\n" if $@;
> }
>
> --
> 2.47.3
[1] lore.proxmox.com/pve-devel/DI0L56K45KJK.1G3MBGPZI2KJV@proxmox.com/T/#m7e7ffe8240f4092755e27c6072e0e27ffcdd96b5