aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2016-10-25 15:11:30 +0200
committerKevin Wolf <kwolf@redhat.com>2016-10-27 19:05:23 +0200
commit442045cbce010688eed2b8ede6141e982c6d6b23 (patch)
treed0c5d881c37d70a5f163d5d70761380e92c740e5 /block
parent82d73014a9111c53fefb7e7954c9e370d23f7569 (diff)
block/nbd: Reject port parameter without host
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 <eblake@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/nbd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/block/nbd.c b/block/nbd.c
index ce7c14f8df..eaca33c35c 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);