* [pve-devel] [PATCH qemu-server] migration: use copy-mode "write-blocking" for drive mirror
@ 2022-09-27 11:50 Fiona Ebner
0 siblings, 0 replies; only message in thread
From: Fiona Ebner @ 2022-09-27 11:50 UTC (permalink / raw)
To: pve-devel
Otherwise, there is nothing enforcing that the drive mirror is ready
when the migration inactivates the block devices, which can lead to a
failing assertion:
> ../block/io.c:2026: bdrv_co_write_req_prepare: Assertion
> `!(bs->open_flags & BDRV_O_INACTIVE)' failed.
QAPI documentation of 'write-blocking' (currently the only alternative
to the default 'background' mode):
> when data is written to the source, write it (synchronously) to the
> target as well. In addition, data is copied in background just like
> in background mode.
Reported in the community forum [0] (and likely [1]).
Reproduced consistently with a 1 core, 1 GiB RAM, 4 GiB disk Debian 11
VM. I added a sleep of 5 second before issuing the migrate QMP command
and executed the following in the VM after the drive-mirror became
first ready:
> fio --name=make-mirror-work --size=100M --direct=1 --rw=randwrite \
> --bs=4k --ioengine=psync --numjobs=5 --runtime=60 --time_based
This ensures that there is a large number of dirty clusters and that
the mirror still has work to do when the block device is inactivated.
[0] https://forum.proxmox.com/threads/111831/
[1] https://forum.proxmox.com/threads/100020/
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
PVE/QemuMigrate.pm | 14 +++++++++++++-
PVE/QemuServer.pm | 6 +++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index d52dc8db..dd6b073e 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -831,7 +831,19 @@ sub phase2 {
my $bitmap = $target->{bitmap};
$self->log('info', "$drive: start migration to $nbd_uri");
- PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $vmid, undef, $self->{storage_migration_jobs}, 'skip', undef, $bwlimit, $bitmap);
+ PVE::QemuServer::qemu_drive_mirror(
+ $vmid,
+ $drive,
+ $nbd_uri,
+ $vmid,
+ undef,
+ $self->{storage_migration_jobs},
+ 'skip',
+ undef,
+ $bwlimit,
+ $bitmap,
+ 1,
+ );
}
}
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 4e85dd02..2901cd83 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -7450,7 +7450,7 @@ sub qemu_img_format {
}
sub qemu_drive_mirror {
- my ($vmid, $drive, $dst_volid, $vmiddst, $is_zero_initialized, $jobs, $completion, $qga, $bwlimit, $src_bitmap) = @_;
+ my ($vmid, $drive, $dst_volid, $vmiddst, $is_zero_initialized, $jobs, $completion, $qga, $bwlimit, $src_bitmap, $write_blocking) = @_;
$jobs = {} if !$jobs;
@@ -7477,6 +7477,10 @@ sub qemu_drive_mirror {
my $opts = { timeout => 10, device => "drive-$drive", mode => "existing", sync => "full", target => $qemu_target };
$opts->{format} = $format if $format;
+ # Relevant for migration, to ensure that the mirror will be ready (after being ready once) when
+ # the migration inactivates the block drives.
+ $opts->{'copy-mode'} = 'write-blocking' if $write_blocking;
+
if (defined($src_bitmap)) {
$opts->{sync} = 'incremental';
$opts->{bitmap} = $src_bitmap;
--
2.30.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-27 11:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 11:50 [pve-devel] [PATCH qemu-server] migration: use copy-mode "write-blocking" for drive mirror Fiona Ebner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal