From nobody Sun Feb 8 21:12:31 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=1638543853; cv=none; d=zohomail.com; s=zohoarc; b=eAZLH2yeNnPjOc3uHl+1sD5en9nbQKZ5Tb1cOvgdVAXPxZcs6bg4z4Hg+ZuhDeMLMUZQQBOdTKMneiPHrf7Gr6/tXkkI8cxw//2WMbRRV9PEcTy6mxEpFvh6mtHRXSdafUssszPER1ZtOPebRmeXZCT7pRaFBEoaPj/f+fu40C4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543853; 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=RK/710aojKOq98WZ0R1xy/uQqZWQhZgNRFlnt/L3s3M=; b=QD++ppbjf+fmK4BQl/LtPK2Wt3v7rGmZJb7l6BZ8CygrSWEPh2YRj9Ns1sS8EeDCC72+EE1DrhujBfxdF3DzHjlGLTIF5f2W2uvUoE8msH7ZkFIHMxgArCybcrqxujXq+Z0JrxAUEvzjKRvgH0U4mWGMzHI28brEMwpGV1ZcxPI= 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 1638543853102634.6933957867009; Fri, 3 Dec 2021 07:04:13 -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-374-Vkt7W0VBPOagvln3Gl7f-g-1; Fri, 03 Dec 2021 10:04:09 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8CD97835E22; Fri, 3 Dec 2021 15:04:00 +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 6D6942B178; Fri, 3 Dec 2021 15:04:00 +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 1529C4A7C8; Fri, 3 Dec 2021 15:04:00 +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 1B3F3wlq031156 for ; Fri, 3 Dec 2021 10:03:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id CBC705DF4C; Fri, 3 Dec 2021 15:03:58 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FC405DF21 for ; Fri, 3 Dec 2021 15:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543852; 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=RK/710aojKOq98WZ0R1xy/uQqZWQhZgNRFlnt/L3s3M=; b=Lk1Zeta/JA1nuRCfxWko89Mn8i4K51WieAEZX3KyUoY7oA50F54oX1XVuC6k9wkI7UMte3 5YKAwgA1GAtfXo1EvEYaZhiKcJ7L+OJk2CqaqJy3qqqmCHLG6LKKggFrXE15Jj/ZzauXR5 vv3hmm/6QmiiQlflfB4naHCLEWj+Ugw= X-MC-Unique: Vkt7W0VBPOagvln3Gl7f-g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/17] virDomainBlockCopy: Introduce VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES flag Date: Fri, 3 Dec 2021 16:01:47 +0100 Message-Id: <2822ff5cf0d30f146d185fc608d54ad95faf64d0.1638543496.git.pkrempa@redhat.com> 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.79 on 10.5.11.11 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: 1638543854154100003 Content-Type: text/plain; charset="utf-8" In cases when the destination storage is slower than the normal VM storage and the VM does intensive I/O to the disk a block copy job may never converge. Switching it to synchronous mode will ensure that all writes done by the guest are propagated to the destination at the cost of slowing down I/O of the guest to the synchronous speed. This patch adds the new API flag and implements virsh support. Signed-off-by: Peter Krempa --- docs/manpages/virsh.rst | 7 ++++++- include/libvirt/libvirt-domain.h | 4 ++++ src/libvirt-domain.c | 6 ++++++ tools/virsh-domain.c | 9 ++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 39636a565e..9728f36a78 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1218,7 +1218,7 @@ blockcopy [--shallow] [--reuse-external] [bandwidth] [--wait [--async] [--verbose]] [{--pivot | --finish}] [--timeout seconds] [granularity] [buf-size] [--bytes] - [--transient-job] + [--transient-job] [--synchronous-writes] Copy a disk backing image chain to a destination. Either *dest* as the destination file name, or *--xml* with the name of an XML file contain= ing @@ -1278,6 +1278,11 @@ be recovered if the VM crashes or is turned off befo= re the job completes. This flag removes the restriction of copy jobs to transient domains if that restriction is applied by the hypervisor. +If *--synchronous-writes* is specified the block job will wait for guest w= rites +to be propagated both to the original image and to the destination of the = copy +so that it's guaranteed that the job converges if the destination storage = is +slower. This may impact performance of writes while the blockjob is runnin= g. + blockjob -------- diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index dddcae86a4..3a76aec90f 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2598,6 +2598,10 @@ typedef enum { /* Don't force usage of recoverable job for the copy operation */ VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB =3D 1 << 2, + + /* Force the copy job to synchronously propagate guest writes into + * the destination image, so that the copy is guaranteed to converge */ + VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES =3D 1 << 3, } virDomainBlockCopyFlags; /** diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index ce7cafde36..8ee2490867 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -10509,6 +10509,12 @@ virDomainBlockRebase(virDomainPtr dom, const char = *disk, * remove the restriction of copy jobs to transient domains. Note that thi= s flag * is automatically implied if the VM is transient at the time it's starte= d. * + * If @flags contains VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES the job wil= l wait + * for guest writes to be propagated both to the original image and to the + * destination of the copy so that it's guaranteed that the job converges = if + * the destination storage is slower. This may impact performance of writes + * while the blockjob is running. + * * The @disk parameter is either an unambiguous source name of the * block device (the sub-element, such as * "/path/to/image"), or the device target shorthand (the diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index e179e24ca9..a00b4cc243 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2284,6 +2284,10 @@ static const vshCmdOptDef opts_blockcopy[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("the copy job is not persisted if VM is turned off") }, + {.name =3D "synchronous-writes", + .type =3D VSH_OT_BOOL, + .help =3D N_("the copy job forces guest writes to be synchronously wr= itten to the destination") + }, {.name =3D NULL} }; @@ -2306,6 +2310,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) bool async =3D vshCommandOptBool(cmd, "async"); bool bytes =3D vshCommandOptBool(cmd, "bytes"); bool transientjob =3D vshCommandOptBool(cmd, "transient-job"); + bool syncWrites =3D vshCommandOptBool(cmd, "synchronous-writes"); int timeout =3D 0; const char *path =3D NULL; int abort_flags =3D 0; @@ -2337,6 +2342,8 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT; if (transientjob) flags |=3D VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB; + if (syncWrites) + flags |=3D VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES; if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) return false; @@ -2386,7 +2393,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) } if (granularity || buf_size || (format && STRNEQ(format, "raw")) || xm= l || - transientjob) { + transientjob || syncWrites) { /* New API */ if (bandwidth || granularity || buf_size) { params =3D g_new0(virTypedParameter, 3); --=20 2.31.1