[PATCH v2] char: don't fail when client is not connected

Pavel Dovgalyuk posted 1 patch 3 years, 2 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/161284977034.741841.12565530923825663110.stgit@pasha-ThinkPad-X280
chardev/char-socket.c |    3 +++
1 file changed, 3 insertions(+)
[PATCH v2] char: don't fail when client is not connected
Posted by Pavel Dovgalyuk 3 years, 2 months ago
This patch checks that ioc is not null before
using it in tcp socket tcp_chr_add_watch function.

The failure occurs in replay mode of the execution,
when monitor and serial port are tcp servers,
and there are no clients connected to them:

-monitor tcp:127.0.0.1:8081,server,nowait
-serial tcp:127.0.0.1:8082,server,nowait


Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 chardev/char-socket.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 213a4c8dd0..cef1d9438f 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -385,6 +385,9 @@ static ssize_t tcp_chr_recv(Chardev *chr, char *buf, size_t len)
 static GSource *tcp_chr_add_watch(Chardev *chr, GIOCondition cond)
 {
     SocketChardev *s = SOCKET_CHARDEV(chr);
+    if (!s->ioc) {
+        return NULL;
+    }
     return qio_channel_create_watch(s->ioc, cond);
 }
 


Re: [PATCH v2] char: don't fail when client is not connected
Posted by Pavel Dovgalyuk 3 years, 2 months ago
ping

On 09.02.2021 08:49, Pavel Dovgalyuk wrote:
> This patch checks that ioc is not null before
> using it in tcp socket tcp_chr_add_watch function.
> 
> The failure occurs in replay mode of the execution,
> when monitor and serial port are tcp servers,
> and there are no clients connected to them:
> 
> -monitor tcp:127.0.0.1:8081,server,nowait
> -serial tcp:127.0.0.1:8082,server,nowait
> 
> 
> Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   chardev/char-socket.c |    3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index 213a4c8dd0..cef1d9438f 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -385,6 +385,9 @@ static ssize_t tcp_chr_recv(Chardev *chr, char *buf, size_t len)
>   static GSource *tcp_chr_add_watch(Chardev *chr, GIOCondition cond)
>   {
>       SocketChardev *s = SOCKET_CHARDEV(chr);
> +    if (!s->ioc) {
> +        return NULL;
> +    }
>       return qio_channel_create_watch(s->ioc, cond);
>   }
>   
> 


Re: [PATCH v2] char: don't fail when client is not connected
Posted by Paolo Bonzini 3 years, 2 months ago
On 09/02/21 06:49, Pavel Dovgalyuk wrote:
> This patch checks that ioc is not null before
> using it in tcp socket tcp_chr_add_watch function.
> 
> The failure occurs in replay mode of the execution,
> when monitor and serial port are tcp servers,
> and there are no clients connected to them:
> 
> -monitor tcp:127.0.0.1:8081,server,nowait
> -serial tcp:127.0.0.1:8082,server,nowait
> 
> 
> Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   chardev/char-socket.c |    3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index 213a4c8dd0..cef1d9438f 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -385,6 +385,9 @@ static ssize_t tcp_chr_recv(Chardev *chr, char *buf, size_t len)
>   static GSource *tcp_chr_add_watch(Chardev *chr, GIOCondition cond)
>   {
>       SocketChardev *s = SOCKET_CHARDEV(chr);
> +    if (!s->ioc) {
> +        return NULL;
> +    }
>       return qio_channel_create_watch(s->ioc, cond);
>   }
>   
> 

Queued, thanks.

Paolo