From nobody Sat Apr 27 19:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523898476570330.43935074812987; Mon, 16 Apr 2018 10:07:56 -0700 (PDT) Received: from localhost ([::1]:58581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87bR-0005qH-GE for importer@patchew.org; Mon, 16 Apr 2018 13:07:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87T8-0007SS-LB for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87T7-0003FJ-5h for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:06 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50858 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87T3-0003Bx-FP; Mon, 16 Apr 2018 12:59:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E78EF4068024; Mon, 16 Apr 2018 16:59:00 +0000 (UTC) Received: from localhost (unknown [10.40.205.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C8742023227; Mon, 16 Apr 2018 16:59:00 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 16 Apr 2018 18:58:41 +0200 Message-Id: <20180416165849.28864-2-mreitz@redhat.com> In-Reply-To: <20180416165849.28864-1-mreitz@redhat.com> References: <20180416165849.28864-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 16 Apr 2018 16:59:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 16 Apr 2018 16:59:00 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 1/9] block: Add COR filter driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This adds a simple copy-on-read filter driver. It relies on the already existing COR functionality in the central block layer code, which may be moved here once we no longer need it there. Signed-off-by: Max Reitz --- block/Makefile.objs | 2 +- qapi/block-core.json | 5 +- block/cor.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 block/cor.c diff --git a/block/Makefile.objs b/block/Makefile.objs index d644bac60a..6fdf786c04 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -26,7 +26,7 @@ block-obj-y +=3D accounting.o dirty-bitmap.o block-obj-y +=3D write-threshold.o block-obj-y +=3D backup.o block-obj-$(CONFIG_REPLICATION) +=3D replication.o -block-obj-y +=3D throttle.o +block-obj-y +=3D throttle.o cor.o =20 block-obj-y +=3D crypto.o =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index c50517bff3..3abbf4fcf1 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2506,11 +2506,12 @@ # @vxhs: Since 2.10 # @throttle: Since 2.11 # @nvme: Since 2.12 +# @cor: Since 2.13 # # Since: 2.9 ## { 'enum': 'BlockdevDriver', - 'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop', + 'data': [ 'blkdebug', 'blkverify', 'bochs', 'cloop', 'cor', 'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', 'qcow', 'qcow2', '= qed', @@ -3522,6 +3523,7 @@ 'blkverify': 'BlockdevOptionsBlkverify', 'bochs': 'BlockdevOptionsGenericFormat', 'cloop': 'BlockdevOptionsGenericFormat', + 'cor': 'BlockdevOptionsGenericFormat', 'dmg': 'BlockdevOptionsGenericFormat', 'file': 'BlockdevOptionsFile', 'ftp': 'BlockdevOptionsCurlFtp', @@ -4049,6 +4051,7 @@ 'blkverify': 'BlockdevCreateNotSupported', 'bochs': 'BlockdevCreateNotSupported', 'cloop': 'BlockdevCreateNotSupported', + 'cor': 'BlockdevCreateNotSupported', 'dmg': 'BlockdevCreateNotSupported', 'file': 'BlockdevCreateOptionsFile', 'ftp': 'BlockdevCreateNotSupported', diff --git a/block/cor.c b/block/cor.c new file mode 100644 index 0000000000..a4cb4e2b84 --- /dev/null +++ b/block/cor.c @@ -0,0 +1,171 @@ +/* + * Copy-on-read filter block driver + * + * Copyright (c) 2018 Red Hat, Inc. + * + * Author: + * Max Reitz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include "block/block_int.h" + + +static int cor_open(BlockDriverState *bs, QDict *options, int flags, + Error **errp) +{ + bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file, f= alse, + errp); + if (!bs->file) { + return -EINVAL; + } + + bs->supported_write_flags =3D BDRV_REQ_FUA & + bs->file->bs->supported_write_flags; + + bs->supported_zero_flags =3D (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & + bs->file->bs->supported_zero_flags; + + return 0; +} + + +static void cor_close(BlockDriverState *bs) +{ +} + + +#define PERM_PASSTHROUGH (BLK_PERM_CONSISTENT_READ \ + | BLK_PERM_WRITE \ + | BLK_PERM_RESIZE) +#define PERM_UNCHANGED (BLK_PERM_ALL & ~PERM_PASSTHROUGH) + +static void cor_child_perm(BlockDriverState *bs, BdrvChild *c, + const BdrvChildRole *role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) +{ + if (c =3D=3D NULL) { + *nperm =3D (perm & PERM_PASSTHROUGH) | BLK_PERM_WRITE_UNCHANGED; + *nshared =3D (shared & PERM_PASSTHROUGH) | PERM_UNCHANGED; + return; + } + + *nperm =3D (perm & PERM_PASSTHROUGH) | + (c->perm & PERM_UNCHANGED); + *nshared =3D (shared & PERM_PASSTHROUGH) | + (c->shared_perm & PERM_UNCHANGED); +} + + +static int64_t cor_getlength(BlockDriverState *bs) +{ + return bdrv_getlength(bs->file->bs); +} + + +static int cor_truncate(BlockDriverState *bs, int64_t offset, + PreallocMode prealloc, Error **errp) +{ + return bdrv_truncate(bs->file, offset, prealloc, errp); +} + + +static int coroutine_fn cor_co_preadv(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags) +{ + return bdrv_co_preadv(bs->file, offset, bytes, qiov, + flags | BDRV_REQ_COPY_ON_READ); +} + + +static int coroutine_fn cor_co_pwritev(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, int flags) +{ + + return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); +} + + +static int coroutine_fn cor_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int bytes, + BdrvRequestFlags flags) +{ + return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); +} + + +static int coroutine_fn cor_co_pdiscard(BlockDriverState *bs, + int64_t offset, int bytes) +{ + return bdrv_co_pdiscard(bs->file->bs, offset, bytes); +} + + +static void cor_eject(BlockDriverState *bs, bool eject_flag) +{ + bdrv_eject(bs->file->bs, eject_flag); +} + + +static void cor_lock_medium(BlockDriverState *bs, bool locked) +{ + bdrv_lock_medium(bs->file->bs, locked); +} + + +static bool cor_recurse_is_first_non_filter(BlockDriverState *bs, + BlockDriverState *candidate) +{ + return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); +} + + +BlockDriver bdrv_cor =3D { + .format_name =3D "cor", + + .bdrv_open =3D cor_open, + .bdrv_close =3D cor_close, + .bdrv_child_perm =3D cor_child_perm, + + .bdrv_getlength =3D cor_getlength, + .bdrv_truncate =3D cor_truncate, + + .bdrv_co_preadv =3D cor_co_preadv, + .bdrv_co_pwritev =3D cor_co_pwritev, + .bdrv_co_pwrite_zeroes =3D cor_co_pwrite_zeroes, + .bdrv_co_pdiscard =3D cor_co_pdiscard, + + .bdrv_eject =3D cor_eject, + .bdrv_lock_medium =3D cor_lock_medium, + + .bdrv_co_block_status =3D bdrv_co_block_status_from_file, + + .bdrv_recurse_is_first_non_filter =3D cor_recurse_is_first_non_filte= r, + + .has_variable_length =3D true, + .is_filter =3D true, +}; + +static void bdrv_cor_init(void) +{ + bdrv_register(&bdrv_cor); +} + +block_init(bdrv_cor_init); --=20 2.14.3 From nobody Sat Apr 27 19:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523898368722231.31419626937236; Mon, 16 Apr 2018 10:06:08 -0700 (PDT) Received: from localhost ([::1]:58549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87Zo-0004Nr-2q for importer@patchew.org; Mon, 16 Apr 2018 13:06:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87T8-0007SY-LP for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87T7-0003Fp-TS for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:06 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54380 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87T5-0003DP-DE; Mon, 16 Apr 2018 12:59:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DCA137CBBA; Mon, 16 Apr 2018 16:59:02 +0000 (UTC) Received: from localhost (unknown [10.40.205.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C6B22142F5C; Mon, 16 Apr 2018 16:59:02 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 16 Apr 2018 18:58:42 +0200 Message-Id: <20180416165849.28864-3-mreitz@redhat.com> In-Reply-To: <20180416165849.28864-1-mreitz@redhat.com> References: <20180416165849.28864-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 16 Apr 2018 16:59:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 16 Apr 2018 16:59:02 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 2/9] block: BLK_PERM_WRITE includes ..._UNCHANGED X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently we never actually check whether the WRITE_UNCHANGED permission has been taken for unchanging writes. But the one check that is commented out checks both WRITE and WRITE_UNCHANGED; and considering that WRITE_UNCHANGED is already documented as being weaker then WRITE, we should probably explicitly document WRITE to include WRITE_UNCHANGED. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi --- include/block/block.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/block/block.h b/include/block/block.h index cdec3639a3..397b5e8d44 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -205,6 +205,9 @@ enum { * This permission (which is weaker than BLK_PERM_WRITE) is both enoug= h and * required for writes to the block node when the caller promises that * the visible disk content doesn't change. + * + * As the BLK_PERM_WRITE permission is strictly stronger, either is + * sufficient to perform an unchanging write. */ BLK_PERM_WRITE_UNCHANGED =3D 0x04, =20 --=20 2.14.3 From nobody Sat Apr 27 19:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523898156742586.9800506763935; Mon, 16 Apr 2018 10:02:36 -0700 (PDT) Received: from localhost ([::1]:58430 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87WO-0001U4-Rx for importer@patchew.org; Mon, 16 Apr 2018 13:02:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87TA-0007Ub-BH for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87T9-0003HN-GV for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:08 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50862 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87T7-0003FC-AN; Mon, 16 Apr 2018 12:59:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D0AE14068024; Mon, 16 Apr 2018 16:59:04 +0000 (UTC) Received: from localhost (unknown [10.40.205.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77F642023227; Mon, 16 Apr 2018 16:59:04 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 16 Apr 2018 18:58:43 +0200 Message-Id: <20180416165849.28864-4-mreitz@redhat.com> In-Reply-To: <20180416165849.28864-1-mreitz@redhat.com> References: <20180416165849.28864-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 16 Apr 2018 16:59:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 16 Apr 2018 16:59:04 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 3/9] block: Add BDRV_REQ_WRITE_UNCHANGED flag X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This flag signifies that a write request will not change the visible disk content. With this flag set, it is sufficient to have the BLK_PERM_WRITE_UNCHANGED permission instead of BLK_PERM_WRITE. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi --- include/block/block.h | 6 +++++- block/io.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index 397b5e8d44..3894edda9d 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -54,8 +54,12 @@ typedef enum { BDRV_REQ_FUA =3D 0x10, BDRV_REQ_WRITE_COMPRESSED =3D 0x20, =20 + /* Signifies that this write request will not change the visible disk + * content. */ + BDRV_REQ_WRITE_UNCHANGED =3D 0x40, + /* Mask of valid flags */ - BDRV_REQ_MASK =3D 0x3f, + BDRV_REQ_MASK =3D 0x7f, } BdrvRequestFlags; =20 typedef struct BlockSizes { diff --git a/block/io.c b/block/io.c index bd9a19a9c4..134b2a498f 100644 --- a/block/io.c +++ b/block/io.c @@ -1501,7 +1501,11 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChi= ld *child, assert(!waited || !req->serialising); assert(req->overlap_offset <=3D offset); assert(offset + bytes <=3D req->overlap_offset + req->overlap_bytes); - assert(child->perm & BLK_PERM_WRITE); + if (flags & BDRV_REQ_WRITE_UNCHANGED) { + assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE)); + } else { + assert(child->perm & BLK_PERM_WRITE); + } assert(end_sector <=3D bs->total_sectors || child->perm & BLK_PERM_RES= IZE); =20 ret =3D notifier_with_return_list_notify(&bs->before_write_notifiers, = req); --=20 2.14.3 From nobody Sat Apr 27 19:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523898630706642.0716684956014; Mon, 16 Apr 2018 10:10:30 -0700 (PDT) Received: from localhost ([::1]:58855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87e3-000829-R7 for importer@patchew.org; Mon, 16 Apr 2018 13:10:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87TI-0007dF-Ts for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87TI-0003N1-4x for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:17 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54382 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87TD-0003Jw-Hq; Mon, 16 Apr 2018 12:59:11 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 151A07CBBA; Mon, 16 Apr 2018 16:59:11 +0000 (UTC) Received: from localhost (unknown [10.40.205.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FA62111DCE5; Mon, 16 Apr 2018 16:59:06 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 16 Apr 2018 18:58:44 +0200 Message-Id: <20180416165849.28864-5-mreitz@redhat.com> In-Reply-To: <20180416165849.28864-1-mreitz@redhat.com> References: <20180416165849.28864-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 16 Apr 2018 16:59:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 16 Apr 2018 16:59:11 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 4/9] block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi --- block/io.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 134b2a498f..fada4efbf3 100644 --- a/block/io.c +++ b/block/io.c @@ -1115,13 +1115,15 @@ static int coroutine_fn bdrv_co_do_copy_on_readv(Bd= rvChild *child, /* FIXME: Should we (perhaps conditionally) be setting * BDRV_REQ_MAY_UNMAP, if it will allow for a sparser copy * that still correctly reads as zero? */ - ret =3D bdrv_co_do_pwrite_zeroes(bs, cluster_offset, pnum,= 0); + ret =3D bdrv_co_do_pwrite_zeroes(bs, cluster_offset, pnum, + BDRV_REQ_WRITE_UNCHANGED); } else { /* This does not change the data on the disk, it is not * necessary to flush even in cache=3Dwritethrough mode. */ ret =3D bdrv_driver_pwritev(bs, cluster_offset, pnum, - &local_qiov, 0); + &local_qiov, + BDRV_REQ_WRITE_UNCHANGED); } =20 if (ret < 0) { --=20 2.14.3 From nobody Sat Apr 27 19:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523898551188681.1265241292834; Mon, 16 Apr 2018 10:09:11 -0700 (PDT) Received: from localhost ([::1]:58800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87cj-000760-BN for importer@patchew.org; Mon, 16 Apr 2018 13:09:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87TJ-0007dS-3C for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87TI-0003N6-8E for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:17 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36200 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87TF-0003Kk-Ib; Mon, 16 Apr 2018 12:59:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BFEC4067EF0; Mon, 16 Apr 2018 16:59:13 +0000 (UTC) Received: from localhost (unknown [10.40.205.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A0AAE214138C; Mon, 16 Apr 2018 16:59:12 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 16 Apr 2018 18:58:45 +0200 Message-Id: <20180416165849.28864-6-mreitz@redhat.com> In-Reply-To: <20180416165849.28864-1-mreitz@redhat.com> References: <20180416165849.28864-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 16 Apr 2018 16:59:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 16 Apr 2018 16:59:13 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 5/9] block/quorum: Support BDRV_REQ_WRITE_UNCHANGED X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We just need to forward it to quorum's children (except in case of a rewrite because of corruption), but for that we first have to support flags in child requests at all. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi --- block/quorum.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index cfe484a945..8cd689b2c1 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -115,6 +115,7 @@ struct QuorumAIOCB { /* Request metadata */ uint64_t offset; uint64_t bytes; + int flags; =20 QEMUIOVector *qiov; /* calling IOV */ =20 @@ -157,7 +158,8 @@ static bool quorum_64bits_compare(QuorumVoteValue *a, Q= uorumVoteValue *b) static QuorumAIOCB *quorum_aio_get(BlockDriverState *bs, QEMUIOVector *qiov, uint64_t offset, - uint64_t bytes) + uint64_t bytes, + int flags) { BDRVQuorumState *s =3D bs->opaque; QuorumAIOCB *acb =3D g_new(QuorumAIOCB, 1); @@ -168,6 +170,7 @@ static QuorumAIOCB *quorum_aio_get(BlockDriverState *bs, .bs =3D bs, .offset =3D offset, .bytes =3D bytes, + .flags =3D flags, .qiov =3D qiov, .votes.compare =3D quorum_sha256_compare, .votes.vote_list =3D QLIST_HEAD_INITIALIZER(acb.votes.vote_list= ), @@ -271,9 +274,11 @@ static void quorum_rewrite_entry(void *opaque) BDRVQuorumState *s =3D acb->bs->opaque; =20 /* Ignore any errors, it's just a correction attempt for already - * corrupted data. */ + * corrupted data. + * Mask out BDRV_REQ_WRITE_UNCHANGED because this overwrites the + * area with different data from the other children. */ bdrv_co_pwritev(s->children[co->idx], acb->offset, acb->bytes, - acb->qiov, 0); + acb->qiov, acb->flags & ~BDRV_REQ_WRITE_UNCHANGED); =20 /* Wake up the caller after the last rewrite */ acb->rewrite_count--; @@ -673,7 +678,7 @@ static int quorum_co_preadv(BlockDriverState *bs, uint6= 4_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVQuorumState *s =3D bs->opaque; - QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, offset, bytes); + QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, offset, bytes, flags); int ret; =20 acb->is_read =3D true; @@ -699,7 +704,7 @@ static void write_quorum_entry(void *opaque) =20 sacb->bs =3D s->children[i]->bs; sacb->ret =3D bdrv_co_pwritev(s->children[i], acb->offset, acb->bytes, - acb->qiov, 0); + acb->qiov, acb->flags); if (sacb->ret =3D=3D 0) { acb->success_count++; } else { @@ -719,7 +724,7 @@ static int quorum_co_pwritev(BlockDriverState *bs, uint= 64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVQuorumState *s =3D bs->opaque; - QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, offset, bytes); + QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, offset, bytes, flags); int i, ret; =20 for (i =3D 0; i < s->num_children; i++) { @@ -961,6 +966,8 @@ static int quorum_open(BlockDriverState *bs, QDict *opt= ions, int flags, } s->next_child_index =3D s->num_children; =20 + bs->supported_write_flags =3D BDRV_REQ_WRITE_UNCHANGED; + g_free(opened); goto exit; =20 --=20 2.14.3 From nobody Sat Apr 27 19:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523898368777258.27478750190073; Mon, 16 Apr 2018 10:06:08 -0700 (PDT) Received: from localhost ([::1]:58550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87Zo-0004O0-9m for importer@patchew.org; Mon, 16 Apr 2018 13:06:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87TL-0007h9-Km for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87TK-0003Ov-FP for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:19 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36202 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87TH-0003MG-GM; Mon, 16 Apr 2018 12:59:15 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0434F4067EF0; Mon, 16 Apr 2018 16:59:15 +0000 (UTC) Received: from localhost (unknown [10.40.205.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 995F22141212; Mon, 16 Apr 2018 16:59:14 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 16 Apr 2018 18:58:46 +0200 Message-Id: <20180416165849.28864-7-mreitz@redhat.com> In-Reply-To: <20180416165849.28864-1-mreitz@redhat.com> References: <20180416165849.28864-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 16 Apr 2018 16:59:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 16 Apr 2018 16:59:15 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 6/9] block: Support BDRV_REQ_WRITE_UNCHANGED in filters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Update the rest of the filter drivers to support BDRV_REQ_WRITE_UNCHANGED. They already forward write request flags to their children, so we just have to announce support for it. This patch does not cover the replication driver because that currently does not support flags at all, and because it just grabs the WRITE permission for its children when it can, so we should be fine just submitting the incoming WRITE_UNCHANGED requests as normal writes. It also does not cover format drivers for similar reasons. They all use bdrv_format_default_perms() as their .bdrv_child_perm() implementation so they just always grab the WRITE permission for their file children whenever possible. In addition, it often would be difficult to ascertain whether incoming unchanging writes end up as unchanging writes in their files. So we just leave them as normal potentially changing writes. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi --- block/blkdebug.c | 9 +++++---- block/blkreplay.c | 3 +++ block/blkverify.c | 3 +++ block/cor.c | 10 ++++++---- block/mirror.c | 2 ++ block/raw-format.c | 9 +++++---- block/throttle.c | 6 ++++-- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 589712475a..762ec2527c 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -398,10 +398,11 @@ static int blkdebug_open(BlockDriverState *bs, QDict = *options, int flags, goto out; } =20 - bs->supported_write_flags =3D BDRV_REQ_FUA & - bs->file->bs->supported_write_flags; - bs->supported_zero_flags =3D (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & - bs->file->bs->supported_zero_flags; + bs->supported_write_flags =3D BDRV_REQ_WRITE_UNCHANGED | + (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); + bs->supported_zero_flags =3D BDRV_REQ_WRITE_UNCHANGED | + ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & + bs->file->bs->supported_zero_flags); ret =3D -EINVAL; =20 /* Set alignment overrides */ diff --git a/block/blkreplay.c b/block/blkreplay.c index fe5a9b4a98..b016dbeee7 100755 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -35,6 +35,9 @@ static int blkreplay_open(BlockDriverState *bs, QDict *op= tions, int flags, goto fail; } =20 + bs->supported_write_flags =3D BDRV_REQ_WRITE_UNCHANGED; + bs->supported_zero_flags =3D BDRV_REQ_WRITE_UNCHANGED; + ret =3D 0; fail: return ret; diff --git a/block/blkverify.c b/block/blkverify.c index 331365be33..1646404b46 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -141,6 +141,9 @@ static int blkverify_open(BlockDriverState *bs, QDict *= options, int flags, goto fail; } =20 + bs->supported_write_flags =3D BDRV_REQ_WRITE_UNCHANGED; + bs->supported_zero_flags =3D BDRV_REQ_WRITE_UNCHANGED; + ret =3D 0; fail: qemu_opts_del(opts); diff --git a/block/cor.c b/block/cor.c index a4cb4e2b84..189e5bd13e 100644 --- a/block/cor.c +++ b/block/cor.c @@ -33,11 +33,13 @@ static int cor_open(BlockDriverState *bs, QDict *option= s, int flags, return -EINVAL; } =20 - bs->supported_write_flags =3D BDRV_REQ_FUA & - bs->file->bs->supported_write_flags; + bs->supported_write_flags =3D BDRV_REQ_WRITE_UNCHANGED | + (BDRV_REQ_FUA & + bs->file->bs->supported_write_flags); =20 - bs->supported_zero_flags =3D (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & - bs->file->bs->supported_zero_flags; + bs->supported_zero_flags =3D BDRV_REQ_WRITE_UNCHANGED | + ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & + bs->file->bs->supported_zero_flags); =20 return 0; } diff --git a/block/mirror.c b/block/mirror.c index 820f512c7b..6fdd36d27f 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1148,6 +1148,8 @@ static void mirror_start_job(const char *job_id, Bloc= kDriverState *bs, mirror_top_bs->implicit =3D true; } mirror_top_bs->total_sectors =3D bs->total_sectors; + mirror_top_bs->supported_write_flags =3D BDRV_REQ_WRITE_UNCHANGED; + mirror_top_bs->supported_zero_flags =3D BDRV_REQ_WRITE_UNCHANGED; bdrv_set_aio_context(mirror_top_bs, bdrv_get_aio_context(bs)); =20 /* bdrv_append takes ownership of the mirror_top_bs reference, need to= keep diff --git a/block/raw-format.c b/block/raw-format.c index a378547c99..fe33693a2d 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -415,10 +415,11 @@ static int raw_open(BlockDriverState *bs, QDict *opti= ons, int flags, } =20 bs->sg =3D bs->file->bs->sg; - bs->supported_write_flags =3D BDRV_REQ_FUA & - bs->file->bs->supported_write_flags; - bs->supported_zero_flags =3D (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & - bs->file->bs->supported_zero_flags; + bs->supported_write_flags =3D BDRV_REQ_WRITE_UNCHANGED | + (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); + bs->supported_zero_flags =3D BDRV_REQ_WRITE_UNCHANGED | + ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & + bs->file->bs->supported_zero_flags); =20 if (bs->probed && !bdrv_is_read_only(bs)) { fprintf(stderr, diff --git a/block/throttle.c b/block/throttle.c index 95ed06acd8..e298827f95 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -81,8 +81,10 @@ static int throttle_open(BlockDriverState *bs, QDict *op= tions, if (!bs->file) { return -EINVAL; } - bs->supported_write_flags =3D bs->file->bs->supported_write_flags; - bs->supported_zero_flags =3D bs->file->bs->supported_zero_flags; + bs->supported_write_flags =3D bs->file->bs->supported_write_flags | + BDRV_REQ_WRITE_UNCHANGED; + bs->supported_zero_flags =3D bs->file->bs->supported_zero_flags | + BDRV_REQ_WRITE_UNCHANGED; =20 return throttle_configure_tgm(bs, tgm, options, errp); } --=20 2.14.3 From nobody Sat Apr 27 19:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523898825486474.8525838624257; Mon, 16 Apr 2018 10:13:45 -0700 (PDT) Received: from localhost ([::1]:58888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87h8-0002S1-Vs for importer@patchew.org; Mon, 16 Apr 2018 13:13:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87TM-0007hZ-1F for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87TL-0003Ph-Ey for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:20 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50868 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87TJ-0003Nz-Fm; Mon, 16 Apr 2018 12:59:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F31294068024; Mon, 16 Apr 2018 16:59:16 +0000 (UTC) Received: from localhost (unknown [10.40.205.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 970982026609; Mon, 16 Apr 2018 16:59:16 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 16 Apr 2018 18:58:47 +0200 Message-Id: <20180416165849.28864-8-mreitz@redhat.com> In-Reply-To: <20180416165849.28864-1-mreitz@redhat.com> References: <20180416165849.28864-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 16 Apr 2018 16:59:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 16 Apr 2018 16:59:17 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 7/9] iotests: Clean up wrap image in 197 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi --- tests/qemu-iotests/197 | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197 index 5e869fe2b7..3ae4975eec 100755 --- a/tests/qemu-iotests/197 +++ b/tests/qemu-iotests/197 @@ -44,6 +44,7 @@ esac _cleanup() { _cleanup_test_img + rm -f "$TEST_WRAP" rm -f "$BLKDBG_CONF" } trap "_cleanup; exit \$status" 0 1 2 3 15 --=20 2.14.3 From nobody Sat Apr 27 19:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15238990148071003.6277575630687; Mon, 16 Apr 2018 10:16:54 -0700 (PDT) Received: from localhost ([::1]:59199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87k8-0005TM-C4 for importer@patchew.org; Mon, 16 Apr 2018 13:16:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87TV-0007qz-8J for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87TT-0003Vp-Qi for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36204 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87TQ-0003Sj-Ar; Mon, 16 Apr 2018 12:59:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C15B84067EF0; Mon, 16 Apr 2018 16:59:23 +0000 (UTC) Received: from localhost (unknown [10.40.205.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8AFF47C38; Mon, 16 Apr 2018 16:59:18 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 16 Apr 2018 18:58:48 +0200 Message-Id: <20180416165849.28864-9-mreitz@redhat.com> In-Reply-To: <20180416165849.28864-1-mreitz@redhat.com> References: <20180416165849.28864-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 16 Apr 2018 16:59:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 16 Apr 2018 16:59:23 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 8/9] iotests: Copy 197 for COR filter driver X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" iotest 197 tests copy-on-read using the (now old) copy-on-read flag. Copy it to 215 and modify it to use the COR filter driver instead. Signed-off-by: Max Reitz Reviewed-by: Stefan Hajnoczi --- tests/qemu-iotests/215 | 120 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/215.out | 26 ++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 147 insertions(+) create mode 100755 tests/qemu-iotests/215 create mode 100644 tests/qemu-iotests/215.out diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215 new file mode 100755 index 0000000000..8c4073a439 --- /dev/null +++ b/tests/qemu-iotests/215 @@ -0,0 +1,120 @@ +#!/bin/bash +# +# Test case for copy-on-read into qcow2, using the COR filter driver +# +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +seq=3D"$(basename $0)" +echo "QA output created by $seq" + +here=3D"$PWD" +status=3D1 # failure is the default! + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +TEST_WRAP=3D"$TEST_DIR/t.wrap.qcow2" +BLKDBG_CONF=3D"$TEST_DIR/blkdebug.conf" + +# Sanity check: our use of blkdebug fails if $TEST_DIR contains spaces +# or other problems +case "$TEST_DIR" in + *[^-_a-zA-Z0-9/]*) + _notrun "Suspicious TEST_DIR=3D'$TEST_DIR', cowardly refusing to r= un" ;; +esac + +_cleanup() +{ + _cleanup_test_img + rm -f "$TEST_WRAP" + rm -f "$BLKDBG_CONF" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# Test is supported for any backing file; but we force qcow2 for our wrapp= er. +_supported_fmt generic +_supported_proto generic +_supported_os Linux +# LUKS support may be possible, but it complicates things. +_unsupported_fmt luks + +echo +echo '=3D=3D=3D Copy-on-read =3D=3D=3D' +echo + +# Prep the images +# VPC rounds image sizes to a specific geometry, force a specific size. +if [ "$IMGFMT" =3D "vpc" ]; then + IMGOPTS=3D$(_optstr_add "$IMGOPTS" "force_size") +fi +_make_test_img 4G +$QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io +IMGPROTO=3Dfile IMGFMT=3Dqcow2 IMGOPTS=3D TEST_IMG_FILE=3D"$TEST_WRAP" \ + _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create +$QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io + +# Ensure that a read of two clusters, but where one is already allocated, +# does not re-write the allocated cluster +cat > "$BLKDBG_CONF" <&1 | _filter_qemu_io) +case $output in + *allocate*) + _notrun "Insufficent memory to run test" ;; + *) printf '%s\n' "$output" ;; +esac +$QEMU_IO \ + -c "open -o driver=3Dcor,file.driver=3Dqcow2 $TEST_WRAP" \ + -c "read -P 0 $((3*1024*1024*1024 + 1024)) 1k" \ + | _filter_qemu_io + +# Copy-on-read is incompatible with read-only +$QEMU_IO \ + -c "open -r -o driver=3Dcor,file.driver=3Dqcow2 $TEST_WRAP" \ + 2>&1 | _filter_testdir + +# Break the backing chain, and show that images are identical, and that +# we properly copied over explicit zeros. +$QEMU_IMG rebase -u -b "" -f qcow2 "$TEST_WRAP" +$QEMU_IO -f qcow2 -c map "$TEST_WRAP" +_check_test_img +$QEMU_IMG compare -f $IMGFMT -F qcow2 "$TEST_IMG" "$TEST_WRAP" + +# success, all done +echo '*** done' +status=3D0 diff --git a/tests/qemu-iotests/215.out b/tests/qemu-iotests/215.out new file mode 100644 index 0000000000..70b0f5fb19 --- /dev/null +++ b/tests/qemu-iotests/215.out @@ -0,0 +1,26 @@ +QA output created by 215 + +=3D=3D=3D Copy-on-read =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4294967296 +wrote 1024/1024 bytes at offset 3221225472 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.wrap.IMGFMT', fmt=3DIMGFMT size=3D4294967296 backin= g_file=3DTEST_DIR/t.IMGFMT backing_fmt=3DIMGFMT +wrote 65536/65536 bytes at offset 1048576 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 131072/131072 bytes at offset 1048576 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 0/0 bytes at offset 0 +0 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 2147483136/2147483136 bytes at offset 1024 +2 GiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 1024/1024 bytes at offset 3221226496 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +can't open device TEST_DIR/t.wrap.qcow2: Block node is read-only +2 GiB (0x80010000) bytes allocated at offset 0 bytes (0x0) +1023.938 MiB (0x3fff0000) bytes not allocated at offset 2 GiB (0x80010000) +64 KiB (0x10000) bytes allocated at offset 3 GiB (0xc0000000) +1023.938 MiB (0x3fff0000) bytes not allocated at offset 3 GiB (0xc0010000) +No errors were found on the image. +Images are identical. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 3e2dcdfa33..f1179ffde7 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -213,3 +213,4 @@ 212 rw auto quick 213 rw auto quick 214 rw auto +215 rw auto quick --=20 2.14.3 From nobody Sat Apr 27 19:30:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523898722378294.49806402339993; Mon, 16 Apr 2018 10:12:02 -0700 (PDT) Received: from localhost ([::1]:58863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87fT-0000vy-KF for importer@patchew.org; Mon, 16 Apr 2018 13:11:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87TY-0007uj-Nk for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87TW-0003Y8-Ci for qemu-devel@nongnu.org; Mon, 16 Apr 2018 12:59:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50872 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87TS-0003Un-K5; Mon, 16 Apr 2018 12:59:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15A6C40006E6; Mon, 16 Apr 2018 16:59:26 +0000 (UTC) Received: from localhost (unknown [10.40.205.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E0392026DFD; Mon, 16 Apr 2018 16:59:25 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 16 Apr 2018 18:58:49 +0200 Message-Id: <20180416165849.28864-10-mreitz@redhat.com> In-Reply-To: <20180416165849.28864-1-mreitz@redhat.com> References: <20180416165849.28864-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 16 Apr 2018 16:59:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 16 Apr 2018 16:59:26 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 9/9] iotests: Add test for COR across nodes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" COR across nodes (that is, you have some filter node between the actually COR target and the node that performs the COR) cannot reliably work together with the permission system when there is no explicit COR node that can request the WRITE_UNCHANGED permission for its child. This is because COR (currently) sneaks its requests by the usual permission checks, so it can work without a WRITE* permission; but if there is a filter node in between, that will re-issue the request, which then passes through the usual check -- and if nobody has requested a WRITE_UNCHANGED permission, that check will fail. There is no real direct fix apart from hoping that there is someone who has requested that permission; in case of just the qemu-io HMP command (and no guest device), however, that is not the case. The real real fix is to implement the copy-on-read flag through an implicitly added COR node. Such a node can request the necessary permissions as shown in this test. Signed-off-by: Max Reitz Reviewed-by: Stefan Hajnoczi --- tests/qemu-iotests/216 | 117 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/216.out | 28 +++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 146 insertions(+) create mode 100755 tests/qemu-iotests/216 create mode 100644 tests/qemu-iotests/216.out diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216 new file mode 100755 index 0000000000..2f34f94faa --- /dev/null +++ b/tests/qemu-iotests/216 @@ -0,0 +1,117 @@ +#!/usr/bin/env python +# +# Copy-on-read tests using a COR filter node +# +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Creator/Owner: Max Reitz +# +# Non-shared storage migration test using NBD server and drive-mirror + +import iotests +from iotests import log, qemu_img_pipe, qemu_io, filter_qemu_io + +# Need backing file support +iotests.verify_image_format(supported_fmts=3D['qcow2', 'qcow', 'qed', 'vmd= k']) +iotests.verify_platform(['linux']) + +log('') +log('=3D=3D=3D Copy-on-read across nodes =3D=3D=3D') +log('') + +# The old copy-on-read mechanism without a filter node cannot request +# WRITE_UNCHANGED permissions for its child. Therefore it just tries +# to sneak its write by the usual permission system and holds its +# fingers crossed. However, that sneaking does not work so well when +# there is a filter node in the way: That will receive the write +# request and re-issue a new one to its child, which this time is a +# proper write request that will make the permission system cough -- +# unless there is someone at the top (like a guest device) that has +# requested write permissions. +# +# A COR filter node, however, can request the proper permissions for +# its child and therefore is not hit by this issue. + +with iotests.FilePath('base.img') as base_img_path, \ + iotests.FilePath('top.img') as top_img_path, \ + iotests.VM() as vm: + + log('--- Setting up images ---') + log('') + + qemu_img_pipe('create', '-f', iotests.imgfmt, base_img_path, '64M') + + log(filter_qemu_io(qemu_io(base_img_path, '-c', 'write -P 1 0M 1M'))) + + qemu_img_pipe('create', '-f', iotests.imgfmt, '-b', base_img_path, + top_img_path) + + log(filter_qemu_io(qemu_io(top_img_path, '-c', 'write -P 2 1M 1M'))) + + log('') + log('--- Doing COR ---') + log('') + + # Compare with e.g. the following: + # vm.add_drive_raw('if=3Dnone,node-name=3Dnode0,copy-on-read=3Don,dr= iver=3Draw,' \ + # 'file.driver=3D%s,file.file.filename=3D%s' % + # (iotests.imgfmt, top_img_path)) + # (Remove the blockdev-add instead.) + # ((Not tested here because it hits an assertion in the permission + # system.)) + + vm.launch() + + log(vm.qmp('blockdev-add', + node_name=3D'node0', + driver=3D'cor', + file=3D{ + 'driver': 'raw', + 'file': { + 'driver': 'cor', + 'file': { + 'driver': 'raw', + 'file': { + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': top_img_path + }, + 'backing': { + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': base_img_path + } + } + } + } + } + })) + + # Trigger COR + log(vm.qmp('human-monitor-command', + command_line=3D'qemu-io node0 "read 0 64M"')) + + vm.shutdown() + + log('') + log('--- Checking COR result ---') + log('') + + log(filter_qemu_io(qemu_io(base_img_path, '-c', 'discard 0 64M'))) + log(filter_qemu_io(qemu_io(top_img_path, '-c', 'read -P 1 0M 1M'))) + log(filter_qemu_io(qemu_io(top_img_path, '-c', 'read -P 2 1M 1M'))) diff --git a/tests/qemu-iotests/216.out b/tests/qemu-iotests/216.out new file mode 100644 index 0000000000..d3fc590d29 --- /dev/null +++ b/tests/qemu-iotests/216.out @@ -0,0 +1,28 @@ + +=3D=3D=3D Copy-on-read across nodes =3D=3D=3D + +--- Setting up images --- + +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +wrote 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + + +--- Doing COR --- + +{u'return': {}} +{u'return': u''} + +--- Checking COR result --- + +discard 67108864/67108864 bytes at offset 0 +64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +read 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index f1179ffde7..2edc377370 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -214,3 +214,4 @@ 213 rw auto quick 214 rw auto 215 rw auto quick +216 rw auto quick --=20 2.14.3