[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 02/12] block/nbd: Reject port parameter without h
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v4 02/12] block/nbd: Reject port parameter without host |
Date: |
Wed, 28 Sep 2016 22:55:52 +0200 |
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.
Signed-off-by: Max Reitz <address@hidden>
---
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);
--
2.10.0
- [Qemu-devel] [PATCH v4 00/12] qapi: Allow blockdev-add for NBD, Max Reitz, 2016/09/28
- [Qemu-devel] [PATCH v4 01/12] block/nbd: Drop trailing "." in error messages, Max Reitz, 2016/09/28
- [Qemu-devel] [PATCH v4 02/12] block/nbd: Reject port parameter without host,
Max Reitz <=
- [Qemu-devel] [PATCH v4 03/12] block/nbd: Default port in nbd_refresh_filename(), Max Reitz, 2016/09/28
- [Qemu-devel] [PATCH v4 04/12] block/nbd: Use qdict_put(), Max Reitz, 2016/09/28
- [Qemu-devel] [PATCH v4 05/12] block/nbd: Add nbd_has_filename_options_conflict(), Max Reitz, 2016/09/28
- [Qemu-devel] [PATCH v4 06/12] block/nbd: Accept SocketAddress, Max Reitz, 2016/09/28
- [Qemu-devel] [PATCH v4 07/12] block/nbd: Use SocketAddress options, Max Reitz, 2016/09/28
- [Qemu-devel] [PATCH v4 08/12] qapi: Allow blockdev-add for NBD, Max Reitz, 2016/09/28
- [Qemu-devel] [PATCH v4 09/12] iotests.py: Add qemu_nbd function, Max Reitz, 2016/09/28
- [Qemu-devel] [PATCH v4 10/12] iotests.py: Allow concurrent qemu instances, Max Reitz, 2016/09/28