[pve-devel] [PATCH qemu-server 20/31] block job: add and use wrapper for mirror
Fiona Ebner
f.ebner at proxmox.com
Wed Jun 25 17:56:43 CEST 2025
In preparation for the switch to -blockdev.
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
src/PVE/QemuMigrate.pm | 19 ++++++++++---------
src/PVE/QemuServer.pm | 19 +++++++++++--------
src/PVE/QemuServer/BlockJob.pm | 20 ++++++++++++++++++++
3 files changed, 41 insertions(+), 17 deletions(-)
diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm
index 16c61837..f46bdf40 100644
--- a/src/PVE/QemuMigrate.pm
+++ b/src/PVE/QemuMigrate.pm
@@ -1207,17 +1207,18 @@ sub phase2 {
my $bitmap = $target->{bitmap};
$self->log('info', "$drive: start migration to $nbd_uri");
- PVE::QemuServer::BlockJob::qemu_drive_mirror(
- $vmid,
- $drive,
- $nbd_uri,
- $vmid,
- undef,
+
+ my $source_info = { vmid => $vmid, drive => $source_drive };
+ $source_info->{bitmap} = $bitmap if defined($bitmap);
+ my $dest_info = { volid => $nbd_uri };
+ my $mirror_opts = {};
+ $mirror_opts->{bwlimit} = $bwlimit if defined($bwlimit);
+ PVE::QemuServer::BlockJob::mirror(
+ $source_info,
+ $dest_info,
$self->{storage_migration_jobs},
'skip',
- undef,
- $bwlimit,
- $bitmap,
+ $mirror_opts,
);
}
diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 30566864..e7c98520 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -7761,16 +7761,19 @@ sub clone_disk {
my $sparseinit = PVE::Storage::volume_has_feature($storecfg, 'sparseinit', $newvolid);
if ($use_drive_mirror) {
- PVE::QemuServer::BlockJob::qemu_drive_mirror(
- $vmid,
- $src_drivename,
- $newvolid,
- $newvmid,
- $sparseinit,
+ my $source_info = { vmid => $vmid, drive => $drive };
+ my $dest_info = { volid => $newvolid };
+ $dest_info->{'zero-initialized'} = 1 if $sparseinit;
+ $dest_info->{vmid} = $newvmid if defined($newvmid);
+ my $mirror_opts = {};
+ $mirror_opts->{'guest-agent'} = 1 if $qga;
+ $mirror_opts->{bwlimit} = $bwlimit if defined($bwlimit);
+ PVE::QemuServer::BlockJob::mirror(
+ $source_info,
+ $dest_info,
$jobs,
$completion,
- $qga,
- $bwlimit,
+ $mirror_opts,
);
} else {
if ($dst_drivename eq 'efidisk0') {
diff --git a/src/PVE/QemuServer/BlockJob.pm b/src/PVE/QemuServer/BlockJob.pm
index 7483aff3..4638fb1e 100644
--- a/src/PVE/QemuServer/BlockJob.pm
+++ b/src/PVE/QemuServer/BlockJob.pm
@@ -330,4 +330,24 @@ sub qemu_drive_mirror_switch_to_active_mode {
}
}
+sub mirror {
+ my ($source, $dest, $jobs, $completion, $options) = @_;
+
+ # for the switch to -blockdev
+
+ my $drive_id = PVE::QemuServer::Drive::get_drive_id($source->{drive});
+ qemu_drive_mirror(
+ $source->{vmid},
+ $drive_id,
+ $dest->{volid},
+ $dest->{vmid},
+ $dest->{'zero-initialized'},
+ $jobs,
+ $completion,
+ $options->{'guest-agent'},
+ $options->{bwlimit},
+ $source->{bitmap},
+ );
+}
+
1;
--
2.47.2
More information about the pve-devel
mailing list