* [Qemu-devel] [PATCH 1/2] nbd: Close socket on negotiation failure.
@ 2014-05-12 23:35 Hani Benhabiles
2014-05-12 23:35 ` [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes Hani Benhabiles
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Hani Benhabiles @ 2014-05-12 23:35 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, pbonzini, kwolf, stefanha
Otherwise, the nbd client may hang waiting for the server response.
Signed-off-by: Hani Benhabiles <hani@linux.com>
---
Quick method to trigger such behaviour:
(qemu) nbd_server_start localhost:10809
(qemu) nbd_server_add sd0
$ nbd-client localhost 10809 -name AAAA /dev/nbd0
Negotiation: ..
(Client will hang indefinitely.)
blockdev-nbd.c | 4 ++--
qemu-nbd.c | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 922cf56..b60b66d 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -27,8 +27,8 @@ static void nbd_accept(void *opaque)
socklen_t addr_len = sizeof(addr);
int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len);
- if (fd >= 0) {
- nbd_client_new(NULL, fd, nbd_client_put);
+ if (fd >= 0 && !nbd_client_new(NULL, fd, nbd_client_put)) {
+ close(fd);
}
}
diff --git a/qemu-nbd.c b/qemu-nbd.c
index eed79fa..f70e4b0 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -369,8 +369,10 @@ static void nbd_accept(void *opaque)
return;
}
- if (fd >= 0 && nbd_client_new(exp, fd, nbd_client_closed)) {
+ if (nbd_client_new(exp, fd, nbd_client_closed)) {
nb_fds++;
+ } else {
+ close(fd);
}
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes.
2014-05-12 23:35 [Qemu-devel] [PATCH 1/2] nbd: Close socket on negotiation failure Hani Benhabiles
@ 2014-05-12 23:35 ` Hani Benhabiles
2014-05-13 9:08 ` Paolo Bonzini
` (2 more replies)
2014-05-13 9:07 ` [Qemu-devel] [PATCH 1/2] nbd: Close socket on negotiation failure Paolo Bonzini
2014-05-17 8:02 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2 siblings, 3 replies; 7+ messages in thread
From: Hani Benhabiles @ 2014-05-12 23:35 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, pbonzini, kwolf, stefanha
Signed-off-by: Hani Benhabiles <hani@linux.com>
---
nbd.c | 2 +-
qemu-nbd.c | 2 +-
qemu-nbd.texi | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/nbd.c b/nbd.c
index e5084b6..e0d032c 100644
--- a/nbd.c
+++ b/nbd.c
@@ -306,7 +306,7 @@ static int nbd_send_negotiate(NBDClient *client)
[ 8 .. 15] magic (NBD_CLIENT_MAGIC)
[16 .. 23] size
[24 .. 25] server flags (0)
- [24 .. 27] export flags
+ [26 .. 27] export flags
[28 .. 151] reserved (0)
Negotiation header with options, part 1:
diff --git a/qemu-nbd.c b/qemu-nbd.c
index f70e4b0..cd6bd50 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -294,7 +294,7 @@ static void *nbd_client_thread(void *arg)
fd = open(device, O_RDWR);
if (fd < 0) {
/* Linux-only, we can use %m in printf. */
- fprintf(stderr, "Failed to open %s: %m", device);
+ fprintf(stderr, "Failed to open %s: %m\n", device);
goto out_socket;
}
diff --git a/qemu-nbd.texi b/qemu-nbd.texi
index 0a7e013..46fd483 100644
--- a/qemu-nbd.texi
+++ b/qemu-nbd.texi
@@ -15,7 +15,7 @@ Export QEMU disk image using NBD protocol.
@item @var{filename}
is a disk image filename
@item -p, --port=@var{port}
- port to listen on (default @samp{1024})
+ port to listen on (default @samp{10809})
@item -o, --offset=@var{offset}
offset into the image
@item -b, --bind=@var{iface}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] nbd: Close socket on negotiation failure.
2014-05-12 23:35 [Qemu-devel] [PATCH 1/2] nbd: Close socket on negotiation failure Hani Benhabiles
2014-05-12 23:35 ` [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes Hani Benhabiles
@ 2014-05-13 9:07 ` Paolo Bonzini
2014-05-17 8:02 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2014-05-13 9:07 UTC (permalink / raw)
To: Hani Benhabiles, qemu-devel; +Cc: qemu-trivial, kwolf, stefanha
Il 13/05/2014 01:35, Hani Benhabiles ha scritto:
> Otherwise, the nbd client may hang waiting for the server response.
>
> Signed-off-by: Hani Benhabiles <hani@linux.com>
> ---
>
> Quick method to trigger such behaviour:
>
> (qemu) nbd_server_start localhost:10809
> (qemu) nbd_server_add sd0
> $ nbd-client localhost 10809 -name AAAA /dev/nbd0
> Negotiation: ..
>
> (Client will hang indefinitely.)
>
> blockdev-nbd.c | 4 ++--
> qemu-nbd.c | 4 +++-
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/blockdev-nbd.c b/blockdev-nbd.c
> index 922cf56..b60b66d 100644
> --- a/blockdev-nbd.c
> +++ b/blockdev-nbd.c
> @@ -27,8 +27,8 @@ static void nbd_accept(void *opaque)
> socklen_t addr_len = sizeof(addr);
>
> int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len);
> - if (fd >= 0) {
> - nbd_client_new(NULL, fd, nbd_client_put);
> + if (fd >= 0 && !nbd_client_new(NULL, fd, nbd_client_put)) {
> + close(fd);
> }
> }
>
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index eed79fa..f70e4b0 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -369,8 +369,10 @@ static void nbd_accept(void *opaque)
> return;
> }
>
> - if (fd >= 0 && nbd_client_new(exp, fd, nbd_client_closed)) {
> + if (nbd_client_new(exp, fd, nbd_client_closed)) {
> nb_fds++;
> + } else {
> + close(fd);
> }
> }
>
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Michael, can you queue this yourself?
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes.
2014-05-12 23:35 ` [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes Hani Benhabiles
@ 2014-05-13 9:08 ` Paolo Bonzini
2014-05-14 12:46 ` Stefan Hajnoczi
2014-05-17 8:02 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2014-05-13 9:08 UTC (permalink / raw)
To: Hani Benhabiles, qemu-devel; +Cc: qemu-trivial, kwolf, stefanha
Il 13/05/2014 01:35, Hani Benhabiles ha scritto:
> Signed-off-by: Hani Benhabiles <hani@linux.com>
> ---
> nbd.c | 2 +-
> qemu-nbd.c | 2 +-
> qemu-nbd.texi | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/nbd.c b/nbd.c
> index e5084b6..e0d032c 100644
> --- a/nbd.c
> +++ b/nbd.c
> @@ -306,7 +306,7 @@ static int nbd_send_negotiate(NBDClient *client)
> [ 8 .. 15] magic (NBD_CLIENT_MAGIC)
> [16 .. 23] size
> [24 .. 25] server flags (0)
> - [24 .. 27] export flags
> + [26 .. 27] export flags
> [28 .. 151] reserved (0)
>
> Negotiation header with options, part 1:
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index f70e4b0..cd6bd50 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -294,7 +294,7 @@ static void *nbd_client_thread(void *arg)
> fd = open(device, O_RDWR);
> if (fd < 0) {
> /* Linux-only, we can use %m in printf. */
> - fprintf(stderr, "Failed to open %s: %m", device);
> + fprintf(stderr, "Failed to open %s: %m\n", device);
> goto out_socket;
> }
>
> diff --git a/qemu-nbd.texi b/qemu-nbd.texi
> index 0a7e013..46fd483 100644
> --- a/qemu-nbd.texi
> +++ b/qemu-nbd.texi
> @@ -15,7 +15,7 @@ Export QEMU disk image using NBD protocol.
> @item @var{filename}
> is a disk image filename
> @item -p, --port=@var{port}
> - port to listen on (default @samp{1024})
> + port to listen on (default @samp{10809})
> @item -o, --offset=@var{offset}
> offset into the image
> @item -b, --bind=@var{iface}
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes.
2014-05-12 23:35 ` [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes Hani Benhabiles
2014-05-13 9:08 ` Paolo Bonzini
@ 2014-05-14 12:46 ` Stefan Hajnoczi
2014-05-17 8:02 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2014-05-14 12:46 UTC (permalink / raw)
To: Hani Benhabiles; +Cc: qemu-trivial, pbonzini, stefanha, qemu-devel, kwolf
On Tue, May 13, 2014 at 12:35:16AM +0100, Hani Benhabiles wrote:
> Signed-off-by: Hani Benhabiles <hani@linux.com>
> ---
> nbd.c | 2 +-
> qemu-nbd.c | 2 +-
> qemu-nbd.texi | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH 1/2] nbd: Close socket on negotiation failure.
2014-05-12 23:35 [Qemu-devel] [PATCH 1/2] nbd: Close socket on negotiation failure Hani Benhabiles
2014-05-12 23:35 ` [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes Hani Benhabiles
2014-05-13 9:07 ` [Qemu-devel] [PATCH 1/2] nbd: Close socket on negotiation failure Paolo Bonzini
@ 2014-05-17 8:02 ` Michael Tokarev
2 siblings, 0 replies; 7+ messages in thread
From: Michael Tokarev @ 2014-05-17 8:02 UTC (permalink / raw)
To: Hani Benhabiles, qemu-devel; +Cc: qemu-trivial, pbonzini, stefanha, kwolf
13.05.2014 03:35, Hani Benhabiles wrote:
> Otherwise, the nbd client may hang waiting for the server response.
Applied to -trivial, thanks!
/mjt
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH 2/2] nbd: Miscellaneous typo fixes.
2014-05-12 23:35 ` [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes Hani Benhabiles
2014-05-13 9:08 ` Paolo Bonzini
2014-05-14 12:46 ` Stefan Hajnoczi
@ 2014-05-17 8:02 ` Michael Tokarev
2 siblings, 0 replies; 7+ messages in thread
From: Michael Tokarev @ 2014-05-17 8:02 UTC (permalink / raw)
To: Hani Benhabiles, qemu-devel; +Cc: qemu-trivial, pbonzini, stefanha, kwolf
Applied to -trivial, thanks!
/mjt
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-05-17 8:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-12 23:35 [Qemu-devel] [PATCH 1/2] nbd: Close socket on negotiation failure Hani Benhabiles
2014-05-12 23:35 ` [Qemu-devel] [PATCH 2/2] nbd: Miscellaneous typo fixes Hani Benhabiles
2014-05-13 9:08 ` Paolo Bonzini
2014-05-14 12:46 ` Stefan Hajnoczi
2014-05-17 8:02 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-05-13 9:07 ` [Qemu-devel] [PATCH 1/2] nbd: Close socket on negotiation failure Paolo Bonzini
2014-05-17 8:02 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.