From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Kevin Wolf 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> Subject: [Qemu-devel] [PATCH 14/14] nbd: Check against invalid option combinations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@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; -- 1.8.1.4