From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491234041604462.6393979534739; Mon, 3 Apr 2017 08:40:41 -0700 (PDT) Received: from localhost ([::1]:59836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv45v-0002n6-U6 for importer@patchew.org; Mon, 03 Apr 2017 11:40:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv3ze-00062Q-1F for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv3zd-0007AQ-05 for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv3zV-00077X-WB; Mon, 03 Apr 2017 11:34:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06063680FB; Mon, 3 Apr 2017 15:34:01 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13D911803E; Mon, 3 Apr 2017 15:33:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 06063680FB Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 06063680FB From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:41 +0200 Message-Id: <20170403153355.19722-2-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 03 Apr 2017 15:34:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/15] block: add missed aio_context_acquire into release_drive X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Denis V. Lunev" Recently we expirience hang with iothreads enabled with the following call trace: Thread 1 (Thread 0x7fa95efebc80 (LWP 177117)): 0 ppoll () from /lib64/libc.so.6 2 qemu_poll_ns () at qemu-timer.c:313 3 aio_poll () at aio-posix.c:457 4 bdrv_flush () at block/io.c:2641 5 bdrv_close () at block.c:2143 6 bdrv_delete () at block.c:2352 7 bdrv_unref () at block.c:3429 8 blk_remove_bs () at block/block-backend.c:427 9 blk_delete () at block/block-backend.c:178 10 blk_unref () at block/block-backend.c:226 11 object_property_del_all () at qom/object.c:399 12 object_finalize () at qom/object.c:461 13 object_unref () at qom/object.c:898 14 object_property_del_child () at qom/object.c:422 15 qmp_marshal_device_del () at qmp-marshal.c:1145 16 handle_qmp_command () at /usr/src/debug/qemu-2.6.0/monitor.c:3929 Technically bdrv_flush() stucks in while (rwco.ret =3D=3D NOT_DONE) { aio_poll(aio_context, true); } but rwco.ret is equal to 0 thus we have missed wakeup. Code investigation reveals that we do not have performed aio_context_acquire() on this call stack. This patch adds missed lock. Signed-off-by: Denis V. Lunev CC: Kevin Wolf CC: Max Reitz CC: Eric Blake CC: Markus Armbruster Message-id: 1490717566-25516-1-git-send-email-den@openvz.org Reviewed-by: Fam Zheng Signed-off-by: Max Reitz --- hw/core/qdev-properties-system.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index c34be1c1ba..e885e650fb 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -124,8 +124,12 @@ static void release_drive(Object *obj, const char *nam= e, void *opaque) BlockBackend **ptr =3D qdev_get_prop_ptr(dev, prop); =20 if (*ptr) { + AioContext *ctx =3D blk_get_aio_context(*ptr); + + aio_context_acquire(ctx); blockdev_auto_del(*ptr); blk_detach_dev(*ptr, dev); + aio_context_release(ctx); } } =20 --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491233909125124.5519873220635; Mon, 3 Apr 2017 08:38:29 -0700 (PDT) Received: from localhost ([::1]:59822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv43l-0000q5-L8 for importer@patchew.org; Mon, 03 Apr 2017 11:38:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv3zc-00061f-6w for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv3zb-00079Y-A7 for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv3zY-00078g-Fy; Mon, 03 Apr 2017 11:34:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7779980497; Mon, 3 Apr 2017 15:34:03 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA49D1837E; Mon, 3 Apr 2017 15:34:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7779980497 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7779980497 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:42 +0200 Message-Id: <20170403153355.19722-3-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 03 Apr 2017 15:34:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/15] nbd sockets vnc: Mark problematic address family tests TODO X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster Certain features make sense only with certain address families. For instance, passing file descriptors requires AF_UNIX. Testing SocketAddress's saddr->type =3D=3D SOCKET_ADDRESS_KIND_UNIX is obvious, but problematic: it can't recognize AF_UNIX when type =3D=3D SOCKET_ADDRESS_KIND_FD. Mark such tests of saddr->type TODO. We may want to check the address family with getsockname() there. Cc: Paolo Bonzini Cc: Gerd Hoffmann Cc: Daniel P. Berrange Signed-off-by: Markus Armbruster Reviewed-by: Max Reitz Reviewed-by: Eric Blake Message-id: 1490895797-29094-2-git-send-email-armbru@redhat.com Signed-off-by: Max Reitz --- block/nbd.c | 1 + blockdev-nbd.c | 1 + chardev/char-socket.c | 5 ++--- ui/vnc.c | 1 + util/qemu-sockets.c | 4 ++++ 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index 1b832c2132..36ea617989 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -421,6 +421,7 @@ static int nbd_open(BlockDriverState *bs, QDict *option= s, int flags, goto error; } =20 + /* TODO SOCKET_ADDRESS_KIND_FD where fd has AF_INET or AF_INET6 */ if (s->saddr->type !=3D SOCKET_ADDRESS_KIND_INET) { error_setg(errp, "TLS only supported over IP sockets"); goto error; diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 7ea836b46e..8a11807df3 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -124,6 +124,7 @@ void qmp_nbd_server_start(SocketAddress *addr, goto error; } =20 + /* TODO SOCKET_ADDRESS_KIND_FD where fd has AF_INET or AF_INET6 */ if (addr->type !=3D SOCKET_ADDRESS_KIND_INET) { error_setg(errp, "TLS is only supported with IPv4/IPv6"); goto error; diff --git a/chardev/char-socket.c b/chardev/char-socket.c index d7e92e1bd3..6344b07822 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -47,7 +47,6 @@ typedef struct { int max_size; int do_telnetopt; int do_nodelay; - int is_unix; int *read_msgfds; size_t read_msgfds_num; int *write_msgfds; @@ -825,7 +824,6 @@ static void qmp_chardev_open_socket(Chardev *chr, int64_t reconnect =3D sock->has_reconnect ? sock->reconnect : 0; QIOChannelSocket *sioc =3D NULL; =20 - s->is_unix =3D addr->type =3D=3D SOCKET_ADDRESS_KIND_UNIX; s->is_listen =3D is_listen; s->is_telnet =3D is_telnet; s->do_nodelay =3D do_nodelay; @@ -865,7 +863,8 @@ static void qmp_chardev_open_socket(Chardev *chr, s->addr =3D QAPI_CLONE(SocketAddress, sock->addr); =20 qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_RECONNECTABLE); - if (s->is_unix) { + /* TODO SOCKET_ADDRESS_FD where fd has AF_UNIX */ + if (addr->type =3D=3D SOCKET_ADDRESS_KIND_UNIX) { qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS); } =20 diff --git a/ui/vnc.c b/ui/vnc.c index 243e99bb95..1095f9de68 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3642,6 +3642,7 @@ static int vnc_display_connect(VncDisplay *vd, error_setg(errp, "Expected a single address in reverse mode"); return -1; } + /* TODO SOCKET_ADDRESS_KIND_FD when fd has AF_UNIX */ vd->is_unix =3D saddr[0]->type =3D=3D SOCKET_ADDRESS_KIND_UNIX; sioc =3D qio_channel_socket_new(); qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse"); diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 40164bf681..9b7368113c 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -1154,6 +1154,10 @@ int socket_dgram(SocketAddress *remote, SocketAddres= s *local, Error **errp) { int fd; =20 + /* + * TODO SOCKET_ADDRESS_KIND_FD when fd is AF_INET or AF_INET6 + * (although other address families can do SOCK_DGRAM, too) + */ switch (remote->type) { case SOCKET_ADDRESS_KIND_INET: fd =3D inet_dgram_saddr(remote->u.inet.data, --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491233827660105.73743517882451; Mon, 3 Apr 2017 08:37:07 -0700 (PDT) Received: from localhost ([::1]:59817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv42U-0008AU-C7 for importer@patchew.org; Mon, 03 Apr 2017 11:37:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv3zl-00068D-7v for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv3zk-0007Ht-C3 for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv3ze-0007Bg-Il; Mon, 03 Apr 2017 11:34:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C2BB8124B; Mon, 3 Apr 2017 15:34:09 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82CAF4DA61; Mon, 3 Apr 2017 15:34:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1C2BB8124B Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1C2BB8124B From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:43 +0200 Message-Id: <20170403153355.19722-4-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 03 Apr 2017 15:34:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/15] char: Fix socket with "type": "vsock" address X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster Watch this: $ qemu-system-x86_64 -nodefaults -S -display none -qmp stdio {"QMP": {"version": {"qemu": {"micro": 91, "minor": 8, "major": 2}, "pa= ckage": " (v2.8.0-1195-gf84141e-dirty)"}, "capabilities": []}} { "execute": "qmp_capabilities" } {"return": {}} { "execute": "chardev-add", "arguments": { "id": "chr0", "backend": { "= type": "socket", "data": { "addr": { "type": "vsock", "data": { "cid": "CID= ", "port": "P" }}}}}} Aborted (core dumped) Crashes because SocketAddress_to_str() is blissfully unaware of SOCKET_ADDRESS_KIND_VSOCK. Fix that. Pick the output format to match socket_parse(), just like the existing formats. Cc: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Marc-Andr=C3=A9 Lureau Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Max Reitz Message-id: 1490895797-29094-3-git-send-email-armbru@redhat.com Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz --- chardev/char-socket.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 6344b07822..36ab0d633a 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -357,6 +357,10 @@ static char *SocketAddress_to_str(const char *prefix, = SocketAddress *addr, return g_strdup_printf("%sfd:%s%s", prefix, addr->u.fd.data->str, is_listen ? ",server" : ""); break; + case SOCKET_ADDRESS_KIND_VSOCK: + return g_strdup_printf("%svsock:%s:%s", prefix, + addr->u.vsock.data->cid, + addr->u.vsock.data->port); default: abort(); } --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491234179566120.52281365049032; Mon, 3 Apr 2017 08:42:59 -0700 (PDT) Received: from localhost ([::1]:59847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv48A-0004nW-6T for importer@patchew.org; Mon, 03 Apr 2017 11:42:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv3zl-000689-53 for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv3zk-0007Ho-B3 for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv3zh-0007Eq-HX; Mon, 03 Apr 2017 11:34:13 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 41CD7711FA; Mon, 3 Apr 2017 15:34:12 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F54B78486; Mon, 3 Apr 2017 15:34:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 41CD7711FA Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 41CD7711FA From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:44 +0200 Message-Id: <20170403153355.19722-5-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 03 Apr 2017 15:34:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/15] io vnc sockets: Clean up SocketAddressKind switches X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster We have quite a few switches over SocketAddressKind. Some have case labels for all enumeration values, others rely on a default label. Some abort when the value isn't a valid SocketAddressKind, others report an error then. Unify as follows. Always provide case labels for all enumeration values, to clarify intent. Abort when the value isn't a valid SocketAddressKind, because the program state is messed up then. Improve a few error messages while there. Signed-off-by: Markus Armbruster Reviewed-by: Max Reitz Message-id: 1490895797-29094-4-git-send-email-armbru@redhat.com Signed-off-by: Max Reitz --- io/dns-resolver.c | 7 +++++-- ui/vnc.c | 18 ++++++++++++------ util/qemu-sockets.c | 4 +--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/io/dns-resolver.c b/io/dns-resolver.c index 0ac6b23c02..a407075934 100644 --- a/io/dns-resolver.c +++ b/io/dns-resolver.c @@ -164,9 +164,12 @@ int qio_dns_resolver_lookup_sync(QIODNSResolver *resol= ver, addrs, errp); =20 - default: - error_setg(errp, "Unknown socket address kind"); + case SOCKET_ADDRESS_KIND_FD: + error_setg(errp, "Unsupported socket address type 'fd'"); return -1; + + default: + abort(); } } =20 diff --git a/ui/vnc.c b/ui/vnc.c index 1095f9de68..349cfc9d86 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -129,10 +129,13 @@ static void vnc_init_basic_info(SocketAddress *addr, info->family =3D NETWORK_ADDRESS_FAMILY_UNIX; break; =20 - default: - error_setg(errp, "Unsupported socket kind %d", - addr->type); + case SOCKET_ADDRESS_KIND_VSOCK: + case SOCKET_ADDRESS_KIND_FD: + error_setg(errp, "Unsupported socket address type %s", + SocketAddressKind_lookup[addr->type]); break; + default: + abort(); } =20 return; @@ -411,10 +414,13 @@ VncInfo *qmp_query_vnc(Error **errp) info->family =3D NETWORK_ADDRESS_FAMILY_UNIX; break; =20 - default: - error_setg(errp, "Unsupported socket kind %d", - addr->type); + case SOCKET_ADDRESS_KIND_VSOCK: + case SOCKET_ADDRESS_KIND_FD: + error_setg(errp, "Unsupported socket address type %s", + SocketAddressKind_lookup[addr->type]); goto out_error; + default: + abort(); } =20 info->has_host =3D true; diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 9b7368113c..4ae37bd2a2 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -1337,9 +1337,7 @@ char *socket_address_to_string(struct SocketAddress *= addr, Error **errp) break; =20 default: - error_setg(errp, "socket family %d unsupported", - addr->type); - return NULL; + abort(); } return buf; } --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491234295927777.5809269669983; Mon, 3 Apr 2017 08:44:55 -0700 (PDT) Received: from localhost ([::1]:59865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv4A2-0006Wn-MT for importer@patchew.org; Mon, 03 Apr 2017 11:44:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv3zt-0006EO-Tt for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv3zp-0007Lj-1p for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52642) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv3zk-0007He-Az; Mon, 03 Apr 2017 11:34:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4ABB5C05492D; Mon, 3 Apr 2017 15:34:15 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CE26B78F2B; Mon, 3 Apr 2017 15:34:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4ABB5C05492D Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4ABB5C05492D From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:45 +0200 Message-Id: <20170403153355.19722-6-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 03 Apr 2017 15:34:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/15] block: Document -drive problematic code and bugs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster -blockdev and blockdev_add convert their arguments via QObject to BlockdevOptions for qmp_blockdev_add(), which converts them back to QObject, then to a flattened QDict. The QDict's members are typed according to the QAPI schema. -drive converts its argument via QemuOpts to a (flat) QDict. This QDict's members are all QString. Thus, the QType of a flat QDict member depends on whether it comes from -drive or -blockdev/blockdev_add, except when the QAPI type maps to QString, which is the case for 'str' and enumeration types. The block layer core extracts generic configuration from the flat QDict, and the block driver extracts driver-specific configuration. Both commonly do so by converting (parts of) the flat QDict to QemuOpts, which turns all values into strings. Not exactly elegant, but correct. However, A few places access the flat QDict directly: * Most of them access members that are always QString. Correct. * bdrv_open_inherit() accesses a boolean, carefully. Correct. * nfs_config() uses a QObject input visitor. Correct only because the visited type contains nothing but QStrings. * nbd_config() and ssh_config() use a QObject input visitor, and the visited types contain non-QStrings: InetSocketAddress members @numeric, @to, @ipv4, @ipv6. -drive works as long as you don't try to use them (they're all optional). @to is ignored anyway. Reproducer: -drive driver=3Dssh,server.host=3Dh,server.port=3D22,server.ipv4,path=3Dp -drive driver=3Dnbd,server.type=3Dinet,server.data.host=3Dh,server.data.p= ort=3D22,server.data.ipv4 both fail with "Invalid parameter type for 'data.ipv4', expected: boolean" Add suitable comments to all these places. Mark the buggy ones FIXME. "Fortunately", -drive's driver-specific options are entirely undocumented. Signed-off-by: Markus Armbruster Message-id: 1490895797-29094-5-git-send-email-armbru@redhat.com [mreitz: Fixed two typos] Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- block.c | 48 +++++++++++++++++++++++++++++++++++++++++++++--- block/file-posix.c | 6 ++++++ block/nbd.c | 8 ++++++++ block/nfs.c | 7 +++++++ block/rbd.c | 6 ++++++ block/ssh.c | 8 ++++++++ 6 files changed, 80 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 6e906ec53c..927ba89eb7 100644 --- a/block.c +++ b/block.c @@ -1157,6 +1157,13 @@ static int bdrv_open_common(BlockDriverState *bs, Bl= ockBackend *file, if (file !=3D NULL) { filename =3D blk_bs(file)->filename; } else { + /* + * Caution: while qdict_get_try_str() is fine, getting + * non-string types would require more care. When @options + * come from -blockdev or blockdev_add, its members are typed + * according to the QAPI schema, but when they come from + * -drive, they're all QString. + */ filename =3D qdict_get_try_str(options, "filename"); } =20 @@ -1324,6 +1331,13 @@ static int bdrv_fill_options(QDict **options, const = char *filename, BlockDriver *drv =3D NULL; Error *local_err =3D NULL; =20 + /* + * Caution: while qdict_get_try_str() is fine, getting non-string + * types would require more care. When @options come from + * -blockdev or blockdev_add, its members are typed according to + * the QAPI schema, but when they come from -drive, they're all + * QString. + */ drvname =3D qdict_get_try_str(*options, "driver"); if (drvname) { drv =3D bdrv_find_format(drvname); @@ -1358,6 +1372,7 @@ static int bdrv_fill_options(QDict **options, const c= har *filename, } =20 /* Find the right block driver */ + /* See cautionary note on accessing @options above */ filename =3D qdict_get_try_str(*options, "filename"); =20 if (!drvname && protocol) { @@ -1987,6 +2002,13 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDi= ct *parent_options, qdict_extract_subqdict(parent_options, &options, bdref_key_dot); g_free(bdref_key_dot); =20 + /* + * Caution: while qdict_get_try_str() is fine, getting non-string + * types would require more care. When @parent_options come from + * -blockdev or blockdev_add, its members are typed according to + * the QAPI schema, but when they come from -drive, they're all + * QString. + */ reference =3D qdict_get_try_str(parent_options, bdref_key); if (reference || qdict_haskey(options, "file.filename")) { backing_filename[0] =3D '\0'; @@ -2059,6 +2081,13 @@ bdrv_open_child_bs(const char *filename, QDict *opti= ons, const char *bdref_key, qdict_extract_subqdict(options, &image_options, bdref_key_dot); g_free(bdref_key_dot); =20 + /* + * Caution: while qdict_get_try_str() is fine, getting non-string + * types would require more care. When @options come from + * -blockdev or blockdev_add, its members are typed according to + * the QAPI schema, but when they come from -drive, they're all + * QString. + */ reference =3D qdict_get_try_str(options, bdref_key); if (!filename && !reference && !qdict_size(image_options)) { if (!allow_none) { @@ -2274,9 +2303,13 @@ static BlockDriverState *bdrv_open_inherit(const cha= r *filename, goto fail; } =20 - /* Set the BDRV_O_RDWR and BDRV_O_ALLOW_RDWR flags. - * FIXME: we're parsing the QDict to avoid having to create a - * QemuOpts just for this, but neither option is optimal. */ + /* + * Set the BDRV_O_RDWR and BDRV_O_ALLOW_RDWR flags. + * Caution: getting a boolean member of @options requires care. + * When @options come from -blockdev or blockdev_add, members are + * typed according to the QAPI schema, but when they come from + * -drive, they're all QString. + */ if (g_strcmp0(qdict_get_try_str(options, BDRV_OPT_READ_ONLY), "on") && !qdict_get_try_bool(options, BDRV_OPT_READ_ONLY, false)) { flags |=3D (BDRV_O_RDWR | BDRV_O_ALLOW_RDWR); @@ -2298,6 +2331,7 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, options =3D qdict_clone_shallow(options); =20 /* Find the right image format driver */ + /* See cautionary note on accessing @options above */ drvname =3D qdict_get_try_str(options, "driver"); if (drvname) { drv =3D bdrv_find_format(drvname); @@ -2309,6 +2343,7 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, =20 assert(drvname || !(flags & BDRV_O_PROTOCOL)); =20 + /* See cautionary note on accessing @options above */ backing =3D qdict_get_try_str(options, "backing"); if (backing && *backing =3D=3D '\0') { flags |=3D BDRV_O_NO_BACKING; @@ -2787,6 +2822,13 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_stat= e, BlockReopenQueue *queue, do { QString *new_obj =3D qobject_to_qstring(entry->value); const char *new =3D qstring_get_str(new_obj); + /* + * Caution: while qdict_get_try_str() is fine, getting + * non-string types would require more care. When + * bs->options come from -blockdev or blockdev_add, its + * members are typed according to the QAPI schema, but + * when they come from -drive, they're all QString. + */ const char *old =3D qdict_get_try_str(reopen_state->bs->option= s, entry->key); =20 diff --git a/block/file-posix.c b/block/file-posix.c index 0841a08785..0c4896876e 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2193,6 +2193,12 @@ static int hdev_open(BlockDriverState *bs, QDict *op= tions, int flags, int ret; =20 #if defined(__APPLE__) && defined(__MACH__) + /* + * Caution: while qdict_get_str() is fine, getting non-string types + * would require more care. When @options come from -blockdev or + * blockdev_add, its members are typed according to the QAPI + * schema, but when they come from -drive, they're all QString. + */ const char *filename =3D qdict_get_str(options, "filename"); char bsd_path[MAXPATHLEN] =3D ""; bool error_occurred =3D false; diff --git a/block/nbd.c b/block/nbd.c index 36ea617989..11e3ba75fa 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -278,6 +278,14 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDic= t *options, Error **errp) goto done; } =20 + /* + * FIXME .numeric, .to, .ipv4 or .ipv6 don't work with -drive + * server.type=3Dinet. .to doesn't matter, it's ignored anyway. + * That's because when @options come from -blockdev or + * blockdev_add, members are typed according to the QAPI schema, + * but when they come from -drive, they're all QString. The + * visitor expects the former. + */ iv =3D qobject_input_visitor_new(crumpled_addr); visit_type_SocketAddress(iv, NULL, &saddr, &local_err); if (local_err) { diff --git a/block/nfs.c b/block/nfs.c index 3f43f6e26a..0816678307 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -474,6 +474,13 @@ static NFSServer *nfs_config(QDict *options, Error **e= rrp) goto out; } =20 + /* + * Caution: this works only because all scalar members of + * NFSServer are QString in @crumpled_addr. The visitor expects + * @crumpled_addr to be typed according to the QAPI schema. It + * is when @options come from -blockdev or blockdev_add. But when + * they come from -drive, they're all QString. + */ iv =3D qobject_input_visitor_new(crumpled_addr); visit_type_NFSServer(iv, NULL, &server, &local_error); if (local_error) { diff --git a/block/rbd.c b/block/rbd.c index fbdb131a68..1ceeeb5a60 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -385,6 +385,12 @@ static int qemu_rbd_create(const char *filename, QemuO= pts *opts, Error **errp) goto exit; } =20 + /* + * Caution: while qdict_get_try_str() is fine, getting non-string + * types would require more care. When @options come from -blockdev + * or blockdev_add, its members are typed according to the QAPI + * schema, but when they come from -drive, they're all QString. + */ pool =3D qdict_get_try_str(options, "pool"); conf =3D qdict_get_try_str(options, "conf"); clientname =3D qdict_get_try_str(options, "user"); diff --git a/block/ssh.c b/block/ssh.c index 278e66faa6..471ba8a260 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -601,6 +601,14 @@ static InetSocketAddress *ssh_config(QDict *options, E= rror **errp) goto out; } =20 + /* + * FIXME .numeric, .to, .ipv4 or .ipv6 don't work with -drive. + * .to doesn't matter, it's ignored anyway. + * That's because when @options come from -blockdev or + * blockdev_add, members are typed according to the QAPI schema, + * but when they come from -drive, they're all QString. The + * visitor expects the former. + */ iv =3D qobject_input_visitor_new(crumpled_addr); visit_type_InetSocketAddress(iv, NULL, &inet, &local_error); if (local_error) { --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491233775397766.2271796551544; Mon, 3 Apr 2017 08:36:15 -0700 (PDT) Received: from localhost ([::1]:59814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv41d-0007T9-LS for importer@patchew.org; Mon, 03 Apr 2017 11:36:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv3zu-0006FE-La for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv3zt-0007P4-Np for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34388) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv3zn-0007KG-HU; Mon, 03 Apr 2017 11:34:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6A977C0467F2; Mon, 3 Apr 2017 15:34:18 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 33803177DF; Mon, 3 Apr 2017 15:34:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6A977C0467F2 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6A977C0467F2 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:46 +0200 Message-Id: <20170403153355.19722-7-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 03 Apr 2017 15:34:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/15] gluster: Prepare for SocketAddressFlat extension X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster qemu_gluster_glfs_init() and qemu_gluster_parse_json() rely on the fact that SocketAddressFlatType has only two members SOCKET_ADDRESS_FLAT_TYPE_INET and SOCKET_ADDRESS_FLAT_TYPE_UNIX. Correct, but won't stay correct. Make them more robust. Signed-off-by: Markus Armbruster Reviewed-by: Max Reitz Reviewed-by: Jeff Cody Message-id: 1490895797-29094-6-git-send-email-armbru@redhat.com Signed-off-by: Max Reitz --- block/gluster.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index a577daef10..fb0aafeaa3 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -412,10 +412,12 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOp= tionsGluster *gconf, glfs_set_preopened(gconf->volume, glfs); =20 for (server =3D gconf->server; server; server =3D server->next) { - if (server->value->type =3D=3D SOCKET_ADDRESS_FLAT_TYPE_UNIX) { + switch (server->value->type) { + case SOCKET_ADDRESS_FLAT_TYPE_UNIX: ret =3D glfs_set_volfile_server(glfs, "unix", server->value->u.q_unix.path, 0); - } else { + break; + case SOCKET_ADDRESS_FLAT_TYPE_INET: if (parse_uint_full(server->value->u.inet.port, &port, 10) < 0= || port > 65535) { error_setg(errp, "'%s' is not a valid port number", @@ -426,6 +428,9 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOpti= onsGluster *gconf, ret =3D glfs_set_volfile_server(glfs, "tcp", server->value->u.inet.host, (int)port); + break; + default: + abort(); } =20 if (ret < 0) { @@ -487,7 +492,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGlust= er *gconf, char *str =3D NULL; const char *ptr; size_t num_servers; - int i; + int i, type; =20 /* create opts info from runtime_json_opts list */ opts =3D qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort); @@ -539,16 +544,17 @@ static int qemu_gluster_parse_json(BlockdevOptionsGlu= ster *gconf, if (!strcmp(ptr, "tcp")) { ptr =3D "inet"; /* accept legacy "tcp" */ } - gsconf->type =3D qapi_enum_parse(SocketAddressFlatType_lookup, ptr, - SOCKET_ADDRESS_FLAT_TYPE__MAX, -1, - &local_err); - if (local_err) { - error_append_hint(&local_err, - "Parameter '%s' may be 'inet' or 'unix'\n", - GLUSTER_OPT_TYPE); + type =3D qapi_enum_parse(SocketAddressFlatType_lookup, ptr, + SOCKET_ADDRESS_FLAT_TYPE__MAX, -1, NULL); + if (type !=3D SOCKET_ADDRESS_FLAT_TYPE_INET + && type !=3D SOCKET_ADDRESS_FLAT_TYPE_UNIX) { + error_setg(&local_err, + "Parameter '%s' may be 'inet' or 'unix'", + GLUSTER_OPT_TYPE); error_append_hint(&local_err, GERR_INDEX_HINT, i); goto out; } + gsconf->type =3D type; qemu_opts_del(opts); =20 if (gsconf->type =3D=3D SOCKET_ADDRESS_FLAT_TYPE_INET) { --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491233977167492.49054005265396; Mon, 3 Apr 2017 08:39:37 -0700 (PDT) Received: from localhost ([::1]:59826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv44t-0001qH-Dh for importer@patchew.org; Mon, 03 Apr 2017 11:39:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv3zw-0006Gb-6m for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv3zv-0007QE-9p for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42936) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv3zq-0007M7-Hk; Mon, 03 Apr 2017 11:34:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 682F651EFE; Mon, 3 Apr 2017 15:34:21 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3CD00174B1; Mon, 3 Apr 2017 15:34:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 682F651EFE Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 682F651EFE From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:47 +0200 Message-Id: <20170403153355.19722-8-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 03 Apr 2017 15:34:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/15] qapi-schema: SocketAddressFlat variants 'vsock' and 'fd' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster Note that the new variants are impossible in qemu_gluster_glfs_init(), because the gconf->server can only come from qemu_gluster_parse_uri() or qemu_gluster_parse_json(), and neither can create anything but 'inet' or 'unix'. Signed-off-by: Markus Armbruster Reviewed-by: Max Reitz Reviewed-by: Eric Blake Message-id: 1490895797-29094-7-git-send-email-armbru@redhat.com Signed-off-by: Max Reitz --- qapi-schema.json | 19 ++++++++----------- block/gluster.c | 2 ++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index b921994ae3..250e4dc49b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4144,7 +4144,7 @@ # Since: 2.9 ## { 'enum': 'SocketAddressFlatType', - 'data': [ 'unix', 'inet' ] } + 'data': [ 'inet', 'unix', 'vsock', 'fd' ] } =20 ## # @SocketAddressFlat: @@ -4153,22 +4153,19 @@ # # @type: Transport type # -# This is similar to SocketAddress, only distinction: -# -# 1. SocketAddressFlat is a flat union, SocketAddress is a simple union. -# A flat union is nicer than simple because it avoids nesting -# (i.e. more {}) on the wire. -# -# 2. SocketAddressFlat supports only types 'unix' and 'inet', because -# that's what its current users need. +# This is just like SocketAddress, except it's a flat union rather +# than a simple union. Nicer because it avoids nesting on the wire, +# i.e. this form has fewer {}. # # Since: 2.9 ## { 'union': 'SocketAddressFlat', 'base': { 'type': 'SocketAddressFlatType' }, 'discriminator': 'type', - 'data': { 'unix': 'UnixSocketAddress', - 'inet': 'InetSocketAddress' } } + 'data': { 'inet': 'InetSocketAddress', + 'unix': 'UnixSocketAddress', + 'vsock': 'VsockSocketAddress', + 'fd': 'String' } } =20 ## # @getfd: diff --git a/block/gluster.c b/block/gluster.c index fb0aafeaa3..cf29b5f9a4 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -429,6 +429,8 @@ static struct glfs *qemu_gluster_glfs_init(BlockdevOpti= onsGluster *gconf, server->value->u.inet.host, (int)port); break; + case SOCKET_ADDRESS_FLAT_TYPE_VSOCK: + case SOCKET_ADDRESS_FLAT_TYPE_FD: default: abort(); } --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491233919284485.6195530439189; Mon, 3 Apr 2017 08:38:39 -0700 (PDT) Received: from localhost ([::1]:59823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv43x-000111-Vx for importer@patchew.org; Mon, 03 Apr 2017 11:38:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv3zw-0006Gy-NE for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv3zv-0007QS-P2 for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14087) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv3zt-0007OF-41; Mon, 03 Apr 2017 11:34:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E27B8C05492A; Mon, 3 Apr 2017 15:34:23 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3923891D00; Mon, 3 Apr 2017 15:34:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E27B8C05492A Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E27B8C05492A From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:48 +0200 Message-Id: <20170403153355.19722-9-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 03 Apr 2017 15:34:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/15] sockets: New helper socket_address_crumple() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster SocketAddress is a simple union, and simple unions are awkward: they have their variant members wrapped in a "data" object on the wire, and require additional indirections in C. I intend to limit its use to existing external interfaces. New ones should use SocketAddressFlat. I further intend to convert all internal interfaces to SocketAddressFlat. This helper should go away then. Signed-off-by: Markus Armbruster Message-id: 1490895797-29094-8-git-send-email-armbru@redhat.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- include/qemu/sockets.h | 11 +++++++++++ util/qemu-sockets.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 5f1bab9b3e..7842f6d150 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -119,4 +119,15 @@ SocketAddress *socket_remote_address(int fd, Error **e= rrp); */ char *socket_address_to_string(struct SocketAddress *addr, Error **errp); =20 +/** + * socket_address_crumple: + * @addr_flat: the socket address to crumple + * + * Convert SocketAddressFlat to SocketAddress. Caller is responsible + * for freeing with qapi_free_SocketAddress(). + * + * Returns: the argument converted to SocketAddress. + */ +SocketAddress *socket_address_crumple(SocketAddressFlat *addr_flat); + #endif /* QEMU_SOCKETS_H */ diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 4ae37bd2a2..21442c30dc 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -25,6 +25,7 @@ #include "qapi/error.h" #include "qemu/sockets.h" #include "qemu/main-loop.h" +#include "qapi/clone-visitor.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" #include "qapi-visit.h" @@ -1341,3 +1342,34 @@ char *socket_address_to_string(struct SocketAddress = *addr, Error **errp) } return buf; } + +SocketAddress *socket_address_crumple(SocketAddressFlat *addr_flat) +{ + SocketAddress *addr =3D g_new(SocketAddress, 1); + + switch (addr_flat->type) { + case SOCKET_ADDRESS_FLAT_TYPE_INET: + addr->type =3D SOCKET_ADDRESS_KIND_INET; + addr->u.inet.data =3D QAPI_CLONE(InetSocketAddress, + &addr_flat->u.inet); + break; + case SOCKET_ADDRESS_FLAT_TYPE_UNIX: + addr->type =3D SOCKET_ADDRESS_KIND_UNIX; + addr->u.q_unix.data =3D QAPI_CLONE(UnixSocketAddress, + &addr_flat->u.q_unix); + break; + case SOCKET_ADDRESS_FLAT_TYPE_VSOCK: + addr->type =3D SOCKET_ADDRESS_KIND_VSOCK; + addr->u.vsock.data =3D QAPI_CLONE(VsockSocketAddress, + &addr_flat->u.vsock); + break; + case SOCKET_ADDRESS_FLAT_TYPE_FD: + addr->type =3D SOCKET_ADDRESS_KIND_FD; + addr->u.fd.data =3D QAPI_CLONE(String, &addr_flat->u.fd); + break; + default: + abort(); + } + + return addr; +} --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14912340582871011.3800297081303; Mon, 3 Apr 2017 08:40:58 -0700 (PDT) Received: from localhost ([::1]:59841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv46C-00030D-QE for importer@patchew.org; Mon, 03 Apr 2017 11:40:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv405-0006Q5-5j for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv400-0007SL-GI for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42744) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv3zw-0007QP-Au; Mon, 03 Apr 2017 11:34:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 179EE38C380; Mon, 3 Apr 2017 15:34:27 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CAE95A2D88; Mon, 3 Apr 2017 15:34:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 179EE38C380 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 179EE38C380 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:49 +0200 Message-Id: <20170403153355.19722-10-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 03 Apr 2017 15:34:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/15] nbd: Tidy up blockdev-add interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster SocketAddress is a simple union, and simple unions are awkward: they have their variant members wrapped in a "data" object on the wire, and require additional indirections in C. I intend to limit its use to existing external interfaces, and convert all internal interfaces to SocketAddressFlat. BlockdevOptionsNbd is an external interface using SocketAddress. We already use SocketAddressFlat elsewhere in blockdev-add. Replace it by SocketAddressFlat while we can (it's new in 2.9) for simplicity and consistency. For example, { "execute": "blockdev-add", "arguments": { "node-name": "foo", "driver": "nbd", "server": { "type": "inet", "data": { "host": "localhost", "port": "12345" } } } } becomes { "execute": "blockdev-add", "arguments": { "node-name": "foo", "driver": "nbd", "server": { "type": "inet", "host": "localhost", "port": "12345" } } } Since the internal interfaces still take SocketAddress, this requires conversion function socket_address_crumple(). It'll go away when I update the interfaces. Unfortunately, SocketAddress is also visible in -drive since 2.8: -drive if=3Dnone,driver=3Dnbd,server.type=3Dinet,server.data.host=3D127= .0.0.1,server.data.port=3D12345 Nobody should be using it, as it's fairly new and has never been documented, so adding still more compatibility gunk to keep it working isn't worth the trouble. You now have to use -drive if=3Dnone,driver=3Dnbd,server.type=3Dinet,server.host=3D127.0.0.= 1,server.port=3D12345 Signed-off-by: Markus Armbruster Message-id: 1490895797-29094-9-git-send-email-armbru@redhat.com [mreitz: Change iotest 147 accordingly] Because of this interface change, iotest 147 has to be adapted. Unfortunately, we cannot just flatten all of the addresses because nbd-server-start still takes a plain SocketAddress. Therefore, we need both and this is most easily achieved by writing the SocketAddress into the code and flattening it where necessary. Signed-off-by: Max Reitz Message-id: 20170330221243.17333-1-mreitz@redhat.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- qapi/block-core.json | 2 +- block/nbd.c | 53 ++++++++++++++++++++++++++--------------------= ---- tests/qemu-iotests/147 | 25 ++++++++++++++++-------- 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 8de39d143a..e4d8a63575 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2847,7 +2847,7 @@ # Since: 2.9 ## { 'struct': 'BlockdevOptionsNbd', - 'data': { 'server': 'SocketAddress', + 'data': { 'server': 'SocketAddressFlat', '*export': 'str', '*tls-creds': 'str' } } =20 diff --git a/block/nbd.c b/block/nbd.c index 11e3ba75fa..8bb29a90bb 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -47,7 +47,7 @@ typedef struct BDRVNBDState { NBDClientSession client; =20 /* For nbd_refresh_filename() */ - SocketAddress *saddr; + SocketAddressFlat *saddr; char *export, *tlscredsid; } BDRVNBDState; =20 @@ -95,7 +95,7 @@ static int nbd_parse_uri(const char *filename, QDict *opt= ions) goto out; } qdict_put(options, "server.type", qstring_from_str("unix")); - qdict_put(options, "server.data.path", + qdict_put(options, "server.path", qstring_from_str(qp->p[0].value)); } else { QString *host; @@ -116,10 +116,10 @@ static int nbd_parse_uri(const char *filename, QDict = *options) } =20 qdict_put(options, "server.type", qstring_from_str("inet")); - qdict_put(options, "server.data.host", host); + qdict_put(options, "server.host", host); =20 port_str =3D g_strdup_printf("%d", uri->port ?: NBD_DEFAULT_PORT); - qdict_put(options, "server.data.port", qstring_from_str(port_str)); + qdict_put(options, "server.port", qstring_from_str(port_str)); g_free(port_str); } =20 @@ -197,7 +197,7 @@ static void nbd_parse_filename(const char *filename, QD= ict *options, /* are we a UNIX or TCP socket? */ if (strstart(host_spec, "unix:", &unixpath)) { qdict_put(options, "server.type", qstring_from_str("unix")); - qdict_put(options, "server.data.path", qstring_from_str(unixpath)); + qdict_put(options, "server.path", qstring_from_str(unixpath)); } else { InetSocketAddress *addr =3D NULL; =20 @@ -207,8 +207,8 @@ static void nbd_parse_filename(const char *filename, QD= ict *options, } =20 qdict_put(options, "server.type", qstring_from_str("inet")); - qdict_put(options, "server.data.host", qstring_from_str(addr->host= )); - qdict_put(options, "server.data.port", qstring_from_str(addr->port= )); + qdict_put(options, "server.host", qstring_from_str(addr->host)); + qdict_put(options, "server.port", qstring_from_str(addr->port)); qapi_free_InetSocketAddress(addr); } =20 @@ -248,20 +248,21 @@ static bool nbd_process_legacy_socket_options(QDict *= output_options, } =20 qdict_put(output_options, "server.type", qstring_from_str("unix")); - qdict_put(output_options, "server.data.path", qstring_from_str(pat= h)); + qdict_put(output_options, "server.path", qstring_from_str(path)); } else if (host) { qdict_put(output_options, "server.type", qstring_from_str("inet")); - qdict_put(output_options, "server.data.host", qstring_from_str(hos= t)); - qdict_put(output_options, "server.data.port", + qdict_put(output_options, "server.host", qstring_from_str(host)); + qdict_put(output_options, "server.port", qstring_from_str(port ?: stringify(NBD_DEFAULT_PORT))); } =20 return true; } =20 -static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options, Error **= errp) +static SocketAddressFlat *nbd_config(BDRVNBDState *s, QDict *options, + Error **errp) { - SocketAddress *saddr =3D NULL; + SocketAddressFlat *saddr =3D NULL; QDict *addr =3D NULL; QObject *crumpled_addr =3D NULL; Visitor *iv =3D NULL; @@ -287,7 +288,7 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict= *options, Error **errp) * visitor expects the former. */ iv =3D qobject_input_visitor_new(crumpled_addr); - visit_type_SocketAddress(iv, NULL, &saddr, &local_err); + visit_type_SocketAddressFlat(iv, NULL, &saddr, &local_err); if (local_err) { error_propagate(errp, local_err); goto done; @@ -306,9 +307,10 @@ NBDClientSession *nbd_get_client_session(BlockDriverSt= ate *bs) return &s->client; } =20 -static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr, +static QIOChannelSocket *nbd_establish_connection(SocketAddressFlat *saddr= _flat, Error **errp) { + SocketAddress *saddr =3D socket_address_crumple(saddr_flat); QIOChannelSocket *sioc; Error *local_err =3D NULL; =20 @@ -318,6 +320,7 @@ static QIOChannelSocket *nbd_establish_connection(Socke= tAddress *saddr, qio_channel_socket_connect_sync(sioc, saddr, &local_err); + qapi_free_SocketAddress(saddr); if (local_err) { error_propagate(errp, local_err); return NULL; @@ -409,7 +412,7 @@ static int nbd_open(BlockDriverState *bs, QDict *option= s, int flags, goto error; } =20 - /* Translate @host, @port, and @path to a SocketAddress */ + /* Translate @host, @port, and @path to a SocketAddressFlat */ if (!nbd_process_legacy_socket_options(options, opts, errp)) { goto error; } @@ -430,11 +433,11 @@ static int nbd_open(BlockDriverState *bs, QDict *opti= ons, int flags, } =20 /* TODO SOCKET_ADDRESS_KIND_FD where fd has AF_INET or AF_INET6 */ - if (s->saddr->type !=3D SOCKET_ADDRESS_KIND_INET) { + if (s->saddr->type !=3D SOCKET_ADDRESS_FLAT_TYPE_INET) { error_setg(errp, "TLS only supported over IP sockets"); goto error; } - hostname =3D s->saddr->u.inet.data->host; + hostname =3D s->saddr->u.inet.host; } =20 /* establish TCP connection, return error if it fails @@ -457,7 +460,7 @@ static int nbd_open(BlockDriverState *bs, QDict *option= s, int flags, object_unref(OBJECT(tlscreds)); } if (ret < 0) { - qapi_free_SocketAddress(s->saddr); + qapi_free_SocketAddressFlat(s->saddr); g_free(s->export); g_free(s->tlscredsid); } @@ -483,7 +486,7 @@ static void nbd_close(BlockDriverState *bs) =20 nbd_client_close(bs); =20 - qapi_free_SocketAddress(s->saddr); + qapi_free_SocketAddressFlat(s->saddr); g_free(s->export); g_free(s->tlscredsid); } @@ -514,15 +517,15 @@ static void nbd_refresh_filename(BlockDriverState *bs= , QDict *options) Visitor *ov; const char *host =3D NULL, *port =3D NULL, *path =3D NULL; =20 - if (s->saddr->type =3D=3D SOCKET_ADDRESS_KIND_INET) { - const InetSocketAddress *inet =3D s->saddr->u.inet.data; + if (s->saddr->type =3D=3D SOCKET_ADDRESS_FLAT_TYPE_INET) { + const InetSocketAddress *inet =3D &s->saddr->u.inet; if (!inet->has_ipv4 && !inet->has_ipv6 && !inet->has_to) { host =3D inet->host; port =3D inet->port; } - } else if (s->saddr->type =3D=3D SOCKET_ADDRESS_KIND_UNIX) { - path =3D s->saddr->u.q_unix.data->path; - } + } else if (s->saddr->type =3D=3D SOCKET_ADDRESS_FLAT_TYPE_UNIX) { + path =3D s->saddr->u.q_unix.path; + } /* else can't represent as pseudo-filename */ =20 qdict_put(opts, "driver", qstring_from_str("nbd")); =20 @@ -541,7 +544,7 @@ static void nbd_refresh_filename(BlockDriverState *bs, = QDict *options) } =20 ov =3D qobject_output_visitor_new(&saddr_qdict); - visit_type_SocketAddress(ov, NULL, &s->saddr, &error_abort); + visit_type_SocketAddressFlat(ov, NULL, &s->saddr, &error_abort); visit_complete(ov, &saddr_qdict); visit_free(ov); qdict_put_obj(opts, "server", saddr_qdict); diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147 index cca75c562c..32afea63d4 100755 --- a/tests/qemu-iotests/147 +++ b/tests/qemu-iotests/147 @@ -30,6 +30,13 @@ NBD_PORT =3D 10811 test_img =3D os.path.join(iotests.test_dir, 'test.img') unix_socket =3D os.path.join(iotests.test_dir, 'nbd.socket') =20 + +def flatten_sock_addr(crumpled_address): + result =3D { 'type': crumpled_address['type'] } + result.update(crumpled_address['data']) + return result + + class NBDBlockdevAddBase(iotests.QMPTestCase): def blockdev_add_options(self, address, export=3DNone): options =3D { 'node-name': 'nbd-blockdev', @@ -85,13 +92,15 @@ class QemuNBD(NBDBlockdevAddBase): 'host': 'localhost', 'port': str(NBD_PORT) } } - self.client_test('nbd://localhost:%i' % NBD_PORT, address) + self.client_test('nbd://localhost:%i' % NBD_PORT, + flatten_sock_addr(address)) =20 def test_unix(self): self._server_up('-k', unix_socket) address =3D { 'type': 'unix', 'data': { 'path': unix_socket } } - self.client_test('nbd+unix://?socket=3D' + unix_socket, address) + self.client_test('nbd+unix://?socket=3D' + unix_socket, + flatten_sock_addr(address)) =20 =20 class BuiltinNBD(NBDBlockdevAddBase): @@ -134,7 +143,7 @@ class BuiltinNBD(NBDBlockdevAddBase): } } self._server_up(address) self.client_test('nbd://localhost:%i/nbd-export' % NBD_PORT, - address, 'nbd-export') + flatten_sock_addr(address), 'nbd-export') self._server_down() =20 def test_inet6(self): @@ -149,10 +158,10 @@ class BuiltinNBD(NBDBlockdevAddBase): 'file': { 'driver': 'nbd', 'export': 'nbd-export', - 'server': address + 'server': flatten_sock_addr(address) } } self._server_up(address) - self.client_test(filename, address, 'nbd-export') + self.client_test(filename, flatten_sock_addr(address), 'nbd-export= ') self._server_down() =20 def test_unix(self): @@ -160,7 +169,7 @@ class BuiltinNBD(NBDBlockdevAddBase): 'data': { 'path': unix_socket } } self._server_up(address) self.client_test('nbd+unix:///nbd-export?socket=3D' + unix_socket, - address, 'nbd-export') + flatten_sock_addr(address), 'nbd-export') self._server_down() =20 def test_fd(self): @@ -182,9 +191,9 @@ class BuiltinNBD(NBDBlockdevAddBase): 'file': { 'driver': 'nbd', 'export': 'nbd-export', - 'server': address + 'server': flatten_sock_addr(address) } } - self.client_test(filename, address, 'nbd-export') + self.client_test(filename, flatten_sock_addr(address), 'nbd-export= ') =20 self._server_down() =20 --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149123441568114.810741039046775; Mon, 3 Apr 2017 08:46:55 -0700 (PDT) Received: from localhost ([::1]:59882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv4By-00086u-9k for importer@patchew.org; Mon, 03 Apr 2017 11:46:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv408-0006St-BA for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv406-0007Tw-RO for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv3zz-0007Ry-Sd; Mon, 03 Apr 2017 11:34:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5439F80477; Mon, 3 Apr 2017 15:34:30 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 043D15C890; Mon, 3 Apr 2017 15:34:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5439F80477 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5439F80477 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:50 +0200 Message-Id: <20170403153355.19722-11-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 03 Apr 2017 15:34:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/15] sheepdog: Fix blockdev-add X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster Commit 831acdc "sheepdog: Implement bdrv_parse_filename()" and commit d282f34 "sheepdog: Support blockdev-add" have different ideas on how the QemuOpts parameters for the server address are named. Fix that. While there, rename BlockdevOptionsSheepdog member addr to server, for consistency with BlockdevOptionsSsh, BlockdevOptionsGluster, BlockdevOptionsNbd. Commit 831acdc's example becomes --drive driver=3Dsheepdog,server.type=3Dinet,server.host=3Dfido,server.= port=3D7000,vdi=3Ddolly instead of --drive driver=3Dsheepdog,host=3Dfido,vdi=3Ddolly Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Tested-by: Kashyap Chamarthy Message-id: 1490895797-29094-10-git-send-email-armbru@redhat.com Signed-off-by: Max Reitz --- qapi/block-core.json | 4 +-- block/sheepdog.c | 90 +++++++++++++++++++++++++++++++++---------------= ---- 2 files changed, 60 insertions(+), 34 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index e4d8a63575..033457ce86 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2623,7 +2623,7 @@ # Driver specific block device options for sheepdog # # @vdi: Virtual disk image name -# @addr: The Sheepdog server to connect to +# @server: The Sheepdog server to connect to # @snap-id: Snapshot ID # @tag: Snapshot tag name # @@ -2632,7 +2632,7 @@ # Since: 2.9 ## { 'struct': 'BlockdevOptionsSheepdog', - 'data': { 'addr': 'SocketAddressFlat', + 'data': { 'server': 'SocketAddressFlat', 'vdi': 'str', '*snap-id': 'uint32', '*tag': 'str' } } diff --git a/block/sheepdog.c b/block/sheepdog.c index 89e98edab6..1b71fc81ec 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -13,9 +13,11 @@ */ =20 #include "qemu/osdep.h" +#include "qapi-visit.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qint.h" +#include "qapi/qobject-input-visitor.h" #include "qemu/uri.h" #include "qemu/error-report.h" #include "qemu/sockets.h" @@ -547,6 +549,47 @@ static SocketAddress *sd_socket_address(const char *pa= th, return addr; } =20 +static SocketAddress *sd_server_config(QDict *options, Error **errp) +{ + QDict *server =3D NULL; + QObject *crumpled_server =3D NULL; + Visitor *iv =3D NULL; + SocketAddressFlat *saddr_flat =3D NULL; + SocketAddress *saddr =3D NULL; + Error *local_err =3D NULL; + + qdict_extract_subqdict(options, &server, "server."); + + crumpled_server =3D qdict_crumple(server, errp); + if (!crumpled_server) { + goto done; + } + + /* + * FIXME .numeric, .to, .ipv4 or .ipv6 don't work with -drive + * server.type=3Dinet. .to doesn't matter, it's ignored anyway. + * That's because when @options come from -blockdev or + * blockdev_add, members are typed according to the QAPI schema, + * but when they come from -drive, they're all QString. The + * visitor expects the former. + */ + iv =3D qobject_input_visitor_new(crumpled_server); + visit_type_SocketAddressFlat(iv, NULL, &saddr_flat, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto done; + } + + saddr =3D socket_address_crumple(saddr_flat); + +done: + qapi_free_SocketAddressFlat(saddr_flat); + visit_free(iv); + qobject_decref(crumpled_server); + QDECREF(server); + return saddr; +} + /* Return -EIO in case of error, file descriptor on success */ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) { @@ -1174,15 +1217,15 @@ static void sd_parse_filename(const char *filename,= QDict *options, return; } =20 - if (cfg.host) { - qdict_set_default_str(options, "host", cfg.host); - } - if (cfg.port) { - snprintf(buf, sizeof(buf), "%d", cfg.port); - qdict_set_default_str(options, "port", buf); - } if (cfg.path) { - qdict_set_default_str(options, "path", cfg.path); + qdict_set_default_str(options, "server.path", cfg.path); + qdict_set_default_str(options, "server.type", "unix"); + } else { + qdict_set_default_str(options, "server.type", "inet"); + qdict_set_default_str(options, "server.host", + cfg.host ?: SD_DEFAULT_ADDR); + snprintf(buf, sizeof(buf), "%d", cfg.port ?: SD_DEFAULT_PORT); + qdict_set_default_str(options, "server.port", buf); } qdict_set_default_str(options, "vdi", cfg.vdi); qdict_set_default_str(options, "tag", cfg.tag); @@ -1510,18 +1553,6 @@ static QemuOptsList runtime_opts =3D { .head =3D QTAILQ_HEAD_INITIALIZER(runtime_opts.head), .desc =3D { { - .name =3D "host", - .type =3D QEMU_OPT_STRING, - }, - { - .name =3D "port", - .type =3D QEMU_OPT_STRING, - }, - { - .name =3D "path", - .type =3D QEMU_OPT_STRING, - }, - { .name =3D "vdi", .type =3D QEMU_OPT_STRING, }, @@ -1543,7 +1574,7 @@ static int sd_open(BlockDriverState *bs, QDict *optio= ns, int flags, int ret, fd; uint32_t vid =3D 0; BDRVSheepdogState *s =3D bs->opaque; - const char *host, *port, *path, *vdi, *snap_id_str, *tag; + const char *vdi, *snap_id_str, *tag; uint64_t snap_id; char *buf =3D NULL; QemuOpts *opts; @@ -1560,20 +1591,17 @@ static int sd_open(BlockDriverState *bs, QDict *opt= ions, int flags, goto err_no_fd; } =20 - host =3D qemu_opt_get(opts, "host"); - port =3D qemu_opt_get(opts, "port"); - path =3D qemu_opt_get(opts, "path"); + s->addr =3D sd_server_config(options, errp); + if (!s->addr) { + ret =3D -EINVAL; + goto err_no_fd; + } + vdi =3D qemu_opt_get(opts, "vdi"); snap_id_str =3D qemu_opt_get(opts, "snap-id"); snap_id =3D qemu_opt_get_number(opts, "snap-id", CURRENT_VDI_ID); tag =3D qemu_opt_get(opts, "tag"); =20 - if ((host || port) && path) { - error_setg(errp, "can't use 'path' together with 'host' or 'port'"= ); - ret =3D -EINVAL; - goto err_no_fd; - } - if (!vdi) { error_setg(errp, "parameter 'vdi' is missing"); ret =3D -EINVAL; @@ -1604,8 +1632,6 @@ static int sd_open(BlockDriverState *bs, QDict *optio= ns, int flags, goto err_no_fd; } =20 - s->addr =3D sd_socket_address(path, host, port); - QLIST_INIT(&s->inflight_aio_head); QLIST_INIT(&s->failed_aio_head); QLIST_INIT(&s->inflight_aiocb_head); --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14912341979661001.7233448082102; Mon, 3 Apr 2017 08:43:17 -0700 (PDT) Received: from localhost ([::1]:59850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv48S-00052y-LS for importer@patchew.org; Mon, 03 Apr 2017 11:43:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv407-0006SY-UT for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv407-0007U4-7H for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43298) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv404-0007Sq-S8; Mon, 03 Apr 2017 11:34:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 558773AD57F; Mon, 3 Apr 2017 15:34:35 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D4DD78390; Mon, 3 Apr 2017 15:34:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 558773AD57F Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 558773AD57F From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:51 +0200 Message-Id: <20170403153355.19722-12-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 03 Apr 2017 15:34:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/15] qemu-io-cmds: Assert that global and nofile commands don't use ct->perms X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Maydell It would be a bug for a command with the CMD_NOFILE_OK or CMD_FLAG_GLOBAL flags set to also set the ct->perms field, because the former says "OK for a file not to be open" but the latter is a check on a file. Add an assertion in qemuio_add_command() so we can catch that sort of buggy command definition immediately rather than it being a bug that only manifests when a particular set of command line options is used. (Coverity gets confused about this (CID 1371723) and reports that we might dereference a NULL blk pointer in this case, because it can't tell that that code path never happens with the cmdinfo_t that we have. This commit won't help unconfuse it, but it does fix the underlying issue.) Signed-off-by: Peter Maydell Message-id: 1490967529-4767-1-git-send-email-peter.maydell@linaro.org Signed-off-by: Max Reitz --- qemu-io-cmds.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 2c48f9ce1a..883f53b64d 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -35,6 +35,13 @@ static int compare_cmdname(const void *a, const void *b) =20 void qemuio_add_command(const cmdinfo_t *ci) { + /* ci->perm assumes a file is open, but the GLOBAL and NOFILE_OK + * flags allow it not to be, so that combination is invalid. + * Catch it now rather than letting it manifest as a crash if a + * particular set of command line options are used. + */ + assert(ci->perm =3D=3D 0 || + (ci->flags & (CMD_FLAG_GLOBAL | CMD_NOFILE_OK)) =3D=3D 0); cmdtab =3D g_renew(cmdinfo_t, cmdtab, ++ncmds); cmdtab[ncmds - 1] =3D *ci; qsort(cmdtab, ncmds, sizeof(*cmdtab), compare_cmdname); --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491233947644179.63586892552712; Mon, 3 Apr 2017 08:39:07 -0700 (PDT) Received: from localhost ([::1]:59824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv44P-0001Pw-W8 for importer@patchew.org; Mon, 03 Apr 2017 11:39:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv40H-0006Z1-O8 for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv40C-0007WH-Vd for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43950) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv406-0007TQ-92; Mon, 03 Apr 2017 11:34:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 233C63B707; Mon, 3 Apr 2017 15:34:37 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C32428FF85; Mon, 3 Apr 2017 15:34:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 233C63B707 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 233C63B707 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:52 +0200 Message-Id: <20170403153355.19722-13-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 03 Apr 2017 15:34:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/15] iotests: fix 097 when run with qcow X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" The previous commit: commit a3e1505daec31ef56f0489f8c8fff1b8e4ca92bd Author: Eric Blake Date: Mon Dec 5 09:49:34 2016 -0600 qcow2: Don't strand clusters near 2G intervals during commit extended the 097 test case so that it did two passes, once with an internal snapshot, once without. qcow (v1) does not support internal snapshots, so this change broke test 097 when run against qcow. This splits 097 in two, creating a new 176 that tests the internal snapshot codepath, effectively putting 097 back to its content before the above commit. Reviewed-by: Max Reitz Signed-off-by: Daniel P. Berrange Message-Id: <20170221115512.21918-8-berrange@redhat.com> [eblake: test collisions: s/173/176/g] Signed-off-by: Eric Blake Message-id: 20170331185356.2479-2-eblake@redhat.com Signed-off-by: Max Reitz --- tests/qemu-iotests/097 | 10 +--- tests/qemu-iotests/097.out | 125 ++---------------------------------------= --- tests/qemu-iotests/176 | 126 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/176.out | 119 ++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 5 files changed, 251 insertions(+), 130 deletions(-) create mode 100755 tests/qemu-iotests/176 create mode 100644 tests/qemu-iotests/176.out diff --git a/tests/qemu-iotests/097 b/tests/qemu-iotests/097 index 4c33e8038a..1d28aff99d 100755 --- a/tests/qemu-iotests/097 +++ b/tests/qemu-iotests/097 @@ -56,26 +56,19 @@ _supported_os Linux # 3: Two-layer backing chain, commit to lower backing file # (in this case, the top image will implicitly stay unchanged) # -# Each pass is run twice, since qcow2 has different code paths for cleaning -# an image depending on whether it has a snapshot. -# # 020 already tests committing, so this only tests whether image chains are # working properly and that all images above the base are emptied; therefo= re, # no complicated patterns are necessary. Check near the 2G mark, as qcow2 # has been buggy at that boundary in the past. for i in 0 1 2 3; do -for j in 0 1; do =20 echo -echo "=3D=3D=3D Test pass $i.$j =3D=3D=3D" +echo "=3D=3D=3D Test pass $i =3D=3D=3D" echo =20 TEST_IMG=3D"$TEST_IMG.base" _make_test_img 2100M TEST_IMG=3D"$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" 2100M _make_test_img -b "$TEST_IMG.itmd" 2100M -if [ $j -eq 0 ]; then - $QEMU_IMG snapshot -c snap "$TEST_IMG" -fi =20 $QEMU_IO -c 'write -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qemu_io $QEMU_IO -c 'write -P 2 0x7ffe0000 128k' "$TEST_IMG.itmd" | _filter_qemu_io @@ -121,7 +114,6 @@ $QEMU_IMG map "$TEST_IMG.itmd" | _filter_qemu_img_map $QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map =20 done -done =20 =20 # success, all done diff --git a/tests/qemu-iotests/097.out b/tests/qemu-iotests/097.out index 8106cc9275..81fc2252a0 100644 --- a/tests/qemu-iotests/097.out +++ b/tests/qemu-iotests/097.out @@ -1,6 +1,6 @@ QA output created by 097 =20 -=3D=3D=3D Test pass 0.0 =3D=3D=3D +=3D=3D=3D Test pass 0 =3D=3D=3D =20 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base @@ -29,66 +29,7 @@ Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd =20 -=3D=3D=3D Test pass 0.1 =3D=3D=3D - -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd -wrote 196608/196608 bytes at offset 2147287040 -192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -wrote 131072/131072 bytes at offset 2147352576 -128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -wrote 65536/65536 bytes at offset 2147418112 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Image committed. -read 196608/196608 bytes at offset 2147287040 -192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147287040 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147352576 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147418112 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Offset Length File -0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base -Offset Length File -0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base -0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd -Offset Length File -0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base -0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd - -=3D=3D=3D Test pass 1.0 =3D=3D=3D - -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd -wrote 196608/196608 bytes at offset 2147287040 -192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -wrote 131072/131072 bytes at offset 2147352576 -128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -wrote 65536/65536 bytes at offset 2147418112 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Image committed. -read 196608/196608 bytes at offset 2147287040 -192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147287040 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147352576 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147418112 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Offset Length File -0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base -Offset Length File -0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base -0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd -Offset Length File -0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base -0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd -0x7fff0000 0x10000 TEST_DIR/t.IMGFMT - -=3D=3D=3D Test pass 1.1 =3D=3D=3D +=3D=3D=3D Test pass 1 =3D=3D=3D =20 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base @@ -118,7 +59,7 @@ Offset Length File 0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd 0x7fff0000 0x10000 TEST_DIR/t.IMGFMT =20 -=3D=3D=3D Test pass 2.0 =3D=3D=3D +=3D=3D=3D Test pass 2 =3D=3D=3D =20 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base @@ -148,65 +89,7 @@ Offset Length File 0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd 0x7fff0000 0x10000 TEST_DIR/t.IMGFMT =20 -=3D=3D=3D Test pass 2.1 =3D=3D=3D - -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd -wrote 196608/196608 bytes at offset 2147287040 -192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -wrote 131072/131072 bytes at offset 2147352576 -128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -wrote 65536/65536 bytes at offset 2147418112 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Image committed. -read 196608/196608 bytes at offset 2147287040 -192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147287040 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147352576 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147418112 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Offset Length File -0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base -Offset Length File -0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base -0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd -Offset Length File -0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base -0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd -0x7fff0000 0x10000 TEST_DIR/t.IMGFMT - -=3D=3D=3D Test pass 3.0 =3D=3D=3D - -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd -wrote 196608/196608 bytes at offset 2147287040 -192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -wrote 131072/131072 bytes at offset 2147352576 -128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -wrote 65536/65536 bytes at offset 2147418112 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Image committed. -read 65536/65536 bytes at offset 2147287040 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147352576 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -read 65536/65536 bytes at offset 2147418112 -64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Offset Length File -0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base -Offset Length File -0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base -0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd -Offset Length File -0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base -0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd -0x7fff0000 0x10000 TEST_DIR/t.IMGFMT - -=3D=3D=3D Test pass 3.1 =3D=3D=3D +=3D=3D=3D Test pass 3 =3D=3D=3D =20 Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base diff --git a/tests/qemu-iotests/176 b/tests/qemu-iotests/176 new file mode 100755 index 0000000000..9a70a8707c --- /dev/null +++ b/tests/qemu-iotests/176 @@ -0,0 +1,126 @@ +#!/bin/bash +# +# Commit changes into backing chains and empty the top image if the +# backing image is not explicitly specified. +# +# Variant of 097, which includes snapshots to test different codepath +# in qcow2 +# +# Copyright (C) 2014 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dmreitz@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_test_img "$TEST_IMG.itmd" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.pattern + +# Any format supporting backing files and bdrv_make_empty +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + + +# Four passes: +# 0: Two-layer backing chain, commit to upper backing file (implicitly) +# (in this case, the top image will be emptied) +# 1: Two-layer backing chain, commit to upper backing file (explicitly) +# (in this case, the top image will implicitly stay unchanged) +# 2: Two-layer backing chain, commit to upper backing file (implicitly wi= th -d) +# (in this case, the top image will explicitly stay unchanged) +# 3: Two-layer backing chain, commit to lower backing file +# (in this case, the top image will implicitly stay unchanged) +# +# 020 already tests committing, so this only tests whether image chains are +# working properly and that all images above the base are emptied; therefo= re, +# no complicated patterns are necessary. Check near the 2G mark, as qcow2 +# has been buggy at that boundary in the past. +for i in 0 1 2 3; do + +echo +echo "=3D=3D=3D Test pass $i =3D=3D=3D" +echo + +TEST_IMG=3D"$TEST_IMG.base" _make_test_img 2100M +TEST_IMG=3D"$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" 2100M +_make_test_img -b "$TEST_IMG.itmd" 2100M +$QEMU_IMG snapshot -c snap "$TEST_IMG" + +$QEMU_IO -c 'write -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c 'write -P 2 0x7ffe0000 128k' "$TEST_IMG.itmd" | _filter_qemu_io +$QEMU_IO -c 'write -P 3 0x7fff0000 64k' "$TEST_IMG" | _filter_qemu_io + +if [ $i -lt 3 ]; then + if [ $i =3D=3D 0 ]; then + # -b "$TEST_IMG.itmd" should be the default (that is, committing t= o the + # first backing file in the chain) + $QEMU_IMG commit "$TEST_IMG" + elif [ $i =3D=3D 1 ]; then + # explicitly specify the commit target (this should imply -d) + $QEMU_IMG commit -b "$TEST_IMG.itmd" "$TEST_IMG" + else + # do not explicitly specify the commit target, but use -d to leave= the + # top image unchanged + $QEMU_IMG commit -d "$TEST_IMG" + fi + + # Bottom should be unchanged + $QEMU_IO -c 'read -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qem= u_io + + # Intermediate should contain changes from top + $QEMU_IO -c 'read -P 1 0x7ffd0000 64k' "$TEST_IMG.itmd" | _filter_qemu= _io + $QEMU_IO -c 'read -P 2 0x7ffe0000 64k' "$TEST_IMG.itmd" | _filter_qemu= _io + $QEMU_IO -c 'read -P 3 0x7fff0000 64k' "$TEST_IMG.itmd" | _filter_qemu= _io + + # And in pass 0, the top image should be empty, whereas in both other = passes + # it should be unchanged (which is both checked by qemu-img map) +else + $QEMU_IMG commit -b "$TEST_IMG.base" "$TEST_IMG" + + # Bottom should contain all changes + $QEMU_IO -c 'read -P 1 0x7ffd0000 64k' "$TEST_IMG.base" | _filter_qemu= _io + $QEMU_IO -c 'read -P 2 0x7ffe0000 64k' "$TEST_IMG.base" | _filter_qemu= _io + $QEMU_IO -c 'read -P 3 0x7fff0000 64k' "$TEST_IMG.base" | _filter_qemu= _io + + # Both top and intermediate should be unchanged +fi + +$QEMU_IMG map "$TEST_IMG.base" | _filter_qemu_img_map +$QEMU_IMG map "$TEST_IMG.itmd" | _filter_qemu_img_map +$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map + +done + + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/176.out b/tests/qemu-iotests/176.out new file mode 100644 index 0000000000..fc6365309e --- /dev/null +++ b/tests/qemu-iotests/176.out @@ -0,0 +1,119 @@ +QA output created by 176 + +=3D=3D=3D Test pass 0 =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +wrote 196608/196608 bytes at offset 2147287040 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 2147352576 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 2147418112 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Image committed. +read 196608/196608 bytes at offset 2147287040 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147287040 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147352576 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147418112 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Offset Length File +0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base +Offset Length File +0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base +0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +Offset Length File +0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base +0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd + +=3D=3D=3D Test pass 1 =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +wrote 196608/196608 bytes at offset 2147287040 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 2147352576 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 2147418112 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Image committed. +read 196608/196608 bytes at offset 2147287040 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147287040 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147352576 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147418112 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Offset Length File +0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base +Offset Length File +0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base +0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +Offset Length File +0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base +0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd +0x7fff0000 0x10000 TEST_DIR/t.IMGFMT + +=3D=3D=3D Test pass 2 =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +wrote 196608/196608 bytes at offset 2147287040 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 2147352576 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 2147418112 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Image committed. +read 196608/196608 bytes at offset 2147287040 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147287040 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147352576 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147418112 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Offset Length File +0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base +Offset Length File +0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base +0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +Offset Length File +0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base +0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd +0x7fff0000 0x10000 TEST_DIR/t.IMGFMT + +=3D=3D=3D Test pass 3 =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +wrote 196608/196608 bytes at offset 2147287040 +192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 2147352576 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 2147418112 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Image committed. +read 65536/65536 bytes at offset 2147287040 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147352576 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 2147418112 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Offset Length File +0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base +Offset Length File +0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base +0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +Offset Length File +0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base +0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd +0x7fff0000 0x10000 TEST_DIR/t.IMGFMT +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 1f4bf03185..43142ddfcf 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -168,3 +168,4 @@ 173 rw auto 174 auto 175 auto quick +176 rw auto backing --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149123380000998.66333791644388; Mon, 3 Apr 2017 08:36:40 -0700 (PDT) Received: from localhost ([::1]:59815 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv422-0007oW-JL for importer@patchew.org; Mon, 03 Apr 2017 11:36:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv40H-0006ZC-TN for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv40C-0007WC-Sy for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43729) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv408-0007UM-R1; Mon, 03 Apr 2017 11:34:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3E8419D4D2; Mon, 3 Apr 2017 15:34:39 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5AAE8FF85; Mon, 3 Apr 2017 15:34:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C3E8419D4D2 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C3E8419D4D2 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:53 +0200 Message-Id: <20170403153355.19722-14-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 03 Apr 2017 15:34:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/15] qcow2: Discard unaligned tail when wiping image X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake There is a subtle difference between the fast (qcow2v3 with no extra data) and slow path (qcow2v2 format [aka 0.10], or when a snapshot is present) of qcow2_make_empty(). The slow path fails to discard the final (partial) cluster of an unaligned image. The problem stems from the fact that qcow2_discard_clusters() was silently ignoring sub-cluster head and tail on unaligned requests. A quick audit of all callers shows that qcow2_snapshot_create() has always passed a cluster-aligned request since the call was added in commit 1ebf561; qcow2_co_pdiscard() has passed a cluster-aligned request since commit ecdbead taught the block layer about preferred discard alignment; and qcow2_make_empty() was fixed to pass an aligned start (but not necessarily end) in commit a3e1505. Asserting that the start is always aligned also points out that we now have a dead check: rounding the end offset down can never result in a value less than the aligned start offset (the check was rendered dead with commit ecdbead). Meanwhile, we do not want to round the end cluster down in the one case of the end offset matching the (unaligned) file size - that final partial cluster should still be discarded. With those fixes in place, the fast and slow paths are back in sync at discarding an entire image; the next patch will update qemu-iotests to ensure we don't regress. Note that bdrv_co_pdiscard ignores ALL partial cluster requests, including the partial cluster at the end of an image; it can be argued that the partial cluster at the end should be special-cased so that a guest issuing discard requests at proper alignments everywhere else can likewise empty the entire image. But that optimization is left for another day. Signed-off-by: Eric Blake Message-id: 20170331185356.2479-3-eblake@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- block/qcow2-cluster.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 78c11d4948..100398c565 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1519,12 +1519,10 @@ int qcow2_discard_clusters(BlockDriverState *bs, ui= nt64_t offset, =20 end_offset =3D offset + (nb_sectors << BDRV_SECTOR_BITS); =20 - /* Round start up and end down */ - offset =3D align_offset(offset, s->cluster_size); - end_offset =3D start_of_cluster(s, end_offset); - - if (offset > end_offset) { - return 0; + /* The caller must cluster-align start; round end down except at EOF */ + assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); + if (end_offset !=3D bs->total_sectors * BDRV_SECTOR_SIZE) { + end_offset =3D start_of_cluster(s, end_offset); } =20 nb_clusters =3D size_to_clusters(s, end_offset - offset); --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491234295650399.9230171209532; Mon, 3 Apr 2017 08:44:55 -0700 (PDT) Received: from localhost ([::1]:59864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv4A2-0006WI-40 for importer@patchew.org; Mon, 03 Apr 2017 11:44:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv40N-0006do-UW for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:35:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv40L-0007Zl-Cb for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44200) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv40C-0007Vt-O4; Mon, 03 Apr 2017 11:34:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B79C685376; Mon, 3 Apr 2017 15:34:43 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B14F05C892; Mon, 3 Apr 2017 15:34:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B79C685376 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B79C685376 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:54 +0200 Message-Id: <20170403153355.19722-15-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 03 Apr 2017 15:34:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/15] iotests: Improve image-clear tests on non-aligned image X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake Tweak 097 and 176 to operate on an image that is not cluster-aligned, to give further coverage of clearing out an entire image, including the recent fix to eliminate the difference between fast path (97) and slow (176) for qcow2. Also tested on qcow (97 only, since qcow lacks snapshots). Signed-off-by: Eric Blake Message-id: 20170331185356.2479-4-eblake@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- tests/qemu-iotests/097 | 17 +++++++++----- tests/qemu-iotests/097.out | 55 ++++++++++++++++++++++++++++++++++++------= ---- tests/qemu-iotests/176 | 17 +++++++++----- tests/qemu-iotests/176.out | 55 ++++++++++++++++++++++++++++++++++++------= ---- 4 files changed, 108 insertions(+), 36 deletions(-) diff --git a/tests/qemu-iotests/097 b/tests/qemu-iotests/097 index 1d28aff99d..e22670c8d0 100755 --- a/tests/qemu-iotests/097 +++ b/tests/qemu-iotests/097 @@ -66,13 +66,15 @@ echo echo "=3D=3D=3D Test pass $i =3D=3D=3D" echo =20 -TEST_IMG=3D"$TEST_IMG.base" _make_test_img 2100M -TEST_IMG=3D"$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" 2100M -_make_test_img -b "$TEST_IMG.itmd" 2100M +len=3D$((2100 * 1024 * 1024 + 512)) # larger than 2G, and not cluster alig= ned +TEST_IMG=3D"$TEST_IMG.base" _make_test_img $len +TEST_IMG=3D"$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" $len +_make_test_img -b "$TEST_IMG.itmd" $len =20 -$QEMU_IO -c 'write -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qemu_io -$QEMU_IO -c 'write -P 2 0x7ffe0000 128k' "$TEST_IMG.itmd" | _filter_qemu_io -$QEMU_IO -c 'write -P 3 0x7fff0000 64k' "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 1 0x7ffd0000 192k" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -P 2 0x7ffe0000 128k" "$TEST_IMG.itmd" | _filter_qemu_io +$QEMU_IO -c "write -P 3 0x7fff0000 64k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 4 $(($len - 512)) 512" "$TEST_IMG" | _filter_qemu_io =20 if [ $i -lt 3 ]; then if [ $i =3D=3D 0 ]; then @@ -90,11 +92,13 @@ if [ $i -lt 3 ]; then =20 # Bottom should be unchanged $QEMU_IO -c 'read -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qem= u_io + $QEMU_IO -c "read -P 0 $((len - 512)) 512" "$TEST_IMG.base" | _filter_= qemu_io =20 # Intermediate should contain changes from top $QEMU_IO -c 'read -P 1 0x7ffd0000 64k' "$TEST_IMG.itmd" | _filter_qemu= _io $QEMU_IO -c 'read -P 2 0x7ffe0000 64k' "$TEST_IMG.itmd" | _filter_qemu= _io $QEMU_IO -c 'read -P 3 0x7fff0000 64k' "$TEST_IMG.itmd" | _filter_qemu= _io + $QEMU_IO -c "read -P 4 $((len - 512)) 512" "$TEST_IMG.itmd" | _filter_= qemu_io =20 # And in pass 0, the top image should be empty, whereas in both other = passes # it should be unchanged (which is both checked by qemu-img map) @@ -105,6 +109,7 @@ else $QEMU_IO -c 'read -P 1 0x7ffd0000 64k' "$TEST_IMG.base" | _filter_qemu= _io $QEMU_IO -c 'read -P 2 0x7ffe0000 64k' "$TEST_IMG.base" | _filter_qemu= _io $QEMU_IO -c 'read -P 3 0x7fff0000 64k' "$TEST_IMG.base" | _filter_qemu= _io + $QEMU_IO -c "read -P 4 $((len - 512)) 512" "$TEST_IMG.base" | _filter_= qemu_io =20 # Both top and intermediate should be unchanged fi diff --git a/tests/qemu-iotests/097.out b/tests/qemu-iotests/097.out index 81fc2252a0..f6705a1cc7 100644 --- a/tests/qemu-iotests/097.out +++ b/tests/qemu-iotests/097.out @@ -2,104 +2,130 @@ QA output created by 097 =20 =3D=3D=3D Test pass 0 =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202010112 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202010112 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202010112 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Image committed. read 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147287040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147352576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Offset Length File 0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +0x83400000 0x200 TEST_DIR/t.IMGFMT.itmd Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +0x83400000 0x200 TEST_DIR/t.IMGFMT.itmd =20 =3D=3D=3D Test pass 1 =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202010112 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202010112 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202010112 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Image committed. read 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147287040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147352576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Offset Length File 0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +0x83400000 0x200 TEST_DIR/t.IMGFMT.itmd Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd 0x7fff0000 0x10000 TEST_DIR/t.IMGFMT +0x83400000 0x200 TEST_DIR/t.IMGFMT =20 =3D=3D=3D Test pass 2 =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202010112 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202010112 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202010112 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Image committed. read 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147287040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147352576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Offset Length File 0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +0x83400000 0x200 TEST_DIR/t.IMGFMT.itmd Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd 0x7fff0000 0x10000 TEST_DIR/t.IMGFMT +0x83400000 0x200 TEST_DIR/t.IMGFMT =20 =3D=3D=3D Test pass 3 =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202010112 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202010112 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202010112 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Image committed. read 65536/65536 bytes at offset 2147287040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -107,13 +133,18 @@ read 65536/65536 bytes at offset 2147352576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Offset Length File 0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base +0x83400000 0x200 TEST_DIR/t.IMGFMT.base Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +0x83400000 0x200 TEST_DIR/t.IMGFMT.base Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd 0x7fff0000 0x10000 TEST_DIR/t.IMGFMT +0x83400000 0x200 TEST_DIR/t.IMGFMT *** done diff --git a/tests/qemu-iotests/176 b/tests/qemu-iotests/176 index 9a70a8707c..950b28720e 100755 --- a/tests/qemu-iotests/176 +++ b/tests/qemu-iotests/176 @@ -69,14 +69,16 @@ echo echo "=3D=3D=3D Test pass $i =3D=3D=3D" echo =20 -TEST_IMG=3D"$TEST_IMG.base" _make_test_img 2100M -TEST_IMG=3D"$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" 2100M -_make_test_img -b "$TEST_IMG.itmd" 2100M +len=3D$((2100 * 1024 * 1024 + 512)) # larger than 2G, and not cluster alig= ned +TEST_IMG=3D"$TEST_IMG.base" _make_test_img $len +TEST_IMG=3D"$TEST_IMG.itmd" _make_test_img -b "$TEST_IMG.base" $len +_make_test_img -b "$TEST_IMG.itmd" $len $QEMU_IMG snapshot -c snap "$TEST_IMG" =20 -$QEMU_IO -c 'write -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qemu_io -$QEMU_IO -c 'write -P 2 0x7ffe0000 128k' "$TEST_IMG.itmd" | _filter_qemu_io -$QEMU_IO -c 'write -P 3 0x7fff0000 64k' "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 1 0x7ffd0000 192k" "$TEST_IMG.base" | _filter_qemu_io +$QEMU_IO -c "write -P 2 0x7ffe0000 128k" "$TEST_IMG.itmd" | _filter_qemu_io +$QEMU_IO -c "write -P 3 0x7fff0000 64k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IO -c "write -P 4 $(($len - 512)) 512" "$TEST_IMG" | _filter_qemu_io =20 if [ $i -lt 3 ]; then if [ $i =3D=3D 0 ]; then @@ -94,11 +96,13 @@ if [ $i -lt 3 ]; then =20 # Bottom should be unchanged $QEMU_IO -c 'read -P 1 0x7ffd0000 192k' "$TEST_IMG.base" | _filter_qem= u_io + $QEMU_IO -c "read -P 0 $((len - 512)) 512" "$TEST_IMG.base" | _filter_= qemu_io =20 # Intermediate should contain changes from top $QEMU_IO -c 'read -P 1 0x7ffd0000 64k' "$TEST_IMG.itmd" | _filter_qemu= _io $QEMU_IO -c 'read -P 2 0x7ffe0000 64k' "$TEST_IMG.itmd" | _filter_qemu= _io $QEMU_IO -c 'read -P 3 0x7fff0000 64k' "$TEST_IMG.itmd" | _filter_qemu= _io + $QEMU_IO -c "read -P 4 $((len - 512)) 512" "$TEST_IMG.itmd" | _filter_= qemu_io =20 # And in pass 0, the top image should be empty, whereas in both other = passes # it should be unchanged (which is both checked by qemu-img map) @@ -109,6 +113,7 @@ else $QEMU_IO -c 'read -P 1 0x7ffd0000 64k' "$TEST_IMG.base" | _filter_qemu= _io $QEMU_IO -c 'read -P 2 0x7ffe0000 64k' "$TEST_IMG.base" | _filter_qemu= _io $QEMU_IO -c 'read -P 3 0x7fff0000 64k' "$TEST_IMG.base" | _filter_qemu= _io + $QEMU_IO -c "read -P 4 $((len - 512)) 512" "$TEST_IMG.base" | _filter_= qemu_io =20 # Both top and intermediate should be unchanged fi diff --git a/tests/qemu-iotests/176.out b/tests/qemu-iotests/176.out index fc6365309e..6271fa7d6f 100644 --- a/tests/qemu-iotests/176.out +++ b/tests/qemu-iotests/176.out @@ -2,104 +2,130 @@ QA output created by 176 =20 =3D=3D=3D Test pass 0 =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202010112 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202010112 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202010112 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Image committed. read 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147287040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147352576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Offset Length File 0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +0x83400000 0x200 TEST_DIR/t.IMGFMT.itmd Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +0x83400000 0x200 TEST_DIR/t.IMGFMT.itmd =20 =3D=3D=3D Test pass 1 =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202010112 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202010112 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202010112 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Image committed. read 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147287040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147352576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Offset Length File 0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +0x83400000 0x200 TEST_DIR/t.IMGFMT.itmd Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd 0x7fff0000 0x10000 TEST_DIR/t.IMGFMT +0x83400000 0x200 TEST_DIR/t.IMGFMT =20 =3D=3D=3D Test pass 2 =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202010112 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202010112 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202010112 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Image committed. read 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147287040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147352576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Offset Length File 0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +0x83400000 0x200 TEST_DIR/t.IMGFMT.itmd Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd 0x7fff0000 0x10000 TEST_DIR/t.IMGFMT +0x83400000 0x200 TEST_DIR/t.IMGFMT =20 =3D=3D=3D Test pass 3 =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202009600 -Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202009600 backin= g_file=3DTEST_DIR/t.IMGFMT.base -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202009600 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D2202010112 +Formatting 'TEST_DIR/t.IMGFMT.itmd', fmt=3DIMGFMT size=3D2202010112 backin= g_file=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2202010112 backing_fil= e=3DTEST_DIR/t.IMGFMT.itmd wrote 196608/196608 bytes at offset 2147287040 192 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 131072/131072 bytes at offset 2147352576 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Image committed. read 65536/65536 bytes at offset 2147287040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -107,13 +133,18 @@ read 65536/65536 bytes at offset 2147352576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 2147418112 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 512/512 bytes at offset 2202009600 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Offset Length File 0x7ffd0000 0x30000 TEST_DIR/t.IMGFMT.base +0x83400000 0x200 TEST_DIR/t.IMGFMT.base Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x20000 TEST_DIR/t.IMGFMT.itmd +0x83400000 0x200 TEST_DIR/t.IMGFMT.base Offset Length File 0x7ffd0000 0x10000 TEST_DIR/t.IMGFMT.base 0x7ffe0000 0x10000 TEST_DIR/t.IMGFMT.itmd 0x7fff0000 0x10000 TEST_DIR/t.IMGFMT +0x83400000 0x200 TEST_DIR/t.IMGFMT *** done --=20 2.12.1 From nobody Thu May 2 18:04:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491234125067588.960521615248; Mon, 3 Apr 2017 08:42:05 -0700 (PDT) Received: from localhost ([::1]:59845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv47H-0003zf-Ko for importer@patchew.org; Mon, 03 Apr 2017 11:42:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv40N-0006by-Ej for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:35:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv40J-0007Z7-8m for qemu-devel@nongnu.org; Mon, 03 Apr 2017 11:34:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65067) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv40F-0007Wu-4R; Mon, 03 Apr 2017 11:34:47 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BFCC3C7A47; Mon, 3 Apr 2017 15:34:46 +0000 (UTC) Received: from localhost (ovpn-204-55.brq.redhat.com [10.40.204.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB38BA0A29; Mon, 3 Apr 2017 15:34:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2BFCC3C7A47 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2BFCC3C7A47 From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 3 Apr 2017 17:33:55 +0200 Message-Id: <20170403153355.19722-16-mreitz@redhat.com> In-Reply-To: <20170403153355.19722-1-mreitz@redhat.com> References: <20170403153355.19722-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 03 Apr 2017 15:34:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 15/15] block/parallels: Avoid overflows X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Change the types of variables in allocate_clusters() to int64_t so we do not have to worry about potential overflows. Add an assertion that our accesses to s->bat[] do not result in a buffer overflow and that the implicit conversion performed when invoking bat_entry_off() does not result in an integer overflow. Coverity-id: 1307776 Signed-off-by: Max Reitz Message-id: 20170331170512.10381-1-mreitz@redhat.com Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Max Reitz --- block/parallels.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 4173b3fb9d..90acf79687 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -192,8 +192,7 @@ static int64_t allocate_clusters(BlockDriverState *bs, = int64_t sector_num, int nb_sectors, int *pnum) { BDRVParallelsState *s =3D bs->opaque; - uint32_t idx, to_allocate, i; - int64_t pos, space; + int64_t pos, space, idx, to_allocate, i; =20 pos =3D block_status(s, sector_num, nb_sectors, pnum); if (pos > 0) { @@ -201,11 +200,19 @@ static int64_t allocate_clusters(BlockDriverState *bs= , int64_t sector_num, } =20 idx =3D sector_num / s->tracks; - if (idx >=3D s->bat_size) { - return -EINVAL; - } - to_allocate =3D DIV_ROUND_UP(sector_num + *pnum, s->tracks) - idx; + + /* This function is called only by parallels_co_writev(), which will n= ever + * pass a sector_num at or beyond the end of the image (because the bl= ock + * layer never passes such a sector_num to that function). Therefore, = idx + * is always below s->bat_size. + * block_status() will limit *pnum so that sector_num + *pnum will not + * exceed the image end. Therefore, idx + to_allocate cannot exceed + * s->bat_size. + * Note that s->bat_size is an unsigned int, therefore idx + to_alloca= te + * will always fit into a uint32_t. */ + assert(idx < s->bat_size && idx + to_allocate <=3D s->bat_size); + space =3D to_allocate * s->tracks; if (s->data_end + space > bdrv_getlength(bs->file->bs) >> BDRV_SECTOR_= BITS) { int ret; --=20 2.12.1