[PATCH qemu-server v4 10/18] blockdev: switch blockdev_external_snapshot() to use QMP peer

Fiona Ebner
2026-04-24T12:44:31Z

src/PVE/QemuServer.pm | 8 +++++++-
src/PVE/QemuServer/VolumeChain.pm | 10 +++++-----
2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 88a5a863..36cbfd59 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -4369,7 +4369,13 @@ sub qemu_volume_snapshot {
my $snapshots = PVE::Storage::volume_snapshot_info($storecfg, $volid);
my $parent_snap = $snapshots->{'current'}->{parent};
PVE::QemuServer::VolumeChain::blockdev_external_snapshot(
- $storecfg, $vmid, $machine_version, $deviceid, $drive, $snap, $parent_snap,
+ $storecfg,
+ vm_qmp_peer($vmid),
+ $machine_version,
+ $deviceid,
+ $drive,
+ $snap,
+ $parent_snap,
);
} elsif ($do_snapshots_type eq 'storage') {
PVE::Storage::volume_snapshot($storecfg, $volid, $snap);
diff --git a/src/PVE/QemuServer/VolumeChain.pm b/src/PVE/QemuServer/VolumeChain.pm
index 01c5dd9b..8c0749de 100644
--- a/src/PVE/QemuServer/VolumeChain.pm
+++ b/src/PVE/QemuServer/VolumeChain.pm
@@ -14,7 +14,7 @@ use PVE::QemuServer::Drive;
use PVE::QemuServer::Monitor qw(mon_cmd qmp_cmd vm_qmp_peer);

sub blockdev_external_snapshot {
- my ($storecfg, $vmid, $machine_version, $deviceid, $drive, $snap, $parent_snap) = @_;
+ my ($storecfg, $qmp_peer, $machine_version, $deviceid, $drive, $snap, $parent_snap) = @_;

print "Creating a new current volume with $snap as backing snap\n";

@@ -26,7 +26,7 @@ sub blockdev_external_snapshot {
#reopen current to snap
blockdev_replace(
$storecfg,
- vm_qmp_peer($vmid),
+ $qmp_peer,
$machine_version,
$deviceid,
$drive,
@@ -53,11 +53,11 @@ sub blockdev_external_snapshot {
#backing need to be forced to undef in blockdev, to avoid reopen of backing-file on blockdev-add
$new_fmt_blockdev->{backing} = undef;

- mon_cmd($vmid, 'blockdev-add', %$new_fmt_blockdev);
+ qmp_cmd($qmp_peer, 'blockdev-add', %$new_fmt_blockdev);

print "blockdev-snapshot: reopen current with $snap backing image\n";
- mon_cmd(
- $vmid, 'blockdev-snapshot',
+ qmp_cmd(
+ $qmp_peer, 'blockdev-snapshot',
node => $snap_fmt_blockdev->{'node-name'},
overlay => $new_fmt_blockdev->{'node-name'},
);
--
2.47.3