[PATCH v2 1/2] chardev: remove deprecated 'reconnect' option

Vladimir Sementsov-Ogievskiy posted 2 patches 4 days, 1 hour ago
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Jason Wang <jasowang@redhat.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>
[PATCH v2 1/2] chardev: remove deprecated 'reconnect' option
Posted by Vladimir Sementsov-Ogievskiy 4 days, 1 hour ago
It was deprecated in 9.2, time to remove.

Note, that (which become obvious with this commit) we forget to do some
checks for reconnect-ms options, for example, it was silently ignored
for listening server, instead of error-out. The commit fixes this, as
now we use reconnect_ms everywhere.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 chardev/char-socket.c           | 24 +++++-------------------
 chardev/char.c                  |  3 ---
 docs/about/deprecated.rst       |  6 ------
 docs/about/removed-features.rst | 12 ++++++++++++
 qapi/char.json                  | 14 +-------------
 5 files changed, 18 insertions(+), 41 deletions(-)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index cb4ec78ebe..62852e3caf 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1296,9 +1296,9 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
     /* Validate any options which have a dependency on address type */
     switch (addr->type) {
     case SOCKET_ADDRESS_TYPE_FD:
-        if (sock->has_reconnect) {
+        if (sock->has_reconnect_ms) {
             error_setg(errp,
-                       "'reconnect' option is incompatible with "
+                       "'reconnect-ms' option is incompatible with "
                        "'fd' address type");
             return false;
         }
@@ -1342,9 +1342,9 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
 
     /* Validate any options which have a dependency on client vs server */
     if (!sock->has_server || sock->server) {
-        if (sock->has_reconnect) {
+        if (sock->has_reconnect_ms) {
             error_setg(errp,
-                       "'reconnect' option is incompatible with "
+                       "'reconnect-ms' option is incompatible with "
                        "socket in server listen mode");
             return false;
         }
@@ -1361,12 +1361,6 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
         }
     }
 
-    if (sock->has_reconnect_ms && sock->has_reconnect) {
-        error_setg(errp,
-            "'reconnect' and 'reconnect-ms' are mutually exclusive");
-        return false;
-    }
-
     return true;
 }
 
@@ -1384,7 +1378,7 @@ static void qmp_chardev_open_socket(Chardev *chr,
     bool is_tn3270      = sock->has_tn3270  ? sock->tn3270  : false;
     bool is_waitconnect = sock->has_wait    ? sock->wait    : false;
     bool is_websock     = sock->has_websocket ? sock->websocket : false;
-    int64_t reconnect_ms = 0;
+    int64_t reconnect_ms = sock->has_reconnect_ms ? sock->reconnect_ms : 0;
     SocketAddress *addr;
 
     s->is_listen = is_listen;
@@ -1456,12 +1450,6 @@ static void qmp_chardev_open_socket(Chardev *chr,
             return;
         }
     } else {
-        if (sock->has_reconnect) {
-            reconnect_ms = sock->reconnect * 1000ULL;
-        } else if (sock->has_reconnect_ms) {
-            reconnect_ms = sock->reconnect_ms;
-        }
-
         if (qmp_chardev_open_socket_client(chr, reconnect_ms, errp) < 0) {
             return;
         }
@@ -1526,8 +1514,6 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
      */
     sock->has_wait = qemu_opt_find(opts, "wait") || sock->server;
     sock->wait = qemu_opt_get_bool(opts, "wait", true);
-    sock->has_reconnect = qemu_opt_find(opts, "reconnect");
-    sock->reconnect = qemu_opt_get_number(opts, "reconnect", 0);
     sock->has_reconnect_ms = qemu_opt_find(opts, "reconnect-ms");
     sock->reconnect_ms = qemu_opt_get_number(opts, "reconnect-ms", 0);
 
diff --git a/chardev/char.c b/chardev/char.c
index bbebd246c3..a43b7e5481 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -892,9 +892,6 @@ QemuOptsList qemu_chardev_opts = {
         },{
             .name = "nodelay",
             .type = QEMU_OPT_BOOL,
-        },{
-            .name = "reconnect",
-            .type = QEMU_OPT_NUMBER,
         },{
             .name = "reconnect-ms",
             .type = QEMU_OPT_NUMBER,
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index aa300bbd50..ba0be97513 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -438,12 +438,6 @@ Backend ``memory`` (since 9.0)
 
 ``memory`` is a deprecated synonym for ``ringbuf``.
 
-``reconnect`` (since 9.2)
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The ``reconnect`` option only allows specifying second granularity timeouts,
-which is not enough for all types of use cases, use ``reconnect-ms`` instead.
-
 
 Net device options
 ''''''''''''''''''
diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst
index a5338e44c2..d67928956a 100644
--- a/docs/about/removed-features.rst
+++ b/docs/about/removed-features.rst
@@ -1361,4 +1361,16 @@ The ``blacklist`` config file option has been renamed to ``block-rpcs``
 (to be in sync with the renaming of the corresponding command line
 option).
 
+Device options
+--------------
+
+Character device options
+''''''''''''''''''''''''
+
+``reconnect`` (removed in 10.2)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The ``reconnect`` has been replaced by ``reconnect-ms``, which provides
+better precision.
+
 .. _Intel discontinuance notification: https://www.intel.com/content/www/us/en/content-details/781327/intel-is-discontinuing-ip-ordering-codes-listed-in-pdn2312-for-nios-ii-ip.html
diff --git a/qapi/char.json b/qapi/char.json
index f0a53f742c..b07e3bb827 100644
--- a/qapi/char.json
+++ b/qapi/char.json
@@ -269,22 +269,11 @@
 # @websocket: enable websocket protocol on server sockets
 #     (default: false) (Since: 3.1)
 #
-# @reconnect: For a client socket, if a socket is disconnected, then
-#     attempt a reconnect after the given number of seconds.  Setting
-#     this to zero disables this function.  The use of this member is
-#     deprecated, use @reconnect-ms instead.  (default: 0) (Since: 2.2)
-#
 # @reconnect-ms: For a client socket, if a socket is disconnected,
 #     then attempt a reconnect after the given number of milliseconds.
-#     Setting this to zero disables this function.  This member is
-#     mutually exclusive with @reconnect.
+#     Setting this to zero disables this function.
 #     (default: 0) (Since: 9.2)
 #
-# Features:
-#
-# @deprecated: Member @reconnect is deprecated.  Use @reconnect-ms
-#     instead.
-#
 # Since: 1.4
 ##
 { 'struct': 'ChardevSocket',
@@ -297,7 +286,6 @@
             '*telnet': 'bool',
             '*tn3270': 'bool',
             '*websocket': 'bool',
-            '*reconnect': { 'type': 'int', 'features': [ 'deprecated' ] },
             '*reconnect-ms': 'int' },
   'base': 'ChardevCommon' }
 
-- 
2.48.1
Re: [PATCH v2 1/2] chardev: remove deprecated 'reconnect' option
Posted by Daniil Tatianin 4 days, 1 hour ago
On 9/24/25 4:33 PM, Vladimir Sementsov-Ogievskiy wrote:

> It was deprecated in 9.2, time to remove.
>
> Note, that (which become obvious with this commit) we forget to do some
> checks for reconnect-ms options, for example, it was silently ignored
> for listening server, instead of error-out. The commit fixes this, as
> now we use reconnect_ms everywhere.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>

Reviewed-by: Daniil Tatianin <d-tatianin@yandex-team.ru>

> ---
>   chardev/char-socket.c           | 24 +++++-------------------
>   chardev/char.c                  |  3 ---
>   docs/about/deprecated.rst       |  6 ------
>   docs/about/removed-features.rst | 12 ++++++++++++
>   qapi/char.json                  | 14 +-------------
>   5 files changed, 18 insertions(+), 41 deletions(-)
>
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index cb4ec78ebe..62852e3caf 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -1296,9 +1296,9 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
>       /* Validate any options which have a dependency on address type */
>       switch (addr->type) {
>       case SOCKET_ADDRESS_TYPE_FD:
> -        if (sock->has_reconnect) {
> +        if (sock->has_reconnect_ms) {
>               error_setg(errp,
> -                       "'reconnect' option is incompatible with "
> +                       "'reconnect-ms' option is incompatible with "
>                          "'fd' address type");
>               return false;
>           }
> @@ -1342,9 +1342,9 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
>   
>       /* Validate any options which have a dependency on client vs server */
>       if (!sock->has_server || sock->server) {
> -        if (sock->has_reconnect) {
> +        if (sock->has_reconnect_ms) {
>               error_setg(errp,
> -                       "'reconnect' option is incompatible with "
> +                       "'reconnect-ms' option is incompatible with "
>                          "socket in server listen mode");
>               return false;
>           }
> @@ -1361,12 +1361,6 @@ static bool qmp_chardev_validate_socket(ChardevSocket *sock,
>           }
>       }
>   
> -    if (sock->has_reconnect_ms && sock->has_reconnect) {
> -        error_setg(errp,
> -            "'reconnect' and 'reconnect-ms' are mutually exclusive");
> -        return false;
> -    }
> -
>       return true;
>   }
>   
> @@ -1384,7 +1378,7 @@ static void qmp_chardev_open_socket(Chardev *chr,
>       bool is_tn3270      = sock->has_tn3270  ? sock->tn3270  : false;
>       bool is_waitconnect = sock->has_wait    ? sock->wait    : false;
>       bool is_websock     = sock->has_websocket ? sock->websocket : false;
> -    int64_t reconnect_ms = 0;
> +    int64_t reconnect_ms = sock->has_reconnect_ms ? sock->reconnect_ms : 0;
>       SocketAddress *addr;
>   
>       s->is_listen = is_listen;
> @@ -1456,12 +1450,6 @@ static void qmp_chardev_open_socket(Chardev *chr,
>               return;
>           }
>       } else {
> -        if (sock->has_reconnect) {
> -            reconnect_ms = sock->reconnect * 1000ULL;
> -        } else if (sock->has_reconnect_ms) {
> -            reconnect_ms = sock->reconnect_ms;
> -        }
> -
>           if (qmp_chardev_open_socket_client(chr, reconnect_ms, errp) < 0) {
>               return;
>           }
> @@ -1526,8 +1514,6 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
>        */
>       sock->has_wait = qemu_opt_find(opts, "wait") || sock->server;
>       sock->wait = qemu_opt_get_bool(opts, "wait", true);
> -    sock->has_reconnect = qemu_opt_find(opts, "reconnect");
> -    sock->reconnect = qemu_opt_get_number(opts, "reconnect", 0);
>       sock->has_reconnect_ms = qemu_opt_find(opts, "reconnect-ms");
>       sock->reconnect_ms = qemu_opt_get_number(opts, "reconnect-ms", 0);
>   
> diff --git a/chardev/char.c b/chardev/char.c
> index bbebd246c3..a43b7e5481 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -892,9 +892,6 @@ QemuOptsList qemu_chardev_opts = {
>           },{
>               .name = "nodelay",
>               .type = QEMU_OPT_BOOL,
> -        },{
> -            .name = "reconnect",
> -            .type = QEMU_OPT_NUMBER,
>           },{
>               .name = "reconnect-ms",
>               .type = QEMU_OPT_NUMBER,
> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> index aa300bbd50..ba0be97513 100644
> --- a/docs/about/deprecated.rst
> +++ b/docs/about/deprecated.rst
> @@ -438,12 +438,6 @@ Backend ``memory`` (since 9.0)
>   
>   ``memory`` is a deprecated synonym for ``ringbuf``.
>   
> -``reconnect`` (since 9.2)
> -^^^^^^^^^^^^^^^^^^^^^^^^^
> -
> -The ``reconnect`` option only allows specifying second granularity timeouts,
> -which is not enough for all types of use cases, use ``reconnect-ms`` instead.
> -
>   
>   Net device options
>   ''''''''''''''''''
> diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst
> index a5338e44c2..d67928956a 100644
> --- a/docs/about/removed-features.rst
> +++ b/docs/about/removed-features.rst
> @@ -1361,4 +1361,16 @@ The ``blacklist`` config file option has been renamed to ``block-rpcs``
>   (to be in sync with the renaming of the corresponding command line
>   option).
>   
> +Device options
> +--------------
> +
> +Character device options
> +''''''''''''''''''''''''
> +
> +``reconnect`` (removed in 10.2)
> +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> +
> +The ``reconnect`` has been replaced by ``reconnect-ms``, which provides
> +better precision.
> +
>   .. _Intel discontinuance notification: https://www.intel.com/content/www/us/en/content-details/781327/intel-is-discontinuing-ip-ordering-codes-listed-in-pdn2312-for-nios-ii-ip.html
> diff --git a/qapi/char.json b/qapi/char.json
> index f0a53f742c..b07e3bb827 100644
> --- a/qapi/char.json
> +++ b/qapi/char.json
> @@ -269,22 +269,11 @@
>   # @websocket: enable websocket protocol on server sockets
>   #     (default: false) (Since: 3.1)
>   #
> -# @reconnect: For a client socket, if a socket is disconnected, then
> -#     attempt a reconnect after the given number of seconds.  Setting
> -#     this to zero disables this function.  The use of this member is
> -#     deprecated, use @reconnect-ms instead.  (default: 0) (Since: 2.2)
> -#
>   # @reconnect-ms: For a client socket, if a socket is disconnected,
>   #     then attempt a reconnect after the given number of milliseconds.
> -#     Setting this to zero disables this function.  This member is
> -#     mutually exclusive with @reconnect.
> +#     Setting this to zero disables this function.
>   #     (default: 0) (Since: 9.2)
>   #
> -# Features:
> -#
> -# @deprecated: Member @reconnect is deprecated.  Use @reconnect-ms
> -#     instead.
> -#
>   # Since: 1.4
>   ##
>   { 'struct': 'ChardevSocket',
> @@ -297,7 +286,6 @@
>               '*telnet': 'bool',
>               '*tn3270': 'bool',
>               '*websocket': 'bool',
> -            '*reconnect': { 'type': 'int', 'features': [ 'deprecated' ] },
>               '*reconnect-ms': 'int' },
>     'base': 'ChardevCommon' }
>