On 02.10.24 16:49, Markus Armbruster wrote:
Eric Blake <ebl...@redhat.com> writes:

Although defaulting the handshake limit to 10 seconds was a nice QoI
change to weed out intentionally slow clients, it can interfere with
integration testing done with manual NBD_OPT commands over 'nbdsh
--opt-mode'.  Expose a QMP knob 'handshake-max-secs' to allow the user
to alter the timeout away from the default.

The parameter name here intentionally matches the spelling of the
constant added in commit fb1c2aaa98, and not the command-line spelling
added in the previous patch for qemu-nbd; that's because in QMP,
longer names serve as good self-documentation, and unlike the command
line, machines don't have problems generating longer spellings.

Signed-off-by: Eric Blake <ebl...@redhat.com>
---
  qapi/block-export.json         | 10 ++++++++++
  include/block/nbd.h            |  6 +++---
  block/monitor/block-hmp-cmds.c |  4 ++--
  blockdev-nbd.c                 | 26 ++++++++++++++++++--------
  4 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/qapi/block-export.json b/qapi/block-export.json
index ce33fe378df..c110dd375ad 100644
--- a/qapi/block-export.json
+++ b/qapi/block-export.json
@@ -17,6 +17,10 @@
  #
  # @addr: Address on which to listen.
  #
+# @handshake-max-secs: Time limit, in seconds, at which a client that
+#     has not completed the negotiation handshake will be disconnected,
+#     or 0 for no limit (since 9.2; default: 10).
+#
  # @tls-creds: ID of the TLS credentials object (since 2.6).
  #
  # @tls-authz: ID of the QAuthZ authorization object used to validate
@@ -34,6 +38,7 @@
  ##
  { 'struct': 'NbdServerOptions',
    'data': { 'addr': 'SocketAddress',
+            '*handshake-max-secs': 'uint32',
              '*tls-creds': 'str',
              '*tls-authz': 'str',
              '*max-connections': 'uint32' } }
@@ -52,6 +57,10 @@
  #
  # @addr: Address on which to listen.
  #
+# @handshake-max-secs: Time limit, in seconds, at which a client that
+#     has not completed the negotiation handshake will be disconnected,
+#     or 0 for no limit (since 9.2; default: 10).
+#
  # @tls-creds: ID of the TLS credentials object (since 2.6).
  #
  # @tls-authz: ID of the QAuthZ authorization object used to validate
@@ -72,6 +81,7 @@
  ##
  { 'command': 'nbd-server-start',
    'data': { 'addr': 'SocketAddressLegacy',
+            '*handshake-max-secs': 'uint32',
              '*tls-creds': 'str',
              '*tls-authz': 'str',
              '*max-connections': 'uint32' },

Are we confident we'll never need less than a full second?


Hmm, recent "[PATCH v2] chardev: introduce 'reconnect-ms' and deprecate 
'reconnect'" shows that at least sometimes second is not enough precision.

Maybe, using milliseconds consistently for all relatively short time intervals 
in QAPI would be a good rule?

--
Best regards,
Vladimir


Reply via email to