From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436184719802.5079983879259;
 Mon, 5 Nov 2018 08:43:04 -0800 (PST)
Received: from localhost ([::1]:36180 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJhxv-0003Xg-5y
	for importer@patchew.org; Mon, 05 Nov 2018 11:43:03 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50274)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtC-0006q3-OF
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:12 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJht6-0002ts-1Z
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:06 -0500
Received: from mx1.redhat.com ([209.132.183.28]:42608)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJht2-0002M3-FY; Mon, 05 Nov 2018 11:38:00 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 5617D308FE92;
	Mon,  5 Nov 2018 16:37:53 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 3D00660C5C;
	Mon,  5 Nov 2018 16:37:52 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:09 +0100
Message-Id: <20181105163744.25139-2-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.49]);
	Mon, 05 Nov 2018 16:37:53 +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] [PULL 01/36] block/vvfat: Fix crash when reporting
 error about too many files in directory
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Thomas Huth <thuth@redhat.com>

When using the vvfat driver with a directory that contains too many files,
QEMU currently crashes. This can be triggered like this for example:

 mkdir /tmp/vvfattest
 cd /tmp/vvfattest
 for ((x=3D0;x<=3D513;x++)); do mkdir $x; done
 qemu-system-x86_64 -drive \
   file.driver=3Dvvfat,file.dir=3D.,read-only=3Don,media=3Dcdrom

Seems like read_directory() is changing the mapping->path variable. Make
sure we use the right pointer instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/vvfat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/vvfat.c b/block/vvfat.c
index fc41841a5c..f2e7d501cf 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -973,10 +973,10 @@ static int init_directories(BDRVVVFATState* s,
         mapping =3D array_get(&(s->mapping), i);
=20
         if (mapping->mode & MODE_DIRECTORY) {
+            char *path =3D mapping->path;
             mapping->begin =3D cluster;
             if(read_directory(s, i)) {
-                error_setg(errp, "Could not read directory %s",
-                           mapping->path);
+                error_setg(errp, "Could not read directory %s", path);
                 return -1;
             }
             mapping =3D array_get(&(s->mapping), i);
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436012698312.0662299291182;
 Mon, 5 Nov 2018 08:40:12 -0800 (PST)
Received: from localhost ([::1]:36162 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJhv8-0008M5-Rq
	for importer@patchew.org; Mon, 05 Nov 2018 11:40:10 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50132)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJht5-0006l8-Cw
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:05 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJht3-0002jj-Gr
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:03 -0500
Received: from mx1.redhat.com ([209.132.183.28]:42630)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJht0-0002Od-2R; Mon, 05 Nov 2018 11:37:58 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id AFBD23081248;
	Mon,  5 Nov 2018 16:37:54 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 98A9860C5C;
	Mon,  5 Nov 2018 16:37:53 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:10 +0100
Message-Id: <20181105163744.25139-3-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.49]);
	Mon, 05 Nov 2018 16:37:54 +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] [PULL 02/36] block: replace "discard" literal with
 BDRV_OPT_DISCARD macro
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Alberto Garcia <berto@igalia.com>

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index 95d8635aa1..9d2adf7962 100644
--- a/block.c
+++ b/block.c
@@ -1327,7 +1327,7 @@ QemuOptsList bdrv_runtime_opts =3D {
             .help =3D "try to optimize zero writes (off, on, unmap)",
         },
         {
-            .name =3D "discard",
+            .name =3D BDRV_OPT_DISCARD,
             .type =3D QEMU_OPT_STRING,
             .help =3D "discard operation (ignore/off, unmap/on)",
         },
@@ -1432,7 +1432,7 @@ static int bdrv_open_common(BlockDriverState *bs, Blo=
ckBackend *file,
         }
     }
=20
-    discard =3D qemu_opt_get(opts, "discard");
+    discard =3D qemu_opt_get(opts, BDRV_OPT_DISCARD);
     if (discard !=3D NULL) {
         if (bdrv_parse_discard_flags(discard, &bs->open_flags) !=3D 0) {
             error_setg(errp, "Invalid discard option");
@@ -3186,7 +3186,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state=
, BlockReopenQueue *queue,
=20
     update_flags_from_options(&reopen_state->flags, opts);
=20
-    discard =3D qemu_opt_get_del(opts, "discard");
+    discard =3D qemu_opt_get_del(opts, BDRV_OPT_DISCARD);
     if (discard !=3D NULL) {
         if (bdrv_parse_discard_flags(discard, &reopen_state->flags) !=3D 0=
) {
             error_setg(errp, "Invalid discard option");
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436015383526.1594913873066;
 Mon, 5 Nov 2018 08:40:15 -0800 (PST)
Received: from localhost ([::1]:36161 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJhv7-0008L0-EX
	for importer@patchew.org; Mon, 05 Nov 2018 11:40:09 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50107)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJht4-0006kg-O9
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:05 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJht3-0002jM-FW
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:02 -0500
Received: from mx1.redhat.com ([209.132.183.28]:51188)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhsz-0002T8-MZ; Mon, 05 Nov 2018 11:37:57 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 1963B85A04;
	Mon,  5 Nov 2018 16:37:56 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 0590060C46;
	Mon,  5 Nov 2018 16:37:54 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:11 +0100
Message-Id: <20181105163744.25139-4-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.26]);
	Mon, 05 Nov 2018 16:37:56 +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] [PULL 03/36] qemu-io-cmds: Fix two format strings
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Stefan Weil <sw@weilnetz.de>

Use %zu instead of %zd for unsigned numbers.

This fixes two error messages from the LSTM static code analyzer:

    This argument should be of type 'ssize_t' but is of type 'unsigned long'

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Philippe Mathieu-Daud=C3=A9 <f4bug@amsat.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu-io-cmds.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index db0b3ee5ef..5363482213 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -907,7 +907,7 @@ static int readv_f(BlockBackend *blk, int argc, char **=
argv)
         memset(cmp_buf, pattern, qiov.size);
         if (memcmp(buf, cmp_buf, qiov.size)) {
             printf("Pattern verification failed at offset %"
-                   PRId64 ", %zd bytes\n", offset, qiov.size);
+                   PRId64 ", %zu bytes\n", offset, qiov.size);
             ret =3D -EINVAL;
         }
         g_free(cmp_buf);
@@ -1294,7 +1294,7 @@ static void aio_read_done(void *opaque, int ret)
         memset(cmp_buf, ctx->pattern, ctx->qiov.size);
         if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) {
             printf("Pattern verification failed at offset %"
-                   PRId64 ", %zd bytes\n", ctx->offset, ctx->qiov.size);
+                   PRId64 ", %zu bytes\n", ctx->offset, ctx->qiov.size);
         }
         g_free(cmp_buf);
     }
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436301777696.6657101159474;
 Mon, 5 Nov 2018 08:45:01 -0800 (PST)
Received: from localhost ([::1]:36195 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJhzo-00076m-I9
	for importer@patchew.org; Mon, 05 Nov 2018 11:45:00 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50373)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtJ-0006x5-8P
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:22 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtH-0003V3-As
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:17 -0500
Received: from mx1.redhat.com ([209.132.183.28]:36318)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJht2-0002Xx-KB; Mon, 05 Nov 2018 11:38:01 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 86ECB3091751;
	Mon,  5 Nov 2018 16:37:57 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 6754560C46;
	Mon,  5 Nov 2018 16:37:56 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:12 +0100
Message-Id: <20181105163744.25139-5-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.41]);
	Mon, 05 Nov 2018 16:37:57 +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] [PULL 04/36] block/qcow2: Don't take address of fields
 in packed structs
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Peter Maydell <peter.maydell@linaro.org>

Taking the address of a field in a packed struct is a bad idea, because
it might not be actually aligned enough for that pointer type (and
thus cause a crash on dereference on some host architectures). Newer
versions of clang warn about this. Avoid the bug by not using the
"modify in place" byte swapping functions.

There are a few places where the in-place swap function is
used on something other than a packed struct field; we convert
those anyway, for consistency.

This patch was produced with the following spatch script
(and hand-editing to fold a few resulting overlength lines):

@@
expression E;
@@
-be16_to_cpus(&E);
+E =3D be16_to_cpu(E);
@@
expression E;
@@
-be32_to_cpus(&E);
+E =3D be32_to_cpu(E);
@@
expression E;
@@
-be64_to_cpus(&E);
+E =3D be64_to_cpu(E);
@@
expression E;
@@
-cpu_to_be16s(&E);
+E =3D cpu_to_be16(E);
@@
expression E;
@@
-cpu_to_be32s(&E);
+E =3D cpu_to_be32(E);
@@
expression E;
@@
-cpu_to_be64s(&E);
+E =3D cpu_to_be64(E);

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: John Snow <jsnow@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qcow2.c | 64 +++++++++++++++++++++++++++------------------------
 1 file changed, 34 insertions(+), 30 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 30689b7688..de94b290e6 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -210,8 +210,8 @@ static int qcow2_read_extensions(BlockDriverState *bs, =
uint64_t start_offset,
                              "pread fail from offset %" PRIu64, offset);
             return 1;
         }
-        be32_to_cpus(&ext.magic);
-        be32_to_cpus(&ext.len);
+        ext.magic =3D be32_to_cpu(ext.magic);
+        ext.len =3D be32_to_cpu(ext.len);
         offset +=3D sizeof(ext);
 #ifdef DEBUG_EXT
         printf("ext.magic =3D 0x%x\n", ext.magic);
@@ -279,8 +279,8 @@ static int qcow2_read_extensions(BlockDriverState *bs, =
uint64_t start_offset,
                                  "Unable to read CRYPTO header extension");
                 return ret;
             }
-            be64_to_cpus(&s->crypto_header.offset);
-            be64_to_cpus(&s->crypto_header.length);
+            s->crypto_header.offset =3D be64_to_cpu(s->crypto_header.offse=
t);
+            s->crypto_header.length =3D be64_to_cpu(s->crypto_header.lengt=
h);
=20
             if ((s->crypto_header.offset % s->cluster_size) !=3D 0) {
                 error_setg(errp, "Encryption header offset '%" PRIu64 "' i=
s "
@@ -342,9 +342,11 @@ static int qcow2_read_extensions(BlockDriverState *bs,=
 uint64_t start_offset,
                 return -EINVAL;
             }
=20
-            be32_to_cpus(&bitmaps_ext.nb_bitmaps);
-            be64_to_cpus(&bitmaps_ext.bitmap_directory_size);
-            be64_to_cpus(&bitmaps_ext.bitmap_directory_offset);
+            bitmaps_ext.nb_bitmaps =3D be32_to_cpu(bitmaps_ext.nb_bitmaps);
+            bitmaps_ext.bitmap_directory_size =3D
+                be64_to_cpu(bitmaps_ext.bitmap_directory_size);
+            bitmaps_ext.bitmap_directory_offset =3D
+                be64_to_cpu(bitmaps_ext.bitmap_directory_offset);
=20
             if (bitmaps_ext.nb_bitmaps > QCOW2_MAX_BITMAPS) {
                 error_setg(errp,
@@ -1159,19 +1161,20 @@ static int coroutine_fn qcow2_do_open(BlockDriverSt=
ate *bs, QDict *options,
         error_setg_errno(errp, -ret, "Could not read qcow2 header");
         goto fail;
     }
-    be32_to_cpus(&header.magic);
-    be32_to_cpus(&header.version);
-    be64_to_cpus(&header.backing_file_offset);
-    be32_to_cpus(&header.backing_file_size);
-    be64_to_cpus(&header.size);
-    be32_to_cpus(&header.cluster_bits);
-    be32_to_cpus(&header.crypt_method);
-    be64_to_cpus(&header.l1_table_offset);
-    be32_to_cpus(&header.l1_size);
-    be64_to_cpus(&header.refcount_table_offset);
-    be32_to_cpus(&header.refcount_table_clusters);
-    be64_to_cpus(&header.snapshots_offset);
-    be32_to_cpus(&header.nb_snapshots);
+    header.magic =3D be32_to_cpu(header.magic);
+    header.version =3D be32_to_cpu(header.version);
+    header.backing_file_offset =3D be64_to_cpu(header.backing_file_offset);
+    header.backing_file_size =3D be32_to_cpu(header.backing_file_size);
+    header.size =3D be64_to_cpu(header.size);
+    header.cluster_bits =3D be32_to_cpu(header.cluster_bits);
+    header.crypt_method =3D be32_to_cpu(header.crypt_method);
+    header.l1_table_offset =3D be64_to_cpu(header.l1_table_offset);
+    header.l1_size =3D be32_to_cpu(header.l1_size);
+    header.refcount_table_offset =3D be64_to_cpu(header.refcount_table_off=
set);
+    header.refcount_table_clusters =3D
+        be32_to_cpu(header.refcount_table_clusters);
+    header.snapshots_offset =3D be64_to_cpu(header.snapshots_offset);
+    header.nb_snapshots =3D be32_to_cpu(header.nb_snapshots);
=20
     if (header.magic !=3D QCOW_MAGIC) {
         error_setg(errp, "Image is not in qcow2 format");
@@ -1207,11 +1210,12 @@ static int coroutine_fn qcow2_do_open(BlockDriverSt=
ate *bs, QDict *options,
         header.refcount_order           =3D 4;
         header.header_length            =3D 72;
     } else {
-        be64_to_cpus(&header.incompatible_features);
-        be64_to_cpus(&header.compatible_features);
-        be64_to_cpus(&header.autoclear_features);
-        be32_to_cpus(&header.refcount_order);
-        be32_to_cpus(&header.header_length);
+        header.incompatible_features =3D
+            be64_to_cpu(header.incompatible_features);
+        header.compatible_features =3D be64_to_cpu(header.compatible_featu=
res);
+        header.autoclear_features =3D be64_to_cpu(header.autoclear_feature=
s);
+        header.refcount_order =3D be32_to_cpu(header.refcount_order);
+        header.header_length =3D be32_to_cpu(header.header_length);
=20
         if (header.header_length < 104) {
             error_setg(errp, "qcow2 header too short");
@@ -1400,7 +1404,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat=
e *bs, QDict *options,
             goto fail;
         }
         for(i =3D 0;i < s->l1_size; i++) {
-            be64_to_cpus(&s->l1_table[i]);
+            s->l1_table[i] =3D be64_to_cpu(s->l1_table[i]);
         }
     }
=20
@@ -2392,13 +2396,13 @@ int qcow2_update_header(BlockDriverState *bs)
=20
     /* Full disk encryption header pointer extension */
     if (s->crypto_header.offset !=3D 0) {
-        cpu_to_be64s(&s->crypto_header.offset);
-        cpu_to_be64s(&s->crypto_header.length);
+        s->crypto_header.offset =3D cpu_to_be64(s->crypto_header.offset);
+        s->crypto_header.length =3D cpu_to_be64(s->crypto_header.length);
         ret =3D header_ext_add(buf, QCOW2_EXT_MAGIC_CRYPTO_HEADER,
                              &s->crypto_header, sizeof(s->crypto_header),
                              buflen);
-        be64_to_cpus(&s->crypto_header.offset);
-        be64_to_cpus(&s->crypto_header.length);
+        s->crypto_header.offset =3D be64_to_cpu(s->crypto_header.offset);
+        s->crypto_header.length =3D be64_to_cpu(s->crypto_header.length);
         if (ret < 0) {
             goto fail;
         }
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436390038307.6503046090943;
 Mon, 5 Nov 2018 08:46:30 -0800 (PST)
Received: from localhost ([::1]:36204 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi15-0001Dy-T0
	for importer@patchew.org; Mon, 05 Nov 2018 11:46:20 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50363)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtJ-0006wm-13
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:21 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtH-0003V2-9z
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:16 -0500
Received: from mx1.redhat.com ([209.132.183.28]:35794)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJht3-0002bq-Cb; Mon, 05 Nov 2018 11:38:01 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id E5FAEC004AB3;
	Mon,  5 Nov 2018 16:37:58 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id D3A5060C46;
	Mon,  5 Nov 2018 16:37:57 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:13 +0100
Message-Id: <20181105163744.25139-6-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.32]);
	Mon, 05 Nov 2018 16:37:58 +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] [PULL 05/36] block/qcow: Don't take address of fields
 in packed structs
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Peter Maydell <peter.maydell@linaro.org>

Taking the address of a field in a packed struct is a bad idea, because
it might not be actually aligned enough for that pointer type (and
thus cause a crash on dereference on some host architectures). Newer
versions of clang warn about this. Avoid the bug by not using the
"modify in place" byte swapping functions.

There are a few places where the in-place swap function is
used on something other than a packed struct field; we convert
those anyway, for consistency.

This patch was produced with the following spatch script:

@@
expression E;
@@
-be16_to_cpus(&E);
+E =3D be16_to_cpu(E);
@@
expression E;
@@
-be32_to_cpus(&E);
+E =3D be32_to_cpu(E);
@@
expression E;
@@
-be64_to_cpus(&E);
+E =3D be64_to_cpu(E);
@@
expression E;
@@
-cpu_to_be16s(&E);
+E =3D cpu_to_be16(E);
@@
expression E;
@@
-cpu_to_be32s(&E);
+E =3D cpu_to_be32(E);
@@
expression E;
@@
-cpu_to_be64s(&E);
+E =3D cpu_to_be64(E);

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: John Snow <jsnow@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qcow.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index 385d935258..4518cb4c35 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -140,14 +140,14 @@ static int qcow_open(BlockDriverState *bs, QDict *opt=
ions, int flags,
     if (ret < 0) {
         goto fail;
     }
-    be32_to_cpus(&header.magic);
-    be32_to_cpus(&header.version);
-    be64_to_cpus(&header.backing_file_offset);
-    be32_to_cpus(&header.backing_file_size);
-    be32_to_cpus(&header.mtime);
-    be64_to_cpus(&header.size);
-    be32_to_cpus(&header.crypt_method);
-    be64_to_cpus(&header.l1_table_offset);
+    header.magic =3D be32_to_cpu(header.magic);
+    header.version =3D be32_to_cpu(header.version);
+    header.backing_file_offset =3D be64_to_cpu(header.backing_file_offset);
+    header.backing_file_size =3D be32_to_cpu(header.backing_file_size);
+    header.mtime =3D be32_to_cpu(header.mtime);
+    header.size =3D be64_to_cpu(header.size);
+    header.crypt_method =3D be32_to_cpu(header.crypt_method);
+    header.l1_table_offset =3D be64_to_cpu(header.l1_table_offset);
=20
     if (header.magic !=3D QCOW_MAGIC) {
         error_setg(errp, "Image not in qcow format");
@@ -270,7 +270,7 @@ static int qcow_open(BlockDriverState *bs, QDict *optio=
ns, int flags,
     }
=20
     for(i =3D 0;i < s->l1_size; i++) {
-        be64_to_cpus(&s->l1_table[i]);
+        s->l1_table[i] =3D be64_to_cpu(s->l1_table[i]);
     }
=20
     /* alloc L2 cache (max. 64k * 16 * 8 =3D 8 MB) */
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436488366692.5057360537716;
 Mon, 5 Nov 2018 08:48:08 -0800 (PST)
Received: from localhost ([::1]:36215 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi2p-0002UF-7W
	for importer@patchew.org; Mon, 05 Nov 2018 11:48:07 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50369)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtJ-0006wx-5J
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:22 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtH-0003VC-A5
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:16 -0500
Received: from mx1.redhat.com ([209.132.183.28]:40764)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJht3-0002gL-Um; Mon, 05 Nov 2018 11:38:02 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 56FF981DE3;
	Mon,  5 Nov 2018 16:38:00 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 3CF1760C5C;
	Mon,  5 Nov 2018 16:37:59 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:14 +0100
Message-Id: <20181105163744.25139-7-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.25]);
	Mon, 05 Nov 2018 16:38:00 +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] [PULL 06/36] block/qcow2-bitmap: Don't take address of
 fields in packed structs
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Peter Maydell <peter.maydell@linaro.org>

Taking the address of a field in a packed struct is a bad idea, because
it might not be actually aligned enough for that pointer type (and
thus cause a crash on dereference on some host architectures). Newer
versions of clang warn about this. Avoid the bug by not using the
"modify in place" byte swapping functions.

There are a few places where the in-place swap function is
used on something other than a packed struct field; we convert
those anyway, for consistency.

This patch was produced with the following spatch script:

@@
expression E;
@@
-be16_to_cpus(&E);
+E =3D be16_to_cpu(E);
@@
expression E;
@@
-be32_to_cpus(&E);
+E =3D be32_to_cpu(E);
@@
expression E;
@@
-be64_to_cpus(&E);
+E =3D be64_to_cpu(E);
@@
expression E;
@@
-cpu_to_be16s(&E);
+E =3D cpu_to_be16(E);
@@
expression E;
@@
-cpu_to_be32s(&E);
+E =3D cpu_to_be32(E);
@@
expression E;
@@
-cpu_to_be64s(&E);
+E =3D cpu_to_be64(E);

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: John Snow <jsnow@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qcow2-bitmap.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index b5f1b3563d..accebef4cf 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -118,7 +118,7 @@ static inline void bitmap_table_to_be(uint64_t *bitmap_=
table, size_t size)
     size_t i;
=20
     for (i =3D 0; i < size; ++i) {
-        cpu_to_be64s(&bitmap_table[i]);
+        bitmap_table[i] =3D cpu_to_be64(bitmap_table[i]);
     }
 }
=20
@@ -231,7 +231,7 @@ static int bitmap_table_load(BlockDriverState *bs, Qcow=
2BitmapTable *tb,
     }
=20
     for (i =3D 0; i < tb->size; ++i) {
-        be64_to_cpus(&table[i]);
+        table[i] =3D be64_to_cpu(table[i]);
         ret =3D check_table_entry(table[i], s->cluster_size);
         if (ret < 0) {
             goto fail;
@@ -394,20 +394,20 @@ fail:
=20
 static inline void bitmap_dir_entry_to_cpu(Qcow2BitmapDirEntry *entry)
 {
-    be64_to_cpus(&entry->bitmap_table_offset);
-    be32_to_cpus(&entry->bitmap_table_size);
-    be32_to_cpus(&entry->flags);
-    be16_to_cpus(&entry->name_size);
-    be32_to_cpus(&entry->extra_data_size);
+    entry->bitmap_table_offset =3D be64_to_cpu(entry->bitmap_table_offset);
+    entry->bitmap_table_size =3D be32_to_cpu(entry->bitmap_table_size);
+    entry->flags =3D be32_to_cpu(entry->flags);
+    entry->name_size =3D be16_to_cpu(entry->name_size);
+    entry->extra_data_size =3D be32_to_cpu(entry->extra_data_size);
 }
=20
 static inline void bitmap_dir_entry_to_be(Qcow2BitmapDirEntry *entry)
 {
-    cpu_to_be64s(&entry->bitmap_table_offset);
-    cpu_to_be32s(&entry->bitmap_table_size);
-    cpu_to_be32s(&entry->flags);
-    cpu_to_be16s(&entry->name_size);
-    cpu_to_be32s(&entry->extra_data_size);
+    entry->bitmap_table_offset =3D cpu_to_be64(entry->bitmap_table_offset);
+    entry->bitmap_table_size =3D cpu_to_be32(entry->bitmap_table_size);
+    entry->flags =3D cpu_to_be32(entry->flags);
+    entry->name_size =3D cpu_to_be16(entry->name_size);
+    entry->extra_data_size =3D cpu_to_be32(entry->extra_data_size);
 }
=20
 static inline int calc_dir_entry_size(size_t name_size, size_t extra_data_=
size)
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436132956728.7429740364468;
 Mon, 5 Nov 2018 08:42:12 -0800 (PST)
Received: from localhost ([::1]:36177 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJhx5-0002Yt-75
	for importer@patchew.org; Mon, 05 Nov 2018 11:42:11 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50366)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtJ-0006wp-1W
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:21 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtH-0003VB-AG
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:16 -0500
Received: from mx1.redhat.com ([209.132.183.28]:44686)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJht5-0002ly-Cb; Mon, 05 Nov 2018 11:38:03 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id B7E4B307D913;
	Mon,  5 Nov 2018 16:38:01 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id A007B60C5C;
	Mon,  5 Nov 2018 16:38:00 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:15 +0100
Message-Id: <20181105163744.25139-8-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.48]);
	Mon, 05 Nov 2018 16:38:01 +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] [PULL 07/36] crypto: initialize sector size even when
 opening with no IO flag
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Daniel P. Berrang=C3=A9 <berrange@redhat.com>

The qcow2 block driver expects to see a valid sector size even when it
has opened the crypto layer with QCRYPTO_BLOCK_OPEN_NO_IO.

Signed-off-by: Daniel P. Berrang=C3=A9 <berrange@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 crypto/block-qcow.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/crypto/block-qcow.c b/crypto/block-qcow.c
index 4284e05167..7606231e79 100644
--- a/crypto/block-qcow.c
+++ b/crypto/block-qcow.c
@@ -102,6 +102,8 @@ qcrypto_block_qcow_open(QCryptoBlock *block,
                         Error **errp)
 {
     if (flags & QCRYPTO_BLOCK_OPEN_NO_IO) {
+        block->sector_size =3D QCRYPTO_BLOCK_QCOW_SECTOR_SIZE;
+        block->payload_offset =3D 0;
         return 0;
     } else {
         if (!options->u.qcow.key_secret) {
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 15414360530011021.7809870806151;
 Mon, 5 Nov 2018 08:40:53 -0800 (PST)
Received: from localhost ([::1]:36171 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJhvn-0000kW-7M
	for importer@patchew.org; Mon, 05 Nov 2018 11:40:51 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50436)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtZ-0007Ej-Ky
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:38 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtJ-0003dC-88
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:38:22 -0500
Received: from mx1.redhat.com ([209.132.183.28]:42714)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhtC-0002yK-Sb; Mon, 05 Nov 2018 11:38:11 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 1FD73308FF0D;
	Mon,  5 Nov 2018 16:38:05 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 0F76360F97;
	Mon,  5 Nov 2018 16:38:01 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:16 +0100
Message-Id: <20181105163744.25139-9-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.49]);
	Mon, 05 Nov 2018 16:38:05 +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] [PULL 08/36] qcow2: Get the request alignment for
 encrypted images from QCryptoBlock
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Alberto Garcia <berto@igalia.com>

This doesn't have any practical effect at the moment because the
values of BDRV_SECTOR_SIZE, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE and
QCRYPTO_BLOCK_QCOW_SECTOR_SIZE are all the same (512 bytes), but
future encryption methods could have different requirements.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Daniel P. Berrang=C3=A9 <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qcow2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index de94b290e6..991d6ac91b 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1677,7 +1677,7 @@ static void qcow2_refresh_limits(BlockDriverState *bs=
, Error **errp)
=20
     if (bs->encrypted) {
         /* Encryption works on a sector granularity */
-        bs->bl.request_alignment =3D BDRV_SECTOR_SIZE;
+        bs->bl.request_alignment =3D qcrypto_block_get_sector_size(s->cryp=
to);
     }
     bs->bl.pwrite_zeroes_alignment =3D s->cluster_size;
     bs->bl.pdiscard_alignment =3D s->cluster_size;
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436223170105.6327301364687;
 Mon, 5 Nov 2018 08:43:43 -0800 (PST)
Received: from localhost ([::1]:36184 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJhyX-0004lL-So
	for importer@patchew.org; Mon, 05 Nov 2018 11:43:41 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50647)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhuD-0007sZ-Hz
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:16 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhtz-0005AL-DE
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:06 -0500
Received: from mx1.redhat.com ([209.132.183.28]:40834)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhtk-0003HV-Fb; Mon, 05 Nov 2018 11:38:44 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 5F0F481DE9;
	Mon,  5 Nov 2018 16:38:11 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 6BCA260C5C;
	Mon,  5 Nov 2018 16:38:05 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:17 +0100
Message-Id: <20181105163744.25139-10-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.25]);
	Mon, 05 Nov 2018 16:38:11 +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] [PULL 09/36] block: change some function return type
 to bool
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Li Qiang <liq3ea@163.com>

Signed-off-by: Li Qiang <liq3ea@163.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/sysemu/block-backend.h | 6 +++---
 block/block-backend.c          | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 830d873f24..c96bcdee14 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -166,9 +166,9 @@ BlockErrorAction blk_get_error_action(BlockBackend *blk=
, bool is_read,
                                       int error);
 void blk_error_action(BlockBackend *blk, BlockErrorAction action,
                       bool is_read, int error);
-int blk_is_read_only(BlockBackend *blk);
-int blk_is_sg(BlockBackend *blk);
-int blk_enable_write_cache(BlockBackend *blk);
+bool blk_is_read_only(BlockBackend *blk);
+bool blk_is_sg(BlockBackend *blk);
+bool blk_enable_write_cache(BlockBackend *blk);
 void blk_set_enable_write_cache(BlockBackend *blk, bool wce);
 void blk_invalidate_cache(BlockBackend *blk, Error **errp);
 bool blk_is_inserted(BlockBackend *blk);
diff --git a/block/block-backend.c b/block/block-backend.c
index dc0cd57724..2a8f3b55f8 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1708,7 +1708,7 @@ void blk_error_action(BlockBackend *blk, BlockErrorAc=
tion action,
     }
 }
=20
-int blk_is_read_only(BlockBackend *blk)
+bool blk_is_read_only(BlockBackend *blk)
 {
     BlockDriverState *bs =3D blk_bs(blk);
=20
@@ -1719,18 +1719,18 @@ int blk_is_read_only(BlockBackend *blk)
     }
 }
=20
-int blk_is_sg(BlockBackend *blk)
+bool blk_is_sg(BlockBackend *blk)
 {
     BlockDriverState *bs =3D blk_bs(blk);
=20
     if (!bs) {
-        return 0;
+        return false;
     }
=20
     return bdrv_is_sg(bs);
 }
=20
-int blk_enable_write_cache(BlockBackend *blk)
+bool blk_enable_write_cache(BlockBackend *blk)
 {
     return blk->enable_write_cache;
 }
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436365499778.6711677134595;
 Mon, 5 Nov 2018 08:46:05 -0800 (PST)
Received: from localhost ([::1]:36203 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi0q-0000ze-90
	for importer@patchew.org; Mon, 05 Nov 2018 11:46:04 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50695)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhuG-0007wR-T1
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:17 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhuB-0005T4-Jw
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:16 -0500
Received: from mx1.redhat.com ([209.132.183.28]:49244)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhtp-0003cQ-Rj; Mon, 05 Nov 2018 11:38:50 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id A3282307EAA2;
	Mon,  5 Nov 2018 16:38:16 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id A96E260C46;
	Mon,  5 Nov 2018 16:38:11 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:18 +0100
Message-Id: <20181105163744.25139-11-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.44]);
	Mon, 05 Nov 2018 16:38:16 +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] [PULL 10/36] iotests: make 083 specific to raw
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Cleber Rosa <crosa@redhat.com>

While testing the Python 3 changes which touch the 083 test, I noticed
that it would fail with qcow2.  Expanding the testing, I noticed it
had nothing to do with the Python 3 changes, and in fact, it would not
pass on anything but raw:

 raw: pass
 bochs: not generic
 cloop: not generic
 parallels: fail
 qcow: fail
 qcow2: fail
 qed: fail
 vdi: fail
 vhdx: fail
 vmdk: fail
 vpc: fail
 luks: fail

The errors are a mixture I/O and "image not in xxx format", such as:

  =3D=3D=3D Check disconnect before data =3D=3D=3D

  Unexpected end-of-file before all bytes were read
 -read failed: Input/output error
 +can't open device nbd+tcp://127.0.0.1:PORT/foo: Could not open 'nbd://127=
.0.0.1:PORT/foo': Input/output error

  =3D=3D=3D Check disconnect after data =3D=3D=3D

 -read 512/512 bytes at offset 0
 -512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 +can't open device nbd+tcp://127.0.0.1:PORT/foo: Image not in qcow format

I'm not aware if there's a quick fix, so, for the time being, it looks
like the honest approach is to make the test known to work on raw
only.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/083 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083
index 3c1adbf0fb..9f92317b0a 100755
--- a/tests/qemu-iotests/083
+++ b/tests/qemu-iotests/083
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.rc
 . ./common.filter
=20
-_supported_fmt generic
+_supported_fmt raw
 _supported_proto nbd
 _supported_os Linux
=20
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436976169714.0093748184522;
 Mon, 5 Nov 2018 08:56:16 -0800 (PST)
Received: from localhost ([::1]:36276 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiAa-0001jc-Kq
	for importer@patchew.org; Mon, 05 Nov 2018 11:56:08 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51638)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwK-00029Q-4y
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:29 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhw7-00038q-4e
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:17 -0500
Received: from mx1.redhat.com ([209.132.183.28]:41640)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhvq-0003ts-NA; Mon, 05 Nov 2018 11:40:55 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 122E331256AF;
	Mon,  5 Nov 2018 16:38:28 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id EDE3E60C46;
	Mon,  5 Nov 2018 16:38:16 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:19 +0100
Message-Id: <20181105163744.25139-12-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.46]);
	Mon, 05 Nov 2018 16:38: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] [PULL 11/36] vpc: Don't leak opts in vpc_open()
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
---
 block/vpc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/vpc.c b/block/vpc.c
index 984187cadd..80c5b2b197 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -456,10 +456,12 @@ static int vpc_open(BlockDriverState *bs, QDict *opti=
ons, int flags,
     }
=20
     qemu_co_mutex_init(&s->lock);
+    qemu_opts_del(opts);
=20
     return 0;
=20
 fail:
+    qemu_opts_del(opts);
     qemu_vfree(s->pagetable);
 #ifdef CACHE
     g_free(s->pageentry_u8);
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436397340976.6633646242595;
 Mon, 5 Nov 2018 08:46:37 -0800 (PST)
Received: from localhost ([::1]:36207 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi1M-0001O6-1r
	for importer@patchew.org; Mon, 05 Nov 2018 11:46:36 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50694)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhuG-0007wP-Sj
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:18 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhuB-0005T6-Jx
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:16 -0500
Received: from mx1.redhat.com ([209.132.183.28]:51374)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhto-0003yq-Qr; Mon, 05 Nov 2018 11:38:49 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 9A8BC8666F;
	Mon,  5 Nov 2018 16:38:31 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 591C160C46;
	Mon,  5 Nov 2018 16:38:28 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:20 +0100
Message-Id: <20181105163744.25139-13-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.26]);
	Mon, 05 Nov 2018 16:38:31 +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] [PULL 12/36] block/vhdx: Don't take address of fields
 in packed structs
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Peter Maydell <peter.maydell@linaro.org>

Taking the address of a field in a packed struct is a bad idea, because
it might not be actually aligned enough for that pointer type (and
thus cause a crash on dereference on some host architectures). Newer
versions of clang warn about this. Avoid the bug by not using the
"modify in place" byte swapping functions.

There are a few places where the in-place swap function is
used on something other than a packed struct field; we convert
those anyway, for consistency.

Patch produced with scripts/coccinelle/inplace-byteswaps.cocci.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/vhdx.h        |  12 ++---
 block/vhdx-endian.c | 118 ++++++++++++++++++++++----------------------
 block/vhdx-log.c    |   4 +-
 block/vhdx.c        |  18 +++----
 4 files changed, 76 insertions(+), 76 deletions(-)

diff --git a/block/vhdx.h b/block/vhdx.h
index 7003ab7a79..3a5f5293ad 100644
--- a/block/vhdx.h
+++ b/block/vhdx.h
@@ -420,16 +420,16 @@ int vhdx_log_write_and_flush(BlockDriverState *bs, BD=
RVVHDXState *s,
=20
 static inline void leguid_to_cpus(MSGUID *guid)
 {
-    le32_to_cpus(&guid->data1);
-    le16_to_cpus(&guid->data2);
-    le16_to_cpus(&guid->data3);
+    guid->data1 =3D le32_to_cpu(guid->data1);
+    guid->data2 =3D le16_to_cpu(guid->data2);
+    guid->data3 =3D le16_to_cpu(guid->data3);
 }
=20
 static inline void cpu_to_leguids(MSGUID *guid)
 {
-    cpu_to_le32s(&guid->data1);
-    cpu_to_le16s(&guid->data2);
-    cpu_to_le16s(&guid->data3);
+    guid->data1 =3D cpu_to_le32(guid->data1);
+    guid->data2 =3D cpu_to_le16(guid->data2);
+    guid->data3 =3D cpu_to_le16(guid->data3);
 }
=20
 void vhdx_header_le_import(VHDXHeader *h);
diff --git a/block/vhdx-endian.c b/block/vhdx-endian.c
index 41fbdd2b8f..ebfa33cb8a 100644
--- a/block/vhdx-endian.c
+++ b/block/vhdx-endian.c
@@ -35,18 +35,18 @@ void vhdx_header_le_import(VHDXHeader *h)
 {
     assert(h !=3D NULL);
=20
-    le32_to_cpus(&h->signature);
-    le32_to_cpus(&h->checksum);
-    le64_to_cpus(&h->sequence_number);
+    h->signature =3D le32_to_cpu(h->signature);
+    h->checksum =3D le32_to_cpu(h->checksum);
+    h->sequence_number =3D le64_to_cpu(h->sequence_number);
=20
     leguid_to_cpus(&h->file_write_guid);
     leguid_to_cpus(&h->data_write_guid);
     leguid_to_cpus(&h->log_guid);
=20
-    le16_to_cpus(&h->log_version);
-    le16_to_cpus(&h->version);
-    le32_to_cpus(&h->log_length);
-    le64_to_cpus(&h->log_offset);
+    h->log_version =3D le16_to_cpu(h->log_version);
+    h->version =3D le16_to_cpu(h->version);
+    h->log_length =3D le32_to_cpu(h->log_length);
+    h->log_offset =3D le64_to_cpu(h->log_offset);
 }
=20
 void vhdx_header_le_export(VHDXHeader *orig_h, VHDXHeader *new_h)
@@ -80,68 +80,68 @@ void vhdx_log_desc_le_import(VHDXLogDescriptor *d)
 {
     assert(d !=3D NULL);
=20
-    le32_to_cpus(&d->signature);
-    le64_to_cpus(&d->file_offset);
-    le64_to_cpus(&d->sequence_number);
+    d->signature =3D le32_to_cpu(d->signature);
+    d->file_offset =3D le64_to_cpu(d->file_offset);
+    d->sequence_number =3D le64_to_cpu(d->sequence_number);
 }
=20
 void vhdx_log_desc_le_export(VHDXLogDescriptor *d)
 {
     assert(d !=3D NULL);
=20
-    cpu_to_le32s(&d->signature);
-    cpu_to_le32s(&d->trailing_bytes);
-    cpu_to_le64s(&d->leading_bytes);
-    cpu_to_le64s(&d->file_offset);
-    cpu_to_le64s(&d->sequence_number);
+    d->signature =3D cpu_to_le32(d->signature);
+    d->trailing_bytes =3D cpu_to_le32(d->trailing_bytes);
+    d->leading_bytes =3D cpu_to_le64(d->leading_bytes);
+    d->file_offset =3D cpu_to_le64(d->file_offset);
+    d->sequence_number =3D cpu_to_le64(d->sequence_number);
 }
=20
 void vhdx_log_data_le_import(VHDXLogDataSector *d)
 {
     assert(d !=3D NULL);
=20
-    le32_to_cpus(&d->data_signature);
-    le32_to_cpus(&d->sequence_high);
-    le32_to_cpus(&d->sequence_low);
+    d->data_signature =3D le32_to_cpu(d->data_signature);
+    d->sequence_high =3D le32_to_cpu(d->sequence_high);
+    d->sequence_low =3D le32_to_cpu(d->sequence_low);
 }
=20
 void vhdx_log_data_le_export(VHDXLogDataSector *d)
 {
     assert(d !=3D NULL);
=20
-    cpu_to_le32s(&d->data_signature);
-    cpu_to_le32s(&d->sequence_high);
-    cpu_to_le32s(&d->sequence_low);
+    d->data_signature =3D cpu_to_le32(d->data_signature);
+    d->sequence_high =3D cpu_to_le32(d->sequence_high);
+    d->sequence_low =3D cpu_to_le32(d->sequence_low);
 }
=20
 void vhdx_log_entry_hdr_le_import(VHDXLogEntryHeader *hdr)
 {
     assert(hdr !=3D NULL);
=20
-    le32_to_cpus(&hdr->signature);
-    le32_to_cpus(&hdr->checksum);
-    le32_to_cpus(&hdr->entry_length);
-    le32_to_cpus(&hdr->tail);
-    le64_to_cpus(&hdr->sequence_number);
-    le32_to_cpus(&hdr->descriptor_count);
+    hdr->signature =3D le32_to_cpu(hdr->signature);
+    hdr->checksum =3D le32_to_cpu(hdr->checksum);
+    hdr->entry_length =3D le32_to_cpu(hdr->entry_length);
+    hdr->tail =3D le32_to_cpu(hdr->tail);
+    hdr->sequence_number =3D le64_to_cpu(hdr->sequence_number);
+    hdr->descriptor_count =3D le32_to_cpu(hdr->descriptor_count);
     leguid_to_cpus(&hdr->log_guid);
-    le64_to_cpus(&hdr->flushed_file_offset);
-    le64_to_cpus(&hdr->last_file_offset);
+    hdr->flushed_file_offset =3D le64_to_cpu(hdr->flushed_file_offset);
+    hdr->last_file_offset =3D le64_to_cpu(hdr->last_file_offset);
 }
=20
 void vhdx_log_entry_hdr_le_export(VHDXLogEntryHeader *hdr)
 {
     assert(hdr !=3D NULL);
=20
-    cpu_to_le32s(&hdr->signature);
-    cpu_to_le32s(&hdr->checksum);
-    cpu_to_le32s(&hdr->entry_length);
-    cpu_to_le32s(&hdr->tail);
-    cpu_to_le64s(&hdr->sequence_number);
-    cpu_to_le32s(&hdr->descriptor_count);
+    hdr->signature =3D cpu_to_le32(hdr->signature);
+    hdr->checksum =3D cpu_to_le32(hdr->checksum);
+    hdr->entry_length =3D cpu_to_le32(hdr->entry_length);
+    hdr->tail =3D cpu_to_le32(hdr->tail);
+    hdr->sequence_number =3D cpu_to_le64(hdr->sequence_number);
+    hdr->descriptor_count =3D cpu_to_le32(hdr->descriptor_count);
     cpu_to_leguids(&hdr->log_guid);
-    cpu_to_le64s(&hdr->flushed_file_offset);
-    cpu_to_le64s(&hdr->last_file_offset);
+    hdr->flushed_file_offset =3D cpu_to_le64(hdr->flushed_file_offset);
+    hdr->last_file_offset =3D cpu_to_le64(hdr->last_file_offset);
 }
=20
=20
@@ -150,18 +150,18 @@ void vhdx_region_header_le_import(VHDXRegionTableHead=
er *hdr)
 {
     assert(hdr !=3D NULL);
=20
-    le32_to_cpus(&hdr->signature);
-    le32_to_cpus(&hdr->checksum);
-    le32_to_cpus(&hdr->entry_count);
+    hdr->signature =3D le32_to_cpu(hdr->signature);
+    hdr->checksum =3D le32_to_cpu(hdr->checksum);
+    hdr->entry_count =3D le32_to_cpu(hdr->entry_count);
 }
=20
 void vhdx_region_header_le_export(VHDXRegionTableHeader *hdr)
 {
     assert(hdr !=3D NULL);
=20
-    cpu_to_le32s(&hdr->signature);
-    cpu_to_le32s(&hdr->checksum);
-    cpu_to_le32s(&hdr->entry_count);
+    hdr->signature =3D cpu_to_le32(hdr->signature);
+    hdr->checksum =3D cpu_to_le32(hdr->checksum);
+    hdr->entry_count =3D cpu_to_le32(hdr->entry_count);
 }
=20
 void vhdx_region_entry_le_import(VHDXRegionTableEntry *e)
@@ -169,9 +169,9 @@ void vhdx_region_entry_le_import(VHDXRegionTableEntry *=
e)
     assert(e !=3D NULL);
=20
     leguid_to_cpus(&e->guid);
-    le64_to_cpus(&e->file_offset);
-    le32_to_cpus(&e->length);
-    le32_to_cpus(&e->data_bits);
+    e->file_offset =3D le64_to_cpu(e->file_offset);
+    e->length =3D le32_to_cpu(e->length);
+    e->data_bits =3D le32_to_cpu(e->data_bits);
 }
=20
 void vhdx_region_entry_le_export(VHDXRegionTableEntry *e)
@@ -179,9 +179,9 @@ void vhdx_region_entry_le_export(VHDXRegionTableEntry *=
e)
     assert(e !=3D NULL);
=20
     cpu_to_leguids(&e->guid);
-    cpu_to_le64s(&e->file_offset);
-    cpu_to_le32s(&e->length);
-    cpu_to_le32s(&e->data_bits);
+    e->file_offset =3D cpu_to_le64(e->file_offset);
+    e->length =3D cpu_to_le32(e->length);
+    e->data_bits =3D cpu_to_le32(e->data_bits);
 }
=20
=20
@@ -190,16 +190,16 @@ void vhdx_metadata_header_le_import(VHDXMetadataTable=
Header *hdr)
 {
     assert(hdr !=3D NULL);
=20
-    le64_to_cpus(&hdr->signature);
-    le16_to_cpus(&hdr->entry_count);
+    hdr->signature =3D le64_to_cpu(hdr->signature);
+    hdr->entry_count =3D le16_to_cpu(hdr->entry_count);
 }
=20
 void vhdx_metadata_header_le_export(VHDXMetadataTableHeader *hdr)
 {
     assert(hdr !=3D NULL);
=20
-    cpu_to_le64s(&hdr->signature);
-    cpu_to_le16s(&hdr->entry_count);
+    hdr->signature =3D cpu_to_le64(hdr->signature);
+    hdr->entry_count =3D cpu_to_le16(hdr->entry_count);
 }
=20
 void vhdx_metadata_entry_le_import(VHDXMetadataTableEntry *e)
@@ -207,16 +207,16 @@ void vhdx_metadata_entry_le_import(VHDXMetadataTableE=
ntry *e)
     assert(e !=3D NULL);
=20
     leguid_to_cpus(&e->item_id);
-    le32_to_cpus(&e->offset);
-    le32_to_cpus(&e->length);
-    le32_to_cpus(&e->data_bits);
+    e->offset =3D le32_to_cpu(e->offset);
+    e->length =3D le32_to_cpu(e->length);
+    e->data_bits =3D le32_to_cpu(e->data_bits);
 }
 void vhdx_metadata_entry_le_export(VHDXMetadataTableEntry *e)
 {
     assert(e !=3D NULL);
=20
     cpu_to_leguids(&e->item_id);
-    cpu_to_le32s(&e->offset);
-    cpu_to_le32s(&e->length);
-    cpu_to_le32s(&e->data_bits);
+    e->offset =3D cpu_to_le32(e->offset);
+    e->length =3D cpu_to_le32(e->length);
+    e->data_bits =3D cpu_to_le32(e->data_bits);
 }
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index d2f1b98199..ecd64266c5 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -835,11 +835,11 @@ static void vhdx_log_raw_to_le_sector(VHDXLogDescript=
or *desc,
     /* 8 + 4084 + 4 =3D 4096, 1 log sector */
     memcpy(&desc->leading_bytes, data, 8);
     data +=3D 8;
-    cpu_to_le64s(&desc->leading_bytes);
+    desc->leading_bytes =3D cpu_to_le64(desc->leading_bytes);
     memcpy(sector->data, data, 4084);
     data +=3D 4084;
     memcpy(&desc->trailing_bytes, data, 4);
-    cpu_to_le32s(&desc->trailing_bytes);
+    desc->trailing_bytes =3D cpu_to_le32(desc->trailing_bytes);
     data +=3D 4;
=20
     sector->sequence_high  =3D (uint32_t) (seq >> 32);
diff --git a/block/vhdx.c b/block/vhdx.c
index 0795ca1985..b785aef4b7 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -156,7 +156,7 @@ uint32_t vhdx_update_checksum(uint8_t *buf, size_t size=
, int crc_offset)
=20
     memset(buf + crc_offset, 0, sizeof(crc));
     crc =3D  crc32c(0xffffffff, buf, size);
-    cpu_to_le32s(&crc);
+    crc =3D cpu_to_le32(crc);
     memcpy(buf + crc_offset, &crc, sizeof(crc));
=20
     return crc;
@@ -753,8 +753,8 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD=
RVVHDXState *s)
         goto exit;
     }
=20
-    le32_to_cpus(&s->params.block_size);
-    le32_to_cpus(&s->params.data_bits);
+    s->params.block_size =3D le32_to_cpu(s->params.block_size);
+    s->params.data_bits =3D le32_to_cpu(s->params.data_bits);
=20
=20
     /* We now have the file parameters, so we can tell if this is a
@@ -803,9 +803,9 @@ static int vhdx_parse_metadata(BlockDriverState *bs, BD=
RVVHDXState *s)
         goto exit;
     }
=20
-    le64_to_cpus(&s->virtual_disk_size);
-    le32_to_cpus(&s->logical_sector_size);
-    le32_to_cpus(&s->physical_sector_size);
+    s->virtual_disk_size =3D le64_to_cpu(s->virtual_disk_size);
+    s->logical_sector_size =3D le32_to_cpu(s->logical_sector_size);
+    s->physical_sector_size =3D le32_to_cpu(s->physical_sector_size);
=20
     if (s->params.block_size < VHDX_BLOCK_SIZE_MIN ||
         s->params.block_size > VHDX_BLOCK_SIZE_MAX) {
@@ -985,7 +985,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *optio=
ns, int flags,
     /* endian convert, and verify populated BAT field file offsets against
      * region table and log entries */
     for (i =3D 0; i < s->bat_entries; i++) {
-        le64_to_cpus(&s->bat[i]);
+        s->bat[i] =3D le64_to_cpu(s->bat[i]);
         if (payblocks--) {
             /* payload bat entries */
             if ((s->bat[i] & VHDX_BAT_STATE_BIT_MASK) =3D=3D
@@ -1509,7 +1509,7 @@ static int vhdx_create_new_metadata(BlockBackend *blk,
     mt_file_params->block_size =3D cpu_to_le32(block_size);
     if (type =3D=3D VHDX_TYPE_FIXED) {
         mt_file_params->data_bits |=3D VHDX_PARAMS_LEAVE_BLOCKS_ALLOCED;
-        cpu_to_le32s(&mt_file_params->data_bits);
+        mt_file_params->data_bits =3D cpu_to_le32(mt_file_params->data_bit=
s);
     }
=20
     vhdx_guid_generate(&mt_page83->page_83_data);
@@ -1656,7 +1656,7 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHD=
XState *s,
             sinfo.file_offset =3D ROUND_UP(sinfo.file_offset, MiB);
             vhdx_update_bat_table_entry(blk_bs(blk), s, &sinfo, &unused, &=
unused,
                                         block_state);
-            cpu_to_le64s(&s->bat[sinfo.bat_idx]);
+            s->bat[sinfo.bat_idx] =3D cpu_to_le64(s->bat[sinfo.bat_idx]);
             sector_num +=3D s->sectors_per_block;
         }
         ret =3D blk_pwrite(blk, file_offset, s->bat, length, 0);
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437686321386.0244878097253;
 Mon, 5 Nov 2018 09:08:06 -0800 (PST)
Received: from localhost ([::1]:36362 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiM4-0008Pk-Ia
	for importer@patchew.org; Mon, 05 Nov 2018 12:08:00 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52961)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhy9-00051N-C7
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:43:18 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhy7-0008Ds-SY
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:43:17 -0500
Received: from mx1.redhat.com ([209.132.183.28]:35070)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhy1-00046p-EZ; Mon, 05 Nov 2018 11:43:09 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id A2DE08E5A4;
	Mon,  5 Nov 2018 16:38:35 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id E19AF60C46;
	Mon,  5 Nov 2018 16:38:31 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:21 +0100
Message-Id: <20181105163744.25139-14-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.28]);
	Mon, 05 Nov 2018 16:38: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] [PULL 13/36] block/vdi: Don't take address of fields
 in packed structs
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Peter Maydell <peter.maydell@linaro.org>

Taking the address of a field in a packed struct is a bad idea, because
it might not be actually aligned enough for that pointer type (and
thus cause a crash on dereference on some host architectures). Newer
versions of clang warn about this. Avoid the bug by not using the
"modify in place" byte swapping functions.

There are a few places where the in-place swap function is
used on something other than a packed struct field; we convert
those anyway, for consistency.

Patch produced with scripts/coccinelle/inplace-byteswaps.cocci.

There are other places where we take the address of a packed member
in this file for other purposes than passing it to a byteswap
function (all the calls to qemu_uuid_*()); we leave those for now.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/vdi.c | 64 ++++++++++++++++++++++++++---------------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/block/vdi.c b/block/vdi.c
index 6555cffb88..0ff1ead736 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -187,22 +187,22 @@ typedef struct {
=20
 static void vdi_header_to_cpu(VdiHeader *header)
 {
-    le32_to_cpus(&header->signature);
-    le32_to_cpus(&header->version);
-    le32_to_cpus(&header->header_size);
-    le32_to_cpus(&header->image_type);
-    le32_to_cpus(&header->image_flags);
-    le32_to_cpus(&header->offset_bmap);
-    le32_to_cpus(&header->offset_data);
-    le32_to_cpus(&header->cylinders);
-    le32_to_cpus(&header->heads);
-    le32_to_cpus(&header->sectors);
-    le32_to_cpus(&header->sector_size);
-    le64_to_cpus(&header->disk_size);
-    le32_to_cpus(&header->block_size);
-    le32_to_cpus(&header->block_extra);
-    le32_to_cpus(&header->blocks_in_image);
-    le32_to_cpus(&header->blocks_allocated);
+    header->signature =3D le32_to_cpu(header->signature);
+    header->version =3D le32_to_cpu(header->version);
+    header->header_size =3D le32_to_cpu(header->header_size);
+    header->image_type =3D le32_to_cpu(header->image_type);
+    header->image_flags =3D le32_to_cpu(header->image_flags);
+    header->offset_bmap =3D le32_to_cpu(header->offset_bmap);
+    header->offset_data =3D le32_to_cpu(header->offset_data);
+    header->cylinders =3D le32_to_cpu(header->cylinders);
+    header->heads =3D le32_to_cpu(header->heads);
+    header->sectors =3D le32_to_cpu(header->sectors);
+    header->sector_size =3D le32_to_cpu(header->sector_size);
+    header->disk_size =3D le64_to_cpu(header->disk_size);
+    header->block_size =3D le32_to_cpu(header->block_size);
+    header->block_extra =3D le32_to_cpu(header->block_extra);
+    header->blocks_in_image =3D le32_to_cpu(header->blocks_in_image);
+    header->blocks_allocated =3D le32_to_cpu(header->blocks_allocated);
     qemu_uuid_bswap(&header->uuid_image);
     qemu_uuid_bswap(&header->uuid_last_snap);
     qemu_uuid_bswap(&header->uuid_link);
@@ -211,22 +211,22 @@ static void vdi_header_to_cpu(VdiHeader *header)
=20
 static void vdi_header_to_le(VdiHeader *header)
 {
-    cpu_to_le32s(&header->signature);
-    cpu_to_le32s(&header->version);
-    cpu_to_le32s(&header->header_size);
-    cpu_to_le32s(&header->image_type);
-    cpu_to_le32s(&header->image_flags);
-    cpu_to_le32s(&header->offset_bmap);
-    cpu_to_le32s(&header->offset_data);
-    cpu_to_le32s(&header->cylinders);
-    cpu_to_le32s(&header->heads);
-    cpu_to_le32s(&header->sectors);
-    cpu_to_le32s(&header->sector_size);
-    cpu_to_le64s(&header->disk_size);
-    cpu_to_le32s(&header->block_size);
-    cpu_to_le32s(&header->block_extra);
-    cpu_to_le32s(&header->blocks_in_image);
-    cpu_to_le32s(&header->blocks_allocated);
+    header->signature =3D cpu_to_le32(header->signature);
+    header->version =3D cpu_to_le32(header->version);
+    header->header_size =3D cpu_to_le32(header->header_size);
+    header->image_type =3D cpu_to_le32(header->image_type);
+    header->image_flags =3D cpu_to_le32(header->image_flags);
+    header->offset_bmap =3D cpu_to_le32(header->offset_bmap);
+    header->offset_data =3D cpu_to_le32(header->offset_data);
+    header->cylinders =3D cpu_to_le32(header->cylinders);
+    header->heads =3D cpu_to_le32(header->heads);
+    header->sectors =3D cpu_to_le32(header->sectors);
+    header->sector_size =3D cpu_to_le32(header->sector_size);
+    header->disk_size =3D cpu_to_le64(header->disk_size);
+    header->block_size =3D cpu_to_le32(header->block_size);
+    header->block_extra =3D cpu_to_le32(header->block_extra);
+    header->blocks_in_image =3D cpu_to_le32(header->blocks_in_image);
+    header->blocks_allocated =3D cpu_to_le32(header->blocks_allocated);
     qemu_uuid_bswap(&header->uuid_image);
     qemu_uuid_bswap(&header->uuid_last_snap);
     qemu_uuid_bswap(&header->uuid_link);
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437406091776.6689014172528;
 Mon, 5 Nov 2018 09:03:26 -0800 (PST)
Received: from localhost ([::1]:36318 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiHc-0000Tr-To
	for importer@patchew.org; Mon, 05 Nov 2018 12:03:24 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51458)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhvx-0001gJ-Lx
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:03 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhvr-0002PW-A6
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:40:58 -0500
Received: from mx1.redhat.com ([209.132.183.28]:36484)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhvj-0004Ce-Kc; Mon, 05 Nov 2018 11:40:47 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 051902D7FC;
	Mon,  5 Nov 2018 16:38:38 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id ECDD160C61;
	Mon,  5 Nov 2018 16:38:35 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:22 +0100
Message-Id: <20181105163744.25139-15-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.30]);
	Mon, 05 Nov 2018 16:38:38 +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] [PULL 14/36] quorum: Remove quorum_err()
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Alberto Garcia <berto@igalia.com>

This is a static function with only one caller, so there's no need to
keep it. Inlining the code in quorum_compare() makes it much simpler.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/quorum.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/block/quorum.c b/block/quorum.c
index eb526cc0f1..b1b777baef 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -437,23 +437,7 @@ static bool quorum_iovec_compare(QEMUIOVector *a, QEMU=
IOVector *b)
     return true;
 }
=20
-static void GCC_FMT_ATTR(2, 3) quorum_err(QuorumAIOCB *acb,
-                                          const char *fmt, ...)
-{
-    va_list ap;
-
-    va_start(ap, fmt);
-    fprintf(stderr, "quorum: offset=3D%" PRIu64 " bytes=3D%" PRIu64 " ",
-            acb->offset, acb->bytes);
-    vfprintf(stderr, fmt, ap);
-    fprintf(stderr, "\n");
-    va_end(ap);
-    exit(1);
-}
-
-static bool quorum_compare(QuorumAIOCB *acb,
-                           QEMUIOVector *a,
-                           QEMUIOVector *b)
+static bool quorum_compare(QuorumAIOCB *acb, QEMUIOVector *a, QEMUIOVector=
 *b)
 {
     BDRVQuorumState *s =3D acb->bs->opaque;
     ssize_t offset;
@@ -462,8 +446,10 @@ static bool quorum_compare(QuorumAIOCB *acb,
     if (s->is_blkverify) {
         offset =3D qemu_iovec_compare(a, b);
         if (offset !=3D -1) {
-            quorum_err(acb, "contents mismatch at offset %" PRIu64,
-                       acb->offset + offset);
+            fprintf(stderr, "quorum: offset=3D%" PRIu64 " bytes=3D%" PRIu64
+                    " contents mismatch at offset %" PRIu64 "\n",
+                    acb->offset, acb->bytes, acb->offset + offset);
+            exit(1);
         }
         return true;
     }
--=20
2.19.1


From nobody Sat May  3 18:59:41 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 154143657884351.47971744990582;
 Mon, 5 Nov 2018 08:49:38 -0800 (PST)
Received: from localhost ([::1]:36223 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi48-0004sZ-J0
	for importer@patchew.org; Mon, 05 Nov 2018 11:49:28 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50883)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhur-0000Gl-DN
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:58 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhul-0007Kq-SG
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:49 -0500
Received: from mx1.redhat.com ([209.132.183.28]:49418)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhuV-0004I5-Sb; Mon, 05 Nov 2018 11:39:34 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 86078308ED5F;
	Mon,  5 Nov 2018 16:38:40 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 53BF49F6E;
	Mon,  5 Nov 2018 16:38:38 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:23 +0100
Message-Id: <20181105163744.25139-16-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.44]);
	Mon, 05 Nov 2018 16:38:40 +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] [PULL 15/36] quorum: Return an error if the blkverify
 mode has invalid settings
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Alberto Garcia <berto@igalia.com>

The blkverify mode of Quorum can only be enabled if the number of
children is exactly two and the value of vote-threshold is also two.

If the user tries to enable it but the other settings are incorrect
then QEMU simply prints an error message to stderr and carries on
disabling the blkverify setting.

This patch makes quorum_open() fail and return an error in this case.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/quorum.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/block/quorum.c b/block/quorum.c
index b1b777baef..6188ff6666 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -912,13 +912,12 @@ static int quorum_open(BlockDriverState *bs, QDict *o=
ptions, int flags,
     s->read_pattern =3D ret;
=20
     if (s->read_pattern =3D=3D QUORUM_READ_PATTERN_QUORUM) {
-        /* is the driver in blkverify mode */
-        if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false) &&
-            s->num_children =3D=3D 2 && s->threshold =3D=3D 2) {
-            s->is_blkverify =3D true;
-        } else if (qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, false)) {
-            fprintf(stderr, "blkverify mode is set by setting blkverify=3D=
on "
-                    "and using two files with vote_threshold=3D2\n");
+        s->is_blkverify =3D qemu_opt_get_bool(opts, QUORUM_OPT_BLKVERIFY, =
false);
+        if (s->is_blkverify && (s->num_children !=3D 2 || s->threshold !=
=3D 2)) {
+            error_setg(&local_err, "blkverify=3Don can only be set if ther=
e are "
+                       "exactly two files and vote-threshold is 2");
+            ret =3D -EINVAL;
+            goto exit;
         }
=20
         s->rewrite_corrupted =3D qemu_opt_get_bool(opts, QUORUM_OPT_REWRIT=
E,
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541438038968842.4654680808762;
 Mon, 5 Nov 2018 09:13:58 -0800 (PST)
Received: from localhost ([::1]:36413 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiRk-00077g-Vx
	for importer@patchew.org; Mon, 05 Nov 2018 12:13:53 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53834)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhzs-0000Ya-99
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:45:09 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhzq-0001pd-82
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:45:04 -0500
Received: from mx1.redhat.com ([209.132.183.28]:41810)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhul-0004Pi-PZ; Mon, 05 Nov 2018 11:39:49 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 8A04631256BB;
	Mon,  5 Nov 2018 16:38:42 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id DB51E60C46;
	Mon,  5 Nov 2018 16:38:40 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:24 +0100
Message-Id: <20181105163744.25139-17-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.46]);
	Mon, 05 Nov 2018 16:38:42 +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] [PULL 16/36] iotest: Test the blkverify mode of the
 Quorum driver
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Alberto Garcia <berto@igalia.com>

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/081     | 30 ++++++++++++++++++++++++++++++
 tests/qemu-iotests/081.out | 16 ++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
index da3fb0984b..0ea010afbf 100755
--- a/tests/qemu-iotests/081
+++ b/tests/qemu-iotests/081
@@ -168,6 +168,36 @@ echo "=3D=3D checking that quorum is broken =3D=3D"
=20
 $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
=20
+echo
+echo "=3D=3D checking the blkverify mode with broken content =3D=3D"
+
+quorum=3D"driver=3Draw,file.driver=3Dquorum,file.vote-threshold=3D2,file.b=
lkverify=3Don"
+quorum=3D"$quorum,file.children.0.file.filename=3D$TEST_DIR/1.raw"
+quorum=3D"$quorum,file.children.1.file.filename=3D$TEST_DIR/2.raw"
+quorum=3D"$quorum,file.children.0.driver=3Draw"
+quorum=3D"$quorum,file.children.1.driver=3Draw"
+
+$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
+
+echo
+echo "=3D=3D writing the same data to both files =3D=3D"
+
+$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io
+$QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
+
+echo
+echo "=3D=3D checking the blkverify mode with valid content =3D=3D"
+
+$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
+
+echo
+echo "=3D=3D checking the blkverify mode with invalid settings =3D=3D"
+
+quorum=3D"$quorum,file.children.2.file.filename=3D$TEST_DIR/3.raw"
+quorum=3D"$quorum,file.children.2.driver=3Draw"
+
+$QEMU_IO -c "open -o $quorum" | _filter_qemu_io
+
 # success, all done
 echo "*** done"
 rm -f $seq.full
diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
index 2533c31c78..2f12c890e9 100644
--- a/tests/qemu-iotests/081.out
+++ b/tests/qemu-iotests/081.out
@@ -55,4 +55,20 @@ wrote 10485760/10485760 bytes at offset 0
=20
 =3D=3D checking that quorum is broken =3D=3D
 read failed: Input/output error
+
+=3D=3D checking the blkverify mode with broken content =3D=3D
+quorum: offset=3D0 bytes=3D10485760 contents mismatch at offset 0
+
+=3D=3D writing the same data to both files =3D=3D
+wrote 10485760/10485760 bytes at offset 0
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 10485760/10485760 bytes at offset 0
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+=3D=3D checking the blkverify mode with valid content =3D=3D
+read 10485760/10485760 bytes at offset 0
+10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+=3D=3D checking the blkverify mode with invalid settings =3D=3D
+can't open: blkverify=3Don can only be set if there are exactly two files =
and vote-threshold is 2
 *** done
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541438190797529.6497854730287;
 Mon, 5 Nov 2018 09:16:30 -0800 (PST)
Received: from localhost ([::1]:36461 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiUH-0002QK-HM
	for importer@patchew.org; Mon, 05 Nov 2018 12:16:29 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:53933)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhzy-0000gM-DS
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:45:11 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhzx-000215-Nf
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:45:10 -0500
Received: from mx1.redhat.com ([209.132.183.28]:36590)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhuz-0004TQ-St; Mon, 05 Nov 2018 11:40:02 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 7B8083091751;
	Mon,  5 Nov 2018 16:38:44 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id D73F265F56;
	Mon,  5 Nov 2018 16:38:42 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:25 +0100
Message-Id: <20181105163744.25139-18-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.41]);
	Mon, 05 Nov 2018 16:38:44 +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] [PULL 17/36] quorum: Forbid adding children in
 blkverify mode
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Alberto Garcia <berto@igalia.com>

The blkverify mode of Quorum only works when the number of children is
exactly two, so any attempt to add a new one must return an error.

quorum_del_child() on the other hand doesn't need any additional check
because decreasing the number of children would make it go under the
vote threshold.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reported-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/quorum.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/block/quorum.c b/block/quorum.c
index 6188ff6666..16b3c8067c 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -992,6 +992,11 @@ static void quorum_add_child(BlockDriverState *bs, Blo=
ckDriverState *child_bs,
     char indexstr[32];
     int ret;
=20
+    if (s->is_blkverify) {
+        error_setg(errp, "Cannot add a child to a quorum in blkverify mode=
");
+        return;
+    }
+
     assert(s->num_children <=3D INT_MAX / sizeof(BdrvChild *));
     if (s->num_children =3D=3D INT_MAX / sizeof(BdrvChild *) ||
         s->next_child_index =3D=3D UINT_MAX) {
@@ -1046,6 +1051,9 @@ static void quorum_del_child(BlockDriverState *bs, Bd=
rvChild *child,
         return;
     }
=20
+    /* We know now that num_children > threshold, so blkverify must be fal=
se */
+    assert(!s->is_blkverify);
+
     bdrv_drained_begin(bs);
=20
     /* We can safely remove this child now */
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 154143702122560.09909473642767;
 Mon, 5 Nov 2018 08:57:01 -0800 (PST)
Received: from localhost ([::1]:36279 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiBQ-0002gU-2X
	for importer@patchew.org; Mon, 05 Nov 2018 11:57:00 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51222)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhva-0001KP-46
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:40:39 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhvR-0000af-Ux
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:40:37 -0500
Received: from mx1.redhat.com ([209.132.183.28]:58190)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhv8-0004bs-0k; Mon, 05 Nov 2018 11:40:10 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id C617B394D42;
	Mon,  5 Nov 2018 16:38:46 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id C743560C46;
	Mon,  5 Nov 2018 16:38:44 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:26 +0100
Message-Id: <20181105163744.25139-19-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.38]);
	Mon, 05 Nov 2018 16:38:46 +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] [PULL 18/36] iotest: Test x-blockdev-change on a Quorum
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Alberto Garcia <berto@igalia.com>

This patch tests that you can add and remove drives from a Quorum
using the x-blockdev-change command.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/081     | 86 ++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/081.out | 54 ++++++++++++++++++++++++
 2 files changed, 140 insertions(+)

diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081
index 0ea010afbf..9f1dece271 100755
--- a/tests/qemu-iotests/081
+++ b/tests/qemu-iotests/081
@@ -198,6 +198,92 @@ quorum=3D"$quorum,file.children.2.driver=3Draw"
=20
 $QEMU_IO -c "open -o $quorum" | _filter_qemu_io
=20
+echo
+echo "=3D=3D dynamically adding a child to a quorum =3D=3D"
+
+for verify in false true; do
+    run_qemu <<EOF
+    { "execute": "qmp_capabilities" }
+    { "execute": "blockdev-add",
+        "arguments": {
+            "driver": "quorum",
+            "node-name": "drive0-quorum",
+            "vote-threshold": 2,
+            "blkverify": ${verify},
+            "children": [
+                {
+                    "driver": "$IMGFMT",
+                    "file": {
+                        "driver": "file",
+                        "filename": "$TEST_DIR/1.raw"
+                    }
+                },
+                {
+                    "driver": "$IMGFMT",
+                    "file": {
+                        "driver": "file",
+                        "filename": "$TEST_DIR/2.raw"
+                    }
+                }
+            ]
+        }
+    }
+    { "execute": "blockdev-add",
+        "arguments": {
+            "node-name": "drive3",
+            "driver": "$IMGFMT",
+            "file": {
+                "driver": "file",
+                "filename": "$TEST_DIR/2.raw"
+            }
+        }
+    }
+    { "execute": "x-blockdev-change",
+      "arguments": { "parent": "drive0-quorum",
+                     "node": "drive3" } }
+    { "execute": "quit" }
+EOF
+done
+
+echo
+echo "=3D=3D dynamically removing a child from a quorum =3D=3D"
+
+for verify in false true; do
+    for vote_threshold in 1 2; do
+        run_qemu <<EOF
+        { "execute": "qmp_capabilities" }
+        { "execute": "blockdev-add",
+            "arguments": {
+                "driver": "quorum",
+                "node-name": "drive0-quorum",
+                "vote-threshold": ${vote_threshold},
+                "blkverify": ${verify},
+                "children": [
+                    {
+                        "driver": "$IMGFMT",
+                        "file": {
+                            "driver": "file",
+                            "filename": "$TEST_DIR/1.raw"
+                        }
+                    },
+                    {
+                        "driver": "$IMGFMT",
+                        "file": {
+                            "driver": "file",
+                            "filename": "$TEST_DIR/2.raw"
+                        }
+                    }
+                ]
+            }
+        }
+        { "execute": "x-blockdev-change",
+          "arguments": { "parent": "drive0-quorum",
+                         "child": "children.1" } }
+        { "execute": "quit" }
+EOF
+    done
+done
+
 # success, all done
 echo "*** done"
 rm -f $seq.full
diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
index 2f12c890e9..8d81736336 100644
--- a/tests/qemu-iotests/081.out
+++ b/tests/qemu-iotests/081.out
@@ -71,4 +71,58 @@ read 10485760/10485760 bytes at offset 0
=20
 =3D=3D checking the blkverify mode with invalid settings =3D=3D
 can't open: blkverify=3Don can only be set if there are exactly two files =
and vote-threshold is 2
+
+=3D=3D dynamically adding a child to a quorum =3D=3D
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event"=
: "SHUTDOWN", "data": {"guest": false}}
+
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"error": {"class": "GenericError", "desc": "Cannot add a child to a quoru=
m in blkverify mode"}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event"=
: "SHUTDOWN", "data": {"guest": false}}
+
+
+=3D=3D dynamically removing a child from a quorum =3D=3D
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event"=
: "SHUTDOWN", "data": {"guest": false}}
+
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"error": {"class": "GenericError", "desc": "The number of children cannot=
 be lower than the vote threshold 2"}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event"=
: "SHUTDOWN", "data": {"guest": false}}
+
+Testing:
+QMP_VERSION
+{"return": {}}
+{"error": {"class": "GenericError", "desc": "blkverify=3Don can only be se=
t if there are exactly two files and vote-threshold is 2"}}
+{"error": {"class": "GenericError", "desc": "Cannot find device=3Ddrive0-q=
uorum nor node_name=3Ddrive0-quorum"}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event"=
: "SHUTDOWN", "data": {"guest": false}}
+
+Testing:
+QMP_VERSION
+{"return": {}}
+{"return": {}}
+{"error": {"class": "GenericError", "desc": "The number of children cannot=
 be lower than the vote threshold 2"}}
+{"return": {}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event"=
: "SHUTDOWN", "data": {"guest": false}}
+
 *** done
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 154143662959336.387990711455586;
 Mon, 5 Nov 2018 08:50:29 -0800 (PST)
Received: from localhost ([::1]:36229 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi55-0005bu-S9
	for importer@patchew.org; Mon, 05 Nov 2018 11:50:27 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51147)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhvF-0000mf-6K
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:40:20 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhv9-0008Pb-Qs
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:40:13 -0500
Received: from mx1.redhat.com ([209.132.183.28]:33852)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhv2-0004hu-Kr; Mon, 05 Nov 2018 11:40:04 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 6209DC028344;
	Mon,  5 Nov 2018 16:38:48 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 1D16960C46;
	Mon,  5 Nov 2018 16:38:46 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:27 +0100
Message-Id: <20181105163744.25139-20-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.31]);
	Mon, 05 Nov 2018 16:38:48 +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] [PULL 19/36] block: Update flags in
 bdrv_set_read_only()
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

To fully change the read-only state of a node, we must not only change
bs->read_only, but also update bs->open_flags.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
---
 block.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/block.c b/block.c
index 9d2adf7962..3132c78f01 100644
--- a/block.c
+++ b/block.c
@@ -281,6 +281,13 @@ int bdrv_set_read_only(BlockDriverState *bs, bool read=
_only, Error **errp)
     }
=20
     bs->read_only =3D read_only;
+
+    if (read_only) {
+        bs->open_flags &=3D ~BDRV_O_RDWR;
+    } else {
+        bs->open_flags |=3D BDRV_O_RDWR;
+    }
+
     return 0;
 }
=20
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 15414370799813.9346268184099245;
 Mon, 5 Nov 2018 08:57:59 -0800 (PST)
Received: from localhost ([::1]:36284 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiCM-00042V-OI
	for importer@patchew.org; Mon, 05 Nov 2018 11:57:58 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51815)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwh-0002uN-Dn
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:53 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwZ-0004Al-DN
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:44 -0500
Received: from mx1.redhat.com ([209.132.183.28]:41938)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhwB-0004ou-CY; Mon, 05 Nov 2018 11:41:15 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 7D67131256D5;
	Mon,  5 Nov 2018 16:38:50 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id AB4EB60C46;
	Mon,  5 Nov 2018 16:38:48 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:28 +0100
Message-Id: <20181105163744.25139-21-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.46]);
	Mon, 05 Nov 2018 16:38:50 +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] [PULL 20/36] block: Add auto-read-only option
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

If a management application builds the block graph node by node, the
protocol layer doesn't inherit its read-only option from the format
layer any more, so it must be set explicitly.

Backing files should work on read-only storage, but at the same time, a
block job like commit should be able to reopen them read-write if they
are on read-write storage. However, without option inheritance, reopen
only changes the read-only option for the root node (typically the
format layer), but not the protocol layer, so reopening fails (the
format layer wants to get write permissions, but the protocol layer is
still read-only).

A simple workaround for the problem in the management tool would be to
open the protocol layer always read-write and to make only the format
layer read-only for backing files. However, sometimes the file is
actually stored on read-only storage and we don't know whether the image
can be opened read-write (for example, for NBD it depends on the server
we're trying to connect to). This adds an option that makes QEMU try to
open the image read-write, but allows it to degrade to a read-only mode
without returning an error.

The documentation for this option is consciously phrased in a way that
allows QEMU to switch to a better model eventually: Instead of trying
when the image is first opened, making the read-only flag dynamic and
changing it automatically whenever the first BLK_PERM_WRITE user is
attached or the last one is detached would be much more useful
behaviour.

Unfortunately, this more useful behaviour is also a lot harder to
implement, and libvirt needs a solution now before it can switch to
-blockdev, so let's start with this easier approach for now.

Instead of adding a new auto-read-only option, turning the existing
read-only into an enum (with a bool alternate for compatibility) was
considered, but it complicated the implementation to the point that it
didn't seem to be worth it.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 qapi/block-core.json  |  7 +++++++
 include/block/block.h |  2 ++
 block.c               | 17 +++++++++++++++++
 block/vvfat.c         |  1 +
 blockdev.c            |  2 +-
 5 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/qapi/block-core.json b/qapi/block-core.json
index 0fc1590c1b..d4fe710836 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3656,6 +3656,12 @@
 #                 either generally or in certain configurations. In this c=
ase,
 #                 the default value does not work and the option must be
 #                 specified explicitly.
+# @auto-read-only: if true and @read-only is false, QEMU may automatically
+#                  decide not to open the image read-write as requested, b=
ut
+#                  fall back to read-only instead (and switch between the =
modes
+#                  later), e.g. depending on whether the image file is wri=
table
+#                  or whether a writing user is attached to the node
+#                  (default: false, since 3.1)
 # @detect-zeroes: detect and optimize zero writes (Since 2.1)
 #                 (default: off)
 # @force-share:   force share all permission on added nodes.
@@ -3671,6 +3677,7 @@
             '*discard': 'BlockdevDiscardOptions',
             '*cache': 'BlockdevCacheOptions',
             '*read-only': 'bool',
+            '*auto-read-only': 'bool',
             '*force-share': 'bool',
             '*detect-zeroes': 'BlockdevDetectZeroesOptions' },
   'discriminator': 'driver',
diff --git a/include/block/block.h b/include/block/block.h
index b189cf422e..580b3716c3 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -115,6 +115,7 @@ typedef struct HDGeometry {
                                       select an appropriate protocol drive=
r,
                                       ignoring the format layer */
 #define BDRV_O_NO_IO       0x10000 /* don't initialize for I/O */
+#define BDRV_O_AUTO_RDONLY 0x20000 /* degrade to read-only if opening read=
-write fails */
=20
 #define BDRV_O_CACHE_MASK  (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH)
=20
@@ -125,6 +126,7 @@ typedef struct HDGeometry {
 #define BDRV_OPT_CACHE_DIRECT   "cache.direct"
 #define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush"
 #define BDRV_OPT_READ_ONLY      "read-only"
+#define BDRV_OPT_AUTO_READ_ONLY "auto-read-only"
 #define BDRV_OPT_DISCARD        "discard"
 #define BDRV_OPT_FORCE_SHARE    "force-share"
=20
diff --git a/block.c b/block.c
index 3132c78f01..96090c3b9a 100644
--- a/block.c
+++ b/block.c
@@ -930,6 +930,7 @@ static void bdrv_inherited_options(int *child_flags, QD=
ict *child_options,
=20
     /* Inherit the read-only option from the parent if it's not set */
     qdict_copy_default(child_options, parent_options, BDRV_OPT_READ_ONLY);
+    qdict_copy_default(child_options, parent_options, BDRV_OPT_AUTO_READ_O=
NLY);
=20
     /* Our block drivers take care to send flushes and respect unmap polic=
y,
      * so we can default to enable both on lower layers regardless of the
@@ -1053,6 +1054,7 @@ static void bdrv_backing_options(int *child_flags, QD=
ict *child_options,
=20
     /* backing files always opened read-only */
     qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "on");
+    qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off");
     flags &=3D ~BDRV_O_COPY_ON_READ;
=20
     /* snapshot=3Don is handled on the top layer */
@@ -1142,6 +1144,10 @@ static void update_flags_from_options(int *flags, Qe=
muOpts *opts)
         *flags |=3D BDRV_O_RDWR;
     }
=20
+    assert(qemu_opt_find(opts, BDRV_OPT_AUTO_READ_ONLY));
+    if (qemu_opt_get_bool_del(opts, BDRV_OPT_AUTO_READ_ONLY, false)) {
+        *flags |=3D BDRV_O_AUTO_RDONLY;
+    }
 }
=20
 static void update_options_from_flags(QDict *options, int flags)
@@ -1156,6 +1162,10 @@ static void update_options_from_flags(QDict *options=
, int flags)
     if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) {
         qdict_put_bool(options, BDRV_OPT_READ_ONLY, !(flags & BDRV_O_RDWR)=
);
     }
+    if (!qdict_haskey(options, BDRV_OPT_AUTO_READ_ONLY)) {
+        qdict_put_bool(options, BDRV_OPT_AUTO_READ_ONLY,
+                       flags & BDRV_O_AUTO_RDONLY);
+    }
 }
=20
 static void bdrv_assign_node_name(BlockDriverState *bs,
@@ -1328,6 +1338,11 @@ QemuOptsList bdrv_runtime_opts =3D {
             .type =3D QEMU_OPT_BOOL,
             .help =3D "Node is opened in read-only mode",
         },
+        {
+            .name =3D BDRV_OPT_AUTO_READ_ONLY,
+            .type =3D QEMU_OPT_BOOL,
+            .help =3D "Node can become read-only if opening read-write fai=
ls",
+        },
         {
             .name =3D "detect-zeroes",
             .type =3D QEMU_OPT_STRING,
@@ -2486,6 +2501,8 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef =
*ref, Error **errp)
         qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off");
         qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off");
         qdict_set_default_str(qdict, BDRV_OPT_READ_ONLY, "off");
+        qdict_set_default_str(qdict, BDRV_OPT_AUTO_READ_ONLY, "off");
+
     }
=20
     bs =3D bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, errp);
diff --git a/block/vvfat.c b/block/vvfat.c
index f2e7d501cf..98ba5e2bac 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -3130,6 +3130,7 @@ static void vvfat_qcow_options(int *child_flags, QDic=
t *child_options,
                                int parent_flags, QDict *parent_options)
 {
     qdict_set_default_str(child_options, BDRV_OPT_READ_ONLY, "off");
+    qdict_set_default_str(child_options, BDRV_OPT_AUTO_READ_ONLY, "off");
     qdict_set_default_str(child_options, BDRV_OPT_CACHE_NO_FLUSH, "on");
 }
=20
diff --git a/blockdev.c b/blockdev.c
index c30495d035..fc8794862f 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2651,7 +2651,7 @@ void qmp_blockdev_change_medium(bool has_device, cons=
t char *device,
=20
     bdrv_flags =3D blk_get_open_flags_from_root_state(blk);
     bdrv_flags &=3D ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKI=
NG |
-        BDRV_O_PROTOCOL);
+        BDRV_O_PROTOCOL | BDRV_O_AUTO_RDONLY);
=20
     if (!has_read_only) {
         read_only =3D BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN;
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541438140562711.4241873208476;
 Mon, 5 Nov 2018 09:15:40 -0800 (PST)
Received: from localhost ([::1]:36431 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiTP-0001k6-3b
	for importer@patchew.org; Mon, 05 Nov 2018 12:15:35 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52320)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhxe-0004AA-00
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:51 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhxL-0006mC-GW
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:37 -0500
Received: from mx1.redhat.com ([209.132.183.28]:37312)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhww-0004wC-Sn; Mon, 05 Nov 2018 11:42:04 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 8489A3084293;
	Mon,  5 Nov 2018 16:38:52 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id AF40467140;
	Mon,  5 Nov 2018 16:38:50 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:29 +0100
Message-Id: <20181105163744.25139-22-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.40]);
	Mon, 05 Nov 2018 16:38:52 +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] [PULL 21/36] rbd: Close image in qemu_rbd_open() error
 path
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

Commit e2b8247a322 introduced an error path in qemu_rbd_open() after
calling rbd_open(), but neglected to close the image again in this error
path. The error path should contain everything that the regular close
function qemu_rbd_close() contains.

This adds the missing rbd_close() call.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/rbd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block/rbd.c b/block/rbd.c
index e5bf5a146f..1e9819a50f 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -787,6 +787,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *o=
ptions, int flags,
                          "automatically marking the image read-only.");
             r =3D bdrv_set_read_only(bs, true, &local_err);
             if (r < 0) {
+                rbd_close(s->image);
                 error_propagate(errp, local_err);
                 goto failed_open;
             }
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 15414366135166.073770234907897;
 Mon, 5 Nov 2018 08:50:13 -0800 (PST)
Received: from localhost ([::1]:36227 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi4q-0005PL-Dn
	for importer@patchew.org; Mon, 05 Nov 2018 11:50:12 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50829)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhuj-0008WJ-Ak
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:46 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhuc-0006ub-ES
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:45 -0500
Received: from mx1.redhat.com ([209.132.183.28]:42032)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhuH-000528-9R; Mon, 05 Nov 2018 11:39:17 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id E038731256AC;
	Mon,  5 Nov 2018 16:38:54 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id CDAE460F97;
	Mon,  5 Nov 2018 16:38:52 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:30 +0100
Message-Id: <20181105163744.25139-23-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.46]);
	Mon, 05 Nov 2018 16:38:54 +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] [PULL 22/36] block: Require auto-read-only for
 existing fallbacks
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

Some block drivers have traditionally changed their node to read-only
mode without asking the user. This behaviour has been marked deprecated
since 2.11, expecting users to provide an explicit read-only=3Don option.

Now that we have auto-read-only=3Don, enable these drivers to make use of
the option.

This is the only use of bdrv_set_read_only(), so we can make it a bit
more specific and turn it into a bdrv_apply_auto_read_only() that is
more convenient for drivers to use.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 include/block/block.h |  3 ++-
 block.c               | 42 +++++++++++++++++++++++++++---------------
 block/bochs.c         | 17 ++++++-----------
 block/cloop.c         | 16 +++++-----------
 block/dmg.c           | 16 +++++-----------
 block/rbd.c           | 15 ++++-----------
 block/vvfat.c         | 10 ++--------
 7 files changed, 51 insertions(+), 68 deletions(-)

diff --git a/include/block/block.h b/include/block/block.h
index 580b3716c3..7f5453b45b 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -438,7 +438,8 @@ int bdrv_is_allocated_above(BlockDriverState *top, Bloc=
kDriverState *base,
 bool bdrv_is_read_only(BlockDriverState *bs);
 int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
                            bool ignore_allow_rdw, Error **errp);
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
+int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg,
+                              Error **errp);
 bool bdrv_is_writable(BlockDriverState *bs);
 bool bdrv_is_sg(BlockDriverState *bs);
 bool bdrv_is_inserted(BlockDriverState *bs);
diff --git a/block.c b/block.c
index 96090c3b9a..fd67e14dfa 100644
--- a/block.c
+++ b/block.c
@@ -266,29 +266,41 @@ int bdrv_can_set_read_only(BlockDriverState *bs, bool=
 read_only,
     return 0;
 }
=20
-/* TODO Remove (deprecated since 2.11)
- * Block drivers are not supposed to automatically change bs->read_only.
- * Instead, they should just check whether they can provide what the user
- * explicitly requested and error out if read-write is requested, but they=
 can
- * only provide read-only access. */
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
+/*
+ * Called by a driver that can only provide a read-only image.
+ *
+ * Returns 0 if the node is already read-only or it could switch the node =
to
+ * read-only because BDRV_O_AUTO_RDONLY is set.
+ *
+ * Returns -EACCES if the node is read-write and BDRV_O_AUTO_RDONLY is not=
 set
+ * or bdrv_can_set_read_only() forbids making the node read-only. If @errm=
sg
+ * is not NULL, it is used as the error message for the Error object.
+ */
+int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg,
+                              Error **errp)
 {
     int ret =3D 0;
=20
-    ret =3D bdrv_can_set_read_only(bs, read_only, false, errp);
-    if (ret < 0) {
-        return ret;
+    if (!(bs->open_flags & BDRV_O_RDWR)) {
+        return 0;
+    }
+    if (!(bs->open_flags & BDRV_O_AUTO_RDONLY)) {
+        goto fail;
     }
=20
-    bs->read_only =3D read_only;
-
-    if (read_only) {
-        bs->open_flags &=3D ~BDRV_O_RDWR;
-    } else {
-        bs->open_flags |=3D BDRV_O_RDWR;
+    ret =3D bdrv_can_set_read_only(bs, true, false, NULL);
+    if (ret < 0) {
+        goto fail;
     }
=20
+    bs->read_only =3D true;
+    bs->open_flags &=3D ~BDRV_O_RDWR;
+
     return 0;
+
+fail:
+    error_setg(errp, "%s", errmsg ?: "Image is read-only");
+    return -EACCES;
 }
=20
 void bdrv_get_full_backing_filename_from_filename(const char *backed,
diff --git a/block/bochs.c b/block/bochs.c
index 50c630047b..22e7d44211 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -105,23 +105,18 @@ static int bochs_open(BlockDriverState *bs, QDict *op=
tions, int flags,
     struct bochs_header bochs;
     int ret;
=20
+    /* No write support yet */
+    ret =3D bdrv_apply_auto_read_only(bs, NULL, errp);
+    if (ret < 0) {
+        return ret;
+    }
+
     bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
     }
=20
-    if (!bdrv_is_read_only(bs)) {
-        error_report("Opening bochs images without an explicit read-only=
=3Don "
-                     "option is deprecated. Future versions will refuse to=
 "
-                     "open the image instead of automatically marking the "
-                     "image read-only.");
-        ret =3D bdrv_set_read_only(bs, true, errp); /* no write support ye=
t */
-        if (ret < 0) {
-            return ret;
-        }
-    }
-
     ret =3D bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
     if (ret < 0) {
         return ret;
diff --git a/block/cloop.c b/block/cloop.c
index 2be68987bd..df2b85f723 100644
--- a/block/cloop.c
+++ b/block/cloop.c
@@ -67,23 +67,17 @@ static int cloop_open(BlockDriverState *bs, QDict *opti=
ons, int flags,
     uint32_t offsets_size, max_compressed_block_size =3D 1, i;
     int ret;
=20
+    ret =3D bdrv_apply_auto_read_only(bs, NULL, errp);
+    if (ret < 0) {
+        return ret;
+    }
+
     bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
     }
=20
-    if (!bdrv_is_read_only(bs)) {
-        error_report("Opening cloop images without an explicit read-only=
=3Don "
-                     "option is deprecated. Future versions will refuse to=
 "
-                     "open the image instead of automatically marking the "
-                     "image read-only.");
-        ret =3D bdrv_set_read_only(bs, true, errp);
-        if (ret < 0) {
-            return ret;
-        }
-    }
-
     /* read header */
     ret =3D bdrv_pread(bs->file, 128, &s->block_size, 4);
     if (ret < 0) {
diff --git a/block/dmg.c b/block/dmg.c
index c9b3c519c4..1d9283ba2f 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -413,23 +413,17 @@ static int dmg_open(BlockDriverState *bs, QDict *opti=
ons, int flags,
     int64_t offset;
     int ret;
=20
+    ret =3D bdrv_apply_auto_read_only(bs, NULL, errp);
+    if (ret < 0) {
+        return ret;
+    }
+
     bs->file =3D bdrv_open_child(NULL, options, "file", bs, &child_file,
                                false, errp);
     if (!bs->file) {
         return -EINVAL;
     }
=20
-    if (!bdrv_is_read_only(bs)) {
-        error_report("Opening dmg images without an explicit read-only=3Do=
n "
-                     "option is deprecated. Future versions will refuse to=
 "
-                     "open the image instead of automatically marking the "
-                     "image read-only.");
-        ret =3D bdrv_set_read_only(bs, true, errp);
-        if (ret < 0) {
-            return ret;
-        }
-    }
-
     block_module_load_one("dmg-bz2");
=20
     s->n_chunks =3D 0;
diff --git a/block/rbd.c b/block/rbd.c
index 1e9819a50f..8a1a9f4b6e 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -780,17 +780,10 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict =
*options, int flags,
     /* If we are using an rbd snapshot, we must be r/o, otherwise
      * leave as-is */
     if (s->snap !=3D NULL) {
-        if (!bdrv_is_read_only(bs)) {
-            error_report("Opening rbd snapshots without an explicit "
-                         "read-only=3Don option is deprecated. Future vers=
ions "
-                         "will refuse to open the image instead of "
-                         "automatically marking the image read-only.");
-            r =3D bdrv_set_read_only(bs, true, &local_err);
-            if (r < 0) {
-                rbd_close(s->image);
-                error_propagate(errp, local_err);
-                goto failed_open;
-            }
+        r =3D bdrv_apply_auto_read_only(bs, "rbd snapshots are read-only",=
 errp);
+        if (r < 0) {
+            rbd_close(s->image);
+            goto failed_open;
         }
     }
=20
diff --git a/block/vvfat.c b/block/vvfat.c
index 98ba5e2bac..e4df255d58 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -1262,15 +1262,9 @@ static int vvfat_open(BlockDriverState *bs, QDict *o=
ptions, int flags,
                        "Unable to set VVFAT to 'rw' when drive is read-onl=
y");
             goto fail;
         }
-    } else  if (!bdrv_is_read_only(bs)) {
-        error_report("Opening non-rw vvfat images without an explicit "
-                     "read-only=3Don option is deprecated. Future versions=
 "
-                     "will refuse to open the image instead of "
-                     "automatically marking the image read-only.");
-        /* read only is the default for safety */
-        ret =3D bdrv_set_read_only(bs, true, &local_err);
+    } else {
+        ret =3D bdrv_apply_auto_read_only(bs, NULL, errp);
         if (ret < 0) {
-            error_propagate(errp, local_err);
             goto fail;
         }
     }
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437198509960.0208141804503;
 Mon, 5 Nov 2018 08:59:58 -0800 (PST)
Received: from localhost ([::1]:36295 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiEH-0005jU-B1
	for importer@patchew.org; Mon, 05 Nov 2018 11:59:57 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51249)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhvb-0001Lz-On
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:40:40 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhvR-0000an-Uz
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:40:37 -0500
Received: from mx1.redhat.com ([209.132.183.28]:35322)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhv8-00055K-SR; Mon, 05 Nov 2018 11:40:11 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 9543C8831A;
	Mon,  5 Nov 2018 16:38:56 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 348F660C61;
	Mon,  5 Nov 2018 16:38:55 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:31 +0100
Message-Id: <20181105163744.25139-24-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.28]);
	Mon, 05 Nov 2018 16:38:56 +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] [PULL 23/36] nbd: Support auto-read-only option
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

If read-only=3Doff, but auto-read-only=3Don is given, open a read-write NBD
connection if the server provides a read-write export, but instead of
erroring out for read-only exports, just degrade to read-only.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/nbd-client.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index 9686ecbd5e..76e9ca3abe 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -992,11 +992,11 @@ int nbd_client_init(BlockDriverState *bs,
         logout("Failed to negotiate with the NBD server\n");
         return ret;
     }
-    if (client->info.flags & NBD_FLAG_READ_ONLY &&
-        !bdrv_is_read_only(bs)) {
-        error_setg(errp,
-                   "request for write access conflicts with read-only expo=
rt");
-        return -EACCES;
+    if (client->info.flags & NBD_FLAG_READ_ONLY) {
+        ret =3D bdrv_apply_auto_read_only(bs, "NBD export is read-only", e=
rrp);
+        if (ret < 0) {
+            return ret;
+        }
     }
     if (client->info.flags & NBD_FLAG_SEND_FUA) {
         bs->supported_write_flags =3D BDRV_REQ_FUA;
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437979030156.55108621986358;
 Mon, 5 Nov 2018 09:12:59 -0800 (PST)
Received: from localhost ([::1]:36412 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiQp-0005xg-Qt
	for importer@patchew.org; Mon, 05 Nov 2018 12:12:55 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52154)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhx2-0003Gm-8G
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:09 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwt-0005HD-2B
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:04 -0500
Received: from mx1.redhat.com ([209.132.183.28]:42102)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhwl-00059I-EP; Mon, 05 Nov 2018 11:41:51 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 9C19331256BE;
	Mon,  5 Nov 2018 16:38:58 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id E128B60C5C;
	Mon,  5 Nov 2018 16:38:56 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:32 +0100
Message-Id: <20181105163744.25139-25-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.46]);
	Mon, 05 Nov 2018 16:38:58 +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] [PULL 24/36] file-posix: Support auto-read-only option
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

If read-only=3Doff, but auto-read-only=3Don is given, open the file
read-write if we have the permissions, but instead of erroring out for
read-only files, just degrade to read-only.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/file-posix.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 2da3a76355..0c1b81ce4b 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -527,9 +527,22 @@ static int raw_open_common(BlockDriverState *bs, QDict=
 *options,
=20
     s->fd =3D -1;
     fd =3D qemu_open(filename, s->open_flags, 0644);
-    if (fd < 0) {
-        ret =3D -errno;
-        error_setg_errno(errp, errno, "Could not open '%s'", filename);
+    ret =3D fd < 0 ? -errno : 0;
+
+    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) {
             ret =3D -EACCES;
         }
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437230591731.1003945919406;
 Mon, 5 Nov 2018 09:00:30 -0800 (PST)
Received: from localhost ([::1]:36296 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiEn-0006aP-F2
	for importer@patchew.org; Mon, 05 Nov 2018 12:00:29 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52744)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhxy-0004k2-SK
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:43:07 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhxw-0007kI-FN
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:43:06 -0500
Received: from mx1.redhat.com ([209.132.183.28]:36430)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhxs-0005El-NE; Mon, 05 Nov 2018 11:43:00 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id B29B5C05D3F3;
	Mon,  5 Nov 2018 16:39:00 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id E5ACA60C5C;
	Mon,  5 Nov 2018 16:38:58 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:33 +0100
Message-Id: <20181105163744.25139-26-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.32]);
	Mon, 05 Nov 2018 16:39:00 +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] [PULL 25/36] curl: Support auto-read-only option
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

If read-only=3Doff, but auto-read-only=3Don is given, just degrade to
read-only.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/curl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/curl.c b/block/curl.c
index fabb2b4da7..db5d2bd8ef 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -684,10 +684,10 @@ static int curl_open(BlockDriverState *bs, QDict *opt=
ions, int flags,
     const char *protocol_delimiter;
     int ret;
=20
-
-    if (flags & BDRV_O_RDWR) {
-        error_setg(errp, "curl block device does not support writes");
-        return -EROFS;
+    ret =3D bdrv_apply_auto_read_only(bs, "curl driver does not support wr=
ites",
+                                    errp);
+    if (ret < 0) {
+        return ret;
     }
=20
     if (!libcurl_initialized) {
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437288612767.6363616453534;
 Mon, 5 Nov 2018 09:01:28 -0800 (PST)
Received: from localhost ([::1]:36306 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiFg-0007D9-Cp
	for importer@patchew.org; Mon, 05 Nov 2018 12:01:24 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52439)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhxk-0004N5-Ol
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:53 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhxj-00079O-Dt
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:52 -0500
Received: from mx1.redhat.com ([209.132.183.28]:58524)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhx6-0005J6-84; Mon, 05 Nov 2018 11:42:14 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 7459630026DA;
	Mon,  5 Nov 2018 16:39:03 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id EF22A65F4C;
	Mon,  5 Nov 2018 16:39:00 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:34 +0100
Message-Id: <20181105163744.25139-27-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.47]);
	Mon, 05 Nov 2018 16:39:03 +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] [PULL 26/36] gluster: Support auto-read-only option
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

If read-only=3Doff, but auto-read-only=3Don is given, open the file
read-write if we have the permissions, but instead of erroring out for
read-only files, just degrade to read-only.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
---
 block/gluster.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/block/gluster.c b/block/gluster.c
index 4fd55a9cc5..5e300c96c8 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -849,8 +849,16 @@ static int qemu_gluster_open(BlockDriverState *bs,  QD=
ict *options,
     qemu_gluster_parse_flags(bdrv_flags, &open_flags);
=20
     s->fd =3D glfs_open(s->glfs, gconf->path, open_flags);
-    if (!s->fd) {
-        ret =3D -errno;
+    ret =3D s->fd ? 0 : -errno;
+
+    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) {
+            open_flags =3D (open_flags & ~O_RDWR) | O_RDONLY;
+            s->fd =3D glfs_open(s->glfs, gconf->path, open_flags);
+            ret =3D s->fd ? 0 : -errno;
+        }
     }
=20
     s->supports_seek_data =3D qemu_gluster_test_seek(s->fd);
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541438326982793.4987023318484;
 Mon, 5 Nov 2018 09:18:46 -0800 (PST)
Received: from localhost ([::1]:36475 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiWT-00045L-R6
	for importer@patchew.org; Mon, 05 Nov 2018 12:18:45 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52913)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhy7-0004zE-CU
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:43:16 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhy6-0008AQ-6g
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:43:15 -0500
Received: from mx1.redhat.com ([209.132.183.28]:43220)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhxy-0005Mk-RB; Mon, 05 Nov 2018 11:43:07 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 687143081248;
	Mon,  5 Nov 2018 16:39:06 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id BE96F60C5C;
	Mon,  5 Nov 2018 16:39:03 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:35 +0100
Message-Id: <20181105163744.25139-28-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.49]);
	Mon, 05 Nov 2018 16:39:06 +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] [PULL 27/36] iscsi: Support auto-read-only option
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

If read-only=3Doff, but auto-read-only=3Don is given, open the volume
read-write if we have the permissions, but instead of erroring out for
read-only volumes, just degrade to read-only.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/iscsi.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/block/iscsi.c b/block/iscsi.c
index 73998c2860..727dee50bf 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1878,9 +1878,11 @@ static int iscsi_open(BlockDriverState *bs, QDict *o=
ptions, int flags,
     /* Check the write protect flag of the LUN if we want to write */
     if (iscsilun->type =3D=3D TYPE_DISK && (flags & BDRV_O_RDWR) &&
         iscsilun->write_protected) {
-        error_setg(errp, "Cannot open a write protected LUN as read-write"=
);
-        ret =3D -EACCES;
-        goto out;
+        ret =3D bdrv_apply_auto_read_only(bs, "LUN is write protected", er=
rp);
+        if (ret < 0) {
+            goto out;
+        }
+        flags &=3D ~BDRV_O_RDWR;
     }
=20
     iscsi_readcapacity_sync(iscsilun, &local_err);
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437603130765.5803428916992;
 Mon, 5 Nov 2018 09:06:43 -0800 (PST)
Received: from localhost ([::1]:36345 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiKo-0007RR-0U
	for importer@patchew.org; Mon, 05 Nov 2018 12:06:42 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51813)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwh-0002uK-EZ
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:48 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwZ-0004At-Dt
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:44 -0500
Received: from mx1.redhat.com ([209.132.183.28]:8154)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhw7-0005PE-RD; Mon, 05 Nov 2018 11:41:12 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 04E7B308FEC3;
	Mon,  5 Nov 2018 16:39:08 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id B4F6660C5C;
	Mon,  5 Nov 2018 16:39:06 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:36 +0100
Message-Id: <20181105163744.25139-29-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.49]);
	Mon, 05 Nov 2018 16:39:08 +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] [PULL 28/36] block: Make auto-read-only=on default for
 -drive
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

While we want machine interfaces like -blockdev and QMP blockdev-add to
add as little auto-detection as possible so that management tools are
explicit about their needs, -drive is a convenience option for human
users. Enabling auto-read-only=3Don by default there enables users to use
read-only images for read-only guest devices without having to specify
read-only=3Don explicitly. If they try to attach the image to a read-write
device, they will still get an error message.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 blockdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/blockdev.c b/blockdev.c
index fc8794862f..e5b5eb46e2 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -590,6 +590,7 @@ static BlockBackend *blockdev_init(const char *file, QD=
ict *bs_opts,
         qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off");
         qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY,
                               read_only ? "on" : "off");
+        qdict_set_default_str(bs_opts, BDRV_OPT_AUTO_READ_ONLY, "on");
         assert((bdrv_flags & BDRV_O_CACHE_MASK) =3D=3D 0);
=20
         if (runstate_check(RUN_STATE_INMIGRATE)) {
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437809252715.548670765954;
 Mon, 5 Nov 2018 09:10:09 -0800 (PST)
Received: from localhost ([::1]:36391 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiO2-0003bN-Sx
	for importer@patchew.org; Mon, 05 Nov 2018 12:10:02 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52075)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwt-000381-9B
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:04 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwn-000529-If
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:56 -0500
Received: from mx1.redhat.com ([209.132.183.28]:56228)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhwc-0005Rs-EU; Mon, 05 Nov 2018 11:41:44 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 564563001FD1;
	Mon,  5 Nov 2018 16:39:10 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 4F5F760C5C;
	Mon,  5 Nov 2018 16:39:08 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:37 +0100
Message-Id: <20181105163744.25139-30-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.45]);
	Mon, 05 Nov 2018 16:39:10 +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] [PULL 29/36] qemu-iotests: Test auto-read-only with
 -drive and -blockdev
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 tests/qemu-iotests/232     | 147 +++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/232.out |  59 +++++++++++++++
 tests/qemu-iotests/group   |   1 +
 3 files changed, 207 insertions(+)
 create mode 100755 tests/qemu-iotests/232
 create mode 100644 tests/qemu-iotests/232.out

diff --git a/tests/qemu-iotests/232 b/tests/qemu-iotests/232
new file mode 100755
index 0000000000..bc2972d124
--- /dev/null
+++ b/tests/qemu-iotests/232
@@ -0,0 +1,147 @@
+#!/bin/bash
+#
+# Test for auto-read-only
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+
+# creator
+owner=3Dkwolf@redhat.com
+
+seq=3D`basename $0`
+echo "QA output created by $seq"
+
+here=3D`pwd`
+status=3D1	# failure is the default!
+
+_cleanup()
+{
+    _cleanup_test_img
+    rm -f $TEST_IMG.snap
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+_supported_fmt generic
+_supported_proto file
+_supported_os Linux
+
+function do_run_qemu()
+{
+    echo Testing: "$@"
+    (
+        if ! test -t 0; then
+            while read cmd; do
+                echo $cmd
+            done
+        fi
+        echo quit
+    ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
+    echo
+}
+
+function run_qemu()
+{
+    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
+        _filter_generated_node_ids | _filter_imgfmt
+}
+
+function run_qemu_info_block()
+{
+    echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG"
+}
+
+size=3D128M
+
+_make_test_img $size
+
+echo
+echo "=3D=3D=3D -drive with read-write image: read-only/auto-read-only com=
binations =3D=3D=3D"
+echo
+
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Don,auto-read-only=3Doff
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Don,auto-read-only=3Don
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Don
+echo
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Doff,auto-read-only=3Doff
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Doff,auto-read-only=3Don
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Doff
+echo
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,auto=
-read-only=3Doff
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,auto=
-read-only=3Don
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone
+
+echo
+echo "=3D=3D=3D -drive with read-only image: read-only/auto-read-only comb=
inations =3D=3D=3D"
+echo
+
+chmod a-w $TEST_IMG
+
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Don,auto-read-only=3Doff
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Don,auto-read-only=3Don
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Don
+echo
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Doff,auto-read-only=3Doff
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Doff,auto-read-only=3Don
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,read=
-only=3Doff
+echo
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,auto=
-read-only=3Doff
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone,auto=
-read-only=3Don
+run_qemu_info_block -drive driver=3Dfile,file=3D"$TEST_IMG",if=3Dnone
+
+echo
+echo "=3D=3D=3D -blockdev with read-write image: read-only/auto-read-only =
combinations =3D=3D=3D"
+echo
+
+chmod a+w $TEST_IMG
+
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Don,auto-read-only=3Doff
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Don,auto-read-only=3Don
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Don
+echo
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Doff,auto-read-only=3Doff
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Doff,auto-read-only=3Don
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Doff
+echo
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,auto-read-only=3Doff
+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
+
+echo
+echo "=3D=3D=3D -blockdev with read-only image: read-only/auto-read-only c=
ombinations =3D=3D=3D"
+echo
+
+chmod a-w $TEST_IMG
+
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Don,auto-read-only=3Doff
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Don,auto-read-only=3Don
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Don
+echo
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Doff,auto-read-only=3Doff
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Doff,auto-read-only=3Don
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,read-only=3Doff
+echo
+run_qemu_info_block -blockdev driver=3Dfile,filename=3D"$TEST_IMG",node-na=
me=3Dnode0,auto-read-only=3Doff
+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
+
+# success, all done
+echo "*** done"
+rm -f $seq.full
+status=3D0
diff --git a/tests/qemu-iotests/232.out b/tests/qemu-iotests/232.out
new file mode 100644
index 0000000000..dcb683afa3
--- /dev/null
+++ b/tests/qemu-iotests/232.out
@@ -0,0 +1,59 @@
+QA output created by 232
+Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728
+
+=3D=3D=3D -drive with read-write image: read-only/auto-read-only combinati=
ons =3D=3D=3D
+
+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, read-only)
+
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
+
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
+NODE_NAME: TEST_DIR/t.IMGFMT (file)
+
+=3D=3D=3D -drive with read-only image: read-only/auto-read-only combinatio=
ns =3D=3D=3D
+
+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, read-only)
+
+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)
+
+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)
+
+=3D=3D=3D -blockdev with read-write image: read-only/auto-read-only combin=
ations =3D=3D=3D
+
+node0: TEST_DIR/t.IMGFMT (file, read-only)
+node0: TEST_DIR/t.IMGFMT (file, read-only)
+node0: TEST_DIR/t.IMGFMT (file, read-only)
+
+node0: TEST_DIR/t.IMGFMT (file)
+node0: TEST_DIR/t.IMGFMT (file)
+node0: TEST_DIR/t.IMGFMT (file)
+
+node0: TEST_DIR/t.IMGFMT (file)
+node0: TEST_DIR/t.IMGFMT (file)
+node0: TEST_DIR/t.IMGFMT (file)
+
+=3D=3D=3D -blockdev with read-only image: read-only/auto-read-only combina=
tions =3D=3D=3D
+
+node0: TEST_DIR/t.IMGFMT (file, read-only)
+node0: TEST_DIR/t.IMGFMT (file, read-only)
+node0: TEST_DIR/t.IMGFMT (file, read-only)
+
+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)
+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
+
+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)
+QEMU_PROG: -blockdev driver=3Dfile,filename=3DTEST_DIR/t.IMGFMT,node-name=
=3Dnode0: Could not open 'TEST_DIR/t.IMGFMT': Permission denied
+*** done
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 31f6e77dcb..ebe4fe78bc 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -227,3 +227,4 @@
 227 auto quick
 229 auto quick
 231 auto quick
+232 auto quick
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436752063727.3915994696251;
 Mon, 5 Nov 2018 08:52:32 -0800 (PST)
Received: from localhost ([::1]:36245 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi6x-00072O-2N
	for importer@patchew.org; Mon, 05 Nov 2018 11:52:23 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50885)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhur-0000Gm-DM
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:59 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhuf-00072R-EQ
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:39:49 -0500
Received: from mx1.redhat.com ([209.132.183.28]:58636)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhuF-0005ZY-TT; Mon, 05 Nov 2018 11:39:16 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 288B630034A5;
	Mon,  5 Nov 2018 16:39:13 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 7FF2760C61;
	Mon,  5 Nov 2018 16:39:10 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:38 +0100
Message-Id: <20181105163744.25139-31-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.47]);
	Mon, 05 Nov 2018 16:39:13 +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] [PULL 30/36] option: Make option help nicer to read
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Max Reitz <mreitz@redhat.com>

This adds some whitespace into the option help (including indentation)
and puts angle brackets around the type names.  Furthermore, the list
name is no longer printed as part of every line, but only once in
advance, and only if the caller did not print a caption already.

This patch also restores the description alignment we had before commit
9cbef9d68ee1d8d0, just at 24 instead of 16 characters like we used to.
This increase is because now we have the type and two spaces of
indentation before the description, and with a usual type name length of
three chracters, this sums up to eight additional characters -- which
means that we now need 24 characters to get the same amount of padding
for most options.  Also, 24 is a third of 80, which makes it kind of a
round number in terminal terms.

Finally, this patch amends the reference output of iotest 082 to match
the changes (and thus makes it pass again).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/qemu/option.h      |   2 +-
 qemu-img.c                 |   4 +-
 util/qemu-option.c         |  32 +-
 tests/qemu-iotests/082.out | 956 ++++++++++++++++++-------------------
 4 files changed, 507 insertions(+), 487 deletions(-)

diff --git a/include/qemu/option.h b/include/qemu/option.h
index 3dfb4493cc..844587cab3 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -132,7 +132,7 @@ typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpt=
s *opts, Error **errp);
 int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func,
                       void *opaque, Error **errp);
 void qemu_opts_print(QemuOpts *opts, const char *sep);
-void qemu_opts_print_help(QemuOptsList *list);
+void qemu_opts_print_help(QemuOptsList *list, bool print_caption);
 void qemu_opts_free(QemuOptsList *list);
 QemuOptsList *qemu_opts_append(QemuOptsList *dst, QemuOptsList *list);
=20
diff --git a/qemu-img.c b/qemu-img.c
index b12f4cd19b..4c96db7ba4 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -269,7 +269,7 @@ static int print_block_option_help(const char *filename=
, const char *fmt)
     }
=20
     printf("Supported options:\n");
-    qemu_opts_print_help(create_opts);
+    qemu_opts_print_help(create_opts, false);
     qemu_opts_free(create_opts);
     return 0;
 }
@@ -3773,7 +3773,7 @@ static int print_amend_option_help(const char *format)
     assert(drv->create_opts);
=20
     printf("Creation options for '%s':\n", format);
-    qemu_opts_print_help(drv->create_opts);
+    qemu_opts_print_help(drv->create_opts, false);
     printf("\nNote that not all of these options may be amendable.\n");
     return 0;
 }
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 9a5f263294..de42e2a406 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -224,7 +224,14 @@ static const char *opt_type_to_string(enum QemuOptType=
 type)
     g_assert_not_reached();
 }
=20
-void qemu_opts_print_help(QemuOptsList *list)
+/**
+ * Print the list of options available in the given list.  If
+ * @print_caption is true, a caption (including the list name, if it
+ * exists) is printed.  The options itself will be indented, so
+ * @print_caption should only be set to false if the caller prints its
+ * own custom caption (so that the indentation makes sense).
+ */
+void qemu_opts_print_help(QemuOptsList *list, bool print_caption)
 {
     QemuOptDesc *desc;
     int i;
@@ -234,12 +241,12 @@ void qemu_opts_print_help(QemuOptsList *list)
     desc =3D list->desc;
     while (desc && desc->name) {
         GString *str =3D g_string_new(NULL);
-        if (list->name) {
-            g_string_append_printf(str, "%s.", list->name);
-        }
-        g_string_append_printf(str, "%s=3D%s", desc->name,
+        g_string_append_printf(str, "  %s=3D<%s>", desc->name,
                                opt_type_to_string(desc->type));
         if (desc->help) {
+            if (str->len < 24) {
+                g_string_append_printf(str, "%*s", 24 - (int)str->len, "");
+            }
             g_string_append_printf(str, " - %s", desc->help);
         }
         g_ptr_array_add(array, g_string_free(str, false));
@@ -247,6 +254,19 @@ void qemu_opts_print_help(QemuOptsList *list)
     }
=20
     g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
+    if (print_caption && array->len > 0) {
+        if (list->name) {
+            printf("%s options:\n", list->name);
+        } else {
+            printf("Options:\n");
+        }
+    } else if (array->len =3D=3D 0) {
+        if (list->name) {
+            printf("There are no options for %s.\n", list->name);
+        } else {
+            printf("No options available.\n");
+        }
+    }
     for (i =3D 0; i < array->len; i++) {
         printf("%s\n", (char *)array->pdata[i]);
     }
@@ -930,7 +950,7 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, c=
onst char *params,
     opts =3D opts_parse(list, params, permit_abbrev, false, &invalidp, &er=
r);
     if (err) {
         if (invalidp && has_help_option(params)) {
-            qemu_opts_print_help(list);
+            qemu_opts_print_help(list, true);
             error_free(err);
         } else {
             error_report_err(err);
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
index 19e9fb13ff..0ce18c075b 100644
--- a/tests/qemu-iotests/082.out
+++ b/tests/qemu-iotests/082.out
@@ -44,171 +44,171 @@ cluster_size: 8192
=20
 Testing: create -f qcow2 -o help TEST_DIR/t.qcow2 128M
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: create -f qcow2 -o ? TEST_DIR/t.qcow2 128M
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: create -f qcow2 -o cluster_size=3D4k,help TEST_DIR/t.qcow2 128M
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: create -f qcow2 -o cluster_size=3D4k,? TEST_DIR/t.qcow2 128M
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: create -f qcow2 -o help,cluster_size=3D4k TEST_DIR/t.qcow2 128M
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: create -f qcow2 -o ?,cluster_size=3D4k TEST_DIR/t.qcow2 128M
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: create -f qcow2 -o cluster_size=3D4k -o help TEST_DIR/t.qcow2 128M
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: create -f qcow2 -o cluster_size=3D4k -o ? TEST_DIR/t.qcow2 128M
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: create -f qcow2 -u -o backing_file=3DTEST_DIR/t.qcow2,,help TEST_=
DIR/t.qcow2 128M
 Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 backing_file=
=3DTEST_DIR/t.qcow2,,help cluster_size=3D65536 lazy_refcounts=3Doff refcoun=
t_bits=3D16
@@ -227,27 +227,27 @@ qemu-img: Invalid option list: ,,
=20
 Testing: create -f qcow2 -o help
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: create -o help
 Supported options:
-size             Virtual disk size
+  size=3D<size>            - Virtual disk size
=20
 Testing: create -f bochs -o help
 qemu-img: Format driver 'bochs' does not support image creation
@@ -300,171 +300,171 @@ cluster_size: 8192
=20
 Testing: convert -O qcow2 -o help TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: convert -O qcow2 -o ? TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: convert -O qcow2 -o cluster_size=3D4k,help TEST_DIR/t.qcow2 TEST_=
DIR/t.qcow2.base
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: convert -O qcow2 -o cluster_size=3D4k,? TEST_DIR/t.qcow2 TEST_DIR=
/t.qcow2.base
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: convert -O qcow2 -o help,cluster_size=3D4k TEST_DIR/t.qcow2 TEST_=
DIR/t.qcow2.base
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: convert -O qcow2 -o ?,cluster_size=3D4k TEST_DIR/t.qcow2 TEST_DIR=
/t.qcow2.base
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: convert -O qcow2 -o cluster_size=3D4k -o help TEST_DIR/t.qcow2 TE=
ST_DIR/t.qcow2.base
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: convert -O qcow2 -o cluster_size=3D4k -o ? TEST_DIR/t.qcow2 TEST_=
DIR/t.qcow2.base
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
-nocow            Turn off copy-on-write (valid only on btrfs)
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  nocow=3D<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: convert -O qcow2 -o backing_file=3DTEST_DIR/t.qcow2,,help TEST_DI=
R/t.qcow2 TEST_DIR/t.qcow2.base
 qemu-img: Could not open 'TEST_DIR/t.qcow2.base': Could not open backing f=
ile: Could not open 'TEST_DIR/t.qcow2,help': No such file or directory
@@ -483,27 +483,27 @@ qemu-img: Invalid option list: ,,
=20
 Testing: convert -O qcow2 -o help
 Supported options:
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Testing: convert -o help
 Supported options:
-size             Virtual disk size
+  size=3D<size>            - Virtual disk size
=20
 Testing: convert -O bochs -o help
 qemu-img: Format driver 'bochs' does not support image creation
@@ -564,177 +564,177 @@ cluster_size: 65536
=20
 Testing: amend -f qcow2 -o help TEST_DIR/t.qcow2
 Creation options for 'qcow2':
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Note that not all of these options may be amendable.
=20
 Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2
 Creation options for 'qcow2':
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Note that not all of these options may be amendable.
=20
 Testing: amend -f qcow2 -o cluster_size=3D4k,help TEST_DIR/t.qcow2
 Creation options for 'qcow2':
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Note that not all of these options may be amendable.
=20
 Testing: amend -f qcow2 -o cluster_size=3D4k,? TEST_DIR/t.qcow2
 Creation options for 'qcow2':
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Note that not all of these options may be amendable.
=20
 Testing: amend -f qcow2 -o help,cluster_size=3D4k TEST_DIR/t.qcow2
 Creation options for 'qcow2':
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Note that not all of these options may be amendable.
=20
 Testing: amend -f qcow2 -o ?,cluster_size=3D4k TEST_DIR/t.qcow2
 Creation options for 'qcow2':
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Note that not all of these options may be amendable.
=20
 Testing: amend -f qcow2 -o cluster_size=3D4k -o help TEST_DIR/t.qcow2
 Creation options for 'qcow2':
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Note that not all of these options may be amendable.
=20
 Testing: amend -f qcow2 -o cluster_size=3D4k -o ? TEST_DIR/t.qcow2
 Creation options for 'qcow2':
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Note that not all of these options may be amendable.
=20
@@ -757,29 +757,29 @@ qemu-img: Invalid option list: ,,
=20
 Testing: amend -f qcow2 -o help
 Creation options for 'qcow2':
-size             Virtual disk size
-compat           Compatibility level (0.10 or 1.1)
-backing_file     File name of a base image
-backing_fmt      Image format of the base image
-encryption       Encrypt the image with format 'aes'. (Deprecated in favor=
 of encrypt.format=3Daes)
-encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
-encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
-encrypt.cipher-alg Name of encryption cipher algorithm
-encrypt.cipher-mode Name of encryption cipher mode
-encrypt.ivgen-alg Name of IV generator algorithm
-encrypt.ivgen-hash-alg Name of IV generator hash algorithm
-encrypt.hash-alg Name of encryption hash algorithm
-encrypt.iter-time Time to spend in PBKDF in milliseconds
-cluster_size     qcow2 cluster size
-preallocation    Preallocation mode (allowed values: off, metadata, falloc=
, full)
-lazy_refcounts   Postpone refcount updates
-refcount_bits    Width of a reference count entry in bits
+  backing_file=3D<str>     - File name of a base image
+  backing_fmt=3D<str>      - Image format of the base image
+  cluster_size=3D<size>    - qcow2 cluster size
+  compat=3D<str>           - Compatibility level (0.10 or 1.1)
+  encrypt.cipher-alg=3D<str> - Name of encryption cipher algorithm
+  encrypt.cipher-mode=3D<str> - Name of encryption cipher mode
+  encrypt.format=3D<str>   - Encrypt the image, format choices: 'aes', 'lu=
ks'
+  encrypt.hash-alg=3D<str> - Name of encryption hash algorithm
+  encrypt.iter-time=3D<num> - Time to spend in PBKDF in milliseconds
+  encrypt.ivgen-alg=3D<str> - Name of IV generator algorithm
+  encrypt.ivgen-hash-alg=3D<str> - Name of IV generator hash algorithm
+  encrypt.key-secret=3D<str> - ID of secret providing qcow AES key or LUKS=
 passphrase
+  encryption=3D<bool (on/off)> - Encrypt the image with format 'aes'. (Dep=
recated in favor of encrypt.format=3Daes)
+  lazy_refcounts=3D<bool (on/off)> - Postpone refcount updates
+  preallocation=3D<str>    - Preallocation mode (allowed values: off, meta=
data, falloc, full)
+  refcount_bits=3D<num>    - Width of a reference count entry in bits
+  size=3D<size>            - Virtual disk size
=20
 Note that not all of these options may be amendable.
=20
 Testing: convert -o help
 Supported options:
-size             Virtual disk size
+  size=3D<size>            - Virtual disk size
=20
 Testing: amend -f bochs -o help
 qemu-img: Format driver 'bochs' does not support option amendment
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436839663189.7727192795545;
 Mon, 5 Nov 2018 08:53:59 -0800 (PST)
Received: from localhost ([::1]:36255 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi8S-0008MK-Eh
	for importer@patchew.org; Mon, 05 Nov 2018 11:53:56 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51148)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhvF-0000mk-6Z
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:40:20 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhv9-0008PS-PD
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:40:12 -0500
Received: from mx1.redhat.com ([209.132.183.28]:64119)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhv2-0005zO-9h; Mon, 05 Nov 2018 11:40:04 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 40B828E5AB;
	Mon,  5 Nov 2018 16:39:17 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id BB6BC662DF;
	Mon,  5 Nov 2018 16:39:12 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:39 +0100
Message-Id: <20181105163744.25139-32-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.28]);
	Mon, 05 Nov 2018 16:39:17 +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] [PULL 31/36] chardev: Indent list of chardevs
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Max Reitz <mreitz@redhat.com>

Following the example of qemu_opts_print_help(), indent all entries in
the list of character devices.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 chardev/char.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/chardev/char.c b/chardev/char.c
index 79b05fb7b7..152dde5327 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -572,7 +572,7 @@ help_string_append(const char *name, void *opaque)
 {
     GString *str =3D opaque;
=20
-    g_string_append_printf(str, "\n%s", name);
+    g_string_append_printf(str, "\n  %s", name);
 }
=20
 static const char *chardev_alias_translate(const char *name)
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436898567266.9717534585807;
 Mon, 5 Nov 2018 08:54:58 -0800 (PST)
Received: from localhost ([::1]:36261 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi9R-0000hD-C8
	for importer@patchew.org; Mon, 05 Nov 2018 11:54:57 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51822)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwh-0002uW-PH
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:49 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwX-00049Y-4T
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:44 -0500
Received: from mx1.redhat.com ([209.132.183.28]:17930)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhw7-0006Cz-9N; Mon, 05 Nov 2018 11:41:11 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id ED8D473;
	Mon,  5 Nov 2018 16:39:20 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 7FC4865F48;
	Mon,  5 Nov 2018 16:39:17 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:40 +0100
Message-Id: <20181105163744.25139-33-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.29]);
	Mon, 05 Nov 2018 16:39:21 +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] [PULL 32/36] qdev-monitor: Make device options help
 nicer
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Max Reitz <mreitz@redhat.com>

Just like in qemu_opts_print_help(), print the device name as a caption
instead of on every single line, indent all options, add angle brackets
around types, and align the descriptions after 24 characters.  Also,
separate the descriptions with " - " instead of putting them in
parentheses, because that is what we do everywhere else.  This does look
a bit funny here because basically all bits have the description
"on/off", but funny does not mean it is less readable.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qdev-monitor.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/qdev-monitor.c b/qdev-monitor.c
index 802c18a74e..07147c63bf 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -285,10 +285,19 @@ int qdev_device_help(QemuOpts *opts)
         goto error;
     }
=20
+    if (prop_list) {
+        out_printf("%s options:\n", driver);
+    } else {
+        out_printf("There are no options for %s.\n", driver);
+    }
     for (prop =3D prop_list; prop; prop =3D prop->next) {
-        out_printf("%s.%s=3D%s", driver, prop->value->name, prop->value->t=
ype);
+        int len;
+        out_printf("  %s=3D<%s>%n", prop->value->name, prop->value->type, =
&len);
         if (prop->value->has_description) {
-            out_printf(" (%s)\n", prop->value->description);
+            if (len < 24) {
+                out_printf("%*s", 24 - len, "");
+            }
+            out_printf(" - %s\n", prop->value->description);
         } else {
             out_printf("\n");
         }
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437037870346.807733136715;
 Mon, 5 Nov 2018 08:57:17 -0800 (PST)
Received: from localhost ([::1]:36280 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiBg-0002yU-4j
	for importer@patchew.org; Mon, 05 Nov 2018 11:57:16 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52510)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhxn-0004QV-Bm
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:56 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhxm-0007Er-2J
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:55 -0500
Received: from mx1.redhat.com ([209.132.183.28]:2423)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhxh-0006NO-Ib; Mon, 05 Nov 2018 11:42:50 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id AAD6CC02834E;
	Mon,  5 Nov 2018 16:39:24 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 411E565F4E;
	Mon,  5 Nov 2018 16:39:21 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:41 +0100
Message-Id: <20181105163744.25139-34-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.31]);
	Mon, 05 Nov 2018 16:39: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] [PULL 33/36] object: Make option help nicer to read
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Max Reitz <mreitz@redhat.com>

Just like in qemu_opts_print_help(), print the object name as a caption
instead of on every single line, indent all options, add angle brackets
around types, and align the descriptions after 24 characters.

Also, indent every object name in the list of available objects.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 vl.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/vl.c b/vl.c
index 1fcacc5caa..bed97b92ac 100644
--- a/vl.c
+++ b/vl.c
@@ -2743,7 +2743,7 @@ static bool object_create_initial(const char *type, Q=
emuOpts *opts)
         list =3D object_class_get_list_sorted(TYPE_USER_CREATABLE, false);
         for (l =3D list; l !=3D NULL; l =3D l->next) {
             ObjectClass *oc =3D OBJECT_CLASS(l->data);
-            printf("%s\n", object_class_get_name(oc));
+            printf("  %s\n", object_class_get_name(oc));
         }
         g_slist_free(list);
         exit(0);
@@ -2765,14 +2765,21 @@ static bool object_create_initial(const char *type,=
 QemuOpts *opts)
             }
=20
             str =3D g_string_new(NULL);
-            g_string_append_printf(str, "%s.%s=3D%s", type,
-                                   prop->name, prop->type);
+            g_string_append_printf(str, "  %s=3D<%s>", prop->name, prop->t=
ype);
             if (prop->description) {
+                if (str->len < 24) {
+                    g_string_append_printf(str, "%*s", 24 - (int)str->len,=
 "");
+                }
                 g_string_append_printf(str, " - %s", prop->description);
             }
             g_ptr_array_add(array, g_string_free(str, false));
         }
         g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
+        if (array->len > 0) {
+            printf("%s options:\n", type);
+        } else {
+            printf("There are no options for %s.\n", type);
+        }
         for (i =3D 0; i < array->len; i++) {
             printf("%s\n", (char *)array->pdata[i]);
         }
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437169479606.4207618633158;
 Mon, 5 Nov 2018 08:59:29 -0800 (PST)
Received: from localhost ([::1]:36291 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiDi-0005HA-4Z
	for importer@patchew.org; Mon, 05 Nov 2018 11:59:22 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52017)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwn-00032E-Hu
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:54 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwj-0004oW-4P
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:53 -0500
Received: from mx1.redhat.com ([209.132.183.28]:37086)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhwS-0006Qy-OG; Mon, 05 Nov 2018 11:41:36 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 7DC513167696;
	Mon,  5 Nov 2018 16:39:26 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id EF82D60CD8;
	Mon,  5 Nov 2018 16:39:24 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:42 +0100
Message-Id: <20181105163744.25139-35-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.41]);
	Mon, 05 Nov 2018 16:39: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] [PULL 34/36] fw_cfg: Drop newline in @file description
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Max Reitz <mreitz@redhat.com>

There is no good reason why there should be a newline in this
description, so remove it.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Philippe Mathieu-Daud=C3=A9 <philmd@redhat.com>
Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 vl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vl.c b/vl.c
index bed97b92ac..03ed215d7b 100644
--- a/vl.c
+++ b/vl.c
@@ -537,7 +537,7 @@ static QemuOptsList qemu_fw_cfg_opts =3D {
         }, {
             .name =3D "file",
             .type =3D QEMU_OPT_STRING,
-            .help =3D "Sets the name of the file from which\n"
+            .help =3D "Sets the name of the file from which "
                     "the fw_cfg blob will be loaded",
         }, {
             .name =3D "string",
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541436819087327.09510296633925;
 Mon, 5 Nov 2018 08:53:39 -0800 (PST)
Received: from localhost ([::1]:36254 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJi89-00086Z-Ow
	for importer@patchew.org; Mon, 05 Nov 2018 11:53:37 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51796)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwg-0002tr-U2
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:48 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhwX-00049F-3a
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:41:43 -0500
Received: from mx1.redhat.com ([209.132.183.28]:55054)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhwB-0006cm-5a; Mon, 05 Nov 2018 11:41:15 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id 25F77308FB95;
	Mon,  5 Nov 2018 16:39:31 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id C864C4148;
	Mon,  5 Nov 2018 16:39:26 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:43 +0100
Message-Id: <20181105163744.25139-36-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.43]);
	Mon, 05 Nov 2018 16:39:31 +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] [PULL 35/36] vdi: Use a literal number of bytes for
 DEFAULT_CLUSTER_SIZE
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Leonid Bloch <lbloch@janustech.com>

If an expression is used to define DEFAULT_CLUSTER_SIZE, when compiled,
it will be embedded as a literal expression in the binary (as the
default value) because it is stringified to mark the size of the default
value. Now this is fixed by using a defined number to define this value.

Signed-off-by: Leonid Bloch <lbloch@janustech.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/vdi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/vdi.c b/block/vdi.c
index 0ff1ead736..2380daa583 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -85,7 +85,7 @@
 #define BLOCK_OPT_STATIC "static"
=20
 #define SECTOR_SIZE 512
-#define DEFAULT_CLUSTER_SIZE (1 * MiB)
+#define DEFAULT_CLUSTER_SIZE S_1MiB
=20
 #if defined(CONFIG_VDI_DEBUG)
 #define VDI_DEBUG 1
@@ -432,7 +432,7 @@ static int vdi_open(BlockDriverState *bs, QDict *option=
s, int flags,
         goto fail;
     } else if (header.block_size !=3D DEFAULT_CLUSTER_SIZE) {
         error_setg(errp, "unsupported VDI image (block size %" PRIu32
-                         " is not %" PRIu64 ")",
+                         " is not %" PRIu32 ")",
                    header.block_size, DEFAULT_CLUSTER_SIZE);
         ret =3D -ENOTSUP;
         goto fail;
--=20
2.19.1


From nobody Sat May  3 18:59:42 2025
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: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by
 mx.zohomail.com
	with SMTPS id 1541437496545317.313563309311;
 Mon, 5 Nov 2018 09:04:56 -0800 (PST)
Received: from localhost ([::1]:36325 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1gJiIx-0004WB-6s
	for importer@patchew.org; Mon, 05 Nov 2018 12:04:47 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52501)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhxm-0004Pf-Pv
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:56 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <kwolf@redhat.com>) id 1gJhxl-0007Do-Fq
	for qemu-devel@nongnu.org; Mon, 05 Nov 2018 11:42:54 -0500
Received: from mx1.redhat.com ([209.132.183.28]:42628)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <kwolf@redhat.com>)
	id 1gJhxe-0006if-SD; Mon, 05 Nov 2018 11:42:48 -0500
Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com
	[10.5.11.12])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.redhat.com (Postfix) with ESMTPS id CEE0131256AC;
	Mon,  5 Nov 2018 16:39:32 +0000 (UTC)
Received: from linux.fritz.box.com (ovpn-117-198.ams2.redhat.com
	[10.36.117.198])
	by smtp.corp.redhat.com (Postfix) with ESMTP id 6928E60C61;
	Mon,  5 Nov 2018 16:39:31 +0000 (UTC)
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Date: Mon,  5 Nov 2018 17:37:44 +0100
Message-Id: <20181105163744.25139-37-kwolf@redhat.com>
In-Reply-To: <20181105163744.25139-1-kwolf@redhat.com>
References: <20181105163744.25139-1-kwolf@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16
	(mx1.redhat.com [10.5.110.46]);
	Mon, 05 Nov 2018 16:39: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] [PULL 36/36] include: Add a comment to explain the
 origin of sizes' lookup table
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
	<mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Content-Type: text/plain; charset="utf-8"

From: Leonid Bloch <lbloch@janustech.com>

The lookup table for power-of-two sizes was added in commit 540b8492618eb
for the purpose of having convenient shortcuts for these sizes in cases
when the literal number has to be present at compile time, and
expressions as '(1 * KiB)' can not be used. One such case is the
stringification of sizes. Beyond that, it is convenient to use these
shortcuts for all power-of-two sizes, even if they don't have to be
literal numbers.

Despite its convenience, this table introduced 55 lines of "dumb" code,
the purpose and origin of which are obscure without reading the message
of the commit which introduced it. This patch fixes that by adding a
comment to the code itself with a brief explanation for the reasoning
behind this table. This comment includes the short AWK script that
generated the table, so that anyone who's interested could make sure
that the values in it are correct (otherwise these values look as if
they were typed manually).

Signed-off-by: Leonid Bloch <lbloch@janustech.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/qemu/units.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/include/qemu/units.h b/include/qemu/units.h
index 68a7758650..1c959d182e 100644
--- a/include/qemu/units.h
+++ b/include/qemu/units.h
@@ -17,6 +17,24 @@
 #define PiB     (INT64_C(1) << 50)
 #define EiB     (INT64_C(1) << 60)
=20
+/*
+ * The following lookup table is intended to be used when a literal string=
 of
+ * the number of bytes is required (for example if it needs to be stringif=
ied).
+ * It can also be used for generic shortcuts of power-of-two sizes.
+ * This table is generated using the AWK script below:
+ *
+ *  BEGIN {
+ *      suffix=3D"KMGTPE";
+ *      for(i=3D10; i<64; i++) {
+ *          val=3D2**i;
+ *          s=3Dsubstr(suffix, int(i/10), 1);
+ *          n=3D2**(i%10);
+ *          pad=3D21-int(log(n)/log(10));
+ *          printf("#define S_%d%siB %*d\n", n, s, pad, val);
+ *      }
+ *  }
+ */
+
 #define S_1KiB                  1024
 #define S_2KiB                  2048
 #define S_4KiB                  4096
--=20
2.19.1