From patchwork Fri Mar 22 17:41:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 230226 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2FFB72C00D1 for ; Sat, 23 Mar 2013 04:45:59 +1100 (EST) Received: from localhost ([::1]:35090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ62P-0007vY-Ea for incoming@patchwork.ozlabs.org; Fri, 22 Mar 2013 13:45:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ5yT-0000s8-S0 for qemu-devel@nongnu.org; Fri, 22 Mar 2013 13:41:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJ5yR-0001RX-1G for qemu-devel@nongnu.org; Fri, 22 Mar 2013 13:41:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ5yQ-0001QS-JB for qemu-devel@nongnu.org; Fri, 22 Mar 2013 13:41:50 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2MHfn9f016147 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 Mar 2013 13:41:49 -0400 Received: from dhcp-200-207.str.redhat.com (ovpn-116-103.ams2.redhat.com [10.36.116.103]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2MHfQDt002071; Fri, 22 Mar 2013 13:41:48 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 22 Mar 2013 18:41:23 +0100 Message-Id: <1363974083-28440-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1363974083-28440-1-git-send-email-kwolf@redhat.com> References: <1363974083-28440-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 14/14] nbd: Check against invalid option combinations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org A file name may only specified if no host or socket path is specified. The latter two may not appear at the same time either. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block/nbd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/nbd.c b/block/nbd.c index 67f1df2..3d711b2 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -148,6 +148,15 @@ static void nbd_parse_filename(const char *filename, QDict *options, const char *host_spec; const char *unixpath; + if (qdict_haskey(options, "host") + || qdict_haskey(options, "port") + || qdict_haskey(options, "path")) + { + error_setg(errp, "host/port/path and a file name may not be specified " + "at the same time"); + return; + } + if (strstr(filename, "://")) { int ret = nbd_parse_uri(filename, options); if (ret < 0) { @@ -204,6 +213,11 @@ static int nbd_config(BDRVNBDState *s, QDict *options) Error *local_err = NULL; if (qdict_haskey(options, "path")) { + if (qdict_haskey(options, "host")) { + qerror_report(ERROR_CLASS_GENERIC_ERROR, "path and host may not " + "be used at the same time."); + return -EINVAL; + } s->is_unix = true; } else if (qdict_haskey(options, "host")) { s->is_unix = false;