From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzp7J-0006nP-AU for qemu-devel@nongnu.org; Thu, 27 Oct 2016 14:09:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzp7I-0006M8-Dk for qemu-devel@nongnu.org; Thu, 27 Oct 2016 14:09:29 -0400 From: Kevin Wolf Date: Thu, 27 Oct 2016 20:08:56 +0200 Message-Id: <1477591747-21962-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1477591747-21962-1-git-send-email-kwolf@redhat.com> References: <1477591747-21962-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 12/23] block/nbd: Reject port parameter without host List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Max Reitz Currently, a port that is passed along with a UNIX socket path is silently ignored. That is not exactly ideal, it should be an error instead. Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/nbd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index ce7c14f..eaca33c 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -197,6 +197,7 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QemuOpts *opts, Error **errp) s->path = g_strdup(qemu_opt_get(opts, "path")); s->host = g_strdup(qemu_opt_get(opts, "host")); + s->port = g_strdup(qemu_opt_get(opts, "port")); if (!s->path == !s->host) { if (s->path) { @@ -206,6 +207,10 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QemuOpts *opts, Error **errp) } return NULL; } + if (s->port && !s->host) { + error_setg(errp, "port may not be used without host"); + return NULL; + } saddr = g_new0(SocketAddress, 1); @@ -217,8 +222,6 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QemuOpts *opts, Error **errp) } else { InetSocketAddress *inet; - s->port = g_strdup(qemu_opt_get(opts, "port")); - saddr->type = SOCKET_ADDRESS_KIND_INET; inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1); inet->host = g_strdup(s->host); -- 1.8.3.1