From nobody Wed May 1 19:20:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552323613394421.9195511674085; Mon, 11 Mar 2019 10:00:13 -0700 (PDT) Received: from localhost ([127.0.0.1]:36844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3OHb-00027C-5S for importer@patchew.org; Mon, 11 Mar 2019 13:00:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3O9Z-0003FI-H0 for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:51:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3O8A-0007U7-7O for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:50:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55986) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3O89-0007QJ-3S; Mon, 11 Mar 2019 12:50:25 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 5B68C86674; Mon, 11 Mar 2019 16:50:24 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id B88006012C; Mon, 11 Mar 2019 16:50:22 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 11 Mar 2019 17:50:08 +0100 Message-Id: <20190311165017.32247-2-kwolf@redhat.com> In-Reply-To: <20190311165017.32247-1-kwolf@redhat.com> References: <20190311165017.32247-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 11 Mar 2019 16:50:24 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 01/10] tests/virtio-blk-test: Disable auto-read-only 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: kwolf@redhat.com, pkrempa@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" tests/virtio-blk-test uses a temporary image file that it deletes while QEMU is still running, so it can't be reopened when writers are attached or detached. Disable auto-read-only to keep it always writable. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- tests/virtio-blk-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c index b02be0274e..b65365934b 100644 --- a/tests/virtio-blk-test.c +++ b/tests/virtio-blk-test.c @@ -751,7 +751,7 @@ static void *virtio_blk_test_setup(GString *cmd_line, v= oid *arg) char *tmp_path =3D drive_create(); =20 g_string_append_printf(cmd_line, - " -drive if=3Dnone,id=3Ddrive0,file=3D%s,format= =3Draw " + " -drive if=3Dnone,id=3Ddrive0,file=3D%s,format= =3Draw,auto-read-only=3Doff " "-drive if=3Dnone,id=3Ddrive1,file=3Dnull-co://= ,format=3Draw ", tmp_path); =20 --=20 2.20.1 From nobody Wed May 1 19:20:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552323453043304.8001963274229; Mon, 11 Mar 2019 09:57:33 -0700 (PDT) Received: from localhost ([127.0.0.1]:36802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3OEz-0007wd-3O for importer@patchew.org; Mon, 11 Mar 2019 12:57:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3O9Y-0003FI-EB for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3O8C-0007Xh-DG for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:50:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59430) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3O8B-0007Uk-00; Mon, 11 Mar 2019 12:50:27 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 4595481F2F; Mon, 11 Mar 2019 16:50:26 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id A70496012C; Mon, 11 Mar 2019 16:50:24 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 11 Mar 2019 17:50:09 +0100 Message-Id: <20190311165017.32247-3-kwolf@redhat.com> In-Reply-To: <20190311165017.32247-1-kwolf@redhat.com> References: <20190311165017.32247-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 11 Mar 2019 16:50:26 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 02/10] qemu-iotests: commit to backing file with auto-read-only 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: kwolf@redhat.com, pkrempa@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- tests/qemu-iotests/232 | 31 +++++++++++++++++++++++++++++++ tests/qemu-iotests/232.out | 20 ++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232 index 71fd48eff0..0de097fc88 100755 --- a/tests/qemu-iotests/232 +++ b/tests/qemu-iotests/232 @@ -29,6 +29,7 @@ status=3D1 # failure is the default! _cleanup() { _cleanup_test_img + rm -f $TEST_IMG.[01234] } trap "_cleanup; exit \$status" 0 1 2 3 15 =20 @@ -143,6 +144,36 @@ run_qemu_info_block -blockdev driver=3Dfile,filename= =3D"$TEST_IMG",node-name=3Dnode0,a run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0,auto-read-only=3Don run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na= me=3Dnode0 =20 +echo +echo "=3D=3D=3D Try commit to backing file with auto-read-only =3D=3D=3D" +echo + +TEST_IMG=3D"$TEST_IMG.0" _make_test_img $size +TEST_IMG=3D"$TEST_IMG.1" _make_test_img $size +TEST_IMG=3D"$TEST_IMG.2" _make_test_img $size +TEST_IMG=3D"$TEST_IMG.3" _make_test_img $size +TEST_IMG=3D"$TEST_IMG.4" _make_test_img $size + +(cat < Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552323423623433.40239276224463; Mon, 11 Mar 2019 09:57:03 -0700 (PDT) Received: from localhost ([127.0.0.1]:36800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3OEV-0007U7-HW for importer@patchew.org; Mon, 11 Mar 2019 12:56:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3O9W-0003FI-Va for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:51:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3O8E-0007an-3N for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:50:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59440) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3O8D-0007Xq-23; Mon, 11 Mar 2019 12:50:29 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 3351981F09; Mon, 11 Mar 2019 16:50:28 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 926DC600CD; Mon, 11 Mar 2019 16:50:26 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 11 Mar 2019 17:50:10 +0100 Message-Id: <20190311165017.32247-4-kwolf@redhat.com> In-Reply-To: <20190311165017.32247-1-kwolf@redhat.com> References: <20190311165017.32247-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 11 Mar 2019 16:50:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 03/10] block: Avoid useless local_err 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: kwolf@redhat.com, pkrempa@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block.c b/block.c index ccf008c177..e18bd5eefd 100644 --- a/block.c +++ b/block.c @@ -3155,14 +3155,12 @@ int bdrv_reopen_multiple(AioContext *ctx, BlockReop= enQueue *bs_queue, Error **er { int ret =3D -1; BlockReopenQueueEntry *bs_entry, *next; - Error *local_err =3D NULL; =20 assert(bs_queue !=3D NULL); =20 QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) { assert(bs_entry->state.bs->quiesce_counter > 0); - if (bdrv_reopen_prepare(&bs_entry->state, bs_queue, &local_err)) { - error_propagate(errp, local_err); + if (bdrv_reopen_prepare(&bs_entry->state, bs_queue, errp)) { goto cleanup; } bs_entry->prepared =3D true; --=20 2.20.1 From nobody Wed May 1 19:20:04 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) 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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552323598529241.6159228923284; Mon, 11 Mar 2019 09:59:58 -0700 (PDT) Received: from localhost ([127.0.0.1]:36840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3OH5-0001Vo-UH for importer@patchew.org; Mon, 11 Mar 2019 12:59:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3O9V-0003FI-VB for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:51:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3O8G-0007dg-6e for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:50:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43914) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3O8E-0007bC-T9; Mon, 11 Mar 2019 12:50:31 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 24EA7307E049; Mon, 11 Mar 2019 16:50:30 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FEFD600CD; Mon, 11 Mar 2019 16:50:28 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 11 Mar 2019 17:50:11 +0100 Message-Id: <20190311165017.32247-5-kwolf@redhat.com> In-Reply-To: <20190311165017.32247-1-kwolf@redhat.com> References: <20190311165017.32247-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 11 Mar 2019 16:50:30 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 04/10] block: Make permission changes in reopen less wrong 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: kwolf@redhat.com, pkrempa@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The way that reopen interacts with permission changes has one big problem: Both operations are recursive, and the permissions are changes for each node in the reopen queue. For a simple graph that consists just of parent and child, .bdrv_check_perm will be called twice for the child, once recursively when adjusting the permissions of parent, and once again when the child itself is reopened. Even worse, the first .bdrv_check_perm call happens before .bdrv_reopen_prepare was called for the child and the second one is called afterwards. Making sure that .bdrv_check_perm (and the other permission callbacks) are called only once is hard. We can cope with multiple calls right now, but as soon as file-posix gets a dynamic auto-read-only that may need to open a new file descriptor, we get the additional requirement that all of them are after the .bdrv_reopen_prepare call. So reorder things in bdrv_reopen_multiple() to first call .bdrv_reopen_prepare for all involved nodes and only then adjust permissions. Signed-off-by: Kevin Wolf --- block.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/block.c b/block.c index e18bd5eefd..9b9d25e843 100644 --- a/block.c +++ b/block.c @@ -1698,6 +1698,7 @@ static void bdrv_child_set_perm(BdrvChild *c, uint64_= t perm, uint64_t shared); =20 typedef struct BlockReopenQueueEntry { bool prepared; + bool perms_checked; BDRVReopenState state; QSIMPLEQ_ENTRY(BlockReopenQueueEntry) entry; } BlockReopenQueueEntry; @@ -3166,6 +3167,16 @@ int bdrv_reopen_multiple(AioContext *ctx, BlockReope= nQueue *bs_queue, Error **er bs_entry->prepared =3D true; } =20 + QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) { + BDRVReopenState *state =3D &bs_entry->state; + ret =3D bdrv_check_perm(state->bs, bs_queue, state->perm, + state->shared_perm, NULL, errp); + if (ret < 0) { + goto cleanup_perm; + } + bs_entry->perms_checked =3D true; + } + /* If we reach this point, we have success and just need to apply the * changes */ @@ -3174,7 +3185,20 @@ int bdrv_reopen_multiple(AioContext *ctx, BlockReope= nQueue *bs_queue, Error **er } =20 ret =3D 0; +cleanup_perm: + QSIMPLEQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { + BDRVReopenState *state =3D &bs_entry->state; + + if (!bs_entry->perms_checked) { + continue; + } =20 + if (ret =3D=3D 0) { + bdrv_set_perm(state->bs, state->perm, state->shared_perm); + } else { + bdrv_abort_perm_update(state->bs); + } + } cleanup: QSIMPLEQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { if (ret) { @@ -3428,12 +3452,6 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_stat= e, BlockReopenQueue *queue, } while ((entry =3D qdict_next(reopen_state->options, entry))); } =20 - ret =3D bdrv_check_perm(reopen_state->bs, queue, reopen_state->perm, - reopen_state->shared_perm, NULL, errp); - if (ret < 0) { - goto error; - } - ret =3D 0; =20 /* Restore the original reopen_state->options QDict */ @@ -3500,9 +3518,6 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state) =20 bdrv_refresh_limits(bs, NULL); =20 - bdrv_set_perm(reopen_state->bs, reopen_state->perm, - reopen_state->shared_perm); - new_can_write =3D !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE); if (!old_can_write && new_can_write && drv->bdrv_reopen_bitmaps_rw) { @@ -3534,8 +3549,6 @@ void bdrv_reopen_abort(BDRVReopenState *reopen_state) if (drv->bdrv_reopen_abort) { drv->bdrv_reopen_abort(reopen_state); } - - bdrv_abort_perm_update(reopen_state->bs); } =20 =20 --=20 2.20.1 From nobody Wed May 1 19:20:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552323420139764.7576460510303; Mon, 11 Mar 2019 09:57:00 -0700 (PDT) Received: from localhost ([127.0.0.1]:36798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3OET-0007SV-2w for importer@patchew.org; Mon, 11 Mar 2019 12:56:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3O9U-0003FI-RK for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3O8I-0007fR-4L for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:50:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3O8G-0007di-OU; Mon, 11 Mar 2019 12:50:33 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 0848330821DF; Mon, 11 Mar 2019 16:50:32 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A71D600CD; Mon, 11 Mar 2019 16:50:30 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 11 Mar 2019 17:50:12 +0100 Message-Id: <20190311165017.32247-6-kwolf@redhat.com> In-Reply-To: <20190311165017.32247-1-kwolf@redhat.com> References: <20190311165017.32247-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 11 Mar 2019 16:50:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 05/10] file-posix: Fix bdrv_open_flags() for snapshot=on 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: kwolf@redhat.com, pkrempa@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Using a different read-only setting for bs->open_flags than for the flags to the driver's open function is just inconsistent and a bad idea. After this patch, the temporary snapshot keeps being opened read-only if read-only=3Don,snapshot=3Don is passed. If we wanted to change this behaviour to make only the orginal image file read-only, but the temporary overlay read-write (as the comment in the removed code suggests), that change would have to be made in bdrv_temp_snapshot_options() (where the comment suggests otherwise). Addressing this inconsistency before introducing dynamic auto-read-only is important because otherwise we would immediately try to reopen the temporary overlay even though the file is already unlinked. Signed-off-by: Kevin Wolf --- block.c | 7 ------- tests/qemu-iotests/051 | 7 +++++++ tests/qemu-iotests/051.out | 9 +++++++++ tests/qemu-iotests/051.pc.out | 9 +++++++++ 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index 9b9d25e843..33804cdcaa 100644 --- a/block.c +++ b/block.c @@ -1163,13 +1163,6 @@ static int bdrv_open_flags(BlockDriverState *bs, int= flags) */ open_flags &=3D ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_PROTOCO= L); =20 - /* - * Snapshots should be writable. - */ - if (flags & BDRV_O_TEMPORARY) { - open_flags |=3D BDRV_O_RDWR; - } - return open_flags; } =20 diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 index 3b50c7f188..151b850a8b 100755 --- a/tests/qemu-iotests/051 +++ b/tests/qemu-iotests/051 @@ -356,6 +356,13 @@ $QEMU_IO -c "read -P 0x33 0 4k" "$TEST_IMG" | _filter_= qemu_io # Using snapshot=3Don with a non-existent TMPDIR TMPDIR=3D/nonexistent run_qemu -drive driver=3Dnull-co,snapshot=3Don =20 +# Using snapshot=3Don together with read-only=3Don +echo "info block" | + run_qemu -drive file=3D"$TEST_IMG",snapshot=3Don,read-only=3Don,if=3Dn= one,id=3D$device_id | + _filter_qemu_io | + sed -e 's#"/[^"]*/vl\.[A-Za-z]\{6\}"#SNAPSHOT_PATH#g' + + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out index b900935fbc..9f1cf22608 100644 --- a/tests/qemu-iotests/051.out +++ b/tests/qemu-iotests/051.out @@ -458,4 +458,13 @@ read 4096/4096 bytes at offset 0 Testing: -drive driver=3Dnull-co,snapshot=3Don QEMU_PROG: -drive driver=3Dnull-co,snapshot=3Don: Could not get temporary = filename: No such file or directory =20 +Testing: -drive file=3DTEST_DIR/t.qcow2,snapshot=3Don,read-only=3Don,if=3D= none,id=3Ddrive0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver"= : "file", "filename": "TEST_DIR/t.qcow2"}}, "driver": "qcow2", "file": {"dr= iver": "file", "filename": SNAPSHOT_PATH}} (qcow2, read-only) + Removable device: not locked, tray closed + Cache mode: writeback, ignore flushes + Backing file: TEST_DIR/t.qcow2 (chain depth: 1) +(qemu) quit + *** done diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out index 8c5c735dfd..c4743cc31c 100644 --- a/tests/qemu-iotests/051.pc.out +++ b/tests/qemu-iotests/051.pc.out @@ -530,4 +530,13 @@ read 4096/4096 bytes at offset 0 Testing: -drive driver=3Dnull-co,snapshot=3Don QEMU_PROG: -drive driver=3Dnull-co,snapshot=3Don: Could not get temporary = filename: No such file or directory =20 +Testing: -drive file=3DTEST_DIR/t.qcow2,snapshot=3Don,read-only=3Don,if=3D= none,id=3Ddrive0 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) info block +drive0 (NODE_NAME): json:{"backing": {"driver": "qcow2", "file": {"driver"= : "file", "filename": "TEST_DIR/t.qcow2"}}, "driver": "qcow2", "file": {"dr= iver": "file", "filename": SNAPSHOT_PATH}} (qcow2, read-only) + Removable device: not locked, tray closed + Cache mode: writeback, ignore flushes + Backing file: TEST_DIR/t.qcow2 (chain depth: 1) +(qemu) quit + *** done --=20 2.20.1 From nobody Wed May 1 19:20:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552323272273451.3285878828342; Mon, 11 Mar 2019 09:54:32 -0700 (PDT) Received: from localhost ([127.0.0.1]:36738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3OC3-00053R-Af for importer@patchew.org; Mon, 11 Mar 2019 12:54:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3O9S-00037v-3K for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:51:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3O8K-0007gx-2V for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:50:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46864) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3O8I-0007fP-LS; Mon, 11 Mar 2019 12:50:34 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id E70833004425; Mon, 11 Mar 2019 16:50:33 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54116600CD; Mon, 11 Mar 2019 16:50:32 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 11 Mar 2019 17:50:13 +0100 Message-Id: <20190311165017.32247-7-kwolf@redhat.com> In-Reply-To: <20190311165017.32247-1-kwolf@redhat.com> References: <20190311165017.32247-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 11 Mar 2019 16:50:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 06/10] file-posix: Factor out raw_reconfigure_getfd() 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: kwolf@redhat.com, pkrempa@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf --- block/file-posix.c | 107 ++++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 45 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index ba6ab62a38..ae57ba1fc6 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -842,6 +842,62 @@ static int raw_handle_perm_lock(BlockDriverState *bs, return ret; } =20 +static int raw_reconfigure_getfd(BlockDriverState *bs, int flags, + int *open_flags, Error **errp) +{ + BDRVRawState *s =3D bs->opaque; + int fd =3D -1; + int ret; + int fcntl_flags =3D O_APPEND | O_NONBLOCK; +#ifdef O_NOATIME + fcntl_flags |=3D O_NOATIME; +#endif + + *open_flags =3D 0; + if (s->type =3D=3D FTYPE_CD) { + *open_flags |=3D O_NONBLOCK; + } + + raw_parse_flags(flags, open_flags); + +#ifdef O_ASYNC + /* Not all operating systems have O_ASYNC, and those that don't + * will not let us track the state into rs->open_flags (typically + * you achieve the same effect with an ioctl, for example I_SETSIG + * on Solaris). But we do not use O_ASYNC, so that's fine. + */ + assert((s->open_flags & O_ASYNC) =3D=3D 0); +#endif + + if ((*open_flags & ~fcntl_flags) =3D=3D (s->open_flags & ~fcntl_flags)= ) { + /* dup the original fd */ + fd =3D qemu_dup(s->fd); + if (fd >=3D 0) { + ret =3D fcntl_setfl(fd, *open_flags); + if (ret) { + qemu_close(fd); + fd =3D -1; + } + } + } + + /* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */ + if (fd =3D=3D -1) { + const char *normalized_filename =3D bs->filename; + ret =3D raw_normalize_devicepath(&normalized_filename, errp); + if (ret >=3D 0) { + assert(!(*open_flags & O_CREAT)); + fd =3D qemu_open(normalized_filename, *open_flags); + if (fd =3D=3D -1) { + error_setg_errno(errp, errno, "Could not reopen file"); + return -1; + } + } + } + + return fd; +} + static int raw_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { @@ -858,7 +914,6 @@ static int raw_reopen_prepare(BDRVReopenState *state, =20 state->opaque =3D g_new0(BDRVRawReopenState, 1); rs =3D state->opaque; - rs->fd =3D -1; =20 /* Handle options changes */ opts =3D qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); @@ -877,50 +932,12 @@ static int raw_reopen_prepare(BDRVReopenState *state, * bdrv_reopen_prepare() will detect changes and complain. */ qemu_opts_to_qdict(opts, state->options); =20 - if (s->type =3D=3D FTYPE_CD) { - rs->open_flags |=3D O_NONBLOCK; - } - - raw_parse_flags(state->flags, &rs->open_flags); - - int fcntl_flags =3D O_APPEND | O_NONBLOCK; -#ifdef O_NOATIME - fcntl_flags |=3D O_NOATIME; -#endif - -#ifdef O_ASYNC - /* Not all operating systems have O_ASYNC, and those that don't - * will not let us track the state into rs->open_flags (typically - * you achieve the same effect with an ioctl, for example I_SETSIG - * on Solaris). But we do not use O_ASYNC, so that's fine. - */ - assert((s->open_flags & O_ASYNC) =3D=3D 0); -#endif - - if ((rs->open_flags & ~fcntl_flags) =3D=3D (s->open_flags & ~fcntl_fla= gs)) { - /* dup the original fd */ - rs->fd =3D qemu_dup(s->fd); - if (rs->fd >=3D 0) { - ret =3D fcntl_setfl(rs->fd, rs->open_flags); - if (ret) { - qemu_close(rs->fd); - rs->fd =3D -1; - } - } - } - - /* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */ - if (rs->fd =3D=3D -1) { - const char *normalized_filename =3D state->bs->filename; - ret =3D raw_normalize_devicepath(&normalized_filename, errp); - if (ret >=3D 0) { - assert(!(rs->open_flags & O_CREAT)); - rs->fd =3D qemu_open(normalized_filename, rs->open_flags); - if (rs->fd =3D=3D -1) { - error_setg_errno(errp, errno, "Could not reopen file"); - ret =3D -1; - } - } + rs->fd =3D raw_reconfigure_getfd(state->bs, state->flags, &rs->open_fl= ags, + &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret =3D -1; + goto out; } =20 /* Fail already reopen_prepare() if we can't get a working O_DIRECT --=20 2.20.1 From nobody Wed May 1 19:20:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552323467279316.7357580514346; Mon, 11 Mar 2019 09:57:47 -0700 (PDT) Received: from localhost ([127.0.0.1]:36804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3OFE-0008Bj-Ah for importer@patchew.org; Mon, 11 Mar 2019 12:57:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3O9Q-00037v-BU for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:51:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3O8L-0007iE-KU for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:50:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60278) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3O8K-0007gt-I7; Mon, 11 Mar 2019 12:50:36 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id D06882DE20; Mon, 11 Mar 2019 16:50:35 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E7C5600CD; Mon, 11 Mar 2019 16:50:34 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 11 Mar 2019 17:50:14 +0100 Message-Id: <20190311165017.32247-8-kwolf@redhat.com> In-Reply-To: <20190311165017.32247-1-kwolf@redhat.com> References: <20190311165017.32247-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 11 Mar 2019 16:50:35 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 07/10] file-posix: Store BDRVRawState.reopen_state during reopen 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: kwolf@redhat.com, pkrempa@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We'll want to access the file descriptor in the reopen_state while processing permission changes in the context of the repoen. Signed-off-by: Kevin Wolf --- block/file-posix.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index ae57ba1fc6..6aaee1df16 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -144,6 +144,8 @@ typedef struct BDRVRawState { uint64_t locked_perm; uint64_t locked_shared_perm; =20 + BDRVReopenState *reopen_state; + #ifdef CONFIG_XFS bool is_xfs:1; #endif @@ -952,6 +954,7 @@ static int raw_reopen_prepare(BDRVReopenState *state, } } =20 + s->reopen_state =3D state; out: qemu_opts_del(opts); return ret; @@ -978,12 +981,16 @@ static void raw_reopen_commit(BDRVReopenState *state) =20 g_free(state->opaque); state->opaque =3D NULL; + + assert(s->reopen_state =3D=3D state); + s->reopen_state =3D NULL; } =20 =20 static void raw_reopen_abort(BDRVReopenState *state) { BDRVRawReopenState *rs =3D state->opaque; + BDRVRawState *s =3D state->bs->opaque; =20 /* nothing to do if NULL, we didn't get far enough */ if (rs =3D=3D NULL) { @@ -996,6 +1003,9 @@ static void raw_reopen_abort(BDRVReopenState *state) } g_free(state->opaque); state->opaque =3D NULL; + + assert(s->reopen_state =3D=3D state); + s->reopen_state =3D NULL; } =20 static int hdev_get_max_transfer_length(BlockDriverState *bs, int fd) --=20 2.20.1 From nobody Wed May 1 19:20:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552323240876882.2012477111786; Mon, 11 Mar 2019 09:54:00 -0700 (PDT) Received: from localhost ([127.0.0.1]:36736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3OBW-0004bZ-3h for importer@patchew.org; Mon, 11 Mar 2019 12:53:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3O9O-00037v-Ji for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3O8N-0007kS-H4 for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:50:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63232) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3O8M-0007id-FE; Mon, 11 Mar 2019 12:50:38 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id BBD6681F10; Mon, 11 Mar 2019 16:50:37 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29868600CD; Mon, 11 Mar 2019 16:50:35 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 11 Mar 2019 17:50:15 +0100 Message-Id: <20190311165017.32247-9-kwolf@redhat.com> In-Reply-To: <20190311165017.32247-1-kwolf@redhat.com> References: <20190311165017.32247-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 11 Mar 2019 16:50:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 08/10] file-posix: Lock new fd in raw_reopen_prepare() 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: kwolf@redhat.com, pkrempa@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" There is no reason why we can take locks on the new file descriptor only in raw_reopen_commit() where error handling isn't possible any more. Instead, we can already do this in raw_reopen_prepare(). Signed-off-by: Kevin Wolf --- block/file-posix.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 6aaee1df16..932cc8e58c 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -906,7 +906,7 @@ static int raw_reopen_prepare(BDRVReopenState *state, BDRVRawState *s; BDRVRawReopenState *rs; QemuOpts *opts; - int ret =3D 0; + int ret; Error *local_err =3D NULL; =20 assert(state !=3D NULL); @@ -947,14 +947,27 @@ static int raw_reopen_prepare(BDRVReopenState *state, if (rs->fd !=3D -1) { raw_probe_alignment(state->bs, rs->fd, &local_err); if (local_err) { - qemu_close(rs->fd); - rs->fd =3D -1; error_propagate(errp, local_err); ret =3D -EINVAL; + goto out_fd; + } + + /* Copy locks to the new fd */ + ret =3D raw_apply_lock_bytes(NULL, rs->fd, s->locked_perm, + s->locked_shared_perm, false, errp); + if (ret < 0) { + ret =3D -EINVAL; + goto out_fd; } } =20 s->reopen_state =3D state; + ret =3D 0; +out_fd: + if (ret < 0) { + qemu_close(rs->fd); + rs->fd =3D -1; + } out: qemu_opts_del(opts); return ret; @@ -964,18 +977,10 @@ static void raw_reopen_commit(BDRVReopenState *state) { BDRVRawReopenState *rs =3D state->opaque; BDRVRawState *s =3D state->bs->opaque; - Error *local_err =3D NULL; =20 s->check_cache_dropped =3D rs->check_cache_dropped; s->open_flags =3D rs->open_flags; =20 - /* Copy locks to the new fd before closing the old one. */ - raw_apply_lock_bytes(NULL, rs->fd, s->locked_perm, - s->locked_shared_perm, false, &local_err); - if (local_err) { - /* shouldn't fail in a sane host, but report it just in case. */ - error_report_err(local_err); - } qemu_close(s->fd); s->fd =3D rs->fd; =20 --=20 2.20.1 From nobody Wed May 1 19:20:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 155232324133390.29636589132247; Mon, 11 Mar 2019 09:54:01 -0700 (PDT) Received: from localhost ([127.0.0.1]:36734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3OBU-0004ZR-5A for importer@patchew.org; Mon, 11 Mar 2019 12:53:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3O9K-00037v-J3 for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:51:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3O8P-0007lt-Pi for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:50:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56800) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3O8O-0007kf-DS; Mon, 11 Mar 2019 12:50:40 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id A774D155AC; Mon, 11 Mar 2019 16:50:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 146D8600CD; Mon, 11 Mar 2019 16:50:37 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 11 Mar 2019 17:50:16 +0100 Message-Id: <20190311165017.32247-10-kwolf@redhat.com> In-Reply-To: <20190311165017.32247-1-kwolf@redhat.com> References: <20190311165017.32247-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 11 Mar 2019 16:50:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 09/10] file-posix: Prepare permission code for fd switching 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: kwolf@redhat.com, pkrempa@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In order to be able to dynamically reopen the file read-only or read-write, depending on the users that are attached, we need to be able to switch to a different file descriptor during the permission change. This interacts with reopen, which also creates a new file descriptor and performs permission changes internally. In this case, the permission change code must reuse the reopen file descriptor instead of creating a third one. In turn, reopen can drop its code to copy file locks to the new file descriptor because that is now done when applying the new permissions. Signed-off-by: Kevin Wolf --- block/file-posix.c | 96 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 11 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 932cc8e58c..e41e0779c6 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -144,6 +144,7 @@ typedef struct BDRVRawState { uint64_t locked_perm; uint64_t locked_shared_perm; =20 + int perm_change_fd; BDRVReopenState *reopen_state; =20 #ifdef CONFIG_XFS @@ -845,7 +846,8 @@ static int raw_handle_perm_lock(BlockDriverState *bs, } =20 static int raw_reconfigure_getfd(BlockDriverState *bs, int flags, - int *open_flags, Error **errp) + int *open_flags, bool force_dup, + Error **errp) { BDRVRawState *s =3D bs->opaque; int fd =3D -1; @@ -871,6 +873,11 @@ static int raw_reconfigure_getfd(BlockDriverState *bs,= int flags, assert((s->open_flags & O_ASYNC) =3D=3D 0); #endif =20 + if (!force_dup && *open_flags =3D=3D s->open_flags) { + /* We're lucky, the existing fd is fine */ + return s->fd; + } + if ((*open_flags & ~fcntl_flags) =3D=3D (s->open_flags & ~fcntl_flags)= ) { /* dup the original fd */ fd =3D qemu_dup(s->fd); @@ -935,7 +942,7 @@ static int raw_reopen_prepare(BDRVReopenState *state, qemu_opts_to_qdict(opts, state->options); =20 rs->fd =3D raw_reconfigure_getfd(state->bs, state->flags, &rs->open_fl= ags, - &local_err); + true, &local_err); if (local_err) { error_propagate(errp, local_err); ret =3D -1; @@ -951,14 +958,6 @@ static int raw_reopen_prepare(BDRVReopenState *state, ret =3D -EINVAL; goto out_fd; } - - /* Copy locks to the new fd */ - ret =3D raw_apply_lock_bytes(NULL, rs->fd, s->locked_perm, - s->locked_shared_perm, false, errp); - if (ret < 0) { - ret =3D -EINVAL; - goto out_fd; - } } =20 s->reopen_state =3D state; @@ -2696,12 +2695,78 @@ static QemuOptsList raw_create_opts =3D { static int raw_check_perm(BlockDriverState *bs, uint64_t perm, uint64_t sh= ared, Error **errp) { - return raw_handle_perm_lock(bs, RAW_PL_PREPARE, perm, shared, errp); + BDRVRawState *s =3D bs->opaque; + BDRVRawReopenState *rs =3D NULL; + int open_flags; + int ret; + + if (s->perm_change_fd) { + /* + * In the context of reopen, this function may be called several t= imes + * (directly and recursively while change permissions of the paren= t). + * This is even true for children that don't inherit from the orig= inal + * reopen node, so s->reopen_state is not set. + * + * Ignore all but the first call. + */ + return 0; + } + + if (s->reopen_state) { + /* We already have a new file descriptor to set permissions for */ + assert(s->reopen_state->perm =3D=3D perm); + assert(s->reopen_state->shared_perm =3D=3D shared); + rs =3D s->reopen_state->opaque; + s->perm_change_fd =3D rs->fd; + } else { + /* We may need a new fd if auto-read-only switches the mode */ + ret =3D raw_reconfigure_getfd(bs, bs->open_flags, &open_flags, + false, errp); + if (ret < 0) { + return ret; + } else if (ret !=3D s->fd) { + s->perm_change_fd =3D ret; + } + } + + /* Prepare permissions on old fd to avoid conflicts between old and ne= w, + * but keep everything locked that new will need. */ + ret =3D raw_handle_perm_lock(bs, RAW_PL_PREPARE, perm, shared, errp); + if (ret < 0) { + goto fail; + } + + /* Copy locks to the new fd */ + if (s->perm_change_fd) { + ret =3D raw_apply_lock_bytes(NULL, s->perm_change_fd, perm, ~share= d, + false, errp); + if (ret < 0) { + raw_handle_perm_lock(bs, RAW_PL_ABORT, 0, 0, NULL); + goto fail; + } + } + return 0; + +fail: + if (s->perm_change_fd && !s->reopen_state) { + qemu_close(s->perm_change_fd); + } + s->perm_change_fd =3D 0; + return ret; } =20 static void raw_set_perm(BlockDriverState *bs, uint64_t perm, uint64_t sha= red) { BDRVRawState *s =3D bs->opaque; + + /* For reopen, we have already switched to the new fd (.bdrv_set_perm = is + * called after .bdrv_reopen_commit) */ + if (s->perm_change_fd && s->fd !=3D s->perm_change_fd) { + qemu_close(s->fd); + s->fd =3D s->perm_change_fd; + } + s->perm_change_fd =3D 0; + raw_handle_perm_lock(bs, RAW_PL_COMMIT, perm, shared, NULL); s->perm =3D perm; s->shared_perm =3D shared; @@ -2709,6 +2774,15 @@ static void raw_set_perm(BlockDriverState *bs, uint6= 4_t perm, uint64_t shared) =20 static void raw_abort_perm_update(BlockDriverState *bs) { + BDRVRawState *s =3D bs->opaque; + + /* For reopen, .bdrv_reopen_abort is called afterwards and will close + * the file descriptor. */ + if (s->perm_change_fd && !s->reopen_state) { + qemu_close(s->perm_change_fd); + } + s->perm_change_fd =3D 0; + raw_handle_perm_lock(bs, RAW_PL_ABORT, 0, 0, NULL); } =20 --=20 2.20.1 From nobody Wed May 1 19:20:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552323239904871.9690319373087; Mon, 11 Mar 2019 09:53:59 -0700 (PDT) Received: from localhost ([127.0.0.1]:36732 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3OBQ-0004WK-If for importer@patchew.org; Mon, 11 Mar 2019 12:53:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3O9I-00037v-4c for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:51:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3O8R-0007nO-Rb for qemu-devel@nongnu.org; Mon, 11 Mar 2019 12:50:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54490) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3O8Q-0007lq-AG; Mon, 11 Mar 2019 12:50:42 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 92CD3318A5FF; Mon, 11 Mar 2019 16:50:41 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-234.ams2.redhat.com [10.36.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3CAF600CD; Mon, 11 Mar 2019 16:50:39 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 11 Mar 2019 17:50:17 +0100 Message-Id: <20190311165017.32247-11-kwolf@redhat.com> In-Reply-To: <20190311165017.32247-1-kwolf@redhat.com> References: <20190311165017.32247-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 11 Mar 2019 16:50:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 10/10] file-posix: Make auto-read-only dynamic 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: kwolf@redhat.com, pkrempa@redhat.com, berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Until now, with auto-read-only=3Don we tried to open the file read-write first and if that failed, read-only was tried. This is actually not good enough for libvirt, which gives QEMU SELinux permissions for read-write only as soon as it actually intends to write to the image. So we need to be able to switch between read-only and read-write at runtime. This patch makes auto-read-only dynamic, i.e. the file is opened read-only as long as no user of the node has requested write permissions, but it is automatically reopened read-write as soon as the first writer is attached. Conversely, if the last writer goes away, the file is reopened read-only again. bs->read_only is no longer set for auto-read-only=3Don files even if the file descriptor is opened read-only because it will be transparently upgraded as soon as a writer is attached. This changes the output of qemu-iotests 232. Signed-off-by: Kevin Wolf --- block/file-posix.c | 36 +++++++++++++++++------------------- tests/qemu-iotests/232.out | 12 ++++++------ 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index e41e0779c6..d41059d139 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -376,13 +376,21 @@ static void raw_probe_alignment(BlockDriverState *bs,= int fd, Error **errp) } } =20 -static void raw_parse_flags(int bdrv_flags, int *open_flags) +static void raw_parse_flags(int bdrv_flags, int *open_flags, bool has_writ= ers) { + bool read_write =3D false; assert(open_flags !=3D NULL); =20 *open_flags |=3D O_BINARY; *open_flags &=3D ~O_ACCMODE; - if (bdrv_flags & BDRV_O_RDWR) { + + if (bdrv_flags & BDRV_O_AUTO_RDONLY) { + read_write =3D has_writers; + } else if (bdrv_flags & BDRV_O_RDWR) { + read_write =3D true; + } + + if (read_write) { *open_flags |=3D O_RDWR; } else { *open_flags |=3D O_RDONLY; @@ -518,24 +526,12 @@ static int raw_open_common(BlockDriverState *bs, QDic= t *options, false); =20 s->open_flags =3D open_flags; - raw_parse_flags(bdrv_flags, &s->open_flags); + raw_parse_flags(bdrv_flags, &s->open_flags, false); =20 s->fd =3D -1; fd =3D qemu_open(filename, s->open_flags, 0644); ret =3D fd < 0 ? -errno : 0; =20 - if (ret =3D=3D -EACCES || ret =3D=3D -EROFS) { - /* Try to degrade to read-only, but if it doesn't work, still use = the - * normal error message. */ - if (bdrv_apply_auto_read_only(bs, NULL, NULL) =3D=3D 0) { - bdrv_flags &=3D ~BDRV_O_RDWR; - raw_parse_flags(bdrv_flags, &s->open_flags); - assert(!(s->open_flags & O_CREAT)); - fd =3D qemu_open(filename, s->open_flags); - ret =3D fd < 0 ? -errno : 0; - } - } - if (ret < 0) { error_setg_errno(errp, -ret, "Could not open '%s'", filename); if (ret =3D=3D -EROFS) { @@ -846,12 +842,14 @@ static int raw_handle_perm_lock(BlockDriverState *bs, } =20 static int raw_reconfigure_getfd(BlockDriverState *bs, int flags, - int *open_flags, bool force_dup, + int *open_flags, uint64_t perm, bool forc= e_dup, Error **errp) { BDRVRawState *s =3D bs->opaque; int fd =3D -1; int ret; + bool has_writers =3D perm & + (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED | BLK_PERM_RESIZE); int fcntl_flags =3D O_APPEND | O_NONBLOCK; #ifdef O_NOATIME fcntl_flags |=3D O_NOATIME; @@ -862,7 +860,7 @@ static int raw_reconfigure_getfd(BlockDriverState *bs, = int flags, *open_flags |=3D O_NONBLOCK; } =20 - raw_parse_flags(flags, open_flags); + raw_parse_flags(flags, open_flags, has_writers); =20 #ifdef O_ASYNC /* Not all operating systems have O_ASYNC, and those that don't @@ -942,7 +940,7 @@ static int raw_reopen_prepare(BDRVReopenState *state, qemu_opts_to_qdict(opts, state->options); =20 rs->fd =3D raw_reconfigure_getfd(state->bs, state->flags, &rs->open_fl= ags, - true, &local_err); + state->perm, true, &local_err); if (local_err) { error_propagate(errp, local_err); ret =3D -1; @@ -2720,7 +2718,7 @@ static int raw_check_perm(BlockDriverState *bs, uint6= 4_t perm, uint64_t shared, s->perm_change_fd =3D rs->fd; } else { /* We may need a new fd if auto-read-only switches the mode */ - ret =3D raw_reconfigure_getfd(bs, bs->open_flags, &open_flags, + ret =3D raw_reconfigure_getfd(bs, bs->open_flags, &open_flags, per= m, false, errp); if (ret < 0) { return ret; diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out index 5036ef13d4..5bcc44bb62 100644 --- a/tests/qemu-iotests/232.out +++ b/tests/qemu-iotests/232.out @@ -22,12 +22,12 @@ NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) =20 QEMU_PROG: -drive driver=3Dfile,file=3DTEST_DIR/t.IMGFMT,if=3Dnone,read-on= ly=3Doff,auto-read-only=3Doff: Could not open 'TEST_DIR/t.IMGFMT': Permissi= on denied -NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) -NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) =20 QEMU_PROG: -drive driver=3Dfile,file=3DTEST_DIR/t.IMGFMT,if=3Dnone,auto-re= ad-only=3Doff: Could not open 'TEST_DIR/t.IMGFMT': Permission denied -NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) -NODE_NAME: TEST_DIR/t.IMGFMT (file, read-only) +NODE_NAME: TEST_DIR/t.IMGFMT (file) +NODE_NAME: TEST_DIR/t.IMGFMT (file) =20 =3D=3D=3D -blockdev with read-write image: read-only/auto-read-only combin= ations =3D=3D=3D =20 @@ -50,11 +50,11 @@ node0: TEST_DIR/t.IMGFMT (file, read-only) node0: TEST_DIR/t.IMGFMT (file, read-only) =20 QEMU_PROG: -blockdev driver=3Dfile,filename=3DTEST_DIR/t.IMGFMT,node-name= =3Dnode0,read-only=3Doff,auto-read-only=3Doff: Could not open 'TEST_DIR/t.I= MGFMT': Permission denied -node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file) QEMU_PROG: -blockdev driver=3Dfile,filename=3DTEST_DIR/t.IMGFMT,node-name= =3Dnode0,read-only=3Doff: Could not open 'TEST_DIR/t.IMGFMT': Permission de= nied =20 QEMU_PROG: -blockdev driver=3Dfile,filename=3DTEST_DIR/t.IMGFMT,node-name= =3Dnode0,auto-read-only=3Doff: Could not open 'TEST_DIR/t.IMGFMT': Permissi= on denied -node0: TEST_DIR/t.IMGFMT (file, read-only) +node0: TEST_DIR/t.IMGFMT (file) QEMU_PROG: -blockdev driver=3Dfile,filename=3DTEST_DIR/t.IMGFMT,node-name= =3Dnode0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied =20 =3D=3D=3D Try commit to backing file with auto-read-only =3D=3D=3D --=20 2.20.1