[pve-devel] [PATCH qemu-server 21/31] drive mirror: add variable for device ID and make name for drive ID precise
Fiona Ebner
f.ebner at proxmox.com
Wed Jun 25 17:56:44 CEST 2025
Suggested-by: Alexandre Derumier <alexandre.derumier at groupe-cyllene.com>
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
src/PVE/QemuServer/BlockJob.pm | 12 +++++++-----
src/test/MigrationTest/QemuMigrateMock.pm | 12 ++++++------
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/PVE/QemuServer/BlockJob.pm b/src/PVE/QemuServer/BlockJob.pm
index 4638fb1e..8a74636c 100644
--- a/src/PVE/QemuServer/BlockJob.pm
+++ b/src/PVE/QemuServer/BlockJob.pm
@@ -215,7 +215,7 @@ sub qemu_drive_mirror_monitor {
sub qemu_drive_mirror {
my (
$vmid,
- $drive,
+ $drive_id,
$dst_volid,
$vmiddst,
$is_zero_initialized,
@@ -226,11 +226,13 @@ sub qemu_drive_mirror {
$src_bitmap,
) = @_;
+ my $device_id = "drive-$drive_id";
+
$jobs = {} if !$jobs;
my $qemu_target;
my $format;
- $jobs->{"drive-$drive"} = {};
+ $jobs->{$device_id} = {};
if ($dst_volid =~ /^nbd:/) {
$qemu_target = $dst_volid;
@@ -247,7 +249,7 @@ sub qemu_drive_mirror {
my $opts = {
timeout => 10,
- device => "drive-$drive",
+ device => "$device_id",
mode => "existing",
sync => "full",
target => $qemu_target,
@@ -263,9 +265,9 @@ sub qemu_drive_mirror {
if (defined($bwlimit)) {
$opts->{speed} = $bwlimit * 1024;
- print "drive mirror is starting for drive-$drive with bandwidth limit: ${bwlimit} KB/s\n";
+ print "drive mirror is starting for $device_id with bandwidth limit: ${bwlimit} KB/s\n";
} else {
- print "drive mirror is starting for drive-$drive\n";
+ print "drive mirror is starting for $device_id\n";
}
# if a job already runs for this device we get an error, catch it for cleanup
diff --git a/src/test/MigrationTest/QemuMigrateMock.pm b/src/test/MigrationTest/QemuMigrateMock.pm
index b69b2b16..bdc574c1 100644
--- a/src/test/MigrationTest/QemuMigrateMock.pm
+++ b/src/test/MigrationTest/QemuMigrateMock.pm
@@ -140,7 +140,7 @@ $qemu_server_blockjob_module->mock(
qemu_drive_mirror => sub {
my (
$vmid,
- $drive,
+ $drive_id,
$dst_volid,
$vmiddst,
$is_zero_initialized,
@@ -152,13 +152,13 @@ $qemu_server_blockjob_module->mock(
) = @_;
die "drive_mirror with wrong vmid: '$vmid'\n" if $vmid ne $test_vmid;
- die "qemu_drive_mirror '$drive' error\n"
- if $fail_config->{qemu_drive_mirror} && $fail_config->{qemu_drive_mirror} eq $drive;
+ die "qemu_drive_mirror '$drive_id' error\n"
+ if $fail_config->{qemu_drive_mirror} && $fail_config->{qemu_drive_mirror} eq $drive_id;
my $nbd_info = decode_json(file_get_contents("${RUN_DIR_PATH}/nbd_info"));
- die "target does not expect drive mirror for '$drive'\n"
- if !defined($nbd_info->{$drive});
- delete $nbd_info->{$drive};
+ die "target does not expect drive mirror for '$drive_id'\n"
+ if !defined($nbd_info->{$drive_id});
+ delete $nbd_info->{$drive_id};
file_set_contents("${RUN_DIR_PATH}/nbd_info", to_json($nbd_info));
},
qemu_drive_mirror_monitor => sub {
--
2.47.2
More information about the pve-devel
mailing list