From nobody Mon Feb 9 12:11:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1638543848; cv=none; d=zohomail.com; s=zohoarc; b=LVehx1LQcNNZyJgxsVIx5BkD3+YKhpxRrIs9wFAt/Wuq3mxoKp3m8e7J0aodxOzeJHcEd+8IMUXLqZrPfM/LhfLUdhTDk+Hoave5eC20LDq8rt0R5S5JcOpB/y6X2O9skMaAR+B0u2FvYmIkgRFyHEw5VheonoSWYheS/wa70F0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543848; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yM2GlECxQzxawmxa7Z0y7wONaaBSqjWQSXOUJ3X2Gu0=; b=O+RXp5ZJ6lf20p6XxldaBV45BqeNvKlC80yTLxBURH2RoR9+qetEMWIhAoCwuV0m87iU6rj+WbC1UazWzgrb3j2LCC++NI+rJa324tUhAGoI5c/DSAv9yRk74QxUSToQslD26TcvvG/Dm/x2qO1wU8S5jXpOB3sTTgw4EAx6uWc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1638543848880328.23362826299103; Fri, 3 Dec 2021 07:04:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-252-TCMuaV41OcacvPV5JCLbvw-1; Fri, 03 Dec 2021 10:04:05 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E766801B2E; Fri, 3 Dec 2021 15:03:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11B921037F39; Fri, 3 Dec 2021 15:03:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D44C44BB7C; Fri, 3 Dec 2021 15:03:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B3F3uVg031132 for ; Fri, 3 Dec 2021 10:03:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 904295DF3F; Fri, 3 Dec 2021 15:03:56 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC24E5DAA5 for ; Fri, 3 Dec 2021 15:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543847; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yM2GlECxQzxawmxa7Z0y7wONaaBSqjWQSXOUJ3X2Gu0=; b=adjClM5fNAgAlnd4NxeCBYNzkq7ch1240dpUqojaapWGkGrnY7TQQYnmXgNkIn+TjpTeMH Mjb6rgLhFsQOiP4mjo63NMpQN24Ssxt3ZF6/ZI1NzIxvE008PAzz9xsr1gp05Ky05z7VIY sZ4yRPS61H3lhXCimVHJWaQKx9Hi3sU= X-MC-Unique: TCMuaV41OcacvPV5JCLbvw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/17] qemu: monitor: Add support for 'write-blocking' copy mode for blockdev-mirror Date: Fri, 3 Dec 2021 16:01:45 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1638543849952100001 Content-Type: text/plain; charset="utf-8" Forces the data to be written synchronously to both the original and the mirrored images which ensures that the job will reach synchronized phase. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 3 ++- src/qemu/qemu_migration.c | 3 ++- src/qemu/qemu_monitor.c | 10 ++++++---- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 8 +++++++- src/qemu/qemu_monitor_json.h | 3 ++- tests/qemumonitorjsontest.c | 2 +- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6333d0af36..4cc1d20b89 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15150,7 +15150,8 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, ret =3D qemuMonitorBlockdevMirror(priv->mon, job->name, true, qemuDomainDiskGetTopNodename(disk), mirror->nodeformat, bandwidth, - granularity, buf_size, mirror_shal= low); + granularity, buf_size, mirror_shal= low, + false); } else { /* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as spe= cified * by the user */ diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f2ea73c923..00c33c869e 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -959,7 +959,8 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriver *d= river, if (mon_ret =3D=3D 0) mon_ret =3D qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), jo= bname, persistjob, sourcename, copysrc->nodeforma= t, - mirror_speed, 0, 0, mirror_sha= llow); + mirror_speed, 0, 0, mirror_sha= llow, + false); if (mon_ret !=3D 0) qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), dat= a); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 26b59801b8..072739f5da 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3059,17 +3059,19 @@ qemuMonitorBlockdevMirror(qemuMonitor *mon, unsigned long long bandwidth, unsigned int granularity, unsigned long long buf_size, - bool shallow) + bool shallow, + bool syncWrite) { VIR_DEBUG("jobname=3D%s, persistjob=3D%d, device=3D%s, target=3D%s, ba= ndwidth=3D%lld, " - "granularity=3D%#x, buf_size=3D%lld, shallow=3D%d", + "granularity=3D%#x, buf_size=3D%lld, shallow=3D%d syncWrite= =3D%d", NULLSTR(jobname), persistjob, device, target, bandwidth, gra= nularity, - buf_size, shallow); + buf_size, shallow, syncWrite); QEMU_CHECK_MONITOR(mon); return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device,= target, - bandwidth, granularity, buf_size,= shallow); + bandwidth, granularity, buf_size,= shallow, + syncWrite); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 99ecebc648..b58c637baf 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1079,7 +1079,8 @@ int qemuMonitorBlockdevMirror(qemuMonitor *mon, unsigned long long bandwidth, unsigned int granularity, unsigned long long buf_size, - bool shallow) + bool shallow, + bool syncWrite) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5); int qemuMonitorDrivePivot(qemuMonitor *mon, const char *jobname) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7cb6795a58..64739762b0 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4305,17 +4305,22 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon, unsigned long long speed, unsigned int granularity, unsigned long long buf_size, - bool shallow) + bool shallow, + bool syncWrite) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; virTristateBool autofinalize =3D VIR_TRISTATE_BOOL_ABSENT; virTristateBool autodismiss =3D VIR_TRISTATE_BOOL_ABSENT; const char *syncmode =3D "full"; + const char *copymode =3D NULL; if (shallow) syncmode =3D "top"; + if (syncWrite) + copymode =3D "write-blocking"; + if (persistjob) { autofinalize =3D VIR_TRISTATE_BOOL_YES; autodismiss =3D VIR_TRISTATE_BOOL_NO; @@ -4329,6 +4334,7 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon, "z:granularity", granularity, "P:buf-size", buf_size, "s:sync", syncmode, + "S:copy-mode", copymode, "T:auto-finalize", autofinalize, "T:auto-dismiss", autodismiss, NULL); diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index f7fb13f56c..0dec49ec28 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -266,7 +266,8 @@ int qemuMonitorJSONBlockdevMirror(qemuMonitor *mon, unsigned long long speed, unsigned int granularity, unsigned long long buf_size, - bool shallow) + bool shallow, + bool syncWrite) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5); int qemuMonitorJSONDrivePivot(qemuMonitor *mon, const char *jobname) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 4c882fa5d3..1ad2912b08 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1175,7 +1175,7 @@ GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate, VIR_DO= MAIN_GRAPHICS_TYPE_SPICE, GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0") GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0") GEN_TEST_FUNC(qemuMonitorJSONDriveMirror, "vdb", "/foo/bar", "formatstr", = 1024, 1234, 31234, true, true) -GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targ= etnode", 1024, 1234, 31234, true) +GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targ= etnode", 1024, 1234, 31234, true, true) GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", true, "/foo/ba= r1", "backingnode", "backingfilename", 1024) GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", true, "/foo/ba= r1", "topnode", "/foo/bar2", "basenode", "backingfilename", 1024) GEN_TEST_FUNC(qemuMonitorJSONDrivePivot, "vdb") --=20 2.31.1