From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UINvy-0002eQ-Ck for qemu-devel@nongnu.org; Wed, 20 Mar 2013 14:40:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UINvw-0004Lf-TN for qemu-devel@nongnu.org; Wed, 20 Mar 2013 14:40:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28457) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UINvw-0004LV-JI for qemu-devel@nongnu.org; Wed, 20 Mar 2013 14:40:20 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2KIeJV9005288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Mar 2013 14:40:19 -0400 From: Kevin Wolf Date: Wed, 20 Mar 2013 19:39:48 +0100 Message-Id: <1363804788-18535-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1363804788-18535-1-git-send-email-kwolf@redhat.com> References: <1363804788-18535-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2 12/12] nbd: Check against invalid option combinations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com 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 --- 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; -- 1.8.1.4