[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/7] nbd: accept relative path to Unix socket
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 2/7] nbd: accept relative path to Unix socket |
Date: |
Mon, 12 Nov 2012 15:22:02 +0100 |
Adding the "is_unix" member now will simplify the parsing of NBD URIs.
Signed-off-by: Paolo Bonzini <address@hidden>
---
block/nbd.c | 17 +++++++----------
1 file modificato, 7 inserzioni(+), 10 rimozioni(-)
diff --git a/block/nbd.c b/block/nbd.c
index 2bce47b..48bbeca 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -55,7 +55,6 @@ typedef struct BDRVNBDState {
uint32_t nbdflags;
off_t size;
size_t blocksize;
- char *export_name; /* An NBD server may export several devices */
CoMutex send_mutex;
CoMutex free_sema;
@@ -65,13 +64,12 @@ typedef struct BDRVNBDState {
Coroutine *recv_coroutine[MAX_NBD_REQUESTS];
struct nbd_reply reply;
- /* If it begins with '/', this is a UNIX domain socket. Otherwise,
- * it's a string of the form <hostname|ip4|\[ip6\]>:port
- */
+ int is_unix;
char *host_spec;
+ char *export_name; /* An NBD server may export several devices */
} BDRVNBDState;
-static int nbd_config(BDRVNBDState *s, const char *filename, int flags)
+static int nbd_config(BDRVNBDState *s, const char *filename)
{
char *file;
char *export_name;
@@ -98,11 +96,10 @@ static int nbd_config(BDRVNBDState *s, const char
*filename, int flags)
/* are we a UNIX or TCP socket? */
if (strstart(host_spec, "unix:", &unixpath)) {
- if (unixpath[0] != '/') { /* We demand an absolute path*/
- goto out;
- }
+ s->is_unix = true;
s->host_spec = g_strdup(unixpath);
} else {
+ s->is_unix = false;
s->host_spec = g_strdup(host_spec);
}
@@ -262,7 +259,7 @@ static int nbd_establish_connection(BlockDriverState *bs)
off_t size;
size_t blocksize;
- if (s->host_spec[0] == '/') {
+ if (s->is_unix) {
sock = unix_socket_outgoing(s->host_spec);
} else {
sock = tcp_socket_outgoing_spec(s->host_spec);
@@ -320,7 +317,7 @@ static int nbd_open(BlockDriverState *bs, const char*
filename, int flags)
qemu_co_mutex_init(&s->free_sema);
/* Pop the config into our state object. Exit if invalid. */
- result = nbd_config(s, filename, flags);
+ result = nbd_config(s, filename);
if (result != 0) {
return result;
}
--
1.7.12.1
- [Qemu-devel] [PULL 1.3 0/7] NBD updates for 2012-11-12, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 1/7] qemu-nbd: initialize main loop before block layer, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 2/7] nbd: accept relative path to Unix socket,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 3/7] nbd: accept URIs, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 4/7] nbd: fix nbd_server_stop crash when no server was running, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 5/7] nbd: force read-only export for read-only devices, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 6/7] nbd: disallow nbd-server-add before nbd-server-start, Paolo Bonzini, 2012/11/12
- [Qemu-devel] [PATCH 7/7] hmp: add NBD server commands, Paolo Bonzini, 2012/11/12
- Re: [Qemu-devel] [PULL 1.3 0/7] NBD updates for 2012-11-12, Paolo Bonzini, 2012/11/13