From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server 7/8] block job: monitor: pass options as a hash
Date: Thu, 30 Jul 2026 15:15:56 +0200 [thread overview]
Message-ID: <20260730131613.157722-8-f.ebner@proxmox.com> (raw)
In-Reply-To: <20260730131613.157722-1-f.ebner@proxmox.com>
No functional change intended.
While the value of $completion is optional, all callers pass it as a
parameter and most do pass a value. Don't include it in the options
hash.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuMigrate.pm | 10 ++--------
src/PVE/QemuServer.pm | 14 +++++++-------
src/PVE/QemuServer/BlockJob.pm | 22 +++++++++++-----------
src/PVE/QemuServer/VolumeChain.pm | 4 ++--
src/test/MigrationTest/QemuMigrateMock.pm | 2 +-
5 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm
index 604eae82..dcf26a1c 100644
--- a/src/PVE/QemuMigrate.pm
+++ b/src/PVE/QemuMigrate.pm
@@ -1580,14 +1580,8 @@ sub phase2 {
# to avoid it trying to re-establish it. We are in blockjob ready state,
# thus, this command changes to it to blockjob complete (see qapi docs)
eval {
- PVE::QemuServer::BlockJob::monitor(
- vm_qmp_peer($vmid),
- undef,
- $self->{storage_migration_jobs},
- 'cancel',
- undef,
- 'mirror',
- );
+ my $jobs = $self->{storage_migration_jobs};
+ PVE::QemuServer::BlockJob::monitor(vm_qmp_peer($vmid), $jobs, 'cancel', 'mirror');
};
if (my $err = $@) {
die "Failed to complete storage migration: $err\n";
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 1be89be9..aad0e323 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -7367,9 +7367,7 @@ sub pbs_live_restore {
}
mon_cmd($vmid, 'cont');
- PVE::QemuServer::BlockJob::monitor(
- vm_qmp_peer($vmid), undef, $jobs, 'auto', 0, 'stream',
- );
+ PVE::QemuServer::BlockJob::monitor(vm_qmp_peer($vmid), $jobs, 'auto', 'stream');
print "restore-drive jobs finished successfully, removing all tracking block devices"
. " to disconnect from Proxmox Backup Server\n";
@@ -7489,9 +7487,7 @@ sub live_import_from_files {
}
mon_cmd($vmid, 'cont');
- PVE::QemuServer::BlockJob::monitor(
- vm_qmp_peer($vmid), undef, $jobs, 'auto', 0, 'stream',
- );
+ PVE::QemuServer::BlockJob::monitor(vm_qmp_peer($vmid), $jobs, 'auto', 'stream');
print "restore-drive jobs finished successfully, removing all tracking block devices\n";
@@ -8010,7 +8006,11 @@ sub clone_disk {
# previous drive-mirrors
if (($completion && $completion eq 'complete') && (scalar(keys %$jobs) > 0)) {
PVE::QemuServer::BlockJob::monitor(
- vm_qmp_peer($vmid), $newvmid, $jobs, $completion, $qga, 'mirror',
+ vm_qmp_peer($vmid),
+ $jobs,
+ $completion,
+ 'mirror',
+ { 'dest-vmid' => $newvmid, qga => $qga },
);
}
goto no_data_clone;
diff --git a/src/PVE/QemuServer/BlockJob.pm b/src/PVE/QemuServer/BlockJob.pm
index d4998370..5fbc311e 100644
--- a/src/PVE/QemuServer/BlockJob.pm
+++ b/src/PVE/QemuServer/BlockJob.pm
@@ -114,7 +114,9 @@ my sub print_job_status {
# 'skip': wait until all jobs are ready, return with block jobs in ready state
# 'auto': wait until all jobs disappear, only use for jobs which complete automatically
sub monitor {
- my ($qmp_peer, $vmiddst, $jobs, $completion, $qga, $operation) = @_;
+ my ($qmp_peer, $jobs, $completion, $operation, $options) = @_;
+
+ my $vmiddst = $options->{'dest-vmid'};
die "drive mirror: different destination is only supported when peer is main QEMU instance\n"
if $vmiddst && $qmp_peer->{type} ne 'qmp';
@@ -182,7 +184,7 @@ sub monitor {
if ($qmp_peer->{type} eq 'qmp' && $vmiddst && $vmiddst != $qmp_peer->{id}) {
my $vmid = $qmp_peer->{id};
my $should_fsfreeze =
- PVE::QemuServer::Agent::guest_fs_freeze_applicable($qga, $vmid);
+ PVE::QemuServer::Agent::guest_fs_freeze_applicable($options->{qga}, $vmid);
if ($should_fsfreeze) {
print "issuing guest agent 'guest-fsfreeze-freeze' command\n";
eval { PVE::QemuServer::Agent::guest_fs_freeze($vmid); };
@@ -340,7 +342,8 @@ sub qemu_drive_mirror {
die "mirroring error: $err\n";
}
- monitor(vm_qmp_peer($vmid), $vmiddst, $jobs, $completion, $qga, 'mirror');
+ my $monitor_options = { 'dest-vmid' => $vmiddst, qga => $qga };
+ monitor(vm_qmp_peer($vmid), $jobs, $completion, 'mirror', $monitor_options);
}
# Callers should version guard this (only available with a binary >= QEMU 8.2)
@@ -537,14 +540,11 @@ sub blockdev_mirror {
log_warn("unable to delete blockdev '$target_node_name' - $@");
die "error starting blockdev mirrror - $err";
}
- monitor(
- vm_qmp_peer($vmid),
- $dest->{vmid},
- $jobs,
- $completion,
- $options->{'guest-agent'},
- 'mirror',
- );
+ my $monitor_options = {
+ 'dest-vmid' => $dest->{vmid},
+ qga => $options->{'guest-agent'},
+ };
+ monitor(vm_qmp_peer($vmid), $jobs, $completion, 'mirror', $monitor_options);
}
sub mirror {
diff --git a/src/PVE/QemuServer/VolumeChain.pm b/src/PVE/QemuServer/VolumeChain.pm
index 1572450b..a67ec247 100644
--- a/src/PVE/QemuServer/VolumeChain.pm
+++ b/src/PVE/QemuServer/VolumeChain.pm
@@ -255,7 +255,7 @@ sub blockdev_commit {
# 'block-commit' will complete automatically.
my $complete = $src_snap && $src_snap ne 'current' ? 'auto' : 'complete';
- PVE::QemuServer::BlockJob::monitor($qmp_peer, undef, $jobs, $complete, 0, 'commit');
+ PVE::QemuServer::BlockJob::monitor($qmp_peer, $jobs, $complete, 'commit');
blockdev_delete(
$storecfg, $qmp_peer, $drive, $src_file_blockdev, $src_fmt_blockdev, $src_snap,
@@ -337,7 +337,7 @@ sub blockdev_stream {
qmp_cmd($qmp_peer, 'block-stream', %$options);
$jobs->{$job_id} = {};
- PVE::QemuServer::BlockJob::monitor($qmp_peer, undef, $jobs, 'auto', 0, 'stream');
+ PVE::QemuServer::BlockJob::monitor($qmp_peer, $jobs, 'auto', 'stream');
blockdev_delete(
$storecfg, $qmp_peer, $drive, $snap_file_blockdev, $snap_fmt_blockdev, $snap,
diff --git a/src/test/MigrationTest/QemuMigrateMock.pm b/src/test/MigrationTest/QemuMigrateMock.pm
index 3a483817..079d1a0f 100644
--- a/src/test/MigrationTest/QemuMigrateMock.pm
+++ b/src/test/MigrationTest/QemuMigrateMock.pm
@@ -173,7 +173,7 @@ $qemu_server_blockjob_module->mock(
common_mirror_mock($source->{vmid}, $drive_id);
},
monitor => sub {
- my ($qmp_peer, $vmiddst, $jobs, $completion, $qga, $op) = @_;
+ my ($qmp_peer, $jobs, $completion, $operation, $options) = @_;
if (
$fail_config->{block_job_monitor}
--
2.47.3
next prev parent reply other threads:[~2026-07-30 13:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 13:15 [PATCH-SERIES qemu-server 0/8] block job: monitor: improve completion handling and style Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 1/8] block job: monitor: avoid duplicate completion Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 2/8] block job: monitor: only print message that jobs are ready once Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 3/8] partially fix #7854: block job: monitor: handle completion faster to benefit migration Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 4/8] block job: monitor: factor out job status printing Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 5/8] block job: monitor: make operation argument non-optional Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 6/8] block job: monitor: rename 'op' argument to 'operation' Fiona Ebner
2026-07-30 13:15 ` Fiona Ebner [this message]
2026-07-30 13:15 ` [PATCH qemu-server 8/8] block job: monitor: properly document function Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260730131613.157722-8-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox