From patchwork Wed Dec 22 18:52:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697186 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 041A0C433EF for ; Wed, 22 Dec 2021 18:59:20 +0000 (UTC) Received: from localhost ([::1]:57088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n06pc-0000jA-3c for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 13:59:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jf-00083K-Gu; Wed, 22 Dec 2021 13:53:11 -0500 Received: from mail-vi1eur05on2137.outbound.protection.outlook.com ([40.107.21.137]:20601 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jc-0004am-IT; Wed, 22 Dec 2021 13:53:10 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gJ6Q1RuAxkpcAaDM2qTmxFoCkZFfSO9OXq+GNiQfj0XiJclOokH4g7yuhiOQ/WVA7H9UfdIDMoipOLq3FLSnxreeLeioHcYIeoy4rYxf4b9KoPtuhlHb1oFhyIpIUW3nGdG46JrcHEHc0BNbRbw5PyOBZda31PVu0D4UkZEtH9cbuUWkxGn07lvNx/c4yx5b0lX/6JQT8Z4hhjqBFNBBzvqjvFO5bJ5uZV8gu41V+CxalPj45gUOG+ZwyoKg0nNGp2YvqAC+5Jv4fJN7ILY43r5llFL6p/HDNqvFfc4JyUTIIEWUGhkyWU/JictPl5usEQ4L62wRjk7bzpVyh9djgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VavSDBMwSDdH8AXDwSgAmWw98hO6nMUhGhE0g+6XmNI=; b=avCy7HIN6kBFxKfOt05LKZ9H2ZOIf7ZOe4qReVswsDIQq4QIrqGMLS0qDUXpXzm1R2fnjpR4P37aDKwIAHo6llJQD39jX5Sv1VkMSYlatHm6qYnFV3dd49S9VJLjClEAxmnZQnHk0nOm7SDM1NP0o00zL8DAgCaXWDW/3osMpb0ruTP/C5PvxjhSDxhw76fbPMhIsFsGcC9fgKnXDdjhcRiUdSqba6YfJpQR071sN5CUfctLHi48GftPYfbGLrpMLwqFpL7BAaH91xkBFIkzS+fND0TtRo9Wm0fDCy4O+B3Y9E0X5B5sa/Av6nKdSycUjwRM7Vw2sOqPDr9x+5BStg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VavSDBMwSDdH8AXDwSgAmWw98hO6nMUhGhE0g+6XmNI=; b=D4uBL32CFjS+EQXyUWjWLK/k4Lg1zoZZLb4sxjVnX0gnzOoAguHGXPl3nRub/MG+8p5CVprg4JZMjEsdnj/pkZ2IFo8bOGXIsvtuzhHCuOhaJKNUYm6Js9GsRS6V9D90013mqwDj/jZkaLQltEV59Aa11+ig7ydvIZW8erd8k6U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM8PR08MB5857.eurprd08.prod.outlook.com (2603:10a6:20b:1d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.16; Wed, 22 Dec 2021 18:53:01 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112%5]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 18:53:01 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, qemu-devel@nongnu.org Subject: [PULL 1/7] nbd: allow reconnect on open, with corresponding new options Date: Wed, 22 Dec 2021 19:52:42 +0100 Message-Id: <20211222185248.466010-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222185248.466010-1-vsementsov@virtuozzo.com> References: <20211222185248.466010-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM7PR02CA0009.eurprd02.prod.outlook.com (2603:10a6:20b:100::19) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 823421bd-2696-495d-1f7c-08d9c57c4757 X-MS-TrafficTypeDiagnostic: AM8PR08MB5857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:126; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8Cr5quxcRoLLcuJLpQVcLL25/VmxqUMuBJ+lD0pMFcTInnt4QfbBQ03sK1G6QP2WzfIBi6PO3A+cY2+GSCSRN7o+rx19lT3B1O46j6649fRZYvNokUlrHuOyePOXxzr0IppMfo3osV7c0SuEI5GztBUstD3pfuxNN/0Ph+fMGwp3HvPFLNwxAmQ2ydhh2JNQI9TPtib5ogqjSMPRAnnzHQFUjXf4BZH8OnZrAicV8jS13m3Sbl+LsuMFkqXXqJCgATG73uCvVOEUTQtciR4boczZm4pmXnLHbmp1cduHR8Rw3eYlf7QqdQljwLwjSkHf3j5Pv9apQvA0cW2CoO6Og6vKQyjeAGPaA3c+CyZi9zQFyiOKDpU9QXmJGH6dZ95B3A4FOQKTZvMGWuW/OGdV2jgsY26BYIEG/QwSB3osKT/V+JQbA1XWQ5VM/OLWSqwru1HP8s9ShZ2VmSz9e1BWg1g6RAn/6uFQETsfanocJXjxyMv4/7As0TlIBEFlkjrMGon5V+yzRHgXioF2U1FAwnVWARC4zmTNYjT6JP1Khe5UIHAlmvFTprda/jGk9NmESdEnAk6tJIIcvT6PDKCXnBJDnKmgnm5DriJDZtbWsYBgURCicyiZyQ5UiHMZAP0f3k+DCzlozD/ubyucwJOQPDtVOMq9ZNDoirZKL+lzJMD+n9XmauVE7aUKcji/HxHGFcOzHUArIL6AkOQHyO72zQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(2616005)(6512007)(4326008)(6486002)(38350700002)(38100700002)(6506007)(83380400001)(66556008)(66476007)(36756003)(26005)(66946007)(5660300002)(8676002)(8936002)(186003)(6666004)(6916009)(2906002)(52116002)(86362001)(508600001)(316002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hbt0HQb+Lxnwn45QTrTsTAtoi1YbGHexYos+ctgWsr9Nn34/vqTSnZPhY3KLY7t7S34bC2fogom+5AeX0Qq50EmJyFOoG2gf+3a9Xm+ZHmqgtFiu7VQePtTuVxcwL2L92IvMXP3tHKVBU9MlVO2qBoGZN0/pYst5ngg/U7JWnHS/XaHGLm1BrKszNjQ5o9l5WgANRcVBXu+U7q61AO8VgVanmSlX3JP9gODVzn3llFZXDer//ZOpc6ELShJiDLbOVZq+h3zI+PWmxxu4TC3TdYNsISWVusCCR77NgNH/sV3skSybZZOGZK4RD5S/54c0s2apYr+AeOlDr8FRDo5EM9ADSWRjAyJw8hmVeD8sY+NVdFn00nsswCuZ0Oigide779aCAru4eg2s/MNqw6tuVubpOnYJVxCDZX2A+6IkP6iEpP2eSBDGkDZI/2Q2O10hvHSMYGZwsFyIGmslhL9du3n/pIKAA4u4j/ZMWb9c72Txos3V9VJbHeZGXKjwIhMzLy9i6V3qiDW+Rg7G9mUsfzinwXehXvoXOQOcUz9KcGAdOpzjK4xp19/KYsY8fto+xjimGM5L3I7CefBU+x5CMjNPGlO8/3eFjDXAKh/yfD7+NhUCzHO8NwjrWszKmVAfXBlp5HMVERk7JcWgKxSmFim1jGXavJoqZETjl67Bz6UZUPtBE7N09Ul8EUB3lpHlWZXBkNCYZ7uGo0hBwH/UJ1sW6YADxQ3CHv9lQrO5tp9gV2+GtVVOptQxdczzt/KPZC+VZBBts4bBipj8GWcCy1sHyA7bXFdmHU7LJIFQI/EmQOPTWNEcZrSSyQzhlh8nKteyj7ubEX1QLDIuSz5VcYJKDS6DKb4zpg1DW0QBMT1q7ru8UHzj3sc3o3aX8EXGezvT7eEfNAurYN+aT8i6V20WtLBek9EKJ3UoeD6fSE3QzMws5pWFXNrYOUSKqqF5ah0kwFVjcszR1I4ZvR8AwUzRpWwQ6mLFUiDbRlCr9UCH/iYvVWm/Ylhnz4QA8Q7NI/8Gu4zJaOmfd1efOxV/NCMXgfbCDDJtIgcVps2KnvazLH7WVFAJaWaPdfXRjuT1j3rkKd/GkNrlBc3tOqltFjj1lc6GVNW21rULeuc8pehUynBmD5rj2DBz8UBR83/gkhvAHACHv+BgX+dZtYUGhXa8tDoActG2gzcxkLWnD/rYpzu95RkI7Z1FLm8DjdgX+2q6oHlucDkfXHsrJ8wEt/kW/GwwqB/cyHeODmhQSeo11a5BtwtaMWvoiCLQn1WUxRn/r36lAkIvgaCJSaW6eXPJjFmEPCbkgnCtVhbPuufzd3nOLX+VMkbtZc0iJrpkdybgCpz28ua9k5v+e5XiFUW1KHHfFShxZDflxLSfaloIgnram1vo7g576SRUvf3lRWU04uOwQgusHv4XBk9jigHaSpNQ0n41vT8oJnA45mGDgC9PI3+KeYgJmEvqdI+8TIwDrVbz0EWNuVAycTWrmcIxrUYAQjpm9Wf29hpWn/gLpvfv0m5cQ3aylmVVU/S1IC1NXsHuegwyRGAqjJ73eqBKp/cmd/N0vGCs03CQe4lESeJOc4PIz2YFArL8GdHDvDtJPtP+VZytm1ndcoOza7ZGbG3Tr5PUSqRZPP4/QXeF6uXeKkqOSIMFqeS+8fLfnbrJeGVF4jxCVJiMcthEEIjPP+3eN+RNZ8LwbtZvoGQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 823421bd-2696-495d-1f7c-08d9c57c4757 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 18:53:01.4706 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 52+1wWSsalGrn7tQEprIUFsWr1TxcGprSitOmbeEkZdvEnDn//KRo42zpxb2CrtDzKertG5+BfGfr6aoOqfiQvghzRZwDk8MBq0Vda5zDSo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5857 Received-SPF: pass client-ip=40.107.21.137; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It is useful when start of vm and start of nbd server are not simple to sync. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- qapi/block-core.json | 9 ++++++++- block/nbd.c | 45 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 1d3dd9cb48..bd0b285245 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4096,6 +4096,12 @@ # future requests before a successful reconnect will # immediately fail. Default 0 (Since 4.2) # +# @open-timeout: In seconds. If zero, the nbd driver tries the connection +# only once, and fails to open if the connection fails. +# If non-zero, the nbd driver will repeat connection attempts +# until successful or until @open-timeout seconds have elapsed. +# Default 0 (Since 7.0) +# # Features: # @unstable: Member @x-dirty-bitmap is experimental. # @@ -4106,7 +4112,8 @@ '*export': 'str', '*tls-creds': 'str', '*x-dirty-bitmap': { 'type': 'str', 'features': [ 'unstable' ] }, - '*reconnect-delay': 'uint32' } } + '*reconnect-delay': 'uint32', + '*open-timeout': 'uint32' } } ## # @BlockdevOptionsRaw: diff --git a/block/nbd.c b/block/nbd.c index 5ef462db1b..63dbfa807d 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -80,6 +80,7 @@ typedef struct BDRVNBDState { NBDClientState state; QEMUTimer *reconnect_delay_timer; + QEMUTimer *open_timer; NBDClientRequest requests[MAX_NBD_REQUESTS]; NBDReply reply; @@ -87,6 +88,7 @@ typedef struct BDRVNBDState { /* Connection parameters */ uint32_t reconnect_delay; + uint32_t open_timeout; SocketAddress *saddr; char *export, *tlscredsid; QCryptoTLSCreds *tlscreds; @@ -218,6 +220,32 @@ static void nbd_teardown_connection(BlockDriverState *bs) s->state = NBD_CLIENT_QUIT; } +static void open_timer_del(BDRVNBDState *s) +{ + if (s->open_timer) { + timer_free(s->open_timer); + s->open_timer = NULL; + } +} + +static void open_timer_cb(void *opaque) +{ + BDRVNBDState *s = opaque; + + nbd_co_establish_connection_cancel(s->conn); + open_timer_del(s); +} + +static void open_timer_init(BDRVNBDState *s, uint64_t expire_time_ns) +{ + assert(!s->open_timer); + s->open_timer = aio_timer_new(bdrv_get_aio_context(s->bs), + QEMU_CLOCK_REALTIME, + SCALE_NS, + open_timer_cb, s); + timer_mod(s->open_timer, expire_time_ns); +} + static bool nbd_client_connecting(BDRVNBDState *s) { NBDClientState state = qatomic_load_acquire(&s->state); @@ -1742,6 +1770,15 @@ static QemuOptsList nbd_runtime_opts = { "future requests before a successful reconnect will " "immediately fail. Default 0", }, + { + .name = "open-timeout", + .type = QEMU_OPT_NUMBER, + .help = "In seconds. If zero, the nbd driver tries the connection " + "only once, and fails to open if the connection fails. " + "If non-zero, the nbd driver will repeat connection " + "attempts until successful or until @open-timeout seconds " + "have elapsed. Default 0", + }, { /* end of list */ } }, }; @@ -1797,6 +1834,7 @@ static int nbd_process_options(BlockDriverState *bs, QDict *options, } s->reconnect_delay = qemu_opt_get_number(opts, "reconnect-delay", 0); + s->open_timeout = qemu_opt_get_number(opts, "open-timeout", 0); ret = 0; @@ -1828,7 +1866,12 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, s->conn = nbd_client_connection_new(s->saddr, true, s->export, s->x_dirty_bitmap, s->tlscreds); - /* TODO: Configurable retry-until-timeout behaviour. */ + if (s->open_timeout) { + nbd_client_connection_enable_retry(s->conn); + open_timer_init(s, qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + + s->open_timeout * NANOSECONDS_PER_SECOND); + } + s->state = NBD_CLIENT_CONNECTING_WAIT; ret = nbd_do_establish_connection(bs, errp); if (ret < 0) { From patchwork Wed Dec 22 18:52:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697184 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23404C433F5 for ; Wed, 22 Dec 2021 18:58:24 +0000 (UTC) Received: from localhost ([::1]:55380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n06oh-0007yh-4t for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 13:58:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jg-00088Z-Ul; Wed, 22 Dec 2021 13:53:12 -0500 Received: from mail-vi1eur05on2113.outbound.protection.outlook.com ([40.107.21.113]:12544 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jb-0004aJ-EP; Wed, 22 Dec 2021 13:53:12 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SmVJuAhic2R1SoPU9AIHOVaP4zrAeqefTpzJZ3UZQgacYNTEKG/Y2o+A31l9yNIJ1iVptQW9vSm5wK7Ygvlbt30G/rlShL0unTlJS0EfrjAI+COlQKhXWsgA61sEMktDIxIZkzmqU4wVf8oLkw5CCr8ZSwok5ZvfR+PCFsuO3DkDeUYAUMFt870bMX0T8stVADQQxP+YVseH8zpsiiErvgP/vpFpcPUVP7gqknE59oR/LQNxUmbFUxEeBAb3UcpHW00XJpCOcASDw5Ntt9dx8YJWLkIGkxMoZmKV0+uUjvvQ7rfchi77Ic4qQeG7SLSVufOTzoAlf46S4zZHdErv4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tc0+E9eGSwi101ON3B9m0vzebc/w4yXDSCrhG9Lhck8=; b=gyh8LpwBUTumRo1PoTQ2xAmkr2O4i7lIiln3etaRrqUdTD4HWKbeeX+x5PC4BxlSzTJWjqpSTzY/ec0siJoBtenROy9QCyoFdM8NX1wrJmCUcKf7JoaQNQJd6CVHAOUbLtJts7ooGSyYs7fOGDkFdwud+rVYX6vUxPNFk8vInHnxElMOjrXj91QgpZTDDNVfeFKH9TYbZHUEBgfnE/HWR3vUom7EAJ0nMKgORqRTz1vWFsBwQeNvVVcptvw3OYktCOcY9j7d+XR9wE1GlEvRwMTyG4RUVJ6AEeuBHd4zN+oTNK27bAbNn26mxBBhbCf57iF9R5+sY7ZUlRWYvPhKKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tc0+E9eGSwi101ON3B9m0vzebc/w4yXDSCrhG9Lhck8=; b=Bse0drhy153Hk1cLalabvVjKdI5uJYeGp9K2iEWOIPGag5Qp1klBds2kENfiAUa9JespZSFTY9M14UQb8SYL5E8zNqxy0dZOoYJPbe71rKJsjXBZRRZzQj2DIMY29IwEhfFFvhD39drRcj5AU57dnnxiljUnGu0sIKVSPMm8mKI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM8PR08MB5857.eurprd08.prod.outlook.com (2603:10a6:20b:1d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.16; Wed, 22 Dec 2021 18:53:01 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112%5]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 18:53:01 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, qemu-devel@nongnu.org Subject: [PULL 2/7] nbd/client-connection: nbd_co_establish_connection(): return real error Date: Wed, 22 Dec 2021 19:52:43 +0100 Message-Id: <20211222185248.466010-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222185248.466010-1-vsementsov@virtuozzo.com> References: <20211222185248.466010-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM7PR02CA0009.eurprd02.prod.outlook.com (2603:10a6:20b:100::19) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4e39b85-d618-4f80-553c-08d9c57c4790 X-MS-TrafficTypeDiagnostic: AM8PR08MB5857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U4tUdnJ8kRcCGhaPUI33RTgcuvBVGUhQgl2g3qpfKysbwB5MBKMeH/7EMmVZQZqeGkJtBgaZQDXhZXEbdewQyoAm9WUfn8InpTn4Zzk4y9bkST46+yIRfUS051SaTc7IErXxPREo5FC24b805TD0zxNU+p0XeiPypnnfXwmJZYDryqw8dKj1J6nU+t9Km0VmgAUFnOOtmulC/C8q2rz0AP3fTz+GJL6y6dy6+CORKp1EJE1mF82z2SY3xUeZBYNVrZ2k2SqPLiZvxkVdHCLzRHK88AXaB/PapVdXut9MJV5pfPLu/1K4rLMrr7P/6DX9eJq6cHc/dbPfm9+bZVYymKdGciP+tc3bi1P4VJCUahv+iqau3FfgmGW8SIKpsR96WrKnLLKZMFy2F0b5iI5xJhXTsgerT7f1rSBFdaxVJCbTleaTB1l8fVlIpT/Qf9CcA+itu4OxX4CFCXO+/50zGTolcvv5tbxDtBn/ZaHkWBSVd5bI5g1CEUDoOpNVnmAK8JccC+5S9jXaggyPyDmOG9jrQh7Eqr8Eau5VSRHMiuxcRg4RLxpFkoOcDoOBZTu0fyUrDfJn2VT3P4RuybHTlim++fq9JjR0hY+F5DmIG1FviGAvm5DegC11N1LRxUbJcm3LVncTYi98dZmxuhi26FdOpIj4RkwjThipREByt8JOdR/z/SbZeFZplN7twOPGif4SDIHBMYCcelFsns0XOg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(2616005)(6512007)(4326008)(6486002)(38350700002)(38100700002)(6506007)(83380400001)(66556008)(66476007)(36756003)(26005)(66946007)(5660300002)(8676002)(8936002)(186003)(6666004)(6916009)(2906002)(52116002)(86362001)(508600001)(316002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WxoZxOq5FkhvxUnOiaK1jHPpPp/4S6zTATtvbCpMJwI9arTlw143zlKeIYuBfb6MU7lI7bfNkNAgM7xSda185GE79I2djMR1cCAhsesaCMpdwRDIadGpdnmgHccamLtqu1I9p5HVo36hmMF/CLPBRIr8hqe54SB4fMEhuPEXFqk2MM0HeqwzaoKAdiSkwAovyLW2p+xbJwzFtXTbqSTZep+I/5N2q8ldvt+pivwJa7Brs9qWrHWGbOnvZ9AJPAolEbAelrHmb6vQZuiTOBQJFW3BkrsG82OthIsSiMob0yK0wAgJ4b9IjzR0zPtV/coW9RlCaDsvYha5/5Xu9Ch5/PuMQwMlPxp00a+WDKL1QZXkc+zgZmya6l9pMPLxclnROfC2Qd7FW8q1COVA/u/h0yrUM7O0KUbLMeAp7sSVkVaLU/tiGahWdKRyuiZu8ho21TNa6gXqHviMbz6hYreZCU7Zh8mThpvcTCqtISIJ1zAU/Rks80PQ1aMS8djAO7uiUFxy2g23yqGMHyqMli1mRD1mgPG9NTbFk8qQCVk/cRHlSlUJkGMnhm4CO2rubAHJJe+PMfLhWm9X9KNzL3URZkTrrGwd8/VNz+HwbYU0oQnFLDZ7njrLhEO+yc4TxEp0uRsmxe1CSGfC8DXHy1BLr5E3eHGbSBJpuNrBqQulOAtPgcLN4YU0O5Hsc9Hjv/Md1N4ZccbbXQeUqsft2Aze6+Y0nzIegto/ZHwRuRkyXRdxtXCIcQagSat1VOQUywF0xOwLrgo8/kTybSyU85tf3kr/jjCfCViRsuqVUJSDcXXpoY+hWHuyEYYNqgfK36UokKOGHPn0JJ9bRl606qgQ5gOrmu2X+tYJOfVA0mo7y3k4Gh+oXLgQD6s7+Z1raegoi8CFee5PyVJW7SAD50KAKfOLyyF5wLkVQuMh6hYn0/LfNJrnriNbApAAIPcGP+t0UtlDHbRTdydnLMjBsxO9mETjQ8n2lCM9xXgUFM+/xQ5uNuA/gByeVnpzMFtnKjdzkLhpsxoSZJ26n0Cm+Kao9/J44J5DiMcrgQNTuS1ACG4m/4oytmXbV5nSKTVDTv/93lododoVbWUS0KbLeZ8ulDUyhQcE3MiBj2PEQv4gCy61tNQRbsHDSig/TCkYZCEJewiqFLTdPueRo0uDVeGUiTvlKCRqnzXjz4f1OzMOYTVld8iDTDhuWo6HWZqV+AY5BZkskpeofSDcqTwneOidwH8hLUSIdYQ8s/5n6DyW2HpEg/gZKrCaP+t2/zVPSGapeDjKl23znvg+dVo6WdLEQnDYKWnrkf1Lcg472JPkPC9XaF+pLze8xZMo7RhZsUAT9U3/O7rmOzfzeX2NxdUdVQ5JNL3zG8uMmuuDBZGPLRdW0IzsHvSaE+NMHbtZ6UmpXN26MMt9n/z0hlkbrXQg9ufgcBg16VBdr40acfdnR675s14tkArrJq6zy/lRx2g6uI1kfLsHUmJ9JCI0TOvhRq8mdPEIT/ALFN395nIoKPanktIoV4LkoKZOHgMsz8EgSvGizGQtG2AU3OXwOR7vYe7y93A5zDeYtDoA5HseTAbH6Za9h8jVQlAjhv9UEBCFBIqybRve9n4OE98j2aYDoYFSuaFJD5/XzArDRkggcit0W4HvyL9J1rDwQ156txToWXaPCYUiLwxQxURCIXUbs2VTdWh3Q/SSNF26B+WHbRk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4e39b85-d618-4f80-553c-08d9c57c4790 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 18:53:01.7831 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +5Vl1Py+kAcIpz/plpIDQXHvTveSfXl+ZbM39JyP6AEsjWMqrboDj3wlJJF37wKr3GdZPeVIk1pX00lLd9rORy6Ti5nB1r0g1lr0BvEBiMA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5857 Received-SPF: pass client-ip=40.107.21.113; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The only caller of nbd_do_establish_connection() that uses errp is nbd_open(). The only way to cancel this call is through open_timer timeout. And for this case, user will be more interested in description of last failed connect rather than in "Connection attempt cancelled by other operation". So, let's change behavior on cancel to return previous failure error if available. Do the same for non-blocking failure case. In this case we still don't have a caller that is interested in errp. But let's be consistent. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- nbd/client-connection.c | 52 +++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/nbd/client-connection.c b/nbd/client-connection.c index 695f855754..722998c985 100644 --- a/nbd/client-connection.c +++ b/nbd/client-connection.c @@ -39,16 +39,18 @@ struct NBDClientConnection { QemuMutex mutex; - /* - * @sioc and @err represent a connection attempt. While running - * is true, they are only used by the connection thread, and mutex - * locking is not needed. Once the thread finishes, - * nbd_co_establish_connection then steals these pointers while - * under the mutex. - */ NBDExportInfo updated_info; + /* + * @sioc represents a successful result. While thread is running, @sioc is + * used only by thread and not protected by mutex. When thread is not + * running, @sioc is stolen by nbd_co_establish_connection() under mutex. + */ QIOChannelSocket *sioc; QIOChannel *ioc; + /* + * @err represents previous attempt. It may be copied by + * nbd_co_establish_connection() when it reports failure. + */ Error *err; /* All further fields are accessed only under mutex */ @@ -170,18 +172,18 @@ static void *connect_thread_func(void *opaque) qemu_mutex_lock(&conn->mutex); while (!conn->detached) { + Error *local_err = NULL; + assert(!conn->sioc); conn->sioc = qio_channel_socket_new(); qemu_mutex_unlock(&conn->mutex); - error_free(conn->err); - conn->err = NULL; conn->updated_info = conn->initial_info; ret = nbd_connect(conn->sioc, conn->saddr, conn->do_negotiation ? &conn->updated_info : NULL, - conn->tlscreds, &conn->ioc, &conn->err); + conn->tlscreds, &conn->ioc, &local_err); /* * conn->updated_info will finally be returned to the user. Clear the @@ -194,6 +196,10 @@ static void *connect_thread_func(void *opaque) qemu_mutex_lock(&conn->mutex); + error_free(conn->err); + conn->err = NULL; + error_propagate(&conn->err, local_err); + if (ret < 0) { object_unref(OBJECT(conn->sioc)); conn->sioc = NULL; @@ -311,14 +317,17 @@ nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info, } conn->running = true; - error_free(conn->err); - conn->err = NULL; qemu_thread_create(&thread, "nbd-connect", connect_thread_func, conn, QEMU_THREAD_DETACHED); } if (!blocking) { - error_setg(errp, "No connection at the moment"); + if (conn->err) { + error_propagate(errp, error_copy(conn->err)); + } else { + error_setg(errp, "No connection at the moment"); + } + return NULL; } @@ -339,14 +348,23 @@ nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info, * attempt as failed, but leave the connection thread running, * to reuse it for the next connection attempt. */ - error_setg(errp, "Connection attempt cancelled by other operation"); + if (conn->err) { + error_propagate(errp, error_copy(conn->err)); + } else { + error_setg(errp, + "Connection attempt cancelled by other operation"); + } + return NULL; } else { - error_propagate(errp, conn->err); - conn->err = NULL; - if (!conn->sioc) { + /* Thread finished. There must be either error or sioc */ + assert(!conn->err != !conn->sioc); + + if (conn->err) { + error_propagate(errp, error_copy(conn->err)); return NULL; } + if (conn->do_negotiation) { memcpy(info, &conn->updated_info, sizeof(*info)); if (conn->ioc) { From patchwork Wed Dec 22 18:52:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9121AC433F5 for ; Wed, 22 Dec 2021 18:54:46 +0000 (UTC) Received: from localhost ([::1]:47468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n06lB-0002be-E3 for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 13:54:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jh-00088l-0M; Wed, 22 Dec 2021 13:53:13 -0500 Received: from mail-vi1eur05on2137.outbound.protection.outlook.com ([40.107.21.137]:20601 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jf-0004am-Dh; Wed, 22 Dec 2021 13:53:12 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nIknrcEJ+wZsujZHA8QhCvFpOyjwJ1L0d7n0Am0u6xKhw37QiFdNoZyA+6Xlz23nkko+cAIMAAX8trdM656DYcBVEvffb5bk5UtbG97ttn893V4n4LzHLi/pI6iP24bzOKld4N87bbhx0WtRoduojtEHl1TKHY6r4AcWhJoXwAgOJHTxZOFYGjKuo3nlIgNECnRLabN+eCngAOJ/Xg+l82LpdcJMjz7HmwHLQ270jbYEHdnRrjyN2ewBcFyKvSQ+1whorsNBOSgxst9mMPPyb+H9SPxj+noTdcAZ3U+DPJ36LRJYS7rpHfqQPij3MK1HoF2OVB0s9HKNOqmUiCGwEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8/XQBzvuOj+2z0KHJakJs/0955lq43qqA+KruNrLMnk=; b=bTKK0/TtgIPTCqaQovcMRQwZZYR4t9DA0JboRrxjpeQlYGJkvp99WTVv8rmyHQME3k7zSlbe9smoL1UwUBQ8PjyM+M+Xb6BMxxUfszi1d2aSjoBUuqykOSsRKImLoyG9wzq9KTM/JMrpzA8WpZwMy2WLZqW/t1DtipKcSx2OXzd6siyW6TklIHjfOB90/O/jBHembwtPqFvWFm4dT7UPnAfAzn+A9pyTL6I0hkMCKDkAiG5EP/OiTtbHwTkY4eMTbUziZ/9UFhtvNpHrYKRyvWHksKHyop9m2/JeyafCj4QjxnvTShspZ+7G52k4FdfhmVfBPjs82omhOBzJOJOVJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8/XQBzvuOj+2z0KHJakJs/0955lq43qqA+KruNrLMnk=; b=VjwaUFC1cNwFGTxmDvGSIHDngYJOwOWdExE/ETK0iG0UbcENC15hhbjm1LVrMLiwgwcQR/dmAfenDAWWYtZzBBDibh/zCCz1COOuI4tA/KZ/wDDmyfiJc8F2F8JKrE4MEPY+FSviZq8qfV4GJnJh1INbW7ZOZ4mR9vdsns+l28c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM8PR08MB5857.eurprd08.prod.outlook.com (2603:10a6:20b:1d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.16; Wed, 22 Dec 2021 18:53:02 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112%5]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 18:53:02 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, qemu-devel@nongnu.org Subject: [PULL 3/7] nbd/client-connection: improve error message of cancelled attempt Date: Wed, 22 Dec 2021 19:52:44 +0100 Message-Id: <20211222185248.466010-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222185248.466010-1-vsementsov@virtuozzo.com> References: <20211222185248.466010-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM7PR02CA0009.eurprd02.prod.outlook.com (2603:10a6:20b:100::19) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e7b17355-6cf0-4b20-4f8b-08d9c57c47ce X-MS-TrafficTypeDiagnostic: AM8PR08MB5857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wNJVEaNG+MIOhDcBNiaiSucLsYTzQew2YeRwGnR/vxUDrSLw6hxMqsASKjYD5UQBjgF91/sOdHpxfyd2hAkQHnqFQlSNPSA5l0u8bI1jW22a6IDqU1MEofFUJecCPJiKk3lZqx8ouVCpJSz1888G8AyVrkN+g/D7Ln3l2ZYv8ACm0iFXxQ8g5mdxIUZlVwbq8sYguqpE3bmGXItyrmkgPwHykQP71oD+atjaGbAUj3QGOqe/0t+ARzc88xqB2/d0KhOpMoWprMufEuiwxb7drNN04pLWyMQkfbILIU6YY2PS1xTipAVvcNb6OPwXyWRmmDseM6VyfnKyJI66BL7E14gmh0o1HgSXG/0q7B0bUfOjAZUz4GvQl7sZ1CEEzzYirxkNPOToSX3bxoKlrpCXI4a0HYdXFmAEDq9uSa6ikNnjSu2SH2YD/h820wL0X9dGVnYHO/n81hQiYVxnxsc80eJxTxpZuJO7XBNqOo45X8Y55xS9t+qs/zN2bxoOSdT3n2MT8uZPwVmodpynALJkzTudtdrx7dCfBvC1zy8lH4Pw/Fuly79Tjqj+uPhqv/dwS2KLyh1Vx7rHa+Pcv3CE62IoJ+APPc/FqjL32qJTKghrUvsY8i/LpAkwE/7zr4Xj0P+FqzwsWr9wD/i9WquI+o0wlK1FgJudjC4+X34Qqs7MhlrxQ2iDAa4XkfacATotDJDIxv576dFQ5J2WjgpP+A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(2616005)(6512007)(4326008)(6486002)(38350700002)(38100700002)(6506007)(83380400001)(66556008)(66476007)(36756003)(26005)(66946007)(5660300002)(8676002)(8936002)(186003)(6666004)(6916009)(2906002)(52116002)(86362001)(508600001)(316002)(15650500001)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s48zIjmtZi8vXmx5END0QR+TRnXiz1zOnhMwn0gt0xlB6n/B4h1fVaimbK5aLaTXKPY1kY31ahfT7MfDDc1Er1OxLi1JlQTwLMlfSFMTeDDVz4BV0Ux3QKUFeZF6HecXleb2Fy24XEdAdGAu9EXu3TV+sSJohQLl+7h550Wf8+EkLrzQDN0jC1Oh35IlDX2oEw3J92dV7Gf7DR4WJvFb5COAMT69KIyspf3H2oAikdB6RtRyoUHfcOprxg0Nd4Jj0Mtfd+QXZMPzOM1t2tjlhmTGneroqvdLnd40gQDf8x/zAp1jfVdBOaSPlq9jAjuzECj25aBIo3+jTDl8ZZCqUJO1/LiO6kU3dyN/TZOKDQIeo3HLKlsrFSBzBSgHGQB1G10xZMxmZnfZEwJujrScU+GTrls9wSx3TvIzaoH2mCQcVg0CnMJFqSPnBDo7ZYrURMp94eiMuVs/7TcaUS59LhiqgkJQ390A/mcyOTgw351xfjYzx++hDqH4K/qgv2jhDatWd/X+v7JgzlcwJ2qr9QCtWc2UMn/duPLONqacVFRqxsd6movr9/IY3RfLioxW2o4d5yQoE3IyGYV0/yHGdGQFCO9aEjDAFdfWziApeI1n+er6y0P07pSyqvxmqySpAMcZ+55RWazxylVVPiQgi8rLIt1O3qu5UgRtgOs9jMK7e5RBUEj3EKLj7xQS9W9YXFeJtbyug1aDyxP9NV2+YBwNxFC8pwGjlRqi2+b6hHxkMVdOxEQAr0VM5wvkZ8XmHqUVs28LpMbE5rn7hY6XCo95+rnhWc2PKNpuvx8oUmTBfR/gspVfbjEODbfzp/xDzr5D81HuqP5x09bwljhaXstjiIxmfOdS0HsZm+507qTfdU3sP5azo9a8YswCTiWbvqMC/LC2CesS7MROtFc1Hv6GCvZkyl/QQtB0bfRX9zXzosVoLNTLqHPvXiHN2hlcKl6YOIkA6yxsSKzEEE9QF+7baaolMeeaUt0+YLtN3euzYClJbQiZizNTMuoVf/YKKXkPvR2AZxkkTjvnFoKyuxRq78QfqWpaOXts8VBuhTzUsSYcIlBL9trW6wzEcYy3oWLiIaPVltKkRx05CH+MRiheL3+PdB2dVIyMH/WpJlF0QBFQMvhWt3lBBooVW1bSQiOkpcVJERSXi5sLAHux6FNhnKBYi95cMCQfx1wlLl3sTPJzYTZdKz7gq1TfzsPIzSUYAp3I/mBf2EQXXeJ3KXI3jAa+9FO8zGv+xt09b0C0XKajLg0VCfm0eYh6Hle2w41H+amRFnSpbaTKUfO/rMfxw4mi01znVYlbL3W8DmuxmQvtA70Lug6zfZ4IYYWkm16BSNaF2oBKEGO8A1hmgMllNbCChRBzM8MAdMIBRp3Kmau0drWNEJg1razrEXaiwsWMUjyZesLPZFOinjbQTwwBmq2EJ69NjE3exNvh0n2E+OiN0v0mmcwe/t41hIS6bI1hd6fe2TBGzvuOgk6kZbK7yUd4jgiVYI1MlyV2sIPl0WoBjLKQYl828zHiyFdNB15DzcukYhQBjJ89I+CmtQH0kiBi1elaEl43+hvVkeseEM2durglf3o//BABKAKyHINyuaMiiUvQfLlkHxf1XnNnDLxTYcUIFnHQOOLceKZkByOXkCX5Ecp0dLyTXQOKXSE8XHp4Xj86JyOtWNv+4CoppSLt2m8//biIJsPVddw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7b17355-6cf0-4b20-4f8b-08d9c57c47ce X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 18:53:02.2049 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iDEx7VcswvsNX5Nkouc79OzfZHGi7lMfZmtXEAxTglcLoj748woODCsubK0GW50Ckq/QtqzG9qUG1Ats2+wwD9VHIcg+VvhJHl7dtzweU/w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5857 Received-SPF: pass client-ip=40.107.21.137; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- nbd/client-connection.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nbd/client-connection.c b/nbd/client-connection.c index 722998c985..2bda42641d 100644 --- a/nbd/client-connection.c +++ b/nbd/client-connection.c @@ -351,8 +351,15 @@ nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info, if (conn->err) { error_propagate(errp, error_copy(conn->err)); } else { - error_setg(errp, - "Connection attempt cancelled by other operation"); + /* + * The only possible case here is cancelling by open_timer + * during nbd_open(). So, the error message is for that case. + * If we have more use cases, we can refactor + * nbd_co_establish_connection_cancel() to take an additional + * parameter cancel_reason, that would be passed than to the + * caller of cancelled nbd_co_establish_connection(). + */ + error_setg(errp, "Connection attempt cancelled by timeout"); } return NULL; From patchwork Wed Dec 22 18:52:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697183 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E6F7C433F5 for ; Wed, 22 Dec 2021 18:54:52 +0000 (UTC) Received: from localhost ([::1]:48054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n06lG-0002ys-W7 for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 13:54:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jj-0008F9-7R; Wed, 22 Dec 2021 13:53:15 -0500 Received: from mail-vi1eur05on2113.outbound.protection.outlook.com ([40.107.21.113]:12544 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jh-0004aJ-IB; Wed, 22 Dec 2021 13:53:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nb/o5n0Qe068G2iS0ut7V7PlzAwQ4lpQ50T2KqzYQxp+DEZIpMHYdVOKIvZIMfbGrzRaA8qvsDw9E+JixrpKgymDeRg/v9/o9ew+0shnPh+gwkzqr0vPiwuZRbRl6mMobwS/fgoJi2f6cF1MDLJXLwjqnaL3LYCG8h+eKsSpOvgKt1qtM9ilLyN8hRYkKFKMRxINd6BX1MBM4nwDu3zaFq5m9t6NPimX7vT/tkxTuAGeCmO0YH1RebktoOnW7VsaSSSP7GuzSs4CQa32y2euALkhFSqkQQGZ/M71DSyeC6bMpnIqQJKYSYugiHhUxicG1xGcvkjgZFL0GZMv77Qg2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W7lErLU3850fVriRjv2MT7Ght4Xs/vqrXSLU61tmF+s=; b=n5YhXIwhWCQw33rXe4XDFBA4g4CM8cfzl9YAv3JOCc35PrbOTLl6RUi89A338/LmYtuh1rN9rGi/HcaOOXhncnM3knO9nn1YoQBc+K9Sd/AFR20/rmSyk/zt0VYJhHw0K0VHYtvKdSI6nIp+Fnab7vChBLyHrDud/8hWWhSUIe60ucetg5Ry0R7ucK8GoAS/uRwKcX5jSItG6wBIhNGM85rnFoMMZL6BYAt58/eo6yYKpDwjE/1h9Ymbly1pyHbKdvN3GUwjwbpkcPiL+XmFKltJDm8nBwvuMRK4pWzTODA0EYrj/S7vOX1FhimyJ79j6N3EfNHQwdl2y+Sf79pSbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W7lErLU3850fVriRjv2MT7Ght4Xs/vqrXSLU61tmF+s=; b=DrThLZB11m+kCvgMSU/E73BREpccONkzreu0X/cCwki1wPj2DSTnl8OOU9Cv/63ikFDZLFWCeLG+v8SEYYYmd5YyOQCslrc+1iHVFXaLd11yDBvkpgw4ICqzDWiJZKqEEyxIoYdyrjDgX20PBG7d1rFAUcHakxHPkl3GhhBJOPs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM8PR08MB5857.eurprd08.prod.outlook.com (2603:10a6:20b:1d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.16; Wed, 22 Dec 2021 18:53:02 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112%5]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 18:53:02 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, qemu-devel@nongnu.org, Nikita Lapshin Subject: [PULL 4/7] iotests.py: add qemu_tool_popen() Date: Wed, 22 Dec 2021 19:52:45 +0100 Message-Id: <20211222185248.466010-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222185248.466010-1-vsementsov@virtuozzo.com> References: <20211222185248.466010-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM7PR02CA0009.eurprd02.prod.outlook.com (2603:10a6:20b:100::19) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0118895f-43a0-4e94-5607-08d9c57c4805 X-MS-TrafficTypeDiagnostic: AM8PR08MB5857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6CROpMkpraHWBwQD54g/hDoWF7P2X9nBitx0qVbrqJpEMhHP2nm5mtqd69RgANXNA7240FQvkMvlQxAKAW7TNIWHm26DNRkit7ygBtQZnQQx1PZ7IXonW72bwrp79PGaBDdYpIe3aVhBG2dn0iXBmDip512Txuj9dFObfePwUw5Z/315cRyyu6pztZ9TazGC7v6x2tYsZlJI4iPy6UXViz8V3WP2Dt4vi9kwMmU4zmIerlXFcPVxBBg+qDEykGHE+bBH6zkTrFF/60/eNqX8YxjMxBU/oTLJ3fhkByo9iJ6vd0hzgnq2V3gKTbjjmfj4oRtB5tawxKMLOg9OmpQU2DpwVUOteE2qNpMvELsZtANvyPpbYtB3YfUc0zUeFdqVs261wPI8Ud84G4VRP3SSGMy3pjXn9bStXn0kW9qrwtmFafVN0rI387DRFmrscrbO76bHw06R4aIcw15fJp4d29Hu4DFBPTqLeL8qf5ePj1+MmW6WCx8XvX7ZUxYLM6QBDzFk9S6BEvOiQkqO8cfdEmZuYNrB/dldxeU2HioWIRf0ZelmuiFCYOufkP1rYAM+CnAxQ7fwdppEka8ITthB/F1XeTrOKVU1+LL9qi/SVNvi7dDwa02LrevsySAS9U87iRBW++cFL33UvwSeue1szVcfQD0pupYL5vNcyosBRBbXY9uDXKJapNH/4K48mvrbhC3nQnofaZ8LKw6oLdbyiA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(2616005)(6512007)(4326008)(6486002)(38350700002)(38100700002)(6506007)(83380400001)(66556008)(66476007)(36756003)(26005)(66946007)(5660300002)(8676002)(8936002)(186003)(6666004)(6916009)(2906002)(52116002)(86362001)(508600001)(316002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XCz4c3QuOQDOhznYjVp9GyCmsFpXj7ircutSsAusrsuAENt4oN0200cDRxKNNyrGGEKFpuSklyFdKrhJyEPt1D/iG8NlfN1Ypay48jOzqb/cIeqedSFNPmIV+HgWCgjbV3Q7/cRLNtHCGIkgCmFQqpmhXnOADfzL5/ibrAmD8iO7VWKr8uxHKGIITeJmFcBnRRJociwxIe/y2ERWAmDfDuh5fXordlGXU2yngVxpkLEYn60hQGWaeChVZh2UvWt28ukPDJdGGXRuT6IwWE3w4IKiA0wlFz0g5xvihDU5Hf7LHBBr62rfv+JzNp94P4tWXE4Uzj7QBCRqdkyg0QOIO+xr5noKD+gxIUzEwb2TIS0iqiAaOV3evAIp3mh0/mYwEClu8oBJzQCEaxJGNJm9M6tKZZNWtEAigRCwhUjulT5MlqhAC75YvtJOw/ImAFtdwX9k8AJlXay0BVB4AuDbOsMH/CYprgEyx6X6oeMCXB5UrTMZBl4lrRvec9DFM/KCGlOtaV3T1VWbLkzmpWoXIz9IaA/eHGeoklRCzelusS5vJN9ojWWt+FAZD74KuLwZjFpWGUAZZf/xX4nO+vE2KMKDbGrHOyzSBBZ4xu1K7ixu0CjWXfmfUc7Ms5Y54XquwcjbQAVhwP/welgPMTZfPoKWJpIiCG2JFusyfhYnO+JHT7K/vbuguvq5ttKFmzfiuIYkmOlRSHf4wDe8WWUded5tIu7xk9/Ta0hnnU5NAKWUJqPMyaAvEecqbMxGDp3qiUc8UoXVgWtIlUNdG+vbYmAtz7Up06v1K/rqRPJHRuzAqXQKImOIGvgOPiKo9cCDPwwcgikGI0lYAALTA4AOUOgoVvl22b9EnqRUMbjsa3Yja+jL7AOZ8PMrp/dEn/cWR9DDn7kVCEdQRzlAQsdzENwLQXmgXKF7iqhRu6y2IilAK1xokZ0SsdRVcqLTFb0XqvtpqFupzqqCHBStX0/l4Mn4lTww5+lyLD6h2iNOwNtiYiKOAvdMmB3MUXkXyIRp2XLFBVjAE1ajuze3zKLTyyDAaXnq6oJQTY7TV2Ly8mMx2N9rYE1NVkX/mm/NzubNjN3mRt1eQh29ubkUsz9Snsn7yJquNxBjBWY2JjlQGERQu8oXW7tX6oQqnzNXzpu4xzyCu+NxtLSjJD5GAvnN2xJ0QEhL+pS0w6oIepzotkHLtrHVOreSxDXcPlHNrq4nF+jVN3hiAmiH/Dd5iCKISM/4V66784piWY0rX+iqPyyWCyjsV//SrTwHJO1CGSvUr+lARolAT2WWMoog9eRd/duqHFcQNvnw5T8XGFtMYzuFfwb0IPxs/Sg3ca9zUdFwSfLr7ILzG5uU3EnSrAWlky8BxUvoh0pbpvnKf4S6k6Oe2rQQm8oe+fTYvX+p7tlK2lHsgjipSPMKraNCrJR62ar4Za27KfI06iCC2jpxJXhFxN7nJxFLnFNDW6rGI4Sn6dz9uDF+ZpEqc6zwggeTOyV59zrqMKpiI0hzLmzPcbH8Ky2KdOdXWDDGwlM6HMVlgSNWp6NlKPByK5eLekXrQst1oOV8B4Furcdvn7VSzXV/fsUrS3L6M7ljQE+uSyBNzAFMYSfEGgq+edoc3HPGQ04WkPt1/d9kx3+TXJiCqFjLH2U209a5N1g434tQ/cR1KcN+VFb/a5nlgWwF5GRUjTsmlMITcEj2I0hqPprF6zk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0118895f-43a0-4e94-5607-08d9c57c4805 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 18:53:02.6436 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AlO7Ry1/M6bqw4d+TcyKU+9yxm3XF0jUtpnx8SXfXYG3GMGnZW50eX4hN1WnF74tUWAOBhDPKnclM1QV27nD0wUBf65g/GyvpIKNfADSFH8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5857 Received-SPF: pass client-ip=40.107.21.113; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Split qemu_tool_popen() from qemu_tool_pipe_and_status() to be used separately. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin --- tests/qemu-iotests/iotests.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 83bfedb902..7f9a8bf012 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -138,14 +138,21 @@ def unarchive_sample_image(sample, fname): shutil.copyfileobj(f_in, f_out) +def qemu_tool_popen(args: Sequence[str], + connect_stderr: bool = True) -> subprocess.Popen: + stderr = subprocess.STDOUT if connect_stderr else None + return subprocess.Popen(args, + stdout=subprocess.PIPE, + stderr=stderr, + universal_newlines=True) + + def qemu_tool_pipe_and_status(tool: str, args: Sequence[str], connect_stderr: bool = True) -> Tuple[str, int]: """ Run a tool and return both its output and its exit code """ - stderr = subprocess.STDOUT if connect_stderr else None - with subprocess.Popen(args, stdout=subprocess.PIPE, - stderr=stderr, universal_newlines=True) as subp: + with qemu_tool_popen(args, connect_stderr) as subp: output = subp.communicate()[0] if subp.returncode < 0: cmd = ' '.join(args) From patchwork Wed Dec 22 18:52:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D83DC4332F for ; Wed, 22 Dec 2021 19:01:21 +0000 (UTC) Received: from localhost ([::1]:33576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n06rY-0003z2-B7 for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 14:01:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jj-0008Fr-AH; Wed, 22 Dec 2021 13:53:15 -0500 Received: from mail-vi1eur05on2137.outbound.protection.outlook.com ([40.107.21.137]:20601 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jh-0004am-Lh; Wed, 22 Dec 2021 13:53:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lFTmvaUgxzu85kMcHg5Kna+a9J+8we5UlxJLLuqZp6qBVdaKFFc0u3GIIGzKq7BOpNTq3Runs9Y4PDvwGY1LNkQTZJ82OgNV/Vm+hOS3SX8zKuvnaAo4GI+Viub4D0RtCIBRSB4WHAvqb+GatY3XRIMmK8v1CPSIwJ1i4ozA8xFpbdEXy+iQdGR1pcAldVs5NGUOR2CZhAiY7yw3CjxkjR5mDHwyp8au6LXvJMCMDGbJRVfDaNSuIXhSyvyHTI5JzNcUYVEFoWJQOPEZdzpoQIVmQEuIMkyIKNWm4d07S+yCa4MHtUPGGaAtF2znSmcso3vSooAibFhmWeLmYVBm/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cmr9n2riQ6bGqpdEnMEYSQxhI4hjxNtZIqsGLwjnqO0=; b=j9QiSqNKTTQqFTWAAhm9gsLIwXrtriMUrdlqTYB14jFfg94BLBOZ3dgAnNMa9xUy/2C9w0fzlhYFjsxlr+CIYX94FHF9ZPt3Pl85zytAIwMqanWiRLtQOdEE2JNu/qhRcB7DYUbR7p/pBNmNMl3v7os4V/CFJaMUUrhM1AzRip9Ux2Q+mqC6cV/eB8U7OUhomKB/iyP9D/9j9Ve7wHo4hnC5uvhdMXiQDaaMFSoas2EaG8n3qNzg8jwZwrKnWFDmRcaGxSTLuS2Y5dunJfECzxyGTzG7277o9h4mn7FN5ePDLYGKdqbGaclpyPyuVf0onTnk883LHHRALqMrUNToSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cmr9n2riQ6bGqpdEnMEYSQxhI4hjxNtZIqsGLwjnqO0=; b=lQPnqz2R+HSxDaXGkSFKjBAlKwTl+SRZSTjoL1Vxf3uwUkkS70NUJ6KyzEjnZR5T+9Am73y3iCC8kxOZMBaguck9MygAQB9occV3bPO9/RCaTht5YgoB06SOvkR2/X4qZMYuOAcNL45U1qsr+IsuqJe1AMTjX+JitR2HQ9m/CPc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM8PR08MB5857.eurprd08.prod.outlook.com (2603:10a6:20b:1d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.16; Wed, 22 Dec 2021 18:53:03 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112%5]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 18:53:03 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, qemu-devel@nongnu.org, Nikita Lapshin Subject: [PULL 5/7] iotests.py: add and use qemu_io_wrap_args() Date: Wed, 22 Dec 2021 19:52:46 +0100 Message-Id: <20211222185248.466010-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222185248.466010-1-vsementsov@virtuozzo.com> References: <20211222185248.466010-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM7PR02CA0009.eurprd02.prod.outlook.com (2603:10a6:20b:100::19) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 651ba886-da80-4317-45f5-08d9c57c4867 X-MS-TrafficTypeDiagnostic: AM8PR08MB5857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f7NzHz/jCZQFoAH4gLv7z9e8Ug+mLMMaS3iJQU2k87NjqjWBL1Z0YtQWcIcw8vQQtWQbQAty7iMukBbDIz78+nJKfLyR14Qf72fIR0JI0h4LqeIXo7cGqLDk3FZ0Zppm2mm0NThzf7cmS1OnqrwkHMSpZTAIDjpuSqv7YJyrNT3fQM8F1uIjwLy5+vkYShTqyiQ/tUYAeWYE+2T/MF6qgJ1cIjDNF2W5KzdiJUjhjh60fES+4TUu7RThWm4l37HE1SZimLMxuCprjNhTUVf5SbI5Qwg9IVsxCxCusqlbcuxe0Mf+hR0RhXX21xXxOg9f6o9wBBFzPWGwg4D2pUOxwZ43qiDC8FCAaN4P6R5Pgws1V84MGhhCkOpzMTIZ1WP7b3MzL7iGiS9+gdP6EW+O3Cps5mNAwCvACU+iAfuooPpCJRxU+SO6SonWmzHpoZ9+UJnKajqlnSi1JhuUbJrpTjoqO7c2LVysQ3r8l6DnL28Ap9Ep3ZE9jpWAdK1fywAHk7xxzRbxeliol63/ekhxcxVy5RZYFVaRwxyvRGeapUTY+dZZ+bCloEGmCMLqrzowOIRIUK/iwV/qefT6H+ec7QZHM1Yf3opQfqDvHQe4xuIt1+Sd1UQaEenUsrnqo1V0jL15CmO5Hh7movTcSe4GftclvHKCmYl0KpEUkJy2T7gqgPSWFuAwZ+XDGwP/5PMcbq0MKF8WXtW5UhFKouylQg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(2616005)(6512007)(4326008)(6486002)(38350700002)(38100700002)(6506007)(83380400001)(66556008)(66476007)(36756003)(26005)(66946007)(5660300002)(8676002)(8936002)(186003)(6666004)(6916009)(2906002)(52116002)(86362001)(508600001)(316002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xyUxbOHAPUIgFpDRtJ6JJhtIpRcGOvuiJ6Q6gTimRmN7SIVG3mgGVzWmnA5xTCKnakg9tFax6aYnh3ufkYuwiNvlf4jpPkj8gRkOa/koTtND8wvWdmtiKDQkhNaxWm30OCHOWAOKfkZQE4GMfBqfejCGTzenqgcggVrtyoIWAF2EJV9FrRzLcdRnB16V0xxZw3ymLp74VQmvu7/R1a4b7SLGdPgGLGyur755PBYaK8f9kDcFkYXgCwRPRGOHQFzRIP00WhVqB/hCvUg08fTd5ETiu0yh3nLAIfHz+VFYsyFM8riN8p94yQgLKqfHiZr55YrOxIGbIxiIQN2bYc52IXjzITK4NAC9cQEAnfrWKIeoogbFtXN86B7S4Lk+W3gaM9bz+ayu+7LwEAZzNrec32V0ahoQNgXNxwHONZR38GDeYun2qXlRrlZCkt5v14LrYI0ScoaP5KzOERcE5MJp4VzBE+dxGoCU3LPLbEBYkBV64d+3b3XLNOEDZLyeLBdAZHDKxhD47o14dzSr94WlZleIkz7eK6LoMrdMCaSnOAXZ8N9J5+48oJeKYKBk2YmTBhNGCBOxeyym5k9vRE8OYZ1kJ3POTr1N4UoNHKAIxbeY8X/ib1hBuCGTTMTsZpDygijYb0/pJl5CcN9egPMLsJv7vD73PvcQKbE9ooA1j0j6B0PyzX0DCoFHDQef8A4dyHdYkVyGcrmX2U6eb2ApQig+vpn0Mx4gsFRG88eYoQVhg/zEqLtYkcBbno+q1x1cIF2W3AUUW2583U4Hv/kti/jWtwJMpzOt+SN5zRSxwntzCiP/YcTNFVArZX2xzucPUw9ZAqcE/CvObS987fVDKp+4Wg3t+Az3yLV3iZ1ZFOg47VL5NWg18xrI7Z94qQPasgdERHIQrgMG2qFO/YYyVwvWLrC6zaIKIxbBVAp8RpvbB7XjCKpMrMjnnnJvxSgB1o+kTqxrVW7oIDi7KQXVsKRStGZvxjkJxXFmYxJlqDOA0MRI6Jrsrl+lJB04A1bngujpvshum0h9xflqcJPikIT6tj+ph8FMY8uIuxed+bJKu2haocdSVaBb1eYHH9Yyvj8awaiCd3kB0CsPHkclUQ/op9d9BQYQv6l18qK+isV8MyRBG7ptZqGzTpMCWXmMh0oIwNZyxVdk2TENsECeFsRKKgu+5OCCgmx4Rv0DGODOqIERx1OimA56w3iiEX5QoK6Lupg/NQrUiMJYg818CF8fwV83S51HgzXS+fHsP04wxgeNliVstwIC3IxmPdhs2nKOjKpKGS7q66xwhjAEs7cS5pO3kvcFKJVBRRdNncAOjlu6H+wuba+yme/JvuxrMYKkQ42zwCBVPFwavMkad5ljsZyDb7TBUArgrTgdItWT6se6jinYxr83YhrdtIycEQThP+eG8XMy3pVc1jisPAJOyOolFCQYq8ARjnaOV3jH4yhBGr+f6EIxblmmEFjCgZ68euLOM4tzx96UC/6IYr4mrDQ1ZecWcU69+iUrtXrWHAU4UQCvoPnSloibWv40GUMmmifyyQw3mwbnxU+lONCpGIxl3h1o/oUYplNafV744AcOkrn06J3R4+16XfBrvoYHdueCU73mTcOwBVEfztiJGGTN/2AtSz9odZjb0tqNtWpgUjjjqv/FZhYWwSMhLb+027JH/MyFRQWthNHxSj93O80AuuD4tzvZcYpyeS0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 651ba886-da80-4317-45f5-08d9c57c4867 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 18:53:03.1761 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Letd2DER7XpoCgnI5eA3hOBK3oYVRHJhO4NwzNmkss5X4wo9eQeUNKESab48kbP6+TlqxOd2jZAgoPOOniVy4ZThl2kER6YUCesP9oHUZQ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5857 Received-SPF: pass client-ip=40.107.21.137; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For qemu_io* functions support --image-opts argument, which conflicts with -f argument from qemu_io_args. For QemuIoInteractive use new wrapper as well, which allows relying on default format. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin --- tests/qemu-iotests/iotests.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 7f9a8bf012..1ed3eb1058 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -240,10 +240,15 @@ def img_info_log(filename, filter_path=None, imgopts=False, extra_args=()): filter_path = filename log(filter_img_info(output, filter_path)) +def qemu_io_wrap_args(args: Sequence[str]) -> List[str]: + if '-f' in args or '--image-opts' in args: + return qemu_io_args_no_fmt + list(args) + else: + return qemu_io_args + list(args) + def qemu_io(*args): '''Run qemu-io and return the stdout data''' - args = qemu_io_args + list(args) - return qemu_tool_pipe_and_status('qemu-io', args)[0] + return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args))[0] def qemu_io_log(*args): result = qemu_io(*args) @@ -252,12 +257,7 @@ def qemu_io_log(*args): def qemu_io_silent(*args): '''Run qemu-io and return the exit code, suppressing stdout''' - if '-f' in args or '--image-opts' in args: - default_args = qemu_io_args_no_fmt - else: - default_args = qemu_io_args - - args = default_args + list(args) + args = qemu_io_wrap_args(args) result = subprocess.run(args, stdout=subprocess.DEVNULL, check=False) if result.returncode < 0: sys.stderr.write('qemu-io received signal %i: %s\n' % @@ -266,14 +266,14 @@ def qemu_io_silent(*args): def qemu_io_silent_check(*args): '''Run qemu-io and return the true if subprocess returned 0''' - args = qemu_io_args + list(args) + args = qemu_io_wrap_args(args) result = subprocess.run(args, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT, check=False) return result.returncode == 0 class QemuIoInteractive: def __init__(self, *args): - self.args = qemu_io_args_no_fmt + list(args) + self.args = qemu_io_wrap_args(args) # We need to keep the Popen objext around, and not # close it immediately. Therefore, disable the pylint check: # pylint: disable=consider-using-with From patchwork Wed Dec 22 18:52:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45A8EC433EF for ; Wed, 22 Dec 2021 18:59:12 +0000 (UTC) Received: from localhost ([::1]:56250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n06pT-00008N-32 for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 13:59:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jl-0008Nb-EM; Wed, 22 Dec 2021 13:53:17 -0500 Received: from mail-vi1eur05on2113.outbound.protection.outlook.com ([40.107.21.113]:12544 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jj-0004aJ-S2; Wed, 22 Dec 2021 13:53:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DbgzAPIJLQXp5EkBpBZ2UsOrnbOyaY/MU1cQK3CFEdDT3r8z7J7viSX1AkzrMUxEKV4NCbxONeljlYdFSuoqS72PlrJubdUe/2kRZw9Rp4aVFYL2vuqayCKmuLIS/ndUvOIXjyWH3lWxE+XRWzOhfD+gLMJtwcKJDEZuHM5Ah9I4BXIXbFJZs8SwGjtLcgKirqCPrbfvwGnH6Xr/LQV8M0Xq0kTb7edwSthDWo4Kc5rB7t3Pk2IYYsweKqUoS2yQvKZiLQvqvkEKrPCSKfWLjioRnJv8H8i+U2KvjvhpLQgfr981Hhh0oTe0jzyCQlIj3BOe4cn5lU9vuq71QkejSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PHc8z4/P4SbapUhnft2QBalQ8QaZZCMZ4CbkKmxHqgw=; b=gmBoWCmeij406NrVJHqgTNbsu2nf2GSLbuYTU2sZV424+A6yB3TUEqhwG8L5M8CFw/WnuDi4BaYf/YfiCXqTVU8Mg9nG5RaRAVbCHegua2HZLsX1CyFmthOHM+5w+q8QIVNL4BmW91Lly0uZKQY80KJDDUlW5+ikNPxVQgCWErmJm7qBXkb8AWd8tJT8mTangTjseUBfOFyfJI9Qwiqrr+eMzKBiT1rFFxsgzWOo/ClQEMM18V2AqwACjMBE+Yy1HiXUdn5GLKm26+7xabpu6Yqqk0o7s+cMgXvKE2Xg6chxNINOIhepgpkGwDNjX6Z1QTetIEtPkN5kBx0r+zhs1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PHc8z4/P4SbapUhnft2QBalQ8QaZZCMZ4CbkKmxHqgw=; b=lLyjJEVGmuwSRwUAjd4LLI1WgTarb+JrUzqIlWHQYnTdKbSwPzh1J2JWQP00N4iJW5PkI/hw5ZX5P+KYjRVKH4iwsE+yAy8LQsE0XEY5mbl85Zh61YaMMy9RWxZv7Yf3+KIWiJ09gtnL6qB480Upx3VoSpaA/2fOj1DiqJ6zk7E= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM8PR08MB5857.eurprd08.prod.outlook.com (2603:10a6:20b:1d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.16; Wed, 22 Dec 2021 18:53:03 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112%5]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 18:53:03 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, qemu-devel@nongnu.org, Nikita Lapshin Subject: [PULL 6/7] iotests.py: add qemu_io_popen() Date: Wed, 22 Dec 2021 19:52:47 +0100 Message-Id: <20211222185248.466010-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222185248.466010-1-vsementsov@virtuozzo.com> References: <20211222185248.466010-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM7PR02CA0009.eurprd02.prod.outlook.com (2603:10a6:20b:100::19) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 96a29b4b-c1c7-47ad-de12-08d9c57c48a2 X-MS-TrafficTypeDiagnostic: AM8PR08MB5857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:317; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HSctenFqURKRIlTQE+OCaEt171Nzme5eCB1mKSATkgVROAscnjBUg/NXlA18Wk2eFLuAuCAMOANI+3tR/Orna9YIyL3cXiSqJHXUvBy3rn4jBBQGRFDSi2efvCgz7dhgp9iGmznyLjxYXpjfmQeP+tVgFuARlUAjgH9OnjXIdEa5y4+o8NuOyU6drsvHZOckBpkrU5jZCMzZ2pe/9gGGZAaD7/U4veIApVQiQIALcT0360hwqUp4DOignDtIBCChG6BF3KZQdZqXLyT1ZX4eashNBUQNPY86asxtjUcMEf08ePihr5Uj+BdHZ2pGMTWjpfGRkbOc+UToXMbGI/8dWqc/Fog1fRL2mLxGjt1vucPKOkzLd3tZMIaeYXyEFF2ucC05DDJKd8wfd74rRDsylen2GW0tM/KcinmxORFyGT/8PCVPdOhSuLYqlEPUcNLiqgkD7bTqTGAJ2kOWlza7k0l+kcj1FUAEv1IYlLMQ/w2xdCN78f0CcotXiUKpOHoahPbngEBHou+Px5zgoLVcfExZevUGVWh+4PGTePE9AWJ0iEkJDHgfB9KRNeepnX5mJcy6jiK7e5ojnalhrKMEsJ0CkQHvPDCE2bz9Km9F+2xp0ljykv25jHYDsiKMs9Nf6TiZS+Ub4jvlM0B0ULdq+WB89wVXTLplWks0W+P7jOMt7N+AKX3OPxdLA9kPOw0pbhN3j2DU21kzfYZ/4TimpA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(2616005)(6512007)(4326008)(6486002)(38350700002)(38100700002)(6506007)(66556008)(4744005)(66476007)(36756003)(26005)(66946007)(5660300002)(8676002)(8936002)(186003)(6666004)(6916009)(2906002)(52116002)(86362001)(508600001)(316002)(1076003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0n7hme9kPISsh1YNg85YBVeehluzgYZvTD6nwhbdNAuHAhrUUniMS3gkmk+gaWE9ScK7EzVkixVyLZRe/29RozR5ASgoyhFGEYT84HBqAHk83MzPA7JcaWLN42gquUiYRcsa73+BLf9bThqPhKHKx9UES/A1hej0q23JF7SXKPxweBoqCW8lQG/e23CrnKqd+IkOUXgpY7BTNAAI1s9do7NZjlMQNK0p4TdaqrgrHF1aju7J39Q94YHs89JDUkIJqdoQHkX8w7y2N9pXTGW5sw1G0o2O44E18WIlevrXhG8pDsXIasgrNbpWpJi+A1pOAhghCD1coTKrEJrUMGlKsA1iKGA8cTNN/7Fh00arhiu/xMgC4iJQU/aAby1kpv2gw5hPqTvRIgjGGxXCyvNOWga567uC5o7ntLHftxbXyqLxowQ9NoNjY7Z5vr9cwwLICNbQ2/JROa+uwWYny2isN2dOJ7dCJHbo1Xq2iV8BS4U6F//pIs15Gm5SRz6vrehMZp02OBdWTHxnlLK4xopX5w+NzuuRCkrcFshkxbI35hakSHtfjyORnOAIt0rA5QZ/26HT4d1zkJWWKCGg/cQD4lIov2s9qPpAt4Fan+UloKtTBIhPrJryFwv8vCD0MNmB/HNivcHMwMbprZCyr5a6M3Q9dfgfVlmG/6E0uB1gz9/JksQ6gNxMLsaBGSnjr8bGTphsrd6yMQQKluatpCNp+b9K8qJfoPQrcSmjpoOHPCVKezfnAXtO16QvJQGtG80mHppWVNnY0rGRnduq184UyrAlBzIJegTus/5M8T1X6ry5FAwk5DeB8NBrS/MqiZE2MR/bQRtp3wwcY7S8ejCF7k33+tiKS92Tt3GDpLP8vEVA2uQMK3r4ux0rM6eYq9PuRygRCHOlh/+OZMeXFjxZkhtr/g6RCYnvIZp8Ab8d9mXfjVfDOUgnTBhsGfx3TZIFVucPTftNVYsGDPkPWS8CGAJIlf5RH4gSaRwnb+bCQVLwbkRDasbk322LEvBCDq0m0EZUx24ZOr586XJ6G9IqOQR/lBg/GvTWy8sevufCbZnIYYUH85uY3hrgZH6l0p9rVw49YoYhvcavn/nu1EW8etgJbe1VxmMBiAwHn/AIuGzcLOIBDwAuXKEj6DvoKdMz9l3LWN6j9qeutSu1LFTBM5tPMpUw2QryKTBam0JERS/fT5i4WYf655aEoZJaCwyM68RYZiEeh5OwN3st2AVqPYDV+6MsVWRNzpcjZ+nKvAWn9vGUhOtr0jA/IiF0NhEuz4GVkJONa5jWd/rsvTp1cz/V+VI/EtTKB067K3CU6q018nF8GN8asT6gsj3JMo9hjoyRhhox7sc/Lms4+VkKUWbSroCkcxqsbSXrlY+/9q9tafZd6Ko2jLMuFw/C7PK5hk0nKOvn9RmEeBbsqE2f+co6iYXeIdDtbTWmLtD7itZ9c7eNh3IyhBoUm7aCe5F/Kcbvvm/3yj6RElaeHCzZJWG7jQSaLE7+Zsj9K66fSbSS3LKRy/R1rOzi0ijqm6dEFuflGaptWluOq/x7MPaKpPqE7y83rPlgu8zOCQjMI0fDrnAllYXYwRVy8FBUkmpbZ0JK2PXeTiIe2FpM5LebMoYDSbxRl0iuyYn/gCBeepUohIQK++e2Uzzm0IN0OgAb4Hu7Se0V5Py0d97PhOE75tGz8i8ZnifSNWXPqNlFIYw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96a29b4b-c1c7-47ad-de12-08d9c57c48a2 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 18:53:03.5822 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AakZL84kvAqIGGIhPS+8TL+fXuSoTABNHBoyVJ745MKCMrAOEsWr09dCv99KzFCDdTHuEb6YcUTtl9s5YbhiaP118cY9b3LN71LWcOf3SRQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5857 Received-SPF: pass client-ip=40.107.21.113; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add qemu-io Popen constructor wrapper. To be used in the following new test commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin --- tests/qemu-iotests/iotests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 1ed3eb1058..69d380e137 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -246,6 +246,9 @@ def qemu_io_wrap_args(args: Sequence[str]) -> List[str]: else: return qemu_io_args + list(args) +def qemu_io_popen(*args): + return qemu_tool_popen(qemu_io_wrap_args(args)) + def qemu_io(*args): '''Run qemu-io and return the stdout data''' return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args))[0] From patchwork Wed Dec 22 18:52:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12697188 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2D942C433F5 for ; Wed, 22 Dec 2021 19:03:14 +0000 (UTC) Received: from localhost ([::1]:36050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n06tN-0005hK-Am for qemu-devel@archiver.kernel.org; Wed, 22 Dec 2021 14:03:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jl-0008PI-VY; Wed, 22 Dec 2021 13:53:18 -0500 Received: from mail-vi1eur05on2137.outbound.protection.outlook.com ([40.107.21.137]:20601 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n06jj-0004am-To; Wed, 22 Dec 2021 13:53:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G8tCTAQF1EI4mfs9ylg05Bq8sLnF6qgTAjO8vZV5Fjo3pPqkO2qU9em8Eya6nUFE9JbbAyempkB4SQXyDqcinBTAw/IdnRPQfqOEt9ysWf7vBPV/A9fZ3yNQtWPYBGS3n9iORIEwYDDLPiBiwpelqtz1NTxeHC7ev49NZlnQ7A7cxk94PdTwipyN6qKVWhMoctorDCZvY3lxt18gP65i1fVaGWaTRm/akprcniE7zcNC5OCB27t32yYSAVIPeForCldSzkaGYSx/mHgM4qy8Lev0KAobTOiv5y/AGev8EWYWGEf6gH4rLib/yoG3mr6Jo7bVenpcMlkDIrittX4WtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OKHdWI3SpyJn/wYVm/4ls8RTPDQNlwd0U9ZHHaRsgeA=; b=nKnrH1Vo6tGxXdFdqWwfK4VWk5hIJm2/Q6kvpqUsf6u8GXMCKyodANmT/DhIdBbgT7en0MqQBR8GhLbRCrM0JqnF0h6KACNOPcMzTan+oQollB6eSj3rs0PdA+SPvk2+1vLciCASWUZkfYHKLtxmdT1fycWhfq/kCzP0LpPguUEjq57Xf12r9RNRxhkK67c3pB07qIvdfNN/UsvR9uktvjlqaVOWGoGe35ZAuI5SxGXnnmAelzi2ftxzjygUirtUByffvoK5gMvFmKdvNvLUmzPol4NOiedGHxjFc2AVXEDF6V4C9OunbnRlZkUCOHhg4hZTl2Ar7be7NokS8oqCxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OKHdWI3SpyJn/wYVm/4ls8RTPDQNlwd0U9ZHHaRsgeA=; b=QQH6AIwJosyUgnraNTwbtZ880beGyuUJm48UzAJf1mxHGMtYTiw5c9zBng8WeXEM9Xg5Jm68cgz2wd29rS/hrwp/ywM4wYRhy4pM8o0et5OptbuMb545+sZJutphKWqu24pwfM+iifFM+WljFjqAVVFmrRB0z0uSHd6P0vCNVw4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) by AM8PR08MB5857.eurprd08.prod.outlook.com (2603:10a6:20b:1d2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.16; Wed, 22 Dec 2021 18:53:04 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::b118:483a:d003:3112%5]) with mapi id 15.20.4823.019; Wed, 22 Dec 2021 18:53:04 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, qemu-devel@nongnu.org, Nikita Lapshin Subject: [PULL 7/7] iotests: add nbd-reconnect-on-open test Date: Wed, 22 Dec 2021 19:52:48 +0100 Message-Id: <20211222185248.466010-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211222185248.466010-1-vsementsov@virtuozzo.com> References: <20211222185248.466010-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM7PR02CA0009.eurprd02.prod.outlook.com (2603:10a6:20b:100::19) To AM9PR08MB6737.eurprd08.prod.outlook.com (2603:10a6:20b:304::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 46e07f55-81b0-4bfc-4f51-08d9c57c48d7 X-MS-TrafficTypeDiagnostic: AM8PR08MB5857:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KFAoTKHxpNAF9b9g4NXheIhKvfhs9mFfnrXIRL+1knAw7GCR6AOevmGsQcQfXlBw9ERBvcrYqHY1VTbVsogos0EU/90VB9OM+s+z9QLe4XaF8H3zrNt9an1lEpVqAwzEZa0+XiQL6kzspVsTiXCZXJm1mBnVMA0PR2MsjSmrfgtdRtm+1irvyU22AvgQU9XG/PYu9O6Kv5wCMOG3nOgfmdQEuMQ78OABlMcF3DbCkQq9k2KEdK9c4W7d4OH/793lsN8Z9vTJZNkLnQ0Yq95EOpTdiLHrkAAiWWFxEn4iT480DpwdI+cH1O54ZRTgHN5a4F6ra9X/TWMdoIQhjc7yYxq57M53IOslXTY0/l7I0RsNg9FnaG7FdI5YAEXXsZ3rj8FLEw7r3OU0+WlM3fhaCpQ4VD9xnWDvFta27nsLZgNjb3agQ+L/CrBZy2UoTX7bsK6ob2FyOHdFmXPwRZqzkveLwt7OCFf9XLtamMRV3OxX7NiJFtPh18ffe/MxqmYUIhArUc7rtEjuq5eeCz7rCcEMD9aCM1QD/h/FvuJQGmuYb0By0oME6/Tmyx4gLq7MEfTA4Z54PhJbzawV+oZuox1+woKGiGHiWuDS5fpN0zqXHmoLJ2gjw9OVS7fpJlOEDTYjYe+E2+1u+D6ed+iq//F4kZvsdhhxKucNAqXFW2Dc3x4j+KGoypfm7AIB/UP9b7ujU135VEQEBhze0gQgFYF7iDuOOqnOdC93A4+kxRbJE96/5OEntckTDEG16XdJ0xJeT/EvnbZblUcGVeHmxIz2fAEjK3QxROF5JhKjsL1eyuEN9/2IRzzS6UdM/FhkInPjlUwn3PtAiXezGbMfjQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR08MB6737.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(2616005)(6512007)(4326008)(6486002)(38350700002)(38100700002)(6506007)(83380400001)(66556008)(66476007)(36756003)(26005)(66946007)(5660300002)(8676002)(8936002)(186003)(6666004)(6916009)(2906002)(52116002)(86362001)(508600001)(316002)(1076003)(21314003)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m+V8L/gNxTSStdliVb5UfIrmNqE2JtWGZUolgmcHtuza6nYr5GBsd1rtN5ldrJKNMS5U7C0o0rf4lu/va1Y19HFQke9IaGFLdaYiS6IJ9ahe0nObfKYN2vutZdEiAIYtOqudmnupPKZDCYd2P1/GSgc9AaCm/J/rd0iJw1sySrxWCzsp2JzGgbx1dUJDffj5mnS8ENX9UBH/tqiqCGMBhNB1e+RYBEP/fJLUWXUEVhH4hAoUsLNUaB17r0PcVdkhn4Dc6Za3IOFDWx3ZjEHNiMv3iDqFDzD5qXTw++k7gnIvFxlgccRNdP4Vuv1si921dxncYgLCys2P9UgTeGCKCpOHAy/C0TwnDMaryR4MVC+mpfbGSKZo9muSYRo2vr986+plNS/XGOuWSHJO7aPFi+MDXFHK3UlvqlloRpuejkvLKhhlWaBj7BOqtE4TfAOdXOQlbCjOChwmXhC5K+NOpZv5Q62cnktwCU9JaHsv+SqmR2i0bvVJF638F79sBcxyUcDVnrWLkfFRtq/40DoIp1tvLMbQJ/6HkN+yX7o0YZBxE2tGaGNILuJZFfd7+Vi/thFjXaAF7gxA+GrHgD0zWhbSHCvhk8FJ3yQIxVl02JpzrB0Asid695Ub14YMrEimGYpFkrQ+7gPDwgxlJEVkkzAkgjS2Pr1YiSImoirdqGSIa4Ve7JO2JpF7cStw0jSvSibPICcev68y/On2Ofm+3235+Jgo/p/mlpkI9TXn9WYqc7YQ4uS6N8gKQ+jON2hZIZSPUDOfagvCeajtP6vod5Yi+Tc/QSPFu2B5vpTcDyWWKQ5dJO+qPNJQ5ymtGmbHdgXXWvRJ7LHZ5FfAtCfQr9pWJG+9h4VBSKIac3Rd5CEOtNgn+g3fCh1QFHuvCyUPpViV5hHJ0/VkHkOFNIyTrMpR/UibpE86m26PeeL4tYLgLsOiPdCSNSvvP8AowjvNjrw3jkWyGfG4RKM0L2O2K7/5FhkXokxey59GAoh3FnbhFdw5SRXIgkrD+EIhIx/EJ008mjkjCayGr0TxgglTeo+dH4xtJ6NS+EZUVfcGHnV3ptasIfRp2uOJBYlTnto6i9/Q4YLn61LSzRJ+/CPqZ5ygRat5HoMwZA500nTo7i8c7FIBjp296ssyXXU220qFDYStNOlfv36p5MZB7Wlml7r24YtZ0g7kkpNcY2ewU0EKIZYsk/dn4GZUvbsmB7WsWRDTWfAtiwtMdb0nVBnhzrDX2/JjKaDYHF0QU5VTLqddrCoWGMc2JTjzeWQ37oHQMVNyHOmzEGupaRNVSuGsAwXaolM8vXonzL77tyiG7vjMJpm0Ls2kulef98dTAp7n/b7Cd7Rj22P/e0ENJvGfF14syriEdymiT2bZ7fcWM2VAPS58mWGcQuSaqexwoL7e5+GrXpZAipPmnRIDclm4wm1taFvPPzupKkuoUDEuwtF4FcqkmvD/DCxIbzm0gDM7/7tx91P5Kw3u8wYNMhSkgfwpNH8fQUAdxLmhLnD6GUubkS1HWcFYUA+Zqia5FMGbUsW085PsbhKP0vGRhb2jhNUKfxpmPxKFEGwPuJIneiJtTKiloZBDEvPb0a08f+4/RTQpXdwBXqI72sqdi+xiUiS98/LoKVTenzwqhUAWYrpf1a0V2zyt7djFwjinLf/42LC3rlSOfhgjVB1JLT3LtWhT1ijxRyYPW+cSsB6Y0GI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46e07f55-81b0-4bfc-4f51-08d9c57c48d7 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 18:53:03.9572 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4feP7CaUcKFo/dc8BY5L1aeRGEfSfeKpCuctnATqSzgOlLgM2KoxsdHRrdFeDT6jL7QvSanSaarudXMQpihHDOMv/xnpM80RxaigyUYJL4g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5857 Received-SPF: pass client-ip=40.107.21.137; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Nikita Lapshin --- .../qemu-iotests/tests/nbd-reconnect-on-open | 71 +++++++++++++++++++ .../tests/nbd-reconnect-on-open.out | 11 +++ 2 files changed, 82 insertions(+) create mode 100755 tests/qemu-iotests/tests/nbd-reconnect-on-open create mode 100644 tests/qemu-iotests/tests/nbd-reconnect-on-open.out diff --git a/tests/qemu-iotests/tests/nbd-reconnect-on-open b/tests/qemu-iotests/tests/nbd-reconnect-on-open new file mode 100755 index 0000000000..8be721a24f --- /dev/null +++ b/tests/qemu-iotests/tests/nbd-reconnect-on-open @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +# +# Test nbd reconnect on open +# +# Copyright (c) 2020 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import time + +import iotests +from iotests import qemu_img_create, file_path, qemu_io_popen, qemu_nbd, \ + qemu_io_log, log + +iotests.script_initialize(supported_fmts=['qcow2']) + +disk, nbd_sock = file_path('disk', 'nbd-sock') + + +def create_args(open_timeout): + return ['--image-opts', '-c', 'read 0 1M', + f'driver=nbd,open-timeout={open_timeout},' + f'server.type=unix,server.path={nbd_sock}'] + + +def check_fail_to_connect(open_timeout): + log(f'Check fail to connect with {open_timeout} seconds of timeout') + + start_t = time.time() + qemu_io_log(*create_args(open_timeout)) + delta_t = time.time() - start_t + + max_delta = open_timeout + 0.2 + if open_timeout <= delta_t <= max_delta: + log(f'qemu_io finished in {open_timeout}..{max_delta} seconds, OK') + else: + note = 'too early' if delta_t < open_timeout else 'too long' + log(f'qemu_io finished in {delta_t:.1f} seconds, {note}') + + +qemu_img_create('-f', iotests.imgfmt, disk, '1M') + +# Start NBD client when NBD server is not yet running. It should not fail, but +# wait for 5 seconds for the server to be available. +client = qemu_io_popen(*create_args(5)) + +time.sleep(1) +qemu_nbd('-k', nbd_sock, '-f', iotests.imgfmt, disk) + +# client should succeed +log(client.communicate()[0], filters=[iotests.filter_qemu_io]) + +# Server was started without --persistent flag, so it should be off now. Let's +# check it and at the same time check that with open-timeout=0 client fails +# immediately. +check_fail_to_connect(0) + +# Check that we will fail after non-zero timeout if server is still unavailable +check_fail_to_connect(1) diff --git a/tests/qemu-iotests/tests/nbd-reconnect-on-open.out b/tests/qemu-iotests/tests/nbd-reconnect-on-open.out new file mode 100644 index 0000000000..a35ae30ea4 --- /dev/null +++ b/tests/qemu-iotests/tests/nbd-reconnect-on-open.out @@ -0,0 +1,11 @@ +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Check fail to connect with 0 seconds of timeout +qemu-io: can't open: Failed to connect to 'TEST_DIR/PID-nbd-sock': No such file or directory + +qemu_io finished in 0..0.2 seconds, OK +Check fail to connect with 1 seconds of timeout +qemu-io: can't open: Failed to connect to 'TEST_DIR/PID-nbd-sock': No such file or directory + +qemu_io finished in 1..1.2 seconds, OK