From patchwork Mon Feb 27 18:58:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 9593789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A83C6601D7 for ; Mon, 27 Feb 2017 19:04:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B789281C3 for ; Mon, 27 Feb 2017 19:04:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FE2B2847F; Mon, 27 Feb 2017 19:04:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 38992281C3 for ; Mon, 27 Feb 2017 19:04:21 +0000 (UTC) Received: from localhost ([::1]:55835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciQao-0000yr-F5 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Feb 2017 14:04:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciQVh-0005FG-0U for qemu-devel@nongnu.org; Mon, 27 Feb 2017 13:59:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciQVg-0003Gi-4f for qemu-devel@nongnu.org; Mon, 27 Feb 2017 13:59:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52958) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciQVd-0003Ct-Mt; Mon, 27 Feb 2017 13:58:57 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD2DC61BA9; Mon, 27 Feb 2017 18:58:57 +0000 (UTC) Received: from localhost (ovpn-116-95.phx2.redhat.com [10.3.116.95]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1RIwumN019460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 27 Feb 2017 13:58:57 -0500 From: Jeff Cody To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2017 13:58:48 -0500 Message-Id: <12a16b28300f871052a49897ec7875a082fc63e3.1488220970.git.jcody@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 27 Feb 2017 18:58:57 +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 v2 5/5] block/rbd: add support for 'mon_host', 'auth_supported' via QAPI 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: armbru@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This adds support for two additional options that may be specified by QAPI in blockdev-add: mon_host: servername and port auth_supported: either 'cephx' or 'none' Signed-off-by: Jeff Cody --- block/rbd.c | 39 +++++++++++++++++++++++++++++++++++++++ qapi/block-core.json | 8 ++++++++ 2 files changed, 47 insertions(+) diff --git a/block/rbd.c b/block/rbd.c index e04a5e1..51e971e 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -394,6 +394,18 @@ static QemuOptsList runtime_opts = { .name = "keyvalue-pairs", .type = QEMU_OPT_STRING, }, + { + .name = "server.host", + .type = QEMU_OPT_STRING, + }, + { + .name = "server.port", + .type = QEMU_OPT_STRING, + }, + { + .name = "auth_supported", + .type = QEMU_OPT_STRING, + }, { /* end of list */ } }, }; @@ -559,6 +571,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, { BDRVRBDState *s = bs->opaque; const char *pool, *snap, *conf, *clientname, *name, *keypairs; + const char *host, *port, *auth_supported; const char *secretid; QemuOpts *opts; Error *local_err = NULL; @@ -580,6 +593,9 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, clientname = qemu_opt_get(opts, "user"); name = qemu_opt_get(opts, "image"); keypairs = qemu_opt_get(opts, "keyvalue-pairs"); + host = qemu_opt_get(opts, "server.host"); + port = qemu_opt_get(opts, "server.port"); + auth_supported = qemu_opt_get(opts, "auth_supported"); r = rados_create(&s->cluster, clientname); if (r < 0) { @@ -604,6 +620,29 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, goto failed_shutdown; } + /* if mon_host was specified */ + if (host) { + const char *hostname = host; + char *mon_host = NULL; + + if (port) { + mon_host = g_strdup_printf("%s:%s", host, port); + hostname = mon_host; + } + r = rados_conf_set(s->cluster, "mon_host", hostname); + g_free(mon_host); + if (r < 0) { + goto failed_shutdown; + } + } + + if (auth_supported) { + r = 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 = -EIO; goto failed_shutdown; diff --git a/qapi/block-core.json b/qapi/block-core.json index 5b311ff..376512c 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2680,6 +2680,12 @@ # # @user: #optional Ceph id name. # +# @server: #optional Monitor host address and port. This maps +# to the "mon_host" Ceph option. +# +# @auth_supported: #optional Authentication supported. +# Either "cephx" or"none". +# # @password-secret: #optional The ID of a QCryptoSecret object providing # the password for the login. # @@ -2691,6 +2697,8 @@ '*conf': 'str', '*snapshot': 'str', '*user': 'str', + '*server': 'InetSocketAddress', + '*auth_supported': 'str', '*password-secret': 'str' } } ##