[Qemu-devel] [PATCH 2/3] char-socket: make 'fd' incompatible with 'reconnect'

Marc-André Lureau posted 3 patches 7 years, 3 months ago
[Qemu-devel] [PATCH 2/3] char-socket: make 'fd' incompatible with 'reconnect'
Posted by Marc-André Lureau 7 years, 3 months ago
A chardev socket created with the 'fd=' argument is not going to
handle reconnection properly by recycling the same fd (or not in a
supported way). Let's forbid this case.

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

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 8950f36317..6daa8d003a 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -992,6 +992,10 @@ static void qmp_chardev_open_socket(Chardev *chr,
 
     s->addr = addr = socket_address_flatten(sock->addr);
 
+    if (sock->has_reconnect && addr->type == SOCKET_ADDRESS_TYPE_FD) {
+        error_setg(errp, "'reconnect' option is incompatible with 'fd'");
+        goto error;
+    }
     qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_RECONNECTABLE);
     /* TODO SOCKET_ADDRESS_FD where fd has AF_UNIX */
     if (addr->type == SOCKET_ADDRESS_TYPE_UNIX) {
-- 
2.18.0.129.ge3331758f1


Re: [Qemu-devel] [PATCH 2/3] char-socket: make 'fd' incompatible with 'reconnect'
Posted by Daniel P. Berrangé 7 years, 3 months ago
On Tue, Jul 17, 2018 at 02:52:38PM +0200, Marc-André Lureau wrote:
> A chardev socket created with the 'fd=' argument is not going to
> handle reconnection properly by recycling the same fd (or not in a
> supported way). Let's forbid this case.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  chardev/char-socket.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index 8950f36317..6daa8d003a 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -992,6 +992,10 @@ static void qmp_chardev_open_socket(Chardev *chr,
>  
>      s->addr = addr = socket_address_flatten(sock->addr);
>  
> +    if (sock->has_reconnect && addr->type == SOCKET_ADDRESS_TYPE_FD) {
> +        error_setg(errp, "'reconnect' option is incompatible with 'fd'");
> +        goto error;
> +    }
>      qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_RECONNECTABLE);
>      /* TODO SOCKET_ADDRESS_FD where fd has AF_UNIX */
>      if (addr->type == SOCKET_ADDRESS_TYPE_UNIX) {

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|