diff mbox series

[RFC,v1,04/26] char-socket: add 'reconnecting' property

Message ID 20200415005938.23895-5-alazar@bitdefender.com
State New
Headers show
Series VM introspection | expand

Commit Message

Adalbert Lazăr April 15, 2020, 12:59 a.m. UTC
This is used by the VM introspection object to check if the connection
will be reestablished in case it disconnects from some reason.

The closing of the socket is used by any of the three parties involved,
KVM, the introspection tool and QEMU (eg. on force-reset), to signal
the other parties that the session is over. As such, it is very important
that the socket will reconnect.

CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com>
---
 chardev/char-socket.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Marc-André Lureau April 15, 2020, 10:46 a.m. UTC | #1
Hi

On Wed, Apr 15, 2020 at 3:03 AM Adalbert Lazăr <alazar@bitdefender.com> wrote:
>
> This is used by the VM introspection object to check if the connection
> will be reestablished in case it disconnects from some reason.
>
> The closing of the socket is used by any of the three parties involved,
> KVM, the introspection tool and QEMU (eg. on force-reset), to signal
> the other parties that the session is over. As such, it is very important
> that the socket will reconnect.
>
> CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com>
> ---
>  chardev/char-socket.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index fd0106ab85..22ab242748 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -1492,6 +1492,13 @@ char_socket_get_connected(Object *obj, Error **errp)
>      return s->state == TCP_CHARDEV_STATE_CONNECTED;
>  }
>
> +static bool char_socket_get_reconnecting(Object *obj, Error **errp)
> +{
> +    SocketChardev *s = SOCKET_CHARDEV(obj);
> +
> +    return s->reconnect_time > 0;
> +}
> +
>  static int tcp_chr_reconnect_time(Chardev *chr, int secs)
>  {
>      SocketChardev *s = SOCKET_CHARDEV(chr);
> @@ -1528,6 +1535,10 @@ static void char_socket_class_init(ObjectClass *oc, void *data)
>
>      object_class_property_add_bool(oc, "connected", char_socket_get_connected,
>                                     NULL, &error_abort);
> +
> +    object_class_property_add_bool(oc, "reconnecting",
> +                                   char_socket_get_reconnecting,
> +                                   NULL, &error_abort);

That may be misleading, as the socket connection may be established
and this will return true if reconnect_time > 0. Why not have a
"reconnect-time" property instead?

>  }
>
>  static const TypeInfo char_socket_type_info = {
>
Adalbert Lazăr April 15, 2020, 12:28 p.m. UTC | #2
On Wed, 15 Apr 2020 12:46:57 +0200, Marc-André Lureau <marcandre.lureau@gmail.com> wrote:
> Hi
> 
> On Wed, Apr 15, 2020 at 3:03 AM Adalbert Lazăr <alazar@bitdefender.com> wrote:
> >
> > This is used by the VM introspection object to check if the connection
> > will be reestablished in case it disconnects from some reason.
> >
> > The closing of the socket is used by any of the three parties involved,
> > KVM, the introspection tool and QEMU (eg. on force-reset), to signal
> > the other parties that the session is over. As such, it is very important
> > that the socket will reconnect.
> >
> > CC: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> > CC: Paolo Bonzini <pbonzini@redhat.com>
> > Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com>
> > ---
> >  chardev/char-socket.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> > index fd0106ab85..22ab242748 100644
> > --- a/chardev/char-socket.c
> > +++ b/chardev/char-socket.c
> > @@ -1492,6 +1492,13 @@ char_socket_get_connected(Object *obj, Error **errp)
> >      return s->state == TCP_CHARDEV_STATE_CONNECTED;
> >  }
> >
> > +static bool char_socket_get_reconnecting(Object *obj, Error **errp)
> > +{
> > +    SocketChardev *s = SOCKET_CHARDEV(obj);
> > +
> > +    return s->reconnect_time > 0;
> > +}
> > +
> >  static int tcp_chr_reconnect_time(Chardev *chr, int secs)
> >  {
> >      SocketChardev *s = SOCKET_CHARDEV(chr);
> > @@ -1528,6 +1535,10 @@ static void char_socket_class_init(ObjectClass *oc, void *data)
> >
> >      object_class_property_add_bool(oc, "connected", char_socket_get_connected,
> >                                     NULL, &error_abort);
> > +
> > +    object_class_property_add_bool(oc, "reconnecting",
> > +                                   char_socket_get_reconnecting,
> > +                                   NULL, &error_abort);
> 
> That may be misleading, as the socket connection may be established
> and this will return true if reconnect_time > 0. Why not have a
> "reconnect-time" property instead?
> 

Sure.
Thanks.
diff mbox series

Patch

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index fd0106ab85..22ab242748 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1492,6 +1492,13 @@  char_socket_get_connected(Object *obj, Error **errp)
     return s->state == TCP_CHARDEV_STATE_CONNECTED;
 }
 
+static bool char_socket_get_reconnecting(Object *obj, Error **errp)
+{
+    SocketChardev *s = SOCKET_CHARDEV(obj);
+
+    return s->reconnect_time > 0;
+}
+
 static int tcp_chr_reconnect_time(Chardev *chr, int secs)
 {
     SocketChardev *s = SOCKET_CHARDEV(chr);
@@ -1528,6 +1535,10 @@  static void char_socket_class_init(ObjectClass *oc, void *data)
 
     object_class_property_add_bool(oc, "connected", char_socket_get_connected,
                                    NULL, &error_abort);
+
+    object_class_property_add_bool(oc, "reconnecting",
+                                   char_socket_get_reconnecting,
+                                   NULL, &error_abort);
 }
 
 static const TypeInfo char_socket_type_info = {