[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 13/14] nbd: Use default port if only host is specifi
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 13/14] nbd: Use default port if only host is specified |
Date: |
Fri, 22 Mar 2013 18:41:22 +0100 |
The URL method already takes care to apply the default port when none is
specfied. Directly specifying driver-specific options required the port
number until now. Allow leaving it out and apply the default.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/nbd.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index 9858f06..67f1df2 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -118,21 +118,18 @@ static int nbd_parse_uri(const char *filename, QDict
*options)
}
qdict_put(options, "path", qstring_from_str(qp->p[0].value));
} else {
- /* nbd[+tcp]://host:port/export */
- char *port_str;
-
+ /* nbd[+tcp]://host[:port]/export */
if (!uri->server) {
ret = -EINVAL;
goto out;
}
- if (!uri->port) {
- uri->port = NBD_DEFAULT_PORT;
- }
- port_str = g_strdup_printf("%d", uri->port);
qdict_put(options, "host", qstring_from_str(uri->server));
- qdict_put(options, "port", qstring_from_str(port_str));
- g_free(port_str);
+ if (uri->port) {
+ char* port_str = g_strdup_printf("%d", uri->port);
+ qdict_put(options, "port", qstring_from_str(port_str));
+ g_free(port_str);
+ }
}
out:
@@ -223,6 +220,10 @@ static int nbd_config(BDRVNBDState *s, QDict *options)
return -EINVAL;
}
+ if (!qemu_opt_get(s->socket_opts, "port")) {
+ qemu_opt_set_number(s->socket_opts, "port", NBD_DEFAULT_PORT);
+ }
+
s->export_name = g_strdup(qdict_get_try_str(options, "export"));
if (s->export_name) {
qdict_del(options, "export");
--
1.8.1.4
- [Qemu-devel] [PATCH 10/14] block: Rename variable to avoid shadowing, (continued)
- [Qemu-devel] [PATCH 10/14] block: Rename variable to avoid shadowing, Kevin Wolf, 2013/03/22
- [Qemu-devel] [PATCH 11/14] block: Make find_image_format safe with NULL filename, Kevin Wolf, 2013/03/22
- [Qemu-devel] [PATCH 03/14] block: Add options QDict to bdrv_file_open() prototypes, Kevin Wolf, 2013/03/22
- [Qemu-devel] [PATCH 14/14] nbd: Check against invalid option combinations, Kevin Wolf, 2013/03/22
- [Qemu-devel] [PATCH 06/14] nbd: Keep hostname and port separate, Kevin Wolf, 2013/03/22
- [Qemu-devel] [PATCH 09/14] block: Introduce .bdrv_parse_filename callback, Kevin Wolf, 2013/03/22
- [Qemu-devel] [PATCH 12/14] block: Allow omitting the file name when using driver-specific options, Kevin Wolf, 2013/03/22
- [Qemu-devel] [PATCH 13/14] nbd: Use default port if only host is specified,
Kevin Wolf <=