From nobody Fri Nov 13 01:20:40 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=ovhcloud.com ARC-Seal: i=1; a=rsa-sha256; t=1794240443; cv=none; d=zohomail.com; s=zohoarc; b=blMLoTsEjQTwZdHB+75dY++C6hBAmLw8rVDeh7mjAjQwXt4IX8scJZ51dYxqM0gPdG1N9G+qPSgCesJ3DNFDvzgR0e5jBjZofMp3x4XMgnIJlHnPA5m1HhXvrGrIVLSCIaey+1R+KtLdF2ye9ZJt7df1n3Tz0S33jDygdRwHnTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794240443; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=CuNYb8lq2RSuS41nKf/cOMrqT2czUSWHLncJKXJVnSE=; b=JPO8F57cXccrny5NZkdCdLnkzi890yg3wJ0Hlsy8HVyOKftGldHWxLRQW3NGsN3fPTFeWH30kB9WND9tKAT2QMm4Gy35Mjuk04CsUyxrHHduXHhLgDgPHz83FyuRN6Rle9qzq2ylioRlXnpzCNAfkw0FV/CVUbhGrEzc485tuH4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794240443736622.1334145190907; Mon, 9 Nov 2026 08:07:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQRtY-00057J-7d; Mon, 09 Nov 2026 11:06:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQRtR-00055O-0N; Mon, 09 Nov 2026 11:06:50 -0500 Received: from 1.mo508.mail-out.ovh.net ([5.135.90.176]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQRtO-0005QB-2w; Mon, 09 Nov 2026 11:06:48 -0500 Received: from DAGFR11EX3.OVH.local (unknown [10.110.54.187]) by mo508.mail-out.ovh.net (Postfix) with ESMTPS id 4jNZQy5vLcz7tDX; Mon, 9 Nov 2026 16:06:34 +0000 (UTC) Received: from ovhcloud.com (109.190.254.61) by DAGFR11EX3.OVH.local (172.16.2.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Mon, 9 Nov 2026 17:06:34 +0100 From: Guillaume Vincke To: CC: , , , , , , Guillaume Vincke Subject: [PATCH 1/2] nbd: Add an unstable query for the client state Date: Mon, 9 Nov 2026 17:06:08 +0100 Message-ID: <20261109160609.1434289-2-guillaume.vincke@ovhcloud.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109160609.1434289-1-guillaume.vincke@ovhcloud.com> References: <20261109160609.1434289-1-guillaume.vincke@ovhcloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [109.190.254.61] X-ClientProxiedBy: CAS4.OVH.local (172.16.1.4) To DAGFR11EX3.OVH.local (172.16.2.113) X-OVH-CORPLIMIT-SKIP: true x-ovh-tracer-id: 17260608524438225336 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: dmFkZTFP/HMCIPMJK4Fn1LSeHOUwlD4FYOZfx9NtiC+yIw3TvKlgPFr0oV+sXnY6O6ogoIlp4T+QFuidJ15usu5lPJF/QFIQ2x1Xep+q3BDawkTePFEG7vZsSmYbOmb8hWp5RP7ABlosQvRHG2Dw07zXMJfbwR1581InlYbpRHFHumVuMrd3PdUpdLVCnsm0JAMPHObY++5cGOT4U5i7jXlvy5lpaqlQnRMn1wj5k2pXibit82JSx8yOA41kQMKfeYrSjGxJQVp4SlAheU/ZrF3KyfTtqzAp8wcrU9GZRYWIJWbSx0MQEfGmuDRbw4HUodIkWwV25IEsQ9Ud172fJ9ILI1UCpZGr3W5oCzymRNCnq0SIIV6XkA//VquRqGegUuT7+MY+razSrZcyVhh6KGwZCPU4lbCaql106fQJ9b39Y0BICHndo3zQkzidvfpDTNce26w8ujJq0MEVGpN4NTdd9EZFUltAJdw3fZIE4h5qOpwpzM5LlQe6dgtHMySH5JArKmUsYCJ4lxyL3ClyMx1HL/fQyceYW1v1vClubaZnfAJ86Hycz3Lh1mTwQ9COUUcmswdQQ3eceO69Oi3MB5jXgkM7/5aCskr4bpf1Ec3BWrYQNxy8tWkcuX3nQn1zMmLszGcEWo4XoBqoSSYecrTdzgzzvLTOXrdEoBjjFXiipjUT9g DKIM-Signature: a=rsa-sha256; bh=CuNYb8lq2RSuS41nKf/cOMrqT2czUSWHLncJKXJVnSE=; c=relaxed/relaxed; d=ovhcloud.com; h=From; s=mailout; t=1794240395; v=1; b=aEuapToEGpm6dYGWgQ0XjEpuKoNf0MudHyNZvVOBylNaIcxAMbCCeLzTyKEcvFQWKb8r2wDf 9lYvsm9gJlXRaP8AZDfYqlV2G/uJEsGLgTPzOx3l/R2PBl4Pu3I5hJCro0+Rnu0jzLbww5sHF5C ZKg+oOyrkU6dHRyOfT/K9QIg= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.135.90.176; envelope-from=guillaume.vincke@ovhcloud.com; helo=1.mo508.mail-out.ovh.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: guillaume.vincke@ovhcloud.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ovhcloud.com) X-ZM-MESSAGEID: 1794240447886158500 Content-Type: text/plain; charset="utf-8" At the moment, NBD client internals cannot be accessed. Therefore, tests have to infer the client state from I/O results and wait with sleeps, which is racy. Add the x-debug-query-nbd-client QMP command that reports the state of the client's connection and of its connector. Other fields will be added when needed. The next patch uses this command to make the nbd-stale-connection test deterministic. Signed-off-by: Guillaume Vincke --- block/nbd.c | 57 +++++++++++++++++++++++++++++ include/block/nbd.h | 9 +++++ nbd/client-connection.c | 18 ++++++++++ qapi/block-core.json | 79 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 163 insertions(+) diff --git a/block/nbd.c b/block/nbd.c index e5e16722ba..b9f8d92e43 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -35,9 +35,11 @@ #include "qemu/cutils.h" #include "qemu/main-loop.h" =20 +#include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-visit-sockets.h" #include "qobject/qstring.h" #include "qapi/clone-visitor.h" +#include "qapi/error.h" =20 #include "block/qdict.h" #include "block/nbd.h" @@ -2246,6 +2248,61 @@ static BlockDriver bdrv_nbd_unix =3D { .bdrv_detach_aio_context =3D nbd_detach_aio_context, }; =20 +XDbgNbdClient *qmp_x_debug_query_nbd_client(const char *node_name, + Error **errp) +{ + BlockDriverState *bs; + BDRVNBDState *s; + XDbgNbdClient *info; + + bs =3D bdrv_find_node(node_name); + if (!bs) { + error_setg(errp, "Node '%s' not found", node_name); + return NULL; + } + + if (bs->drv !=3D &bdrv_nbd && + bs->drv !=3D &bdrv_nbd_tcp && + bs->drv !=3D &bdrv_nbd_unix) { + error_setg(errp, "Node '%s' is not an NBD client", node_name); + return NULL; + } + + s =3D bs->opaque; + info =3D g_new0(XDbgNbdClient, 1); + WITH_QEMU_LOCK_GUARD(&s->requests_lock) { + switch (s->state) { + case NBD_CLIENT_CONNECTING_WAIT: + info->state =3D XDBG_NBD_CLIENT_STATE_CONNECTING_WAIT; + break; + case NBD_CLIENT_CONNECTING_NOWAIT: + info->state =3D XDBG_NBD_CLIENT_STATE_CONNECTING_NOWAIT; + break; + case NBD_CLIENT_CONNECTED: + info->state =3D XDBG_NBD_CLIENT_STATE_CONNECTED; + break; + case NBD_CLIENT_QUIT: + info->state =3D XDBG_NBD_CLIENT_STATE_QUIT; + break; + } + } + + switch (nbd_client_connection_get_thread_state(s->conn)) { + case NBD_CLIENT_CONNECTION_THREAD_IDLE: + break; + case NBD_CLIENT_CONNECTION_THREAD_RUNNING: + info->connector =3D g_new0(XDbgNbdClientConnector, 1); + info->connector->state =3D XDBG_NBD_CLIENT_CONNECTOR_STATE_RUNNING; + break; + case NBD_CLIENT_CONNECTION_THREAD_PARKED: + info->connector =3D g_new0(XDbgNbdClientConnector, 1); + info->connector->state =3D XDBG_NBD_CLIENT_CONNECTOR_STATE_PARKED; + break; + } + + return info; +} + static void bdrv_nbd_init(void) { bdrv_register(&bdrv_nbd); diff --git a/include/block/nbd.h b/include/block/nbd.h index ab40842da9..15ddec91ac 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -492,6 +492,15 @@ const char *nbd_mode_lookup(NBDMode mode); /* nbd/client-connection.c */ void nbd_client_connection_enable_retry(NBDClientConnection *conn); =20 +typedef enum NBDClientConnectionThreadState { + NBD_CLIENT_CONNECTION_THREAD_IDLE, + NBD_CLIENT_CONNECTION_THREAD_RUNNING, + NBD_CLIENT_CONNECTION_THREAD_PARKED, +} NBDClientConnectionThreadState; + +NBDClientConnectionThreadState +nbd_client_connection_get_thread_state(NBDClientConnection *conn); + NBDClientConnection *nbd_client_connection_new(const SocketAddress *saddr, bool do_negotiation, const char *export_name, diff --git a/nbd/client-connection.c b/nbd/client-connection.c index aec62934d1..7172ba49b3 100644 --- a/nbd/client-connection.c +++ b/nbd/client-connection.c @@ -78,6 +78,24 @@ void nbd_client_connection_enable_retry(NBDClientConnect= ion *conn) conn->do_retry =3D true; } =20 +NBDClientConnectionThreadState +nbd_client_connection_get_thread_state(NBDClientConnection *conn) +{ + NBDClientConnectionThreadState ret; + + WITH_QEMU_LOCK_GUARD(&conn->mutex) { + if (conn->running) { + ret =3D NBD_CLIENT_CONNECTION_THREAD_RUNNING; + } else if (conn->sioc) { + ret =3D NBD_CLIENT_CONNECTION_THREAD_PARKED; + } else { + ret =3D NBD_CLIENT_CONNECTION_THREAD_IDLE; + } + } + + return ret; +} + NBDClientConnection *nbd_client_connection_new(const SocketAddress *saddr, bool do_negotiation, const char *export_name, diff --git a/qapi/block-core.json b/qapi/block-core.json index 23c5787d99..973be06dfd 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2217,6 +2217,85 @@ 'features': [ 'unstable' ], 'allow-preconfig': true } =20 +## +# @XDbgNbdClientState: +# Enum of NBD client state. +# +# @connecting-wait: No active connection. A request waits for the +# connection attempt to finish, while reconnect-delay has not +# expired. +# +# @connecting-nowait: No active connection. A request fails at once +# if no channel is ready. +# +# @connected: Client has a valid connection. +# +# @quit: Client will not reconnect. +# +# Since: 11.2 +## +{ 'enum': 'XDbgNbdClientState', + 'data': [ 'connecting-wait', 'connecting-nowait', 'connected', 'quit' ] } + +## +# @XDbgNbdClientConnectorState: +# Enum of NBD client connector state. +# +# @running: Connection attempt is in progress. +# +# @parked: Connection was successful and channel is kept for the next +# request. +# +# Since: 11.2 +## +{ 'enum': 'XDbgNbdClientConnectorState', + 'data': [ 'running', 'parked' ] } + +## +# @XDbgNbdClientConnector: +# The NBD connector information. +# +# @state: State of the connector. +# +# Since: 11.2 +## +{ 'struct': 'XDbgNbdClientConnector', + 'data': { 'state': 'XDbgNbdClientConnectorState' } } + +## +# @XDbgNbdClient: +# The NBD connection state of the client and its connector. +# The two members are read independently and may not reflect a +# single point in time. +# +# @state: The client state. +# +# @connector: The connector details. Only present while a connection +# attempt is running or its channel is parked. +# +# Since: 11.2 +## +{ 'struct': 'XDbgNbdClient', + 'data': { 'state': 'XDbgNbdClientState', + '*connector': 'XDbgNbdClientConnector' } } + +## +# @x-debug-query-nbd-client: +# Get the NBD client state. +# +# @node-name: node name of the NBD client to query. +# +# Features: +# +# @unstable: This command is meant for debugging and testing. +# +# Since: 11.2 +## +{ 'command': 'x-debug-query-nbd-client', + 'data': { 'node-name': 'str' }, + 'returns': 'XDbgNbdClient', + 'features': [ 'unstable' ] } + ## # @drive-mirror: # Start mirroring a block device's writes to a new destination. --=20 2.43.0 From nobody Fri Nov 13 01:20:40 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=ovhcloud.com ARC-Seal: i=1; a=rsa-sha256; t=1794240482; cv=none; d=zohomail.com; s=zohoarc; b=FyXfb5VIrtlEPI2g6LFpLQQYmy3hrBnry+AkICfcoeQepreF2l5FCObJkbcczSCsz4/pazI7rmmy4AXhcpA5BTJExYEyBgOP3OAzwILO1hbP0fW7FFUxqzFTohvEI80PfjN0tMB+QMuevfNT6KjIxqiSPonDgx2/Skk6f8jko0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794240482; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=e2Qy73SEZVWTtCgn2HWdQg5ILHswMSTZxXJsa0J+J0o=; b=cs4oT3P5Lk193f9Hza6yi9vv0h2ecPp4s1i7k4bZ3wrEq0lNL4DdiU31Yh+K6io515Y/CMhW4LwFtNdghqjXA2YUJK8iTgoxmV0OQiiDWJGTJ6REtXYqxO3z1K84qJvnsx5bC2nBMpV8hcUJznySxh3YBYaL1DCkWUIdc4+wTLc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794240482233890.5312379909318; Mon, 9 Nov 2026 08:08:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQRtV-00055g-2P; Mon, 09 Nov 2026 11:06:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQRtQ-00054v-Kw for qemu-devel@nongnu.org; Mon, 09 Nov 2026 11:06:48 -0500 Received: from 1.mo508.mail-out.ovh.net ([5.135.90.176]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQRtN-0005QC-Oz for qemu-devel@nongnu.org; Mon, 09 Nov 2026 11:06:48 -0500 Received: from DAGFR11EX3.OVH.local (unknown [10.110.0.226]) by mo508.mail-out.ovh.net (Postfix) with ESMTPS id 4jNZQz1xpwz7tDb; Mon, 9 Nov 2026 16:06:35 +0000 (UTC) Received: from ovhcloud.com (109.190.254.61) by DAGFR11EX3.OVH.local (172.16.2.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Mon, 9 Nov 2026 17:06:34 +0100 From: Guillaume Vincke To: CC: , , , , , , Guillaume Vincke Subject: [PATCH 2/2] iotests: Make nbd-stale-connection test deterministic Date: Mon, 9 Nov 2026 17:06:09 +0100 Message-ID: <20261109160609.1434289-3-guillaume.vincke@ovhcloud.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109160609.1434289-1-guillaume.vincke@ovhcloud.com> References: <20261109160609.1434289-1-guillaume.vincke@ovhcloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [109.190.254.61] X-ClientProxiedBy: CAS4.OVH.local (172.16.1.4) To DAGFR11EX3.OVH.local (172.16.2.113) X-OVH-CORPLIMIT-SKIP: true x-ovh-tracer-id: 17260890000062235064 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: dmFkZTFP/HMCIPMJK4Fn1LSeHOUwlD4FYOZfx9NtiC+yIw3TvKlgPFr0oV+sXnY6O6ogoIlp4T+QFuidJ15usu5lPJF/QFIQ2x1Xep+q3BDawkTePFEG7vZsSmYbOmb8hWp5RP7ABlosQvRHG2Dw07zXMJfbwR1581InlYbpRHFHumVuMrd3PdUpdLVCnsm0JAMPHObY++5cGOT4U5i7jXlvy5lpaqlQnRMn1wj5k2pXibit82JSx8yOA41kQMKfeYrSjGxJQVp4SlAheU/ZrF3KyfTtqzAp8wcrU9GZRYWIJWbSx0MQEfGmuDRbw4HUodIkWwV25IEsQ9Ud172fJ9ILI1UCNfILjCQWsxfE/6xZ2+LpPzmlnVVUvB2xIfvwoZBCDpntUCA7cBRBSx7lFuYFwvH+LaNyFvwLeK9JYDm5pa/HvZwrhFNWL3nnuL5W+gLc3iGWRoWV8uLR9F2KER6FgXr1K+5rsjaLaFreskLPq43GKP0A/UzlxGK98twPHBxdi0bBXApKTavMsorhSRyZI8/GrbgDXKu7VbQcCeNBcYTdimy3a2syyn2OUwcy14NDpkGWC8V0kJGDa3PGcTagTEmvuuUpTRVO71QY0ITflduGUi4NBtKXRNOxeTRQ4haLbSdKOpN6BGqQ9s2CAtblK9xJmLaSNMAntmuN294TQT3FRw DKIM-Signature: a=rsa-sha256; bh=e2Qy73SEZVWTtCgn2HWdQg5ILHswMSTZxXJsa0J+J0o=; c=relaxed/relaxed; d=ovhcloud.com; h=From; s=mailout; t=1794240395; v=1; b=mW7hMPSdjnAVaC4LGGN6kLh/0IszdGJqNU9eddJSnEH85XjLcbbCQe4Je6On7W9gGMLfNAxD KrH+tK6bSoTjGRTe41UOn3Mtf/pP6HBqiPFQG3RaR2UmbRJoVAZktvip/1LdZ75KwAGh6JvNtI1 gjI8OIeLFcIEKrVlhdc7jZvk= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=5.135.90.176; envelope-from=guillaume.vincke@ovhcloud.com; helo=1.mo508.mail-out.ovh.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: guillaume.vincke@ovhcloud.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ovhcloud.com) X-ZM-MESSAGEID: 1794240483836158500 Content-Type: text/plain; charset="utf-8" At the moment, the test sleeps to wait for the connector to park a new channel, which can fail on slow or loaded hosts. Poll the x-debug-query-nbd-client command to verify the current state instead of relying on timing. Signed-off-by: Guillaume Vincke --- tests/qemu-iotests/tests/nbd-stale-connection | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/tests/nbd-stale-connection b/tests/qemu-iot= ests/tests/nbd-stale-connection index e361bccfa9..265e18adcf 100755 --- a/tests/qemu-iotests/tests/nbd-stale-connection +++ b/tests/qemu-iotests/tests/nbd-stale-connection @@ -12,14 +12,21 @@ import iotests from iotests import qemu_nbd_popen, qemu_img_create, file_path, log =20 =20 -# estimated duration required by the connect thread to reach a running ser= ver -MAX_NBD_CONNECT_DURATION =3D 1 - iotests.script_initialize(supported_fmts=3D['qcow2']) nbd_sock =3D file_path('nbd-sock', base_dir=3Diotests.sock_dir) disk =3D file_path('disk') qemu_img_create('-f', iotests.imgfmt, disk, '1M') =20 + +def wait_for_parked_connection(virtm, node_name): + with iotests.Timeout(30, "connect-thread did not reach 'parked' state"= ): + while True: + client =3D virtm.qmp('x-debug-query-nbd-client', node_name=3Dn= ode_name) + if client['return'].get('connector', {}).get('state') =3D=3D '= parked': + return + time.sleep(0.1) + + with iotests.VM() as vm: =20 vm.launch() @@ -44,7 +51,7 @@ with iotests.VM() as vm: # in CONNECTING, the operation starts the connect thread log(vm.qmp('x-qemu-io', device=3D'nbd0', command=3D'write -P 0x5a = 0 64k')) # wait for the connect thread to get a new channel and stop - time.sleep(MAX_NBD_CONNECT_DURATION) + wait_for_parked_connection(vm, 'nbd0') =20 iotests.log('=3D=3D=3D NBD server down. The parked channel is closed = =3D=3D=3D') =20 @@ -56,5 +63,5 @@ with iotests.VM() as vm: # Wait for it to succeed iotests.log('=3D=3D=3D Wait for the connect thread to park the new= channel. ' 'Subsequent operations are successful =3D=3D=3D') - time.sleep(MAX_NBD_CONNECT_DURATION) + wait_for_parked_connection(vm, 'nbd0') log(vm.qmp('x-qemu-io', device=3D'nbd0', command=3D'write -P 0x5a = 0 64k')) --=20 2.43.0