From patchwork Mon Dec 13 15:32:34 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: 12674141 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 713F0C433F5 for ; Mon, 13 Dec 2021 15:37:16 +0000 (UTC) Received: from localhost ([::1]:45662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwnO7-00044B-JE for qemu-devel@archiver.kernel.org; Mon, 13 Dec 2021 10:37:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwnK0-0003ne-8K; Mon, 13 Dec 2021 10:33:00 -0500 Received: from [2a01:111:f400:7d00::703] (port=2464 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 1mwnJv-0000jw-NG; Mon, 13 Dec 2021 10:32:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RRe3f1nZB2IoM1bBB/uHoMZCeqABHpBcu3tABYVR0V5DqfI3pYGezYTsGM+t7AeXP0FiS3JTzPOmbUPdQ1y4ayPATOfGSmjnYQMvU0dYPwQuqjU7fhWiED9LgCAn8l/dQyrHA9zcoIQw+RWKrsI5IB4YfEbWGNBA5ba6EOAkCJqTa4tLAzouVDo2zOhVHqhKGbHiamYL43pyVQXLNG+bg+/Ydx3vVE/Ww/lYa1BlItyhxl4MkwhEMRLzH2b0smnCkkJ/j99Y/3j4OeBm6iNQvW3aRuXfsJBxTYNsUkVg8uc41n9NAIz3lu3mocv5c5R0clikzRh2ml3tAhqsnGm3uA== 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=+C3PYtNkL2c5qo5udAhGEo97xa6gl21J40zzQUCEELc=; b=msNnmBIObKHZcMTrcYMano+KHWQTbLILWZ6jxkFPJuDYZK/k812uHX42uY1kbrXzrWY7wn8iMU17QfleP1SMnFMJ+MIw1ZgsBtQU04LlX3m+2LkiNc36KDx7iBUfG+1PomlNu575ex2MNNyb6EBdOEBsp7vMx7EH1ciY+1el01BtqBzqY9aHTGaq9b4EYqeDb8D80eTRJxUCLUJBXd8mP1GRWbVzmWb0SefuaIdY5ZJlxhQCA4o2E9mWmQtZCPfBs+ze3+nu/+ZMGdW8h6Wm4d2r3uBtABsQs00bXxH0zq4bWcHQu7ieck6KQk6uV/hny+22FUvzS727eZeCp8YLvQ== 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=+C3PYtNkL2c5qo5udAhGEo97xa6gl21J40zzQUCEELc=; b=R97L/z+7Ewq2VLiQ/aaUpNf1qbqfGiCLYUPnmk0m49zmlDX/jg7/oDOy3tCEbYWZkyFedubcSMENEAuWaVZ2Lrs2ISqmms1a6YIkmxMxwZuBiIs9xYHfw31MtqrujVq5bmJHbqr+KhZ9Uh9HNDgTsT4geOjsdpQvsHgHL0UtI9g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) by AM5PR0802MB2516.eurprd08.prod.outlook.com (2603:10a6:203:a1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Mon, 13 Dec 2021 15:32:51 +0000 Received: from AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5]) by AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5%4]) with mapi id 15.20.4778.017; Mon, 13 Dec 2021 15:32:51 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH v4 1/7] nbd: allow reconnect on open, with corresponding new options Date: Mon, 13 Dec 2021 16:32:34 +0100 Message-Id: <20211213153240.480103-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211213153240.480103-1-vsementsov@virtuozzo.com> References: <20211213153240.480103-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0402CA0023.eurprd04.prod.outlook.com (2603:10a6:203:90::33) To AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac1dd801-ebfe-4424-b6ca-08d9be4dd2aa X-MS-TrafficTypeDiagnostic: AM5PR0802MB2516: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: bM1OoFFikkyaLsO6fWlMC0qoplVCKI02eLBkFbLHH5A5fZwiuPc4nq5hxv1vyTPcTepH1aH7XugtFRoG/OOuvrb2ZGQVdonbQN2ILZ3DIzFhLEjfMHtthxWnfCtsDFwLkfddHmzOEe0psn9n98j3xiiXhexlIXT720/q3dNHREDxPBnSMg7uc+Mmpg4R8OwY7S1mDQe8+QyXxafExq96DRUZAF2bTr6mmZxxFMhz9j39R1irnmgn8jVkUQ3G7du6OLBcPE/wTCrSsHuozU0ULRyL1sgyOeoff8r1CqCVkBVpw15rXkAJud2kiCjrmtEjA9hA1STjyR1aUi1gbkXkP5CXPGw/dIKQ6pwzW5p5pBlu1p/owUGZUaHuRaa5sKbnuaelvLB9KVtsFd5eo5e/pF9VKTnp8AfhFdd2sLmyCPNlYJmHu85n+JcOlm59fIB0fKPH6Q1BHVnn2NK0tUbftzisVnTudePSD+g7WrT5NI/8EcJhRcRvoGsUsC09AF+8qcMW2IB0PEY/uJ8G7CelZQJHcvQR3RXeQ/dkgnOHabxecLKtizcHYLqv/JuAN1AOngQTc+HPyJSulUQRIH0qQUUlB5ChDl+zkvG+LEN7oLbGmu682iOaOuwlx8WD759WqSoTMV4f4ohD1383VuILGKVa7Qb7DzPJz4khd5xS95iWbfkzu17XpjnhgOZOkRV9rQfNm59OuisUIuxLyoOdZA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6741.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(38350700002)(38100700002)(8936002)(6486002)(66556008)(26005)(66946007)(186003)(2906002)(4326008)(2616005)(66476007)(1076003)(316002)(6506007)(6916009)(52116002)(83380400001)(8676002)(36756003)(86362001)(6666004)(6512007)(508600001)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WSAJFoF2yqWrgfC0QTZ8K5rlCf4cp7uWzUoaY4HXr0tEZpjx1YsQjCq7F86hFk0QK5wDJAmtD53armXyR2xIvIq5Jj0jo7lBY/kQBbCYsd+wiucrYkf1EVl03uWgqVjX1/KqLDphcfMrOIddT0OET3r2CwVAmDFMCb0Sjehc93qqSX9L9VrZ1vmBRhciHjT0MJ4w5HVVvtPoYavjh+WfXTkHiX1jWlZhbKR+mrKeqJICn0dID7/hoP250TZhTCoFxzNbMW/Mfz5+W4D1woiRg4mcZvDVxMDdJradGy7dkRptMFp3kBuU6rvXBtF5Glga72PQpdfrUIWj6OqXTLOwwBgU8NN35JYMVVcDwwQ9UZY1dnZcj4Ud/EFEXic1KNmSXVykrH+SqCa8Bp+/yNk9+AJaNvB8G3GUHlUk0Vw2ZTaKW+xAW80UxPFARzx3R+DPSMhKBOiqBIIJBFvem6QXUQYCd/qcj6enu6lJwvFBIN/1T7RplbxqH2j7DE/iDgu8rCP8FvHG0dodjzImhAurISCRRCsb0NMLCU0pqu4Ahi6HuOtvbiFBktfLqkyI7IQgOBvKHfH3u6rrOwg+NJRiXwxEpCK6bkRPych3OdEoc1LOJgAfMWZNOLBcXUdJZV52kLdMVWFrqTDXdafZ7v+tyaIXAxTRWIQuyypz2S05yRwBqCY5YkBDLukKNS0At9xlBXh1pXMF8QeX9m+9CK7+1mkhAXObiVS4dOzHB5t7nHAyn2hsYQtnDJzLOIlwC3i6pSzg5SIo8pTfJpslhG0PSO4n/8IaEvfRjj01yuOBTsb2vq4rOeL1N4dAm6fJOlKxhEjPW1GalYfVXrBzZzRgXfJVsL2cyghZjLwsNwuslfkkBguLudWu7kuVMVYXBV3kUmhqzO0FZyfItMsKXPmcoVLH6v1UZ2MhozFmn8o56PeFrHkP1h67Erav1gaXmUx+pY+8IKpn33GotMmCyMtkfDmik7tYglvIW8BTAZ8TfkxUVYNGKbjbYhHERb3N070UuOEqq/xE3kEuuKs5ygUKRj7EMuWsX6Rquel7vMuOzKin74CBeIBYyybrxhyN0fNf3WGVCelxTNIQT6PUNfz/9+3dj9O1Xv8tWt9VGzGcFhQDe+KJ5brRoIimrEuXwaaQzbhQxWSOm7BG7QaSlAiu6Gh5jUDj/XhI+yb/9dpmsviXotl1+xwb2E/gEMoX8tpi924pwug7htznQcn+yTqT8VYHnkvP0eUsYLCMI7fa7yUVH38ffxvL3OuZRElAoSFM0i3VO8/2S8BB7Zt2++jQHef313Me0k26tGrygnX6wwHYqKQPmmrC7dhTc3TYCDJtaSA313UiUzXf8erY63vKtqh24Mg85fimDY1cPW2Pb+yyrgrb8zq+scz5I6bHHzFkof9BxIJceDCWd8//T8UGks3QBPrVuMoaE8Wv7XMZXrtQ9VKrT+Fo4VvP7/u761oEoUXfaF46Cj6s0lHhTU76yqXsDVNX78heaentDwQXmrrZh6yCvTnObhyCocTAw4D9mSBqTyFD1DF33NJMtaaxH53q7pj+9CkftugTg+c8IngCzNWNua+c0PiHs9pf+id1cFMbP7ZB84OA4ZnjLMEzYI7jaaIHHu9D8mjFsZLczIVdASRWyGkGKiKAF0UbaxneKNpg5a5A3EZId9M0FnGH+vlrAjhYYasC8wO/MH5l9yk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac1dd801-ebfe-4424-b6ca-08d9be4dd2aa X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB6741.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2021 15:32:50.6784 (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: ukGP53mpY1QLp5kdIpAJY/fryZqwt4b4IyZ0xYWLhive31Ujt6BJiRdLpKvHGH0BsAXdO9Efo1OlJsfKBOOggOO+zrkyYbJoWAX3SNKsgs8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2516 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::703 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::703; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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..8cf82417a6 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 6.2) +# # 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 Mon Dec 13 15:32:35 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: 12674149 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 1CA36C433EF for ; Mon, 13 Dec 2021 15:40:40 +0000 (UTC) Received: from localhost ([::1]:55218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwnRP-00020N-5l for qemu-devel@archiver.kernel.org; Mon, 13 Dec 2021 10:40:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwnK4-0003tC-PJ; Mon, 13 Dec 2021 10:33:04 -0500 Received: from [2a01:111:f400:7d00::703] (port=2464 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 1mwnK2-0000jw-Lx; Mon, 13 Dec 2021 10:33:04 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UJh0wDZdH525BccWb1bcfeW6LBgeqvv78b41oSJpWoHsyZtzSL13Gho9Qn8IHzc2T2XNrk+4tVD8oa+u+dFDFjVOEQK81uUu2S3ang6rfzpO1ybce2Z4DrpkV2AYXlUVRdW5h1C8xKX78iDHd1pO+pmLQw4e2N66UEe7vrcfJAetu7peQ1ORZVhcdG/4WRz0GFC0A7DOWS8I55dqUO7a7J15848I5GyAHaML//9rJVvkhvetrdseWrI8vEAbxVjga0uLECb9OOERNuYlFCL9stBFW4ZATqW2b+AtOGFulxTeBagSHDBsQK1fRIm9Zg2ny6bvQNBjNrxmifURyQjDpA== 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=fQn1c4gtYB3cW/5TGzrdIV/5G5QK5/qSTRHoCEP24uJyE+ZmjNOHoVVeyWXf4Hqub+cb9qUqtNH0Kuo4eU0lgA+GY6S1lPo04jI0S0wmLRl0pqb1NBlipmwSADnnZx0s9gOeNmXUUJpHBVg3WDhELmIqt09Y+Ke66wBhTMXkyUWh0Ln3MUipen8QGO7rKoKVM+5NqiKHXgdUWfHDxLP5N7VX7nMGdOlvp+/rJoMcODGs3goxS59F8qPgiEGTGTOjW2pmjHsUiciDbnC13f47bU+OMfNLltRaEY/4FPwT110sHCOD3GJEJs9FoToSNbs5dPPXtB3GG3lITq7LZCugog== 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=l9WBNM3Dubjusrwg02kMPfiWcdYXJwp9lD+NBiuUyzIKkEtDAFuQveww0h8rpGklfwr5TzGjnPEdulTM3oGnXLoeFrBhxf09rkl0130t3jx7tKPduyuTpfBxm/6n0KfIwsR4Kq5/QmMCO5Us8dSSmbyTeh6x7BGXK0ZEc1vWVJs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) by AM5PR0802MB2516.eurprd08.prod.outlook.com (2603:10a6:203:a1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Mon, 13 Dec 2021 15:32:51 +0000 Received: from AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5]) by AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5%4]) with mapi id 15.20.4778.017; Mon, 13 Dec 2021 15:32:51 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH v4 2/7] nbd/client-connection: nbd_co_establish_connection(): return real error Date: Mon, 13 Dec 2021 16:32:35 +0100 Message-Id: <20211213153240.480103-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211213153240.480103-1-vsementsov@virtuozzo.com> References: <20211213153240.480103-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0402CA0023.eurprd04.prod.outlook.com (2603:10a6:203:90::33) To AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0ae83c78-21f0-4756-1b49-08d9be4dd305 X-MS-TrafficTypeDiagnostic: AM5PR0802MB2516: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: I+CzGFs21Klr23008bEtQ6XQ4rjlQo0FgiYn+nBCG9el7rNULNPe/OlckhROKVXhVdGwbSSYntsGOowsq2PSpQvx1/9feZoXjKbVKc6H1vBQlTvwduVDHlx9qKPuFAFzCo3oK9Nxg5sutWGx7fAkvTheX6C+o0319657MJNL/Oxkq7S75cV1mQa/QazKXkbJ582bqgcWaOh9QuGkSZ/aQTr/dLbJL36cy8V0xMLqLWb+VxUwPrD7WyCfTUvCHpR4T393MTYJdofnqLbPf8mJSlrLqJlwr4GvKf9B2S56q1PJc8W63XjB+SqdsBBuGpq4s8Q3G9t2Wx0BaiJDo3kNUY62QGCVelv4/g+1Rp0SIIrqY9rqMi8ZTTAPITF9TJw8IgYMySQspZtrodtlGZ7yv0mtsqrPFsc2zkEhzqxCg7ykZ3gkiX4ed8yxT/kqgPN/aiuG63riq/YdnVg41Sjgb6BTSqfgvsy44d7KZt380OeV5iE2QCNNGxFZWsZTcdP2N/FpRrhyy5abfimpaR6Ep0v7BXVFAPFhQ7TUyNZVDk9F/Ow7Cke5tyCKn6yLkGzM2zaczCHKsnu9JkcthMai2iXqZgTB7fxQvcrbaMpeiORuxG8GesDcKOjT3TFhiUU9BjTuiOr+j9XVkdFaBygy0DctKuelA0pzg7EXFO8mf+W+yhjFGGxRzVUTfNnsj6i2fcPgiMnQa/fuiPquwON3Aw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6741.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(38350700002)(38100700002)(8936002)(6486002)(66556008)(26005)(66946007)(186003)(2906002)(4326008)(2616005)(66476007)(1076003)(316002)(6506007)(6916009)(52116002)(83380400001)(8676002)(36756003)(86362001)(6666004)(6512007)(508600001)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5TJTxogWsG8jCrNo54XM+Yy70Jc+D9yAB6bSqCRsaEIAR/DP3eNhavJUvEAuXAO1JNO3qkhRG1g+I6IJP919RftpsXSjCmlZFAYubx4Kv5MwxZWNZZ9+H5Aj70Fc9UU2MpwbP/VErRkrpUDZI7WBvSdKR9Pbdj1aQfuaeYlgKHy5ZyElswgTNgbMz8Bzk+xGRY3K6WUQ9NOJNbvy1Yv9Ox5dfPw4q4RxhdH+GrvBmX7Sb/ll6cZ+gQq4ZLmBsppX+er9pVLYQna1xj3phOaMKwJSaReru2oQsQzkSav1Tws2TRAYsxhP45d2zmDEZBgTfxyLKhTAkTctGYiVOzFrHOd49WWWlFK6HvrtBS7XplR+oCSbVRDos3Ac63i9hgG3ClUtwmS7ZcHLHRZ+u1T52MhLi94zpWrj9RojkUpNxd8cnRMj6RSgqjBcSqSMnPHqUMZ/mDVFSKYAcLs7TI3qISQfF2TbrY+lTC2QgVk+fqvti4jE8gVRXccDzZ10NCCCKEuPg8lt9t8kC4mTFLrDE32xEZUST2198DtF1zVeAe+yqdgP1R6u0hf+AvEExwke0MCkJrk2RqeiqM8UJaXNGjLzOTwhF0VgjHAqi2pErKkmtokA3ZxVR2KAyqtnWQEOrOQE8aeZK90+FjOYPyGKoOacNw71LO7JhBm7fgftzwTyEfieopak8B+ID6R9uXBuEJTAz4I4WygX5YTHALPlC16KimFFrLhE8fbMbv9QZBxVBLyw220BuUtAohph6K2Y3hVW1VqpTxcTTGe4rC2gfNQR2tQ+V7yGjvz2beoLOV56Mz45c0DCy+jh0+cCIkXdgj/2RXzFTQ+M4pvCivwvMXfr30YT8MLEavsnErZbby2ra9mJnpEbIl2V25worQc75DbOwRHMVduefjMsqrpAUcEMd/XEXjOGb970VGYC3HOXU+Eg82LTmgfUvE9xgN/ONoYCDxo3fSLUhAK/BOza9PpDXaK+j2D9579LsMdnr/7DT8OUqZIMqoiuvlsMfGkGJ0QehELTZU1oTBgdXVBOI4WVHpX6/P0ooM0xuM/hcwi73AuO5SyiDizAir0uRYbY0ZL+5Cw9xaEZWm7lKTvGRMyNWoCSMKfLZcWip/5GUKLY5UWWjkG/SkDkUbG3UWFAf7O8Goycxp0d7LxAOf/iz9DgqSPI2TcsXwaBZBW3nMjkXWJ0b7HmzlH5x84pv50nWlhR4Kef4VcFZzZEMHCsRDfqxHKNpzYSbGFKCQImYSh9PbK8nxFWgUO+9eaUXprTyFU2K3p8IdbnI8mc16GTcefifyb+KG5f6xhTGKoRWvUFvrUdxhzESfvzRN74/ktWcBtqT47r6EVL+TD4xu9fA67ViJdf2QY9db+vAVLsOAeWiF77wQLgm28JQAQZTnrlkcQwAYzknYw//Jpi4+iiBgnRb35cg+Sy4mAsvILWNwDJ2YTm8nUfCS5aDGl0OTygFGQHjssPFcw7qMtSKtP9B6lTwX/HrOvdoWp+kRxp8Sme9TrDyHqI9HZGuTsnLxzqxUA6YEsBEe3GjTu8wETY7uY3BX78FziZyQhc8j2mWqzIpkagThitWhu1lWuiDo44P9QIF0FspJ6Icg+a4vJ/lPP9+XDynQTXBwqJl2HUwuS/AizHW97Zr9/uhRMUclLdjej3l/vKs2qwuWsReWwGSXHHkv7ityYEEBAxVUIVcyY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ae83c78-21f0-4756-1b49-08d9be4dd305 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB6741.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2021 15:32:51.4460 (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: 9Tl6b5/+xVoTpP73BdItwMHol7IgD4Tlv2FzURVJkFDptE4B3o4UQK4fEkh6L3GMCpN86LkSWbGZpTy/4tl2bzx//2bJdlzq2fmYBZzdMUw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2516 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::703 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::703; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 Mon Dec 13 15:32:36 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: 12674137 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 E85FEC433EF for ; Mon, 13 Dec 2021 15:34:30 +0000 (UTC) Received: from localhost ([::1]:37448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwnLR-0006wJ-OK for qemu-devel@archiver.kernel.org; Mon, 13 Dec 2021 10:34:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwnK8-00043X-Hx; Mon, 13 Dec 2021 10:33:08 -0500 Received: from [2a01:111:f400:7d00::703] (port=2464 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 1mwnK7-0000jw-3o; Mon, 13 Dec 2021 10:33:08 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VqUT18VsPFh/E134FX6glcgo9hoKLlzXZJDM3o/hYRG2FiM9pweQ1QL3JcLgcO8CilbColbll49efzEtqtu4utc8YAUNK5ZQ/s5Ej1c1Eo1IMOWQSbTqiQaSxo4ET3lzDzSxXeJAMUWX/hvIPeLbxU5YT6F+S23CayzOWpiaxdlxGfz+FICg0vbCLKBBGOjSvKD3Njcm4AJqJElhgSjrXwF1xQku5+a1TATsrzVS3sXF737X069jopS/IIW3PzEORTD7NHt52yDjlkC7b23Hr+1GFP/jtQWLrbaJWeUj5tfXcd8eo/a8ojMsk0L+pbDs52YUcu49G5c6TIW7iR5m3A== 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=AcSsWkj9GE2OIFZoFo91QJUJSTi9ampfa0rGEiOo9GFs0/81NGJE/W+6msr+gOjB5anWO6RtwuQM34D3cTH8bkk0xmagPYmvAAQURFg7paCZMc5M3k9pPta3mczAmh+0fAw5QXzxcDBsoGj3yII6r7d+5Ofg6K/tKsOroYVHaag3n1Yl/fzfX2toLvkutdwA5un87Dkzq0UqF1yhVzH/QdD8BVy583Uhh4dD8FfQHn7vAFGsNZjKXHO03oDnhWM2/+Rc+hcQbB6wHreaJtvw5uldKhL76TGzYn+ENLrbxGR3Unq/3ObIQBOc/cu1VO+IenAxH+RhsaBOLAT+MmT90Q== 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=mPGLZkObrbCSVNjfigK/yT1xAy2ILqCcOVrqyBsR3HhHftUyS7+Sc31qcurMnK9oIjaO3dCpDgyK8XdVxdkspqeT9qBbw7sZK6ciFS+kd15LFjY/OAPb2S86/tZq9eZNOv+w6Qn3Q3tzMBsEKRre+eriYDoctUIk/XLpzpARZXM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) by AM5PR0802MB2516.eurprd08.prod.outlook.com (2603:10a6:203:a1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Mon, 13 Dec 2021 15:32:52 +0000 Received: from AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5]) by AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5%4]) with mapi id 15.20.4778.017; Mon, 13 Dec 2021 15:32:52 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH v4 3/7] nbd/client-connection: improve error message of cancelled attempt Date: Mon, 13 Dec 2021 16:32:36 +0100 Message-Id: <20211213153240.480103-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211213153240.480103-1-vsementsov@virtuozzo.com> References: <20211213153240.480103-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0402CA0023.eurprd04.prod.outlook.com (2603:10a6:203:90::33) To AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d8e64cd7-d85c-42b1-4ea7-08d9be4dd350 X-MS-TrafficTypeDiagnostic: AM5PR0802MB2516: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: h/CnGle0on6pjvQD8YPM86Zlgg5qzjow/Xwlksy2FuuGkno2lvlY1jqidgjBP5SwP7tatIv0KDeUos9LWra8Ykq025H6A9a4WWIQXsVaaKJdxxMUFlE5QoDHSc1XbDgRjuMnIgoa36ydOn1oJdfAibd1uqs3T/8kJP5CY5HGDdBlJh2fgOsDYvKF+KLz+koUmS+hglJ5ID0KKXFB7Gp4sOZ2WPDoSXV85lq+EwzM5PZmVEDCCQTSRq8zS5ZytDeURmbUI7EgnbUgEDHtqX15Ds4MeBVIDitEqgH3NbZS6tU+taunIa3QkiQcdjYELIecG3O6LKRrlJ8APDvt1tWSVdMpT/1Qbq8J5nL4sxI19Bawre7OxoP14SOr4QFL+slYxpDX6vcG5HyEdujnBkJXg78vMoESlFuR6rXDTlLSbzzGullBePbQElMXMPvsqLE050//JNhGoKSPv4Gmo12p4WkXvDVDz39I26ykW3QEOx/lBHLHPkNG2iySU+b1XoJSsAJaRtTrfSnrvQ9uTb0BRqWh8bGQOOAn2UR2J8JRRZHEzOrY/GAs/YjzPYHpcAQysHf9HPiXdECjkQq3+ttMWEKGdErOqNXNqED9YdYcROiOHpABjzmrGbnkYEeQORVqsmgn91wdXGw6trz7KNqDYdaeuTjg5HD4QIuXWoIAEY8FNZBe1YojDq9udrZGpEZ0MJh4Sbko5Ji0BsNthxmtkw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6741.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(38350700002)(38100700002)(8936002)(6486002)(66556008)(26005)(66946007)(186003)(2906002)(4326008)(2616005)(66476007)(1076003)(316002)(6506007)(6916009)(15650500001)(52116002)(83380400001)(8676002)(36756003)(86362001)(6666004)(6512007)(508600001)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bGgDFJCU+TGI5RewRqG2ekfo9ptUigXBsK0xYhCzsftGZIpzecQM3mD4+2KrVeUtMpnVfmdlItwipwK5kYxKR3LlYu2e2YaiaXxMpiBNr946TT0YxTDYwtfjaMlx0i4lTNL9fiijHJT6OTGPJDRKVNLd4zDv2y115lKXQs/n/hhd12oB2tIDXU5Q7tE7muMGtfXjBuJ1bMFongzGnlioW+RosOgbAJ8RLsmZ7TRzShyTVWtrCPHVl6/CLlX9MDnj8LBt7BFgjloepfTA3uXbsxjionTjtDYWcAPRWqdbDe14qnqImg8JrhtmnUpzpnTexmEMlMQHUIsaOP0AdIur4OWegBv8E/4KciusunOCuupYJgkrnTz+DDZ8A62eiL2SsJPeGfEdWj3yO9BsFAi4RvtaOtLFNTfWNe2wEE9k1IAa64tBUMgRaOzqIp7s/HPy69aJMCl3dIYo4XCMkKjVfFWA4Pomc8+p3P4MibTmU10Kni/pst66gmJLf2Yg6vs3Y4mo/TQkemw6o2rQlYQb9LalBX+60tJ0wE15w3LbFccf570OuqAA8nQkuQLe0X+2g34/om3kD9U/TXBGfrxom3m20C3vZ8qGsJ+ywJd6BXMk0A8pIZM/RvJ43bws2XcQbcpiQu7yb5C2OnGpavedgYesEYzuHNvgEoKtZkTbs37COUlPVwxWiTBNB8ak6LAxglajahxOedclSMiobouShXCLwR5GD01zei8ksidBsCkiIEtwxU63/DclixSrc9LzUEQZIebDCD8ZXmql/2SWycvKT9FpDn9wtIW8IgY3nLa7RYdbryYC+pzjGpocfOxquktN0xAFwItmxq3rc8Rj+0InbrWizp5MKc2kQhce0mWXQo/mQ7RnpnqMtBtz0aKdeeXZ+jS6NOQaiWmXxenxW4G1wLUYtHwn7XTNgKLreMCIJry3lp8SkT+aGH/TlkVbTAksre6fQXH9kgsWEu41kz8Vw4v1yxyQzway+BNcguT2o+bHElXSsA7MBT/fVpI/fh48jy57lmn6XbUJmi/COPeJUv6ixqLF35QV/rpprAY5F6m6DRtK3k7TF3jYOTSEaYZ4LpwUYqmAQK6wyRJYuwK2ZrNikJ0ee5ZG/DY0GATBqo7NyLupgjsTocLvU+zKaeQ9VTetjRlaUbM8lX9cBmp0w9nskeVmoCZds+gTFoM4LV8gDJCfdFvnVo9VTB4NwYYq3geC7V0CecL1NnnCbPmE8EXoG6A7ks1IrNXoI6/GyrJw07M/h6T2AFyVSrh/mgCLcJs0h212I3edz5pMq+jFVhY7tPbcSRKJSdhSPkGpEEyNb31Q7QtRUJ2fRJ4a6QQQIoDQnU0/vXDsxLPAUvtjo/rYglM34MXQve49K8M7LQ/7surWOO/ronfZjf0Qdo4CSCRQVXBAKWSCK7X+ggelitS3C+wNJpX3aYNR8a7G5P7u6YqCOMR2FdGUn8+Fy3ebu2hBp8VN72L24vQKomqanh7jyjyW0SindSrdLSBS93oW3H+QFXUZSkGJpG07VLtjReigtSFbmK/htGcY/zUwOmVzPnRQ9mSa/2wdF4gTiM+1UQ3Yn+Sa2vO3+DM0TufKqP0j+bFzTgUPoZ9+RdGlyd2rCyHJ/NcxtnO85hgTtbVPA6gkhwujsmM9j0Ax0/FzxHa94LOO9o56JtgsIqIk4wF6WDZIVM+TuY9JX78= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8e64cd7-d85c-42b1-4ea7-08d9be4dd350 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB6741.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2021 15:32:51.7915 (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: Yr2QVugQXngw3QYf3iWeNNbv8PQylcjGQYlZJwB9oOeeu6sWGAup1SYRbnjNCjyjMKeu2y1W7B1QlcOrhtyDDTKv7yWINOI6M6jRLqCPxuQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2516 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::703 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::703; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 Mon Dec 13 15:32:37 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: 12674135 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 87F0AC433F5 for ; Mon, 13 Dec 2021 15:34:24 +0000 (UTC) Received: from localhost ([::1]:36850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwnLL-0006YN-9r for qemu-devel@archiver.kernel.org; Mon, 13 Dec 2021 10:34:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwnK0-0003mo-03; Mon, 13 Dec 2021 10:33:00 -0500 Received: from mail-eopbgr70120.outbound.protection.outlook.com ([40.107.7.120]:48667 helo=EUR04-HE1-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 1mwnJw-0000k5-0x; Mon, 13 Dec 2021 10:32:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=li0A4bIxjhLViIh/4LdPgJOyE4QEqclLwWbaAGk6XUpJ/I8GdDllWSrclmbCIFg8aIqtLFoUDekFq0+s5qsICJbNPv3tzFCrLLsQqbzQTgezlcFZ1rANDi1Fw5Job5Xs21WWKtl7ojfeDCRfxCA4Bo/sITwKTtdJfC4jy0QVjtIC31k38/CLQ0otqSweiIBqp3tqhdl0kL/Vg481u8QGLrsinx4yVCt3/YGLqPt184KAHjv8DJmgLwJKhrgOXpRE0CLpUGA0DLwWTeayb4bp+keaYwY5zZKggUAsEFwWiNNh8067gdH+bOR3MQvDzSjNTW4ur5O4yqMy907+CdaFkA== 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=YxPPo46eTn5K9PmHFCg7qcVFcE1tVwI2AHLT5ZumT70=; b=kFcIL+ggvddPpjVH5yuDewt4Yqeuqe+DHI/ugGjmz917qaZiCjm1JOYRghM+U2WiFsZdXlUuIHbsALBH0DUjyDUrRVLoBm8qpDtCgk7kuu4ot86VVUVBnQzN3X46aUF+HXc3YvY/cA994WdWjvSGECPMt8dGfTq3Fl7A0KcuBR9z2z+Lvgbr+MCFZ/pRU0nEAAnJ36h4ogdNvBogUvyQoCbL28WTCYk79S4/P3yRhwWPzv10Lunv0pcqGuQ5AhYVe2hEA4N7P7hfRIyeW+TH0PDuyz2cFm0MGkiOkm3PcY8agVkgsFIoMMV3WPbSBe4xkOagDfDoLt+5bkScv3GIIw== 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=YxPPo46eTn5K9PmHFCg7qcVFcE1tVwI2AHLT5ZumT70=; b=R2rnkyEIqd+gf0+lqWx41WrIIQbjrGdccnQQVMI5rz/55xX6RF8AAnn7ZKgppExrdtNi3KSnZho2JU+TmuGTgBkc5eFgKSAOtkwuyyylOPm+Cj4htK3SYbQizXRO76+u+n/V/mH5Uk6BXIWmBzwqJc/ZZGrNPhS5X/Xt6RaHjvs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) by AM6PR08MB5094.eurprd08.prod.outlook.com (2603:10a6:20b:e4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Mon, 13 Dec 2021 15:32:52 +0000 Received: from AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5]) by AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5%4]) with mapi id 15.20.4778.017; Mon, 13 Dec 2021 15:32:52 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH v4 4/7] iotests.py: add qemu_tool_popen() Date: Mon, 13 Dec 2021 16:32:37 +0100 Message-Id: <20211213153240.480103-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211213153240.480103-1-vsementsov@virtuozzo.com> References: <20211213153240.480103-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0402CA0023.eurprd04.prod.outlook.com (2603:10a6:203:90::33) To AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c90e9b0d-19e9-433c-fa85-08d9be4dd3ac X-MS-TrafficTypeDiagnostic: AM6PR08MB5094: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: 9/yaINvJzUB8+2V/ii5SndGGpu77tLCCgiFHxZcZ1PNHfWVAmeoNjq5F8DMTNuYA+2Jx3YKp4cu6URgRRjIHiYAEsroqD+UIIgBni8/SVaokn2dLCX0uLxyPEIzuAKbZvSC8vvJdCc+fSn/a3Uwzs1vT9Px7Nrndb2Tq57i0wWevPcWrnJzTazfJHXDo6WQzi0dU+DFhE/pehzabuixw3ijImsfwmsYXfot3N5IPv3n3sAFAmO2LiUZaO1TNpLQIMLeb3yv4/BdwgwXMUW7yhHvrOrJbgrhj/d/543zop8oVac2gkcGlgQTOdo96CkGsewJH+Vs8KTtPjZtXmdl5DMz0pyVTr/kFU95o3WPHDhQern4HhvmagdOnp+TotcxYFK2Z2aegWNmSWbTu+7e4VA6jO+ZojqR5NedTyTcLi5l3HSofqt/6bH3GyjNU3FMr/60ebCIx/sZQtpAm75CAO8M4gbYnx2R2IM4Kvg+h7bwKzQ7gfaksaCsfsRYtlAsdvT08c9e1K5O4V6TLAKNFfHkalXIRZ53aN+bZkOphPKFL4CZcwUgR8CdZRB82D682cJcuFL83CVh0MgnUL6jLt5kLw2u7UieCCbVn+39XnkYspMeIn/zpmwOfiFv7f87jqas/7OJC+t6ETj95sfEdx1lyeW3IEbsst07dJ6o3UmDp2JC8fWDZyqGG504ZnWIm7jRIV5SqfMqV1+mhyowAKw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6741.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(186003)(38100700002)(8676002)(6666004)(2906002)(6916009)(8936002)(6512007)(36756003)(5660300002)(38350700002)(52116002)(83380400001)(26005)(1076003)(508600001)(316002)(2616005)(66476007)(66946007)(86362001)(6506007)(66556008)(4326008)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6aUW23vBBCtFi9l4acqOyhIj5lC2HuP+rnoRHyCxlzRYtjhNEsQLOG4GbBARY30F7z1Tn3BDr4b1otmJfIA6U9eh5WviuhbKQJVGh/fg+SCWyoOkfE4K+rBVMGJNxV5U94hmzIsSGjqfsWfwLEUU9k9pizFc0NBycBDBp2QxYhYr6dlHOcgVYOwf12240TE6IsoWtREs6oi3Css56tLQLYaMICyQaLsc8gO7ndY7KczB8IJNVaTAbqlfpsGQ4DrwOvtu0MCSI59aG5IU6wUxLKaD6grdVevkvWrOGtM6uuWWGcakLK6m9sPNN2zdBdkn4sLp4Wm2hm2SVSkhJbqWXbQG+bNmtleOxDsFRhR0qtMcQ4uz7goJVrghJlja3a6KO66ETRp4hPmvGkjd3/iyb/4Yguk0T2AH0zkV5WogZAujFvcyuDUtFcegOZ65fMpexqV+eVp0lGfCCqfUCRzAoaswZILCTM5WOMLEKCxdjoOfdwgvelD+y+tUYzlIP7THRbdBP3MOiLigGolXSgenz5gQJE7j2kIH1tjT0W4QSQ+Mu+rDtwp+/6hJbuUDVJ1qoiz3AvgX3PqAAT70h9Fq6piMGBurwKcEHEsK+vQ/Zjkut5vdp7w9aAbYZ8hHbr72lJjvM6iOlwZHzaA7hWsR8rbL9LCm5LcH+NiLUOn3qst8M/urkjl+KBLWS1H0T4+IWscJU6Q5yT9z2MDVxeF1CDXpn4N8titpVd8uFxAFa9ARYFMP8ODdTSbkUXHwlY44PZ+dnBAOo4TGA4ezq88zdrdiKf4l3bwDpdQSNf/gNJDannGM48DkfFBhDuBLCIySxllk92vMa7rZm+TbzjEZEbcp6FN9UxdMn4Q71fbeOQcTXG9zNfe0aTVOqTesox0Yg0+tTNXlgXxpfmoJH9k3/seJLybC4sSagCIcoV4VrnIPLNAdEohB0RrrzhK84/Cu9DKuz99THLxc+WEmNONXViLPhvQTG2PW1QBNxn46GOy9GysFGc+S1vWPRMEAeX+2bMlpDa2yMa/0sSk+S0+KjKNfrjRgo5PNdcbAbNPnfCcwXHCDvp59lmI56c/IavUiY/8sAALtWi4RvNoLgXnsc+QlYLwVItsWQew0PrD9vQr8fQ+M6cr2mqqkWlClCC2w9l37gJ0wA4f4lzc4RZ143YMrZFWnwAiA0FZCbcwVaKonYV782gKBQ+haSjft3M+IegkrPz6ZDOUX8m0RSp2epGn9LXtFHPm7Jz/M7Pg4ZY+Je5G7d6ZMIj/mvt6z8QdqfB2mDSQjP+TTXnUd9eWt2U7lWlqayklcLGSL7uOKVHsvfoY7zZ+bkRtdddYt3sy39+lV01Co32KyOCDbG2T9e9tOLPVa7R2yfz1abEVm7dyBIcYW96sbFXDIRABsfByxDmTgmMT2qOQmloHjUhNWZ9sJz7QWHJHFlMgD0FpPnbIzEpWmNTmsfTGREaT8hlan11Hf1viHNQQ3gEZnTem64O7Dgm4PIvqcJXLug8EtojCE7QvCWhI5WZNCT5OYJno1DSkErSdssMhzFWzICLTPYMvYRzqXGSoPfA0ras878zsyyGvVSlRos7uThuZCZnTY+2o4bmPALppcVwUWGr1EFA7GMln8UNni8/WYa8EBsiOaYjyH1rrFF5v59B9VmbB/pgxY3hb9EivtpzVrM1hMuoerbAkdbtaFG5S790iLZb8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c90e9b0d-19e9-433c-fa85-08d9be4dd3ac X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB6741.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2021 15:32:52.4416 (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: f7YN9kPC8SL2Byrgl6lFGPW/0zd+IL3/SqDLpDrjh56sr03hXgNlNDIU4t8CqtFC7cZ3aTx7GKpZ9bsjwIGflVppHzEkUHV1Ze8nmXmfOYw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5094 Received-SPF: pass client-ip=40.107.7.120; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-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 Mon Dec 13 15:32:38 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: 12674147 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 08B53C433EF for ; Mon, 13 Dec 2021 15:38:33 +0000 (UTC) Received: from localhost ([::1]:48272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwnPL-0005mo-TM for qemu-devel@archiver.kernel.org; Mon, 13 Dec 2021 10:38:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwnK3-0003sD-Tq; Mon, 13 Dec 2021 10:33:03 -0500 Received: from mail-eopbgr70120.outbound.protection.outlook.com ([40.107.7.120]:48667 helo=EUR04-HE1-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 1mwnK0-0000k5-EB; Mon, 13 Dec 2021 10:33:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A5Id8JKD3sn9Bl2mWoVmFk4nCnyJeUK4B1U+4/INa6ZQYfowyupSSlwwY2JZF2Z3cMy2O0/z3QSTysckeAN2t+WVKREGk6+FcIjSX3sWvdVReJZ5YTsZk4IQrO2ThNgGB7/tMx8QTpgYve9uK2glhaxGBEHJA8ujrbbCHguC+4k968VDPlnIl9TqdmDVtRx8r9rsTYq/wODUK3X5fGSt1GLR2sD2SLSmnJr1xNNw8PzzYiKNwUMBxF/g8/QjXJUdzSnjPVXidcuMHLV7WtYhsIG4fEWH2LiVi1JzkZ+XRBLmS4hBXV7tHjw6TfgrPaoo2Xj2kwjAckGIUJt4YHQIQA== 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=qZsdCQLyhlWBBsWDQY1VNDstcc8Wd6ATx01gxuhQ6Lw=; b=bDHqatG57xwAFu6FB1ReRBs5KgU1jRcMsG6zZaFY4EfyAIkYtzXTqIdsSNMpzq9q1g8CvyNZ5EJ8t1U6AC6MSK3qwCxq0ojoQRkNKVLxtzrnu2I7pPwnz2nnH5GKMpt7h8wEC/iFfp9YbY4WJllIZ/UfpFTLMHREmYh1oi7LlSzw4WYR7aH3FFVBfUwDVPD9vCr1r2oVaeeEYWXe4A1OiC29yDcXH1bdamosO3m+gSfV5MS0ZnxTHLC/WCFO6fAfIXH5i9XjJYrmCheHGZLj9RQCFgD9qiXwYex/720NaEB2pKSkBstsTutJPaWg7q2ms836HWLhh74RoS28KEdeMQ== 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=qZsdCQLyhlWBBsWDQY1VNDstcc8Wd6ATx01gxuhQ6Lw=; b=uT1i3jAUBaMY3eMxmZf5K+NGr94pqFwCWo4k+QmnUYn4C7R3Rq2CEI/pRXwryTOXPD60bJk/SdRIXo921EQ+QQAL+tNbsDG+JGWjL1eVe2l5R3YlfEl3CiVRHFg5tOcuwHbpPkF59lojL+Bh1bOWeMaD+WpSJ3J0lIEX9VI/CHw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) by AM6PR08MB5094.eurprd08.prod.outlook.com (2603:10a6:20b:e4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Mon, 13 Dec 2021 15:32:53 +0000 Received: from AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5]) by AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5%4]) with mapi id 15.20.4778.017; Mon, 13 Dec 2021 15:32:53 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH v4 5/7] For qemu_io* functions support --image-opts argument, which conflicts with -f argument from qemu_io_args. Date: Mon, 13 Dec 2021 16:32:38 +0100 Message-Id: <20211213153240.480103-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211213153240.480103-1-vsementsov@virtuozzo.com> References: <20211213153240.480103-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0402CA0023.eurprd04.prod.outlook.com (2603:10a6:203:90::33) To AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c3dd365-5596-49a8-3446-08d9be4dd3f6 X-MS-TrafficTypeDiagnostic: AM6PR08MB5094:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e7C+9Dt/hx9YFXyTurKydelyzMAipdJ7nUE94UvIrWw4t9oO1FQYo9RgIiKEXcXsVoOhvcjidGQEcVUhXKIR4MxU1rFV7FusKs8VwvEHNNNm0VDD049MgLA/VNk3Zx3uv6UVDY1OJH21gAsmALGNqhVFEpdUs8cdsgzTk+mVgAk7i5nCOWGhj3K65sj8cXdMCBqahh0+788vRFWAk1yYV5f50+Zt/8i/Kg7ltR0raePPAdme3yzNof4pu0nry6FEgHxSii2yeoghrfx1kwbsRtfwHs0ztePrb1swKxL0nh9vTUquJzm4Bl/cyFP5YnaEe5kpLu0dwqef+2+kLFcXfPtxU8MtM52q1JuJc10llF55QhfgxeH1bBUuE/efMY+IH3LiX7X3qlxdAaDadMNxaFmFnCma0cJSWM86gHlDVWNrF+ovRBDu0QV5gHU6USgGneDkGXuDupTe4nV0uz0bF7uYtym81RSJxoTO0ekcVGI5JpwuKO02d2MFh0lW36Sj1X4aUqjMoYJ55w3/xo8vSKdDC77KWlmi9ttgsCefnsOZuvOkbfLmIv0URwHNHZ+jJs/2owegsG8COq302FhTDscYekSbwPD1ld7v960noWS8V3q0alnOlFT1CSuOnyB3p67V5uoV6cTx8HnWJ0+qwz5ESht/YfzDP0j6aWLJGSIH/YnViDtOQuN98V9vV+FfAZVZY6Tfv0BCapYSkNDN7A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6741.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(186003)(38100700002)(8676002)(6666004)(2906002)(6916009)(8936002)(6512007)(36756003)(5660300002)(38350700002)(52116002)(83380400001)(26005)(1076003)(508600001)(316002)(2616005)(66476007)(66946007)(86362001)(6506007)(66556008)(4326008)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6/702SaW6SFoAx0ch/EHA2bVFnM9cx65aIyKhMAzedpB6CI3iGIoBq3pBdVIPl2Z9VsHDpaXp4NmTmPwBMdd8hbS+FjIfZeEw0s1qmfwaibPeT6pWNHdlK8xmkbbF/QmMS3jnal0+sFUM35+70bwltIaW+qWlPsSGLKNx/Qhh6e3fsmZE3FC52MLg86OCg9wf5JOuScpk5vhg5YAmepzWpZsu9mE7n9rwBarpyBklPOhyyquQirE0/fxXfOAHycQfuFlv7+kM2QYF4yA5xPPSuyOqAqAjQwPVTNRWTjEX1RDVvscL+k2N97lU+wi1SFlaBpy9i7sh5aPHnxqJYZsangDYtvyrXrtPqvz9U3YOfOLDk+E0E2lwqqETYffS9LGlXIOvSHe8vXBYkMU6BDIKuW5wHazsSxpH6eHtZkstyl48EWS92EiwMNfStiJfZiUMfE3IbjKT1blVHM+gGZDl983L+w5K1Z9xfMc4MM7bFL9c8Kx8emS/nT2jRt6TB2orlizv1IH5eMFZsT9JltoExTTy2YX/dp2v8RcFEw10vlcxzN9iJ3lwEgl5nsXl4v7COBQZWJv2VdLZnZiSfe5b1ttAbsWKZVtbKIRtX9ievxmSwf7s5/QXVkEou/fGXFYJrtEjN8OFfUnHdZYkMQHSGq89qbI81LesSevSKNt4cnOmzFHQIe6FeIin/cifHYulLqLc0hDVe2pIx+eG9JVin6Hz37d/wPxDE0VPOtL7xkPkwsAFxE4pVvs79yEyaMurL3yOY7ZhtFn+U5j2afAEoD+Lv7GnEBOFwZe4nFSfMl+PWztEdb6Xjd+b9i/P85FFsv8LzsyOzQas85LHkB8vyqxheNEwhZ5ocWTnXtTXWSBOYY2nopUP3lbDx0CQi7CfZCC1sGNsCmG8GLEveLktqa5Mt9vGAZIYGND6sSVPwtpk1NDLNS2nG/DdFs0Zfv6Di34wOZBK3MI+l0lURuCAC3S5WJDwnGOUqW6rOxZYhWMxBMJQOuXcZSzPTHFPFuS6qvV5DkAHc2ZGf/iq7ketbjwDSH5UohnU5IfvTJe4ueEh5VZ0dF92RXq/itADMo0uUcr0amLVDArcwxDHmBSk3UEBDkPFLNfIO+NO3UpzpayeolBS0nugE/zAxh2xfz9jd2r9RC4d6EIoFwbQJRTeWJu+pEo6f6Ti3nFLxMNpn02G51F7KVF4lSBrSQCN1W6bp1j7MBOSJYhI0DGaE852L1gr38Id2dSd2IewzhfNtNES8V7Af+xhI9leZvtfTGiUzJalSDpOB4zdT1Cpoki+/ZqhY9472wh/h3I340r0r3lv+z3WdwUODqisHUXAWofar0964epDvkOpSwZnjzeY/mx869xTTzyMwXI14tI0rjRFbq0vTKY38JxkxYZtkzkClNlki/zKbxodKJQvzyCu3JKqFYu4YmGwN+XBjOoejQaCCuvEpv5yz44twGyQfHy13F26qoQ1I/bKF8Vc+LuopoEBs44yvUc26kHTwMn9QRXVx4BMsrWl3lGcK3nDBIahSik5l/DLNtewxCXWqNiUqE6PXXbKZPWoSX+h3cYcBJDNov7utJ+aYK/GYDXhGhmGbdWO9+rm30D8GoPaEHqI1akwxqGOWjwVcMd1Qgmwt6U1Y6QbVq9Imyif6YOm3IR6/hMnAXIFu3ypWroIXiX/Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c3dd365-5596-49a8-3446-08d9be4dd3f6 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB6741.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2021 15:32:52.8657 (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: Sf0OGw4rBGM5sTsf1tncrFMK9JCPFdUghbVJqMI3S1T75fasOkFelVWqHYedrkqsLGzr1jKHsd08crrj3ajZzfClu57rLF0xHcq80YfHVT4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5094 Received-SPF: pass client-ip=40.107.7.120; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-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 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 Mon Dec 13 15:32:39 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: 12674145 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 3FEA6C433F5 for ; Mon, 13 Dec 2021 15:37:54 +0000 (UTC) Received: from localhost ([::1]:47552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwnOj-0005KN-2h for qemu-devel@archiver.kernel.org; Mon, 13 Dec 2021 10:37:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwnK7-00040I-8e; Mon, 13 Dec 2021 10:33:07 -0500 Received: from mail-eopbgr70120.outbound.protection.outlook.com ([40.107.7.120]:48667 helo=EUR04-HE1-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 1mwnK4-0000k5-Ue; Mon, 13 Dec 2021 10:33:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mvCfRfdIIwRX4d5MPt8Iuv5G8B2hv/lfJFMarzB4PH1cVVkrQntl+goTTNUs2YMBpfZ7eKRFli9VLrpXMIKUClV33Wi9cbjInMg+1HsoHQYQhme7ecWhpCs1YHqJ3/6oRDHI8LxjcgqNnZIBkhLMP6jqCijPA94hLOWW40zer26k6Dqtk1ElnTVC0c/uMjZc7EE3SnwQpIJodr2IhLmu5irbBM1qHbbtO37qwKE5u9DQ8x/hiJ1neSH3KJMXIClpnOzmiTPoDoGYlQGrNAwOfVBgdQhm6jxNvh+o8HGBRdBaTAR2pc8FGSHh5fCTL0Vq7RwvEad4p4nLJBRaOsg+jw== 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=3A+YTHe6zqjH9B9wOUGT6V2iqT1JrWgBg/j8U34/O6Q=; b=BLJqFR4ZGwM0IjZGIKx+4b17JeuqvTRKNetHYaTgTRM083cURGRbGaPLJ1avrwvDrn2KIPdSpeWz7PC7kFnhmX8HacdW58oj5h8d3+lmc50xXFgQMSVl8zWsvGTfv4/+DHDV35Et5PVtwNYga6FgSxrLRWlVN4VEJ3PhIAuBeI99bo+iF/2dQ+bzj8Yoy2T70fkjgpEYRNe60Tk7xnEYYOJ9J4bdepW7UI+4WCJBCI4exrUkesLMsTKV01e5o5LBxfc4qu86mg8V4puCFG6mY+b3ecZleOnpJThf7Rrm/J3i2u05SYbx3Iz+BwNZm6RRgNzTg+hwFhUmIyj3MoePCA== 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=3A+YTHe6zqjH9B9wOUGT6V2iqT1JrWgBg/j8U34/O6Q=; b=EYf4a8JYhpc3zPWyt9FL8hyVYCq/iEkKIh2PkNwsHM2fy5zKfaB6hxpCPZuk+6LcOy8maPs/MRIZi2e/YiJ0/6y1EVuRa/pA2K3MI3OA9ZaiAm4SwEG5t3Zy0KTSOu6mvZ7WWYZFt+YfasKLXBEaRHg97hJeDpfVvr5M7nB2ecc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) by AM6PR08MB5094.eurprd08.prod.outlook.com (2603:10a6:20b:e4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Mon, 13 Dec 2021 15:32:53 +0000 Received: from AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5]) by AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5%4]) with mapi id 15.20.4778.017; Mon, 13 Dec 2021 15:32:53 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH v4 6/7] Add qemu-io Popen constructor wrapper. To be used in the following new test commit. Date: Mon, 13 Dec 2021 16:32:39 +0100 Message-Id: <20211213153240.480103-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211213153240.480103-1-vsementsov@virtuozzo.com> References: <20211213153240.480103-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0402CA0023.eurprd04.prod.outlook.com (2603:10a6:203:90::33) To AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1e9a5bea-8a0c-495f-c9f0-08d9be4dd45f X-MS-TrafficTypeDiagnostic: AM6PR08MB5094:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ACrajAnFzzpVT3E1iBCtwitHCRmjkNbLBoAs8Lc5Z1W0f7D0BldMBO28Y/UjZ1z+aX713GrpWtsJ3asHPhT+yEI+ZiFEZ8u7Fb2exYPje55xr3XsOT99DzzpPiS/zRPfZyULp2knJZeWleubNl3CIce09F3BZi+zEr5Dx6WfwBkdnYJfHVkde8WIbcXDgINPz4EADkehq8SiRUJxl1urip547HOENUyEq+qZMQIyM5+wP/PkQcEQldCIQOInRMXJY9REkAPSRDaN2H84KQAuDGYlM6H742b1pz91BnbX8D+HNzLiGvwkee6fdhrgxprOSd8VYa61oXeJF+xIRL/alI88++wyqZR+TiJLNr84PceMwZto6Hy9bYDLGHPnNHRd9/9Z+Dh3tkzY8YAxg7NMPztWEksz0cec1E8C5qsOPm/O9nb9+L+getxSeuAvhkpO7ny5SiTKm+Xx6lMgLg9WyxatCB3FTAmkVht0LTf3oHS0KSJXyb+d9Wjvv3UY+M28gJ63Xn3fFIxx44veREPl3gV5hLd8A1ogJrgRVAs5YHuIi+v9Iv57KYqsf6utqER4Q0HhuANB9dz/qDxzamD/XPAL0sO/sQhryAtvpQhh+e9DpONMAT1g4QsYDrB2+gSjsVo25QNhKq8UhsLIBYf0m/XqRcL2gwEjjCcVthx3+Nd2/KFBfS5cNTu6HUcsrQhfCQHmtMBNXd+ga2jfIxQkdA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6741.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(186003)(38100700002)(8676002)(6666004)(2906002)(6916009)(8936002)(6512007)(36756003)(5660300002)(38350700002)(52116002)(26005)(1076003)(508600001)(316002)(2616005)(4744005)(66476007)(66946007)(86362001)(6506007)(66556008)(4326008)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: V5Kv9hmX+eBItospLHDJjnCajXnxrBFku3qnUjpK0nXeiarJHe5QhWbbUtcwuLf2mKsCmH9vpS6LWR83SiP0hPSwNTtWYKNEOHnZpZOFTjRLK4nTu3+ZP3ZRI/Ze9kGeqrJ9LGVzT6/cSPdPrmV7O4bLxh05uwwBBBXcrUJg0s6+hf52jNiSkxyeJZ6j6TWKgHI9iImk3Cc3hZcII7UlmnySK50ZkpLrAugHj0u1nOggACs7/yznGOAfObH7IKg8eFn8EhrIq9Z8yD6cdFNVCfj9W5pcMZXjKhd7mwgqTz9spWuIwDm6kmVjjt1TJzTc08363o5vMFvTa9hpJ2LQya50WynoWUV8YeS6LGvNCtDGha/OdTFnB220JX/QF9qaa1xXRUsxJtn+MhXx3V12/hs9IX7xeTWqWePbjwqnvlywd/QhK64YnUoTyb6HataQ4Y9R57/35ynW7suZwBkgnfmXHdM2jaqCCDdYppb4irRtBI/FAg7LHhycSEePdIemCyeW6hY+3UsEoI15TMJSwkRWdXWqF7MXMII5ns/ZlgHIIkh0VIWrLXB2sPMUSY+N6Z/Z2LugT5KSeZ5vnxGYfhlmm+46jqL+57BNdPcNA/j4pec1A+2vlDT8R+lEN9ZFeJMSYUVUtgWEACdPumYoYPOWTiNC68yNJGtZrERMD1bPikoBm8CwYUpMgCZeHBdAvr+/Svui0PwjNt2NaxIXT8yaE8pSdX8TxjPF/i1WT21duD/8+zkSSXiYyydiLNZQg9ne76vjfEML3fd9rULzkoFeKKzpENWU1/YaPGkjLUQftMRsV3JlBf/HlErCu46Y3qaxKHfos4UdhDsLvYURzByaAz2/B505JkAu7onwEwJrUlkYZ9U30yO818nSvXnSOhqCkabIBTXdk1yevwOoSbmQGcypA27icNvxIx94ywLooIMf11Bx9+1afgtsXkwvckXESgyCG57DdX7iVdM0G+afTtx3Hjg4AjIhmHhySk+bwpLZ/W0gRuEzllZRJxcsFqFGeXTLa2jspYHy3X7hVBNRzT+jT+ro4wz8MrB69mOdUZNuBb/pHWJC/8jfGP0Zzt9PUTJRD0UUBlipQTpOTpOw/0+1abNr7uIO883o0rOjmK89xCD/jqflrdK//hWZOWDKCHaWMykb2B8kc0bmAGD4G7S798uu27viYmKjnS+WwuaGfj89ZsN0I++5RCFvwpDAyqHhDZovRVmRSCBIyjQH2vJqOlgMd1VNOfHm5WFDTacvnptndFxUYBlxt3HzqkrhiTWnHimY4BsOpmWmtCNNbYqyXVD33BkmuLZ4r+FPebGcLPXdr7MY3JxqKplJ9POWruI8HAzwkTqxGFWtHjuj1iQeOWJtX/aYAMnFMVKnbOr5Mm9K5vEhDKZnSbwBuVEZPWzWjGYJVOZCl5zS2vnPQBs1zVULHbHjPHPO2EQZyPbwvmOEEb7RV6Cvrf8/7xNryJ0rTy/XAG4XYVQTngGY6WXQWlF+edflkpyE/GZfz1SGAirEn0Z5nTbsEZYbvENPMddaAxhQHvpi28OPDz3PCyLAvKtU9CZ7DFGL1UxLvOB1neyL2yl1ZdikbQNkNaXD+0/E0GYuBHuAWxbcsFe7hKWzIBniwHrPje0jeBygGsJWfibD/u5DB92KAF+pUmJkmKc8Vlpsr5oRlze8mw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e9a5bea-8a0c-495f-c9f0-08d9be4dd45f X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB6741.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2021 15:32:53.7031 (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: ZOImG/49EamZy/f7XND9gvbPlz3r3zzril8Qgo4zE/hLcwaE1VNyq0RnC+aKwAyynBhqkTOT+LjEeUR88YYMaXCZbdmj1WjqHsq0QEsZ5KU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5094 Received-SPF: pass client-ip=40.107.7.120; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-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 --- 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 Mon Dec 13 15:32:40 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: 12674143 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 A36F4C433EF for ; Mon, 13 Dec 2021 15:37:29 +0000 (UTC) Received: from localhost ([::1]:46308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwnOK-0004Uu-Ry for qemu-devel@archiver.kernel.org; Mon, 13 Dec 2021 10:37:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwnK9-00044j-NQ; Mon, 13 Dec 2021 10:33:10 -0500 Received: from mail-eopbgr70120.outbound.protection.outlook.com ([40.107.7.120]:48667 helo=EUR04-HE1-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 1mwnK7-0000k5-T5; Mon, 13 Dec 2021 10:33:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BWVDd5eKQGUDDjaI6+tVI3JJEMHhfQVv6WHkvknTX9V/97TH/cLdyxG/oB31A52s/nmLhWtFBsCFMjVe1lv8L5Fo4vpA4QwRgyWsqMM1J+mS6wN8tLB+e12oXTPJBJUpFXkb7BW0yzwHn1Ue2Oyy6crUhcO0CpR4XVklz2xTHilHmxFrgqM/VdKd3qaC2qdm1Qc276T3+WE+M3EUAwTIevMBLCVSDz2pc+7/+cG1Gy0VIHSkalG4vpZJp7AoByI6kjGHc6QoCra6ShNz9P4N9ZrXg/74bCQrCKnxgGP5SU2dIcRQNUtp25fia1xw38a9O38ArTkZG7KwiQN2u3HA7w== 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=YohgdZU7L2ULZ2isSszwdFxgEwRmjK4/Ve5RA8xyJkY=; b=kxODDp/bq5CEOWGOKi6PJ12m7uCRo4eFe4F3xPyl6vk2srPT9XcoLf9FaqHI9o615QatobYZWmbFXxe3A/GiA+axZmiGTEQ4Et3X96Re+Rm57WzdChyWquXyntDXRL0n+ZyHRDwRhyBG/LPYPly/808+6hABVELblIO6Nu0i8GvPA34YNe4L9fsd5z+MGrpVgE735qodv/Rg2lzDFufIgSiqMsqyOtX/Jp7LHKBAH+VMPxdVWVgvStZVjERxZ+BhFwk5sImOV0qyixDommyIk4okpUyJpZqMnmhZUiQj3BaCbz4EtMeHX8Ze2N33cHqdzA0++tkxZCOQ/4qRampZtA== 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=YohgdZU7L2ULZ2isSszwdFxgEwRmjK4/Ve5RA8xyJkY=; b=b1KbZt15014sPHJzu69uSqkpD5wf9mv+ympy47ga09Mh27QhHC0Kyvjw2cArFKM1oKypXizYjr3S/GZqAHndWSA7U0kA/YHk4BiI3yMZxizbb1v9CZAvb8iQ4GycErLchRa+phzwyxAJGvn1HVLdh11pwNmqhLkVFfbhw74CwP0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) by AM6PR08MB5094.eurprd08.prod.outlook.com (2603:10a6:20b:e4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Mon, 13 Dec 2021 15:32:54 +0000 Received: from AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5]) by AS8PR08MB6741.eurprd08.prod.outlook.com ([fe80::c80b:8f00:60b2:81c5%4]) with mapi id 15.20.4778.017; Mon, 13 Dec 2021 15:32:54 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com Subject: [PATCH v4 7/7] iotests: add nbd-reconnect-on-open test Date: Mon, 13 Dec 2021 16:32:40 +0100 Message-Id: <20211213153240.480103-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211213153240.480103-1-vsementsov@virtuozzo.com> References: <20211213153240.480103-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0402CA0023.eurprd04.prod.outlook.com (2603:10a6:203:90::33) To AS8PR08MB6741.eurprd08.prod.outlook.com (2603:10a6:20b:353::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b0853d6-c501-4f2f-8312-08d9be4dd4c4 X-MS-TrafficTypeDiagnostic: AM6PR08MB5094: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: cHD6LKx+xcrQakJo2JmMMDCnLnH428EAfBUuFzfV31Hmkoy13Ct3HGUBNOlCN6xkHBJRFqP59a9VL/6SEahm/J3miNpamDzYY85crRjytpWUw9foWm3JTEBMtaJYr8VETdGWdQlm5WEwn4beu7JYyKvge7m5/iOsP/ouXzsTcDZwE6RQRWKdwUaJIA+I+QdHigDOfMeuG38+SXuGNyLf1LPc4p4fALGqNx2argwghl7ZB+64pezLZR3PTCvHBHpfAxxUddQTOZZOX4kmycpN9Ds7GunaZsaENksmLNHFrPxgT1mnPihtfsAQduaD8UhcPqQzv/dbiUgY/26E62wzuSXJuY8dzA22hc6JW8kiSk5SsusmaL+zRb/EcPF7AAGtLlABPvoTIti6Sw10YwguQuMxPbnGoUW6hZTbmm4QuwW8mqOpn/k0i6/nsHN4+7CLQCBfzGzI6wT9+QVmZ2oJ+UapZuTWwxYNlVdDgyEYlp2pMpFkM5Npqiww1taa1FeH1bD2y1lYWRTmrDG0LDV+vnux8X39dYnJfrXg8DelwboImmuXCV9WblAaqOtikhwU9gxCszONoph/JCh7cOrZejoKhMoppx3iMmVVe4eUOsJKJf7LgogLhQ7Yz79n0bvwcSapeWi3SQYEd5h+8qAtaZjW8pO2uvx8hpltqqg+2yR2pupvZqBkr5/jIxG3UbIS3cvGgeLqkZsLia8qI4pc/Yvw8gtK6bum6ta86BfimliY6opF1v7HB2duuMW7boY5Zi3FO/+HqJXutMiY46Ks4HBlau7TbyWq0iCzsGRO4w0bpysuEcE8aitFYhNHL6PhSxK5RVoqp+cTY037R8loUA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6741.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(186003)(38100700002)(8676002)(6666004)(2906002)(6916009)(8936002)(6512007)(36756003)(5660300002)(38350700002)(52116002)(83380400001)(26005)(1076003)(508600001)(316002)(2616005)(66476007)(66946007)(86362001)(6506007)(66556008)(4326008)(6486002)(21314003)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XZTc2suXXc/s4tSoQoERVWm+oD/0JaqSURLlVzYsU0E0E1LpjDLK1CY39O/Zgt72EUm5aWXDht+OK/nzBQIulF1t2kVnC/OW67XJlzPxw5IJw+vcF8g6/HbSEpNt1ZfhTFGleS2YwoPQosbc0cGwR44iKymH/Y6BpkgB/nAlX5bPnV0/VlvZHIA+KBohb0vhjLPU6XoWr9GikEZ7CupmGu8WhqSpzXPRLfLTA8lrxnHV0MJ4RpT/4zAHOwraY6aEMqQ0hIelTKBq4zMtq/Uqo2Izv2N4Tuj8R7EVBW+PU7UHCeW/gcFF1Qmf+xKZXKDbaWT3gIgKl9bGxmtY6lLx2My7ONG4RMUWXERzPzYh/0QB3klxeiAjNijtMPeCrwjdQvsZ3L1bCpXEFfqd+lTHi6gwerqywwca15GzQp/CmLJqZlmU+nyIxZadQKsJrMCpbTi8s5vVtTDjalHtStP4xmhRD5zOe190cFSG+WBgFQziFGJ+hdzyxHldbIPlTEUV0eBuyL8DuwnNfP8R3cACo7p36q+3i2pp6w5rWwLHm4PmPHVcgBsKlXHrQe/cXCRpzgiUNnsLipwo+f2DWxh2q87yD3PGpCRl8RK/m+bUEprOS1IVdQd+6dVwDH3EXpC9ESE6zGSkk7tnZ8dOhcsDePoF5zcxTpsphcWBiwRZlv+hk4g1UebBIAIvyBRmfkzX5cl9K7+1nXlO6imis4ZBBJ+e5BJE/BLORR7PGMjtjNxcLzkEcoz3lULAuJUjK8Fl9fmImfOuA2OK4wm39hcDYw/G6qn/r+v91Ir78QKMwcWQV8kiARctSKQYINvXcveyNCQJIfLSEbLqnJQ0q8oD4hhj0VgWDNqcV0IybnoWcNdhBvQv9AkNK3/GFjQEl2lT9b+wl/g7LGkxgHroGbExpwc1JCPrsCmfc0OarHdNYMWZE5xnStlvYIsHi69E1PNRvcobNZZeSlTKoj1206EfoBLFfli7pe5uxR0xYY70TImZ7k+DVE1r39zG7sWdBaH85u0lsWF913u7OTFfhwIDch3uB98OeGnrRcpY3EcGm/KpaJNSdcg0K2MIEi4stcEn++rL9nUr1OHgKzSpYvM4TMMtd/Rkw2PK55Rq+hw6dtIoM7QHRxrSbgSqYQbhmCNpydk2WowAIn3z7PpCPvgiKBRPHhSyNsg1N27f3d1ht5zZVQ7lqESGFyZCrhXE8PxzYKCrWZ+uwKeMeeUyCxMH/bqI56ogjijTyjhWqOKqGNLGbSu7NOy9eVexVmtsxktOuxel7Lp/O/VXgSsfLsvibnW9QN/qztl8QEH5hbyUyTf5mWrJYdiDGw9ffkLJpdC9gwV3rOcWESmO2h54v6hHgVu9gSxMu3gVbA/0qNB/r3vifxN8VBmux2sU0LPeXCxlHf7upwkorc+QtQKbG4pmapHfZSepX2dfUtGTW7nIDkoN8oNfqocUZgHuI46wofXGa6Pg/hcftjNF6KdV9wePCQmZjYAS6Jh3KF2VUF5Mjk09qORZ9v7OZYPnRUOzJU+MWQyqdk9hQ5vHTRq6V4BdD9qh2XjDJNqxnkLxS9bMcLU72qtzU+mVDpLQLXsVGFjB3HlxSi7uWlzX57pD2qMpsD9Cbahfw8Y/dZFemQ28Ykxh145ZQwXiTSLEwP1mVs+BONl7nlDf2ogkenP+qTfK/A== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b0853d6-c501-4f2f-8312-08d9be4dd4c4 X-MS-Exchange-CrossTenant-AuthSource: AS8PR08MB6741.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2021 15:32:54.1939 (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: j4ovfpX8zu5SRralzds1UCRtT5/Q4aJaFgmUrv4JYjUtnWhlTc7VTQC5XrQTDz2yvrVvYkNOAUG6Oo76lXXl0iPmtaz8t6+z38QbBJM3gKU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5094 Received-SPF: pass client-ip=40.107.7.120; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-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