From nobody Fri May 3 03:48:30 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 1490621587344745.8846436044273; Mon, 27 Mar 2017 06:33:07 -0700 (PDT) Received: from localhost ([::1]:46834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUle-0007B8-5g for importer@patchew.org; Mon, 27 Mar 2017 09:33:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfU-00026p-TP for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfO-0006Nr-Fd for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfO-0006ND-5W for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:38 -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 3C04F3F725 for ; Mon, 27 Mar 2017 13:26:37 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F327318845; Mon, 27 Mar 2017 13:26:36 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 714801138648; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C04F3F725 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=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3C04F3F725 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:25 +0200 Message-Id: <1490621195-2228-2-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@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.30]); Mon, 27 Mar 2017 13:26: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] [PATCH RFC v3 for-2.9 01/11] rbd: Reject -blockdev server.*.{numeric, to, ipv4, ipv6} X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We use InetSocketAddress in the QAPI schema. However, the code doesn't use inet_connect_saddr(), but formats "host" and "port" into a configuration string for rados_conf_set(). Thus, members "numeric", "to", "ipv4" and "ipv6" are silently ignored. Not nice. Example: -blockdev rbd,node-name=3Dnn,pool=3Dp,image=3Di,server.0.host=3Dh0,serv= er.0.port=3D12345,server.0.ipv4=3Doff Factor a suitable InetSocketAddressBase out of InetSocketAddress, and use that. "numeric", "to", "ipv4" and "ipv6" are now rejected. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: Max Reitz --- qapi-schema.json | 21 ++++++++++++++------- qapi/block-core.json | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 68a4327..b921994 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4051,19 +4051,27 @@ 'data': [ 'all', 'rx', 'tx' ] } =20 ## +# @InetSocketAddressBase: +# +# @host: host part of the address +# @port: port part of the address +## +{ 'struct': 'InetSocketAddressBase', + 'data': { + 'host': 'str', + 'port': 'str' } } + +## # @InetSocketAddress: # # Captures a socket address or address range in the Internet namespace. # -# @host: host part of the address -# -# @port: port part of the address, or lowest port if @to is present -# # @numeric: true if the host/port are guaranteed to be numeric, # false if name resolution should be attempted. Defaults to fals= e. # (Since 2.9) # -# @to: highest port to try +# @to: If present, this is range of possible addresses, with port +# between @port and @to. # # @ipv4: whether to accept IPv4 addresses, default try both IPv4 and IPv6 # @@ -4072,9 +4080,8 @@ # Since: 1.3 ## { 'struct': 'InetSocketAddress', + 'base': 'InetSocketAddressBase', 'data': { - 'host': 'str', - 'port': 'str', '*numeric': 'bool', '*to': 'uint16', '*ipv4': 'bool', diff --git a/qapi/block-core.json b/qapi/block-core.json index 0f132fc..5d2efe4 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2652,7 +2652,7 @@ '*conf': 'str', '*snapshot': 'str', '*user': 'str', - '*server': ['InetSocketAddress'], + '*server': ['InetSocketAddressBase'], '*auth-supported': ['RbdAuthMethod'], '*password-secret': 'str' } } =20 --=20 2.7.4 From nobody Fri May 3 03:48:30 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 1490621452089600.2812219336524; Mon, 27 Mar 2017 06:30:52 -0700 (PDT) Received: from localhost ([::1]:46825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUjS-0005S7-R3 for importer@patchew.org; Mon, 27 Mar 2017 09:30:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfU-00026n-Ih for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfO-0006Nl-DG for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51362) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfO-0006NK-6M for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:38 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49457F6227 for ; Mon, 27 Mar 2017 13:26:37 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02796189E6; Mon, 27 Mar 2017 13:26:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 74555113864C; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 49457F6227 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 49457F6227 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:26 +0200 Message-Id: <1490621195-2228-3-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 27 Mar 2017 13:26: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] [PATCH RFC v3 for-2.9 02/11] rbd: Fix to cleanly reject -drive without pool or 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: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com 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" qemu_rbd_open() neglects to check pool and image are present. Reproducer: $ qemu-system-x86_64 -nodefaults -drive if=3Dnone,driver=3Drbd,pool=3Dp Segmentation fault (core dumped) $ qemu-system-x86_64 -nodefaults -drive if=3Dnone,driver=3Drbd,image=3Di qemu-system-x86_64: -drive if=3Dnone,driver=3Drbd,image=3Di: error open= ing pool (null) Doesn't affect -drive with file=3D..., because qemu_rbd_parse_filename() always sets both pool and image. Doesn't affect -blockdev, because pool and image are mandatory in the QAPI schema. Fix by adding the missing checks. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: Max Reitz --- block/rbd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index ee13f3d..5ba2a87 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -711,6 +711,12 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *= options, int flags, name =3D qemu_opt_get(opts, "image"); keypairs =3D qemu_opt_get(opts, "keyvalue-pairs"); =20 + if (!pool || !name) { + error_setg(errp, "Parameters 'pool' and 'image' are required"); + r =3D -EINVAL; + goto failed_opts; + } + r =3D rados_create(&s->cluster, clientname); if (r < 0) { error_setg_errno(errp, -r, "error initializing"); @@ -718,9 +724,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *o= ptions, int flags, } =20 s->snap =3D g_strdup(snap); - if (name) { - pstrcpy(s->name, RBD_MAX_IMAGE_NAME_SIZE, name); - } + pstrcpy(s->name, RBD_MAX_IMAGE_NAME_SIZE, name); =20 /* try default location when conf=3DNULL, but ignore failure */ r =3D rados_conf_read_file(s->cluster, conf); --=20 2.7.4 From nobody Fri May 3 03:48:30 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 1490621450603987.2219912892264; Mon, 27 Mar 2017 06:30:50 -0700 (PDT) Received: from localhost ([::1]:46824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUjR-0005Qb-Dp for importer@patchew.org; Mon, 27 Mar 2017 09:30:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfV-00026q-Eb for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfP-0006O7-6F for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34688) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfO-0006NQ-SC for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 724929D1E1 for ; Mon, 27 Mar 2017 13:26:37 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02D4480696; Mon, 27 Mar 2017 13:26:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 772F61138651; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 724929D1E1 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=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 724929D1E1 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:27 +0200 Message-Id: <1490621195-2228-4-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 27 Mar 2017 13:26: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] [PATCH RFC v3 for-2.9 03/11] rbd: Don't limit length of parameter values X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We laboriously enforce parameter values are between one and some arbitrary limit in length. Only RBD_MAX_IMAGE_NAME_SIZE comes from librbd.h, and I'm not sure it applies. Where the other limits come from is unclear. Drop the length checking. The limits librbd actually imposes must be checked by librbd anyway. There's one minor complication: BDRVRBDState member name is a fixed-size array. Depends on the length limit. Make it a pointer to a dynamically allocated string. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: Max Reitz --- block/rbd.c | 91 ++++++++++-----------------------------------------------= ---- 1 file changed, 14 insertions(+), 77 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 5ba2a87..0fea348 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -56,11 +56,6 @@ =20 #define OBJ_MAX_SIZE (1UL << OBJ_DEFAULT_OBJ_ORDER) =20 -#define RBD_MAX_CONF_NAME_SIZE 128 -#define RBD_MAX_CONF_VAL_SIZE 512 -#define RBD_MAX_CONF_SIZE 1024 -#define RBD_MAX_POOL_NAME_SIZE 128 -#define RBD_MAX_SNAP_NAME_SIZE 128 #define RBD_MAX_SNAPS 100 =20 /* The LIBRBD_SUPPORTS_IOVEC is defined in librbd.h */ @@ -99,16 +94,12 @@ typedef struct BDRVRBDState { rados_t cluster; rados_ioctx_t io_ctx; rbd_image_t image; - char name[RBD_MAX_IMAGE_NAME_SIZE]; + char *name; char *snap; } BDRVRBDState; =20 -static char *qemu_rbd_next_tok(int max_len, - char *src, char delim, - const char *name, - char **p, Error **errp) +static char *qemu_rbd_next_tok(char *src, char delim, char **p) { - int l; char *end; =20 *p =3D NULL; @@ -127,15 +118,6 @@ static char *qemu_rbd_next_tok(int max_len, *end =3D '\0'; } } - l =3D strlen(src); - if (l >=3D max_len) { - error_setg(errp, "%s too long", name); - return NULL; - } else if (l =3D=3D 0) { - error_setg(errp, "%s too short", name); - return NULL; - } - return src; } =20 @@ -159,7 +141,6 @@ static void qemu_rbd_parse_filename(const char *filenam= e, QDict *options, char *p, *buf, *keypairs; char *found_str; size_t max_keypair_size; - Error *local_err =3D NULL; =20 if (!strstart(filename, "rbd:", &start)) { error_setg(errp, "File name must start with 'rbd:'"); @@ -171,11 +152,7 @@ static void qemu_rbd_parse_filename(const char *filena= me, QDict *options, keypairs =3D g_malloc0(max_keypair_size); p =3D buf; =20 - found_str =3D qemu_rbd_next_tok(RBD_MAX_POOL_NAME_SIZE, p, - '/', "pool name", &p, &local_err); - if (local_err) { - goto done; - } + found_str =3D qemu_rbd_next_tok(p, '/', &p); if (!p) { error_setg(errp, "Pool name is required"); goto done; @@ -184,27 +161,15 @@ static void qemu_rbd_parse_filename(const char *filen= ame, QDict *options, qdict_put(options, "pool", qstring_from_str(found_str)); =20 if (strchr(p, '@')) { - found_str =3D qemu_rbd_next_tok(RBD_MAX_IMAGE_NAME_SIZE, p, - '@', "object name", &p, &local_err); - if (local_err) { - goto done; - } + found_str =3D qemu_rbd_next_tok(p, '@', &p); qemu_rbd_unescape(found_str); qdict_put(options, "image", qstring_from_str(found_str)); =20 - found_str =3D qemu_rbd_next_tok(RBD_MAX_SNAP_NAME_SIZE, p, - ':', "snap name", &p, &local_err); - if (local_err) { - goto done; - } + found_str =3D qemu_rbd_next_tok(p, ':', &p); qemu_rbd_unescape(found_str); qdict_put(options, "snapshot", qstring_from_str(found_str)); } else { - found_str =3D qemu_rbd_next_tok(RBD_MAX_IMAGE_NAME_SIZE, p, - ':', "object name", &p, &local_err); - if (local_err) { - goto done; - } + found_str =3D qemu_rbd_next_tok(p, ':', &p); qemu_rbd_unescape(found_str); qdict_put(options, "image", qstring_from_str(found_str)); } @@ -212,11 +177,7 @@ static void qemu_rbd_parse_filename(const char *filena= me, QDict *options, goto done; } =20 - found_str =3D qemu_rbd_next_tok(RBD_MAX_CONF_NAME_SIZE, p, - '\0', "configuration", &p, &local_err); - if (local_err) { - goto done; - } + found_str =3D qemu_rbd_next_tok(p, '\0', &p); =20 p =3D found_str; =20 @@ -224,12 +185,7 @@ static void qemu_rbd_parse_filename(const char *filena= me, QDict *options, * 'id' and 'conf' a bit special. Key/value pairs may be in any order= . */ while (p) { char *name, *value; - name =3D qemu_rbd_next_tok(RBD_MAX_CONF_NAME_SIZE, p, - '=3D', "conf option name", &p, &local_err= ); - if (local_err) { - break; - } - + name =3D qemu_rbd_next_tok(p, '=3D', &p); if (!p) { error_setg(errp, "conf option %s has no value", name); break; @@ -237,11 +193,7 @@ static void qemu_rbd_parse_filename(const char *filena= me, QDict *options, =20 qemu_rbd_unescape(name); =20 - value =3D qemu_rbd_next_tok(RBD_MAX_CONF_VAL_SIZE, p, - ':', "conf option value", &p, &local_err= ); - if (local_err) { - break; - } + value =3D qemu_rbd_next_tok(p, ':', &p); qemu_rbd_unescape(value); =20 if (!strcmp(name, "conf")) { @@ -274,9 +226,6 @@ static void qemu_rbd_parse_filename(const char *filenam= e, QDict *options, =20 =20 done: - if (local_err) { - error_propagate(errp, local_err); - } g_free(buf); g_free(keypairs); return; @@ -308,30 +257,20 @@ static int qemu_rbd_set_keypairs(rados_t cluster, con= st char *keypairs, char *p, *buf; char *name; char *value; - Error *local_err =3D NULL; int ret =3D 0; =20 buf =3D g_strdup(keypairs); p =3D buf; =20 while (p) { - name =3D qemu_rbd_next_tok(RBD_MAX_CONF_NAME_SIZE, p, - '=3D', "conf option name", &p, &local_err= ); - if (local_err) { - break; - } - + name =3D qemu_rbd_next_tok(p, '=3D', &p); if (!p) { error_setg(errp, "conf option %s has no value", name); ret =3D -EINVAL; break; } =20 - value =3D qemu_rbd_next_tok(RBD_MAX_CONF_VAL_SIZE, p, - ':', "conf option value", &p, &local_err= ); - if (local_err) { - break; - } + value =3D qemu_rbd_next_tok(p, ':', &p); =20 ret =3D rados_conf_set(cluster, name, value); if (ret < 0) { @@ -341,10 +280,6 @@ static int qemu_rbd_set_keypairs(rados_t cluster, cons= t char *keypairs, } } =20 - if (local_err) { - error_propagate(errp, local_err); - ret =3D -EINVAL; - } g_free(buf); return ret; } @@ -724,7 +659,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *o= ptions, int flags, } =20 s->snap =3D g_strdup(snap); - pstrcpy(s->name, RBD_MAX_IMAGE_NAME_SIZE, name); + s->name =3D g_strdup(name); =20 /* try default location when conf=3DNULL, but ignore failure */ r =3D rados_conf_read_file(s->cluster, conf); @@ -798,6 +733,7 @@ failed_open: failed_shutdown: rados_shutdown(s->cluster); g_free(s->snap); + g_free(s->name); failed_opts: qemu_opts_del(opts); g_free(mon_host); @@ -812,6 +748,7 @@ static void qemu_rbd_close(BlockDriverState *bs) rbd_close(s->image); rados_ioctx_destroy(s->io_ctx); g_free(s->snap); + g_free(s->name); rados_shutdown(s->cluster); } =20 --=20 2.7.4 From nobody Fri May 3 03:48:30 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 1490621452160866.0832918913253; Mon, 27 Mar 2017 06:30:52 -0700 (PDT) Received: from localhost ([::1]:46826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUjS-0005SL-VR for importer@patchew.org; Mon, 27 Mar 2017 09:30:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfU-00026o-Rh for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfO-0006Nf-Cd for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59400) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfO-0006NH-5k for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:38 -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 413178E682 for ; Mon, 27 Mar 2017 13:26:37 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07D0D84FEB; Mon, 27 Mar 2017 13:26:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7A8FD11386CB; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 413178E682 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=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 413178E682 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:28 +0200 Message-Id: <1490621195-2228-5-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@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.25]); Mon, 27 Mar 2017 13:26: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] [PATCH RFC v3 for-2.9 04/11] rbd: Clean up after the previous commit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This code in qemu_rbd_parse_filename() found_str =3D qemu_rbd_next_tok(p, '\0', &p); p =3D found_str; has no effect. Drop it, and simplify qemu_rbd_next_tok(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: Max Reitz --- block/rbd.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 0fea348..182a5a3 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -104,19 +104,17 @@ static char *qemu_rbd_next_tok(char *src, char delim,= char **p) =20 *p =3D NULL; =20 - if (delim !=3D '\0') { - for (end =3D src; *end; ++end) { - if (*end =3D=3D delim) { - break; - } - if (*end =3D=3D '\\' && end[1] !=3D '\0') { - end++; - } - } + for (end =3D src; *end; ++end) { if (*end =3D=3D delim) { - *p =3D end + 1; - *end =3D '\0'; + break; } + if (*end =3D=3D '\\' && end[1] !=3D '\0') { + end++; + } + } + if (*end =3D=3D delim) { + *p =3D end + 1; + *end =3D '\0'; } return src; } @@ -177,10 +175,6 @@ static void qemu_rbd_parse_filename(const char *filena= me, QDict *options, goto done; } =20 - found_str =3D qemu_rbd_next_tok(p, '\0', &p); - - p =3D found_str; - /* The following are essentially all key/value pairs, and we treat * 'id' and 'conf' a bit special. Key/value pairs may be in any order= . */ while (p) { --=20 2.7.4 From nobody Fri May 3 03:48:30 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 1490621700252777.728872497849; Mon, 27 Mar 2017 06:35:00 -0700 (PDT) Received: from localhost ([::1]:46843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUnT-00005Q-1M for importer@patchew.org; Mon, 27 Mar 2017 09:34:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfW-00026t-8y for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfQ-0006Ou-6K for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49440) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfP-0006O1-VC for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0218D6561 for ; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8723E18BBC; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7F0D711385E2; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C0218D6561 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=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C0218D6561 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:29 +0200 Message-Id: <1490621195-2228-6-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 27 Mar 2017 13:26:38 +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] [PATCH RFC v3 for-2.9 05/11] rbd: Don't accept -drive driver=rbd, keyvalue-pairs=... X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com 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" The way we communicate extra key-value pairs from qemu_rbd_parse_filename() to qemu_rbd_open() exposes option parameter "keyvalue-pairs" on the command line. It's not wanted there. Hack: rename the parameter to "=3Dkeyvalue-pairs" to make it inaccessible. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: Max Reitz --- block/rbd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 182a5a3..2632533 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -215,7 +215,7 @@ static void qemu_rbd_parse_filename(const char *filenam= e, QDict *options, } =20 if (keypairs[0]) { - qdict_put(options, "keyvalue-pairs", qstring_from_str(keypairs)); + qdict_put(options, "=3Dkeyvalue-pairs", qstring_from_str(keypairs)= ); } =20 =20 @@ -330,7 +330,11 @@ static QemuOptsList runtime_opts =3D { .help =3D "Rados id name", }, { - .name =3D "keyvalue-pairs", + /* + * HACK: name starts with '=3D' so that qemu_opts_parse() + * can't set it + */ + .name =3D "=3Dkeyvalue-pairs", .type =3D QEMU_OPT_STRING, .help =3D "Legacy rados key/value option parameters", }, @@ -405,7 +409,7 @@ static int qemu_rbd_create(const char *filename, QemuOp= ts *opts, Error **errp) conf =3D qemu_opt_get(rbd_opts, "conf"); clientname =3D qemu_opt_get(rbd_opts, "user"); name =3D qemu_opt_get(rbd_opts, "image"); - keypairs =3D qemu_opt_get(rbd_opts, "keyvalue-pairs"); + keypairs =3D qemu_opt_get(rbd_opts, "=3Dkeyvalue-pairs"); =20 ret =3D rados_create(&cluster, clientname); if (ret < 0) { @@ -638,7 +642,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *o= ptions, int flags, snap =3D qemu_opt_get(opts, "snapshot"); clientname =3D qemu_opt_get(opts, "user"); name =3D qemu_opt_get(opts, "image"); - keypairs =3D qemu_opt_get(opts, "keyvalue-pairs"); + keypairs =3D qemu_opt_get(opts, "=3Dkeyvalue-pairs"); =20 if (!pool || !name) { error_setg(errp, "Parameters 'pool' and 'image' are required"); --=20 2.7.4 From nobody Fri May 3 03:48:30 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 1490621307420580.316414523007; Mon, 27 Mar 2017 06:28:27 -0700 (PDT) Received: from localhost ([::1]:46810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUh7-0003NN-RS for importer@patchew.org; Mon, 27 Mar 2017 09:28:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfW-00026v-Py for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfQ-0006PP-H7 for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38984) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfQ-0006OH-4h for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:40 -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 E88C9C0624C3 for ; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8734B17100; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8256F11385EF; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E88C9C0624C3 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=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E88C9C0624C3 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:30 +0200 Message-Id: <1490621195-2228-7-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@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.32]); Mon, 27 Mar 2017 13:26:39 +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] [PATCH RFC v3 for-2.9 06/11] rbd: Clean up runtime_opts, fix -drive to reject filename X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com 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" runtime_opts is used for three different purposes: * qemu_rbd_open() uses it to accept options it recognizes, such as "pool" and "image". Other .bdrv_open() methods do it similarly. * qemu_rbd_open() accepts additional list-valued options auth-supported and server, with the help of qemu_rbd_array_opts(). The list elements are again dictionaries. qemu_rbd_array_opts() uses runtime_opts to accept their members. Thus, runtime_opts contains recognized sub-sub-options "auth", "host", "port" in addition to recognized options. No other block driver does that. * qemu_rbd_create() uses it to convert the QDict produced by qemu_rbd_parse_filename() to QemuOpts. No other block driver does that. The keys produced by qemu_rbd_parse_filename() are "pool", "image", "snapshot", "conf", "user" and "keyvalue-pairs". qemu_rbd_open() accepts these, so no additional ones here. This is a confusing mess. Dates back to commit 0f9d252. First step to clean it up is documenting runtime_opts.desc[]: * Reorder entries to match the QAPI schema, like we do in other block drivers. * Document why the schema's "server" and "auth-supported" aren't in .desc[]. * Document why "keyvalue-pairs", "host", "port" and "auth" are in .desc[], but not the schema. * Delete "filename", because none of the three users actually uses it. This fixes -drive to reject parameter filename instead of silently ignoring it. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: Max Reitz --- block/rbd.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 2632533..b2afe07 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -294,21 +294,6 @@ static QemuOptsList runtime_opts =3D { .head =3D QTAILQ_HEAD_INITIALIZER(runtime_opts.head), .desc =3D { { - .name =3D "filename", - .type =3D QEMU_OPT_STRING, - .help =3D "Specification of the rbd image", - }, - { - .name =3D "password-secret", - .type =3D QEMU_OPT_STRING, - .help =3D "ID of secret providing the password", - }, - { - .name =3D "conf", - .type =3D QEMU_OPT_STRING, - .help =3D "Rados config file location", - }, - { .name =3D "pool", .type =3D QEMU_OPT_STRING, .help =3D "Rados pool name", @@ -319,6 +304,11 @@ static QemuOptsList runtime_opts =3D { .help =3D "Image name in the pool", }, { + .name =3D "conf", + .type =3D QEMU_OPT_STRING, + .help =3D "Rados config file location", + }, + { .name =3D "snapshot", .type =3D QEMU_OPT_STRING, .help =3D "Ceph snapshot name", @@ -329,6 +319,19 @@ static QemuOptsList runtime_opts =3D { .type =3D QEMU_OPT_STRING, .help =3D "Rados id name", }, + /* + * server.* and auth-supported.* extracted manually, see + * qemu_rbd_array_opts() + */ + { + .name =3D "password-secret", + .type =3D QEMU_OPT_STRING, + .help =3D "ID of secret providing the password", + }, + + /* + * Keys for qemu_rbd_parse_filename(), not in the QAPI schema + */ { /* * HACK: name starts with '=3D' so that qemu_opts_parse() @@ -338,6 +341,13 @@ static QemuOptsList runtime_opts =3D { .type =3D QEMU_OPT_STRING, .help =3D "Legacy rados key/value option parameters", }, + + /* + * The remainder aren't option keys, but option sub-sub-keys, + * so that qemu_rbd_array_opts() can abuse runtime_opts for + * its own purposes + * TODO clean this up + */ { .name =3D "host", .type =3D QEMU_OPT_STRING, --=20 2.7.4 From nobody Fri May 3 03:48:30 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 1490621800053147.16294930896368; Mon, 27 Mar 2017 06:36:40 -0700 (PDT) Received: from localhost ([::1]:46858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUp4-0001DV-S2 for importer@patchew.org; Mon, 27 Mar 2017 09:36:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfW-00026s-7b for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfQ-0006Op-5y for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59452) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfP-0006O2-VJ for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:40 -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 C15804C52F for ; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8833618845; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8532611385FD; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C15804C52F 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=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C15804C52F From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:31 +0200 Message-Id: <1490621195-2228-8-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@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.25]); Mon, 27 Mar 2017 13:26:38 +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] [PATCH RFC v3 for-2.9 07/11] rbd: Clean up qemu_rbd_create()'s detour through QemuOpts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com 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" The conversion from QDict to QemuOpts is pointless. Simply get the stuff straight from the QDict. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf --- block/rbd.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index b2afe07..cf0bab0 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -376,7 +376,6 @@ static int qemu_rbd_create(const char *filename, QemuOp= ts *opts, Error **errp) rados_t cluster; rados_ioctx_t io_ctx; QDict *options =3D NULL; - QemuOpts *rbd_opts =3D NULL; int ret =3D 0; =20 secretid =3D qemu_opt_get(opts, "password-secret"); @@ -407,19 +406,11 @@ static int qemu_rbd_create(const char *filename, Qemu= Opts *opts, Error **errp) goto exit; } =20 - rbd_opts =3D qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(rbd_opts, options, &local_err); - if (local_err) { - error_propagate(errp, local_err); - ret =3D -EINVAL; - goto exit; - } - - pool =3D qemu_opt_get(rbd_opts, "pool"); - conf =3D qemu_opt_get(rbd_opts, "conf"); - clientname =3D qemu_opt_get(rbd_opts, "user"); - name =3D qemu_opt_get(rbd_opts, "image"); - keypairs =3D qemu_opt_get(rbd_opts, "=3Dkeyvalue-pairs"); + pool =3D qdict_get_str(options, "pool"); + conf =3D qdict_get_str(options, "conf"); + clientname =3D qdict_get_str(options, "user"); + name =3D qdict_get_str(options, "image"); + keypairs =3D qdict_get_str(options, "=3Dkeyvalue-pairs"); =20 ret =3D rados_create(&cluster, clientname); if (ret < 0) { @@ -470,7 +461,6 @@ shutdown: =20 exit: QDECREF(options); - qemu_opts_del(rbd_opts); return ret; } =20 --=20 2.7.4 From nobody Fri May 3 03:48:30 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 149062158640190.62410067365829; Mon, 27 Mar 2017 06:33:06 -0700 (PDT) Received: from localhost ([::1]:46833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUld-0007AX-1o for importer@patchew.org; Mon, 27 Mar 2017 09:33:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfW-00026u-PD for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfQ-0006Pf-Ls for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49456) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfQ-0006OU-9X for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C942D7127 for ; Mon, 27 Mar 2017 13:26:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 890AB80696; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 883F61138606; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1C942D7127 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=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1C942D7127 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:32 +0200 Message-Id: <1490621195-2228-9-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 27 Mar 2017 13:26:39 +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] [PATCH RFC v3 for-2.9 08/11] rbd: Revert -blockdev and -drive parameter auth-supported X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This reverts half of commit 0a55679. We're having second thoughts on the QAPI schema (and thus the external interface), and haven't reached consensus, yet. Issues include: * The implementation uses deprecated rados_conf_set() key "auth_supported". No biggie. * The implementation makes -drive silently ignore invalid parameters "auth" and "auth-supported.*.X" where X isn't "auth". Fixable (in fact I'm going to fix similar bugs around parameter server), so again no biggie. * BlockdevOptionsRbd member @password-secret applies only to authentication method cephx. Should it be a variant member of RbdAuthMethod? * BlockdevOptionsRbd member @user could apply to both methods cephx and none, but I'm not sure it's actually used with none. If it isn't, should it be a variant member of RbdAuthMethod? * The client offers a *set* of authentication methods, not a list. Should the methods be optional members of BlockdevOptionsRbd instead of members of list @auth-supported? The latter begs the question what multiple entries for the same method mean. Trivial question now that RbdAuthMethod contains nothing but @type, but less so when RbdAuthMethod acquires other members, such the ones discussed above. * How BlockdevOptionsRbd member @auth-supported interacts with settings from a configuration file specified with @conf is undocumented. I suspect it's untested, too. Let's avoid painting ourselves into a corner now, and revert the feature for 2.9. Note that users can still configure authentication methods with a configuration file. They probably do that anyway if they use Ceph outside QEMU as well. qemu_rbd_array_opts()'s parameter @type now must be RBD_MON_HOST, which is silly. This will be cleaned up shortly. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: Max Reitz --- block/rbd.c | 31 +++---------------------------- qapi/block-core.json | 24 ------------------------ 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index cf0bab0..103ce44 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -320,8 +320,7 @@ static QemuOptsList runtime_opts =3D { .help =3D "Rados id name", }, /* - * server.* and auth-supported.* extracted manually, see - * qemu_rbd_array_opts() + * server.* extracted manually, see qemu_rbd_array_opts() */ { .name =3D "password-secret", @@ -356,11 +355,6 @@ static QemuOptsList runtime_opts =3D { .name =3D "port", .type =3D QEMU_OPT_STRING, }, - { - .name =3D "auth", - .type =3D QEMU_OPT_STRING, - .help =3D "Supported authentication method, either cephx or no= ne", - }, { /* end of list */ } }, }; @@ -512,7 +506,6 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb) } =20 #define RBD_MON_HOST 0 -#define RBD_AUTH_SUPPORTED 1 =20 static char *qemu_rbd_array_opts(QDict *options, const char *prefix, int t= ype, Error **errp) @@ -527,7 +520,7 @@ static char *qemu_rbd_array_opts(QDict *options, const = char *prefix, int type, Error *local_err =3D NULL; int i; =20 - assert(type =3D=3D RBD_MON_HOST || type =3D=3D RBD_AUTH_SUPPORTED); + assert(type =3D=3D RBD_MON_HOST); =20 num_entries =3D qdict_array_entries(options, prefix); =20 @@ -573,10 +566,9 @@ static char *qemu_rbd_array_opts(QDict *options, const= char *prefix, int type, value =3D strbuf; } } else { - value =3D qemu_opt_get(opts, "auth"); + abort(); } =20 - /* each iteration in the for loop will build upon the string, and = if * rados_str is NULL then it is our first pass */ if (rados_str) { @@ -608,7 +600,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *o= ptions, int flags, QemuOpts *opts; Error *local_err =3D NULL; char *mon_host =3D NULL; - char *auth_supported =3D NULL; int r; =20 opts =3D qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); @@ -619,14 +610,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *= options, int flags, return -EINVAL; } =20 - auth_supported =3D qemu_rbd_array_opts(options, "auth-supported.", - RBD_AUTH_SUPPORTED, &local_err); - if (local_err) { - error_propagate(errp, local_err); - r =3D -EINVAL; - goto failed_opts; - } - mon_host =3D qemu_rbd_array_opts(options, "server.", RBD_MON_HOST, &local_err); if (local_err) { @@ -678,13 +661,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *= options, int flags, } } =20 - if (auth_supported) { - r =3D rados_conf_set(s->cluster, "auth_supported", auth_supported); - if (r < 0) { - goto failed_shutdown; - } - } - if (qemu_rbd_set_auth(s->cluster, secretid, errp) < 0) { r =3D -EIO; goto failed_shutdown; @@ -735,7 +711,6 @@ failed_shutdown: failed_opts: qemu_opts_del(opts); g_free(mon_host); - g_free(auth_supported); return r; } =20 diff --git a/qapi/block-core.json b/qapi/block-core.json index 5d2efe4..6a7ca0b 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2601,27 +2601,6 @@ =20 =20 ## -# @RbdAuthSupport: -# -# An enumeration of RBD auth support -# -# Since: 2.9 -## -{ 'enum': 'RbdAuthSupport', - 'data': [ 'cephx', 'none' ] } - - -## -# @RbdAuthMethod: -# -# An enumeration of rados auth_supported types -# -# Since: 2.9 -## -{ 'struct': 'RbdAuthMethod', - 'data': { 'auth': 'RbdAuthSupport' } } - -## # @BlockdevOptionsRbd: # # @pool: Ceph pool name. @@ -2639,8 +2618,6 @@ # @server: Monitor host address and port. This maps # to the "mon_host" Ceph option. # -# @auth-supported: Authentication supported. -# # @password-secret: The ID of a QCryptoSecret object providing # the password for the login. # @@ -2653,7 +2630,6 @@ '*snapshot': 'str', '*user': 'str', '*server': ['InetSocketAddressBase'], - '*auth-supported': ['RbdAuthMethod'], '*password-secret': 'str' } } =20 ## --=20 2.7.4 From nobody Fri May 3 03:48:30 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 1490621448897720.3723684218417; Mon, 27 Mar 2017 06:30:48 -0700 (PDT) Received: from localhost ([::1]:46823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUjP-0005QL-H2 for importer@patchew.org; Mon, 27 Mar 2017 09:30:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfX-00026y-IO for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfR-0006QF-I4 for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38666) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfR-0006PK-AW for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26: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 17D408DF02 for ; Mon, 27 Mar 2017 13:26:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BA408FAEA; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8B45A1138609; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 17D408DF02 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=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 17D408DF02 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:33 +0200 Message-Id: <1490621195-2228-10-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@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, 27 Mar 2017 13:26: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] [PATCH RFC v3 for-2.9 09/11] rbd: Revert -blockdev parameter password-secret X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This reverts a part of commit 8a47e8e. We're having second thoughts on the QAPI schema (and thus the external interface), and haven't reached consensus, yet. Issues include: * BlockdevOptionsRbd member @password-secret isn't actually a password, it's a key generated by Ceph. * We're not sure where member @password-secret belongs (see the previous commit). * How @password-secret interacts with settings from a configuration file specified with @conf is undocumented. I suspect it's untested, too. Let's avoid painting ourselves into a corner now, and revert the feature for 2.9. Note that users can still configure an authentication key with a configuration file. They probably do that anyway if they use Ceph outside QEMU as well. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: Max Reitz --- qapi/block-core.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 6a7ca0b..2e60ab5 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2618,9 +2618,6 @@ # @server: Monitor host address and port. This maps # to the "mon_host" Ceph option. # -# @password-secret: The ID of a QCryptoSecret object providing -# the password for the login. -# # Since: 2.9 ## { 'struct': 'BlockdevOptionsRbd', --=20 2.7.4 From nobody Fri May 3 03:48:30 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 1490621309406457.4011878828446; Mon, 27 Mar 2017 06:28:29 -0700 (PDT) Received: from localhost ([::1]:46812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUhA-0003OL-1T for importer@patchew.org; Mon, 27 Mar 2017 09:28:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfW-00026x-WB for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfQ-0006Pk-LU for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39030) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfQ-0006OW-9y for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C6D8C0641EA for ; Mon, 27 Mar 2017 13:26:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 903A48866A; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8E481113860E; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1C6D8C0641EA 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=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1C6D8C0641EA From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:34 +0200 Message-Id: <1490621195-2228-11-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 27 Mar 2017 13:26:39 +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] [PATCH RFC v3 for-2.9 10/11] Revert "rbd: add support for getting password from QCryptoSecret object" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This reverts commit 60390a2192e7b38aee18db6ce7fb740498709737. The commit's rationale Currently RBD passwords must be provided on the command line via $QEMU -drive file=3Drbd:pool/image:id=3Dmyname:\ key=3DQVFDVm41aE82SHpGQWhBQXEwTkN2OGp0SmNJY0UrSE9CbE1RMU= E=3D:\ auth_supported=3Dcephx This is insecure because the key is visible in the OS process listing. is invalid. You can easily avoid passing keys on the command line by using "keyfile" instead of "key". In fact, the Ceph documentation calls use of key "not recommended". But the most common way to provide keys is a keyring. The default keyrings should be just fine for most users. When they aren't, you can configure your own keyrings with "keyring" or override the key with "keyfile". The commit adds parameter password-secret to -drive. Support for it was included in -blockdev, but reverted in the previous commit due to concerns about the QMP interface. Revert it from -drive, too. Cc: Daniel P. Berrange Signed-off-by: Markus Armbruster --- block/rbd.c | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 103ce44..5a58d3e 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -16,7 +16,6 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "block/block_int.h" -#include "crypto/secret.h" #include "qemu/cutils.h" #include "qapi/qmp/qstring.h" =20 @@ -225,26 +224,6 @@ done: return; } =20 - -static int qemu_rbd_set_auth(rados_t cluster, const char *secretid, - Error **errp) -{ - if (secretid =3D=3D 0) { - return 0; - } - - gchar *secret =3D qcrypto_secret_lookup_as_base64(secretid, - errp); - if (!secret) { - return -1; - } - - rados_conf_set(cluster, "key", secret); - g_free(secret); - - return 0; -} - static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs, Error **errp) { @@ -322,11 +301,6 @@ static QemuOptsList runtime_opts =3D { /* * server.* extracted manually, see qemu_rbd_array_opts() */ - { - .name =3D "password-secret", - .type =3D QEMU_OPT_STRING, - .help =3D "ID of secret providing the password", - }, =20 /* * Keys for qemu_rbd_parse_filename(), not in the QAPI schema @@ -366,14 +340,11 @@ static int qemu_rbd_create(const char *filename, Qemu= Opts *opts, Error **errp) int64_t objsize; int obj_order =3D 0; const char *pool, *name, *conf, *clientname, *keypairs; - const char *secretid; rados_t cluster; rados_ioctx_t io_ctx; QDict *options =3D NULL; int ret =3D 0; =20 - secretid =3D qemu_opt_get(opts, "password-secret"); - /* Read out options */ bytes =3D ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); @@ -426,11 +397,6 @@ static int qemu_rbd_create(const char *filename, QemuO= pts *opts, Error **errp) goto shutdown; } =20 - if (qemu_rbd_set_auth(cluster, secretid, errp) < 0) { - ret =3D -EIO; - goto shutdown; - } - ret =3D rados_connect(cluster); if (ret < 0) { error_setg_errno(errp, -ret, "error connecting"); @@ -596,7 +562,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *o= ptions, int flags, { BDRVRBDState *s =3D bs->opaque; const char *pool, *snap, *conf, *clientname, *name, *keypairs; - const char *secretid; QemuOpts *opts; Error *local_err =3D NULL; char *mon_host =3D NULL; @@ -618,8 +583,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *o= ptions, int flags, goto failed_opts; } =20 - secretid =3D qemu_opt_get(opts, "password-secret"); - pool =3D qemu_opt_get(opts, "pool"); conf =3D qemu_opt_get(opts, "conf"); snap =3D qemu_opt_get(opts, "snapshot"); @@ -661,11 +624,6 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *= options, int flags, } } =20 - if (qemu_rbd_set_auth(s->cluster, secretid, errp) < 0) { - r =3D -EIO; - goto failed_shutdown; - } - /* * Fallback to more conservative semantics if setting cache * options fails. Ignore errors from setting rbd_cache because the @@ -1105,11 +1063,6 @@ static QemuOptsList qemu_rbd_create_opts =3D { .type =3D QEMU_OPT_SIZE, .help =3D "RBD object size" }, - { - .name =3D "password-secret", - .type =3D QEMU_OPT_STRING, - .help =3D "ID of secret providing the password", - }, { /* end of list */ } } }; --=20 2.7.4 From nobody Fri May 3 03:48:30 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 1490621309354473.6388439970036; Mon, 27 Mar 2017 06:28:29 -0700 (PDT) Received: from localhost ([::1]:46813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUhA-0003Oc-0a for importer@patchew.org; Mon, 27 Mar 2017 09:28:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csUfW-00026w-Ux for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csUfQ-0006PQ-Hl for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43620) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1csUfQ-0006OK-4v for qemu-devel@nongnu.org; Mon, 27 Mar 2017 09:26:40 -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 F1D2B437F70 for ; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 914F55C881; Mon, 27 Mar 2017 13:26:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 914CE1138612; Mon, 27 Mar 2017 15:26:35 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F1D2B437F70 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=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F1D2B437F70 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 15:26:35 +0200 Message-Id: <1490621195-2228-12-git-send-email-armbru@redhat.com> In-Reply-To: <1490621195-2228-1-git-send-email-armbru@redhat.com> References: <1490621195-2228-1-git-send-email-armbru@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.29]); Mon, 27 Mar 2017 13:26:39 +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] [PATCH RFC v3 for-2.9 11/11] rbd: Fix bugs around -drive parameter "server" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jdurgin@redhat.com, jcody@redhat.com, mreitz@redhat.com 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" qemu_rbd_open() takes option parameters as a flattened QDict, with keys of the form server.%d.host, server.%d.port, where %d counts up from zero. qemu_rbd_array_opts() extracts these values as follows. First, it calls qdict_array_entries() to find the list's length. For each list element, it formats the list's key prefix (e.g. "server.0."), then creates a new QDict holding the options with that key prefix, then converts that to a QemuOpts, so it can finally get the member values from there. If there's one surefire way to make code using QDict more awkward, it's creating more of them and mixing in QemuOpts for good measure. The extraction of keys starting with server.%d into another QDict makes us ignore parameters like server.0.neither-host-nor-port silently. The conversion to QemuOpts abuses runtime_opts, as described a few commits ago. Rewrite to simply get the values straight from the options QDict. Fixes -drive not to crash when server.*.* are present, but server.*.host is absent. Fixes -drive to reject invalid server.*.*. Permits cleaning up runtime_opts. Do that, and fix -drive to reject bogus parameters host and port instead of silently ignoring them. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- block/rbd.c | 127 +++++++++++++++-----------------------------------------= ---- 1 file changed, 32 insertions(+), 95 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 5a58d3e..7c6f084 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -13,14 +13,13 @@ =20 #include "qemu/osdep.h" =20 +#include #include "qapi/error.h" #include "qemu/error-report.h" #include "block/block_int.h" #include "qemu/cutils.h" #include "qapi/qmp/qstring.h" =20 -#include - /* * When specifying the image filename use: * @@ -299,7 +298,7 @@ static QemuOptsList runtime_opts =3D { .help =3D "Rados id name", }, /* - * server.* extracted manually, see qemu_rbd_array_opts() + * server.* extracted manually, see qemu_rbd_mon_host() */ =20 /* @@ -314,21 +313,6 @@ static QemuOptsList runtime_opts =3D { .type =3D QEMU_OPT_STRING, .help =3D "Legacy rados key/value option parameters", }, - - /* - * The remainder aren't option keys, but option sub-sub-keys, - * so that qemu_rbd_array_opts() can abuse runtime_opts for - * its own purposes - * TODO clean this up - */ - { - .name =3D "host", - .type =3D QEMU_OPT_STRING, - }, - { - .name =3D "port", - .type =3D QEMU_OPT_STRING, - }, { /* end of list */ } }, }; @@ -471,89 +455,43 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb) qemu_aio_unref(acb); } =20 -#define RBD_MON_HOST 0 - -static char *qemu_rbd_array_opts(QDict *options, const char *prefix, int t= ype, - Error **errp) +static char *qemu_rbd_mon_host(QDict *options, Error **errp) { - int num_entries; - QemuOpts *opts =3D NULL; - QDict *sub_options; - const char *host; - const char *port; - char *str; - char *rados_str =3D NULL; - Error *local_err =3D NULL; + const char **vals =3D g_new(const char *, qdict_size(options) + 1); + char keybuf[32]; + const char *host, *port; + char *rados_str; int i; =20 - assert(type =3D=3D RBD_MON_HOST); - - num_entries =3D qdict_array_entries(options, prefix); - - if (num_entries < 0) { - error_setg(errp, "Parse error on RBD QDict array"); - return NULL; - } - - for (i =3D 0; i < num_entries; i++) { - char *strbuf =3D NULL; - const char *value; - char *rados_str_tmp; - - str =3D g_strdup_printf("%s%d.", prefix, i); - qdict_extract_subqdict(options, &sub_options, str); - g_free(str); - - opts =3D qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); - qemu_opts_absorb_qdict(opts, sub_options, &local_err); - QDECREF(sub_options); - if (local_err) { - error_propagate(errp, local_err); - g_free(rados_str); + for (i =3D 0;; i++) { + sprintf(keybuf, "server.%d.host", i); + host =3D qdict_get_try_str(options, keybuf); + qdict_del(options, keybuf); + sprintf(keybuf, "server.%d.port", i); + port =3D qdict_get_try_str(options, keybuf); + qdict_del(options, keybuf); + if (!host && !port) { + break; + } + if (!host) { + error_setg(errp, "Parameter server.%d.host is missing", i); rados_str =3D NULL; - goto exit; + goto out; } =20 - if (type =3D=3D RBD_MON_HOST) { - host =3D qemu_opt_get(opts, "host"); - port =3D qemu_opt_get(opts, "port"); - - value =3D host; - if (port) { - /* check for ipv6 */ - if (strchr(host, ':')) { - strbuf =3D g_strdup_printf("[%s]:%s", host, port); - } else { - strbuf =3D g_strdup_printf("%s:%s", host, port); - } - value =3D strbuf; - } else if (strchr(host, ':')) { - strbuf =3D g_strdup_printf("[%s]", host); - value =3D strbuf; - } + if (strchr(host, ':')) { + vals[i] =3D port ? g_strdup_printf("[%s]:%s", host, port) + : g_strdup_printf("[%s]", host); } else { - abort(); + vals[i] =3D port ? g_strdup_printf("%s:%s", host, port) + : g_strdup(host); } - - /* each iteration in the for loop will build upon the string, and = if - * rados_str is NULL then it is our first pass */ - if (rados_str) { - /* separate options with ';', as that is what rados_conf_set() - * requires */ - rados_str_tmp =3D rados_str; - rados_str =3D g_strdup_printf("%s;%s", rados_str_tmp, value); - g_free(rados_str_tmp); - } else { - rados_str =3D g_strdup(value); - } - - g_free(strbuf); - qemu_opts_del(opts); - opts =3D NULL; } + vals[i] =3D NULL; =20 -exit: - qemu_opts_del(opts); + rados_str =3D i ? g_strjoinv(";", (char **)vals) : NULL; +out: + g_strfreev((char **)vals); return rados_str; } =20 @@ -571,12 +509,11 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict = *options, int flags, qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); - qemu_opts_del(opts); - return -EINVAL; + r =3D -EINVAL; + goto failed_opts; } =20 - mon_host =3D qemu_rbd_array_opts(options, "server.", - RBD_MON_HOST, &local_err); + mon_host =3D qemu_rbd_mon_host(options, &local_err); if (local_err) { error_propagate(errp, local_err); r =3D -EINVAL; --=20 2.7.4