From patchwork Fri Feb 11 13:22:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12743459 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 070BAC433EF for ; Fri, 11 Feb 2022 13:57:55 +0000 (UTC) Received: from localhost ([::1]:60226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIWQs-0004zP-95 for qemu-devel@archiver.kernel.org; Fri, 11 Feb 2022 08:57:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIVt6-0000ZG-Eu; Fri, 11 Feb 2022 08:23:00 -0500 Received: from [2a01:111:f400:fe1e::71c] (port=25931 helo=EUR01-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 1nIVt3-0008IF-Np; Fri, 11 Feb 2022 08:22:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jTiGtHcbWFkg0CUDbaicGYE4OTgKYRL2p60aerjYd0gYWUndhB7w6a/z5cwGVucbH1uBOzFckRjVDazAptx+3v9Etl+eJgnwaXrE3OJlZdZH60576JgXy9Zv7BDf1FoFukAFm7Ptqzm17DJbPBideAHiW4UsY7Eo7qoqvAugDETAm/CQ9Lj/5xetOM/kNoFhTkSba6g17XQfJUQpKSaNlqCAmU3dzSx27rLzVNwYPbZD0udHH5bw59jiCibjZ5reTUjUsQjsaBPj2j8064v50wn9wOrJHsPxAWxeia/tWSn15b/6mG3PNmgTokwXN3QxNJrvLbglmczP7W6d2o11Qg== 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=gJsFAe5ACOn0229ao5p9/4VX+0rNyZWVVJPWbR8xKJc=; b=HG9/a/n8SkdoQIybXZa78+p7BvkjnNQ73lRRhifg77/97PhAWdBmt5r5fJOFOYFW5TWTyx2vPHlAw0OCWsx8QVq9D4S3rJHB5EoasnKDfNH1on0kFOdhANcewtash8d1yncy9APwGnbh9Sb5O+cRNl9Cs3vwrJA1d+byRhC1BXcoYuhu+9K3YRd+mBCsIeabiyJmpYa2NYSE6S2SY96n1RJe1jHU323/9ln9Ioqs7OeSNi9yeQFthZdDYMXBDZiIA5LnrOUY7QFTPYx4L3esegylU21mJ5hk/nKyZw/8uMNvw76Utc5BVgsZ+yecF3+2qCWgjzquIuTfBFMLev4vbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=gJsFAe5ACOn0229ao5p9/4VX+0rNyZWVVJPWbR8xKJc=; b=obhD4EeYgEvjm6wQtwHo86RA3vDDYE7up9e/NYqEn1ocMvkJfW1FYTHzhgOeP93WOfeXq3ak8bBc3rpptS0NgZdH9v9GPr45Nh6GkU2oX3LX+0qbOYNb2DRHo+W2T3zdQXFIXmwwGNcMaloqbLwJLbb8RNrSqfMHndkWZE7OKWU= 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 DB7PR08MB3865.eurprd08.prod.outlook.com (2603:10a6:10:74::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 11 Feb 2022 13:22:51 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4975.011; Fri, 11 Feb 2022 13:22:51 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, Hanna Reitz Subject: [PULL v2 1/7] block/nbd: Delete reconnect delay timer when done Date: Fri, 11 Feb 2022 14:22:34 +0100 Message-Id: <20220211132240.781958-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220211132240.781958-1-vsementsov@virtuozzo.com> References: <20220211132240.781958-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0601CA0048.eurprd06.prod.outlook.com (2603:10a6:203:68::34) 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: e9ee0039-06e4-46bb-287b-08d9ed619a93 X-MS-TrafficTypeDiagnostic: DB7PR08MB3865:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0n/QMdtmFxEaR+jTn3WZV7Jh7ZgVozmWY5xeZvHW5poExaW+5Jk1tAJpXpGvXyEvJr5E72y07jQ7cKNjhn+LPSYP2bdN5BirYnFNC0Jq5PlhBC+30Fu4tpBKWmOfess28HHZTWGU7veI6JnthReLJrDPGFWakNdHWvB4THDZm7hWKH80vtQAfVixKV/c0u3LEDjtbB/BF9K+7sbZKi7j80cNVk8NPl8eesXCGTzvLg2myelPv5rkcw3JlBozapW4/Pu1svgsZnQ98MXBFE0Jf7zLVH/+nQmLn6jroVoS1X8m8R6zx19c4lrLyDf54tZ9O3eZMErUgiJ3ATAFlbUteZ9tZVPTJ1xTAweh80x6S09DTe5su6K0+68EQ6NhdDh0Ru9y5LSG+j4AXeoPfhLwP3hnvbOmknhhIXBDJqetcZO/j7UNo8ZjplqZL2LjfNmABMJ1Xm28vvNwlZ0REDeTev5f5F7QUuukkl1rKYJb2AuJFBnOHqpX2H2wI/dOxdNXXHiEkG9egLK0KX4N+o6vbMm8GOaixQb85snlaop/ag2/6ZlxglvoOaRnYxs/836YNwXicZHcUjSvRtOzFY12sb9f6xecsdtJQAYQ41NcRzDe+xmQLzHPW9aXp8qeNarE76vOSJM63BqV/0hyKNnt91G6FQ5UVdiBa74AUVLf9CCVUUupMx6YEMjr72mUpvCMlrZ6M3fQX9KLvyoFWn7UMw== 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:(13230001)(4636009)(366004)(316002)(6916009)(2906002)(38100700002)(86362001)(508600001)(38350700002)(6486002)(36756003)(83380400001)(52116002)(186003)(26005)(5660300002)(6666004)(1076003)(8936002)(4326008)(6506007)(8676002)(66946007)(66556008)(6512007)(2616005)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LMrmtAWK5WNj3sarUfBn1djtCnw+6cJJlh/UnCd0YIOYgOYZF2Sm9J9u+gWjF/QEL1jhWhREncwRhk5tlT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Mr9nMInHVpxpBt8nUaa6AKPaNgFB8zAL596pamHlMoNmHUND6zXy570R4+DGfSwHEX60jtGjxGhUlwv632cqu+xGA8mbm6et7DEnTk4vpShJYjq62HBPihsib/3HVCr+cXbeofcid92UHhrASX7vUJXyHhu5+g7w67qxgCU9YhVDZIZhgLWl6g5JqFIGp4UmcbfdMDIoTF/hyl0EOlQbLV8BuyDanLwKmMy3irGepaCTQeNRyebSE7kdBOxpjGKk6WgghTw+9W5kJIScMdcimedr0BNUcaIoCTaAcp8R8dCgLwDqttRHoIfwFM4UdqHNmFWHIvBzRoQQnFA0w9rvRqHchJ9N+n4SgmM9rJroVdOSoxg1yTfBoG+7fV2hGCu+Pt2hDHiWx4hxN+kneSZ+uZbiT8u5rU+umgMGd3Dd/3t2b+VBrEU73VLn5UUG7vzSXIAEwAI/tA2jonBEI868jgtaa3iBQLtbaCQjwtJB0qOMZr7zAvykks4h4+DUYm/4wBTqYejo/N2Paj67MA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9ee0039-06e4-46bb-287b-08d9ed619a93 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2022 13:22:51.2768 (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: JS4QC/f8Rh3LAslCPhx0W1UOfLpQQ31SXl6TXtvFHfTH5ggQgHLEAHf+W8MdzOJ9jpTdcXBo31+hb+7B0extwp+o9MyEUjmF6yCn7l5wXXs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3865 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe1e::71c (failed) Received-SPF: pass client-ip=2a01:111:f400:fe1e::71c; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-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, PDS_HP_HELO_NORDNS=0.001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Hanna Reitz We start the reconnect delay timer to cancel the reconnection attempt after a while. Once nbd_co_do_establish_connection() has returned, this attempt is over, and we no longer need the timer. Delete it before returning from nbd_reconnect_attempt(), so that it does not persist beyond the I/O request that was paused for reconnecting; we do not want it to fire in a drained section, because all sort of things can happen in such a section (e.g. the AioContext might be changed, and we do not want the timer to fire in the wrong context; or the BDS might even be deleted, and so the timer CB would access already-freed data). Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Hanna Reitz Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/nbd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/nbd.c b/block/nbd.c index 63dbfa807d..16cd7fef77 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -381,6 +381,13 @@ static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s) } nbd_co_do_establish_connection(s->bs, NULL); + + /* + * The reconnect attempt is done (maybe successfully, maybe not), so + * we no longer need this timer. Delete it so it will not outlive + * this I/O request (so draining removes all timers). + */ + reconnect_delay_timer_del(s); } static coroutine_fn int nbd_receive_replies(BDRVNBDState *s, uint64_t handle) From patchwork Fri Feb 11 13:22:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12743458 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 C42CCC433F5 for ; Fri, 11 Feb 2022 13:57:52 +0000 (UTC) Received: from localhost ([::1]:59992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIWQp-0004oG-QR for qemu-devel@archiver.kernel.org; Fri, 11 Feb 2022 08:57:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIVt8-0000bE-BL; Fri, 11 Feb 2022 08:23:06 -0500 Received: from [2a01:111:f400:fe0c::726] (port=41871 helo=EUR04-DB3-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 1nIVt6-0008I0-E5; Fri, 11 Feb 2022 08:23:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eVSFWDHcvVjYgBvrO0iqcmuyEs/9xmQSQ4WMkgMVYq+adTUdAjDGWmqdPP4mT3ZpdxNRbld4hrhbelZ+59I8k3Xrdookt6RYCv4lmTpigb46IiHNdwGgsKAUCdtQGIQnvNZvo0NYmQIk/H4saTJ65QmakcMzycEbygvXMTiX60pSaxVM39WO9p4c+KEIYKH7hynv7YxAxvFjRqjnXzaJtcgKb+C6CRwcgEgkJCP9RD8y4zy9VUvcmrLgDcA14xtMfpPQ58AQZ8NlHR+CN+1/CGSQ+9rzJruPQGhvqI7dV0Axg8d1yIKG/dDFh4urEL497iIqgZjeH9jvY/t6ncXtAw== 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=QB0Y9SApIuqwhwYqJTzYzlWa74N5xMaYr4QvDu4KsKI=; b=dUlE2/VSfC5Jn1nfD682upnK0OMOVy4d69Unzh+Y33kbvy04awuDUcJ903AP+kaLF0CXLA/Mwmeg/VHRxpumDUrVPQ9UV8rhc+nWAwbHiG0vIJqMaJxSRliKN85ZtHnjLTGgwI6v8eRbLNiZh/CWbXeJW1wMtRLhqCMKzzCfKeiM8IdVT6xw/4fenUAJlU+JqZRGSeFn1QLgHN2z/GYpM2GEgsqtbQZ/Uy/lMhW8s+JDkSJs3ZgWzoC7UEVY5seXlJxXe7tTOz1pDtmWaloQluIs1f+VZ14D1Ln2dewBUaq7rMOBkHjr8KIHRIQQMkBGp1OEdW6yikSnrxtQFeu1ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=QB0Y9SApIuqwhwYqJTzYzlWa74N5xMaYr4QvDu4KsKI=; b=ceuYicfLQs8G9iK6Zf69/R7H7ruzw52lJKs3DzDwPiFA9lAZjDGq2y6B6kuY6fl8BHGfEDab6EIH2oW1/bZQJL1W3CYL96twwmQpdDDQBz870OPax8vk2FYaTdJ/CYkm4NxdGPQ/Nq9ECzir7/MffvB4WXtMEknk64srs9HrgMs= 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 DB7PR08MB3865.eurprd08.prod.outlook.com (2603:10a6:10:74::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 11 Feb 2022 13:22:51 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4975.011; Fri, 11 Feb 2022 13:22:51 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, Hanna Reitz Subject: [PULL v2 2/7] block/nbd: Delete open timer when done Date: Fri, 11 Feb 2022 14:22:35 +0100 Message-Id: <20220211132240.781958-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220211132240.781958-1-vsementsov@virtuozzo.com> References: <20220211132240.781958-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0601CA0048.eurprd06.prod.outlook.com (2603:10a6:203:68::34) 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: 909c6406-1565-4b2f-96fd-08d9ed619ae6 X-MS-TrafficTypeDiagnostic: DB7PR08MB3865:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bJSuZjq8AhAUe/OP7HJq5jknl4HMrnAUZZrTIM5U47VEA44HGFid3dC7WNPG76oLMr1j9bagYLjNzRv7d1ooxnqPoKMpUJPXVS+JhifmroyeE9xq5qaQkoSRWqHcF7zkTylxqjHLG2s6ZWGEDLHJflR8Cw737LOWV90Z/p+14p4LTiKLCZbLbXUPMJMo6gVROmBfZ889h4opNFJZsbvZGKZKkZZfH4zoRCwCqs3K5K/EFLgLJ+JDofMFr0NhABatHJoXla1a+t+mjy9x8MJ2LJILy3bMYEi7mmWblN2uZJf+26w50cBdJpQcrTiv/v/X5VnJdDF+CEUqsziZaADimot4J/6yEMwudO5WOSWg77LBFSGPPTvmU9GfcQN3SpxDpUqWfkmZt+Pc57O4DM+DkLi542fb2iwZbJwAG4mnw8ztsaIlVM2Yiboh7AaTVD+/fhocGcEWFI/7exkLerGfFctvrrEEcUoPpYG/ZRr/kmP3szDy50Paao69N1LJfOoYvwZlbQPLXR5TscqVVqF9+hKZvlBSmVegvN1MmGUiTFOnw6yoVB7h5diWl0T36NdwedsdrVQxahWVDZtm+tn8MGUnAv8jWbIKVJKgKwR4mzzGVUdpRqc6QTYxOaaSaPzmubrZ+uK55ZzPT8q6E8ShYZKssp8WgbFN6F9bfhel/r9OYeiFriSDYCJBxnS30QZBmgkM60Iqra3qtvKxa7sZxA== 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:(13230001)(4636009)(366004)(316002)(6916009)(2906002)(38100700002)(86362001)(508600001)(38350700002)(6486002)(36756003)(83380400001)(52116002)(186003)(26005)(5660300002)(6666004)(1076003)(8936002)(4326008)(6506007)(8676002)(66946007)(66556008)(6512007)(2616005)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0pU1XISjXXhArdwgDgJALr4GPsSRLDDnpogoNJq0loGe1q7gPb8vWD4FPXvy/uXd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BHL4faU//7wxADUA9yu14qJNJc5FZRlEeI8ZsV8Squ/bjIQ7UJMU8szfBeNux0Bd6IrxXW37pI/cNUostUmjmiv8+cQkTK7bkAu/uMlqJ5pQviV+xQ/4OGH83MpE4jbH8CeYvIK107coFAA+GCvMlSLmBWcW70FZRuWnkYlYXvIDtxTFZ3lAooBU8xDu/pHpOkZ2ztj16IfciQpCg/SeTyxfi4IQ3R9g3YDuAxPZakviVb4YRga0gqrpSAPsdP6ULpApzbHKjD2qXK0T3iHhwX2+3kqeJmakPPbn7eUkj3/p0o2+1DzzKjyXs1B2ZfkCdZypNPu1BMebcabXYAdW/povDyqW6xvkQ4nKOeeg0WK3x5o8lSwg3+5LdPzNKIzZEsMGcW+jKusIo7RDHRvQ4zOWATBtrWcFknGsMgdOKkIV0GktyNkeu+c1mq3Z+rxnMY6jFKyGybhp3apPdZUOZIGCq0el0NAn+HnD/52ZnXMWQv8Dh6TY9VP+r8w5ig1F6tDuk4bcaqnw7gh4+0zmp58ScCIdn6vC4pzMoRw== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 909c6406-1565-4b2f-96fd-08d9ed619ae6 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2022 13:22:51.7299 (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: u4FHT3rqIJFsR7XDtTecKScxs2or46/amELais9rM5Aq5FH+PPk1pxtVluDwkb4qsT1simLrbmQlDoFdTwAI+zIIKkIWC6AOt08tPJdMYIg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3865 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0c::726 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0c::726; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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, PDS_HP_HELO_NORDNS=0.001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Hanna Reitz We start the open timer to cancel the connection attempt after a while. Once nbd_do_establish_connection() has returned, the attempt is over, and we no longer need the timer. Delete it before returning from nbd_open(), so that it does not persist for longer. It has no use after nbd_open(), and just like the reconnect delay timer, it might well be dangerous if it were to fire afterwards. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Hanna Reitz Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/nbd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/nbd.c b/block/nbd.c index 16cd7fef77..5ff8a57314 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1885,11 +1885,19 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } + /* + * The connect attempt is done, so we no longer need this timer. + * Delete it, because we do not want it to be around when this node + * is drained or closed. + */ + open_timer_del(s); + nbd_client_connection_enable_retry(s->conn); return 0; fail: + open_timer_del(s); nbd_clear_bdrvstate(bs); return ret; } From patchwork Fri Feb 11 13:22:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12743462 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 7E993C433F5 for ; Fri, 11 Feb 2022 14:03:07 +0000 (UTC) Received: from localhost ([::1]:38570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIWVu-0001D5-Hk for qemu-devel@archiver.kernel.org; Fri, 11 Feb 2022 09:03:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIVtA-0000bL-BP; Fri, 11 Feb 2022 08:23:06 -0500 Received: from [2a01:111:f400:fe1e::71c] (port=25931 helo=EUR01-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 1nIVt6-0008IF-SD; Fri, 11 Feb 2022 08:23:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h7tIqml7lgsZmcmGoW0cuzrYYq8L7DAWBDrxlQLRlcujiga+rtlyPvhADCXyUuqshUTSIut7StWHYesIydpMTCwiLgmRXrIp9K9+4kBGepzTfxbdC4x5+Eo0C7yT6yjCmdXxd5xxTnQEYk4Xv6W7hhhwkh7dcoBWxEEF7W6ZP2XJpHnEUevSPuJH+zxlhWIIT8hr0O/Dh0eoLeVlzcyUKaontkYkbrAPycm8gzfq9NS1SDHYebdY4+QkkQVvEECH8JudFHf9yuV19IM32rjlN9h60B4qM1AuRkefUDrRk/MydEoBrMieDzpseYSxQOusQ5sxlf/688//tLsNXYyJqA== 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=i0US65Qe/Fsnkm0uOLTc6MQTkPaMMeKWAlGCAp8VUMA=; b=hiMzi0dp82rdSBoNI0o/pOa0DP+I2JM17i1tC1ctJ8yfS8lCprv1Ni4rHSA/OU1ATg+54AwETUxbvyZgKSKsC3jkuK5oanh+G5e/6hQqPH5N7zZb5t4t3mRG4WoXkFWUS92IL3/TuIH3HpVdO/D0ZTVdZPlXW9LXQXpuG21msiAtE4F4f0fMqWnR0SdGpscx1q1sUzxi7LWEx0/f0ZtV9JWvvaGRz4sByS0YJKU0nkhay5sGA2exlurVIvUx1m6IpUi+RjalECFmqK8bMeHCsbl7nrfjGmt44rBWF1qHvYsBqO+BEFazn98aN7x9DpZQ4GQDmAN3Zx2qk9N7b+3S1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=i0US65Qe/Fsnkm0uOLTc6MQTkPaMMeKWAlGCAp8VUMA=; b=uVdwNr5fDwCw0hxqa5Ia2X0R/qVhD8jN4pvIus3i08LWZAliMA7J6q4Ud9XF4A5e2juTiRdSVFJOPw9vmEwlSC0yi48PVhb3PXW4mgZmefjw9idgDccZIpQveQzMk41nM9rKN9NuumsEhWUnNQwzaxSQsHb9tD29tlOIuFYeL+k= 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 DB7PR08MB3865.eurprd08.prod.outlook.com (2603:10a6:10:74::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 11 Feb 2022 13:22:52 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4975.011; Fri, 11 Feb 2022 13:22:52 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, Hanna Reitz Subject: [PULL v2 3/7] block/nbd: Assert there are no timers when closed Date: Fri, 11 Feb 2022 14:22:36 +0100 Message-Id: <20220211132240.781958-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220211132240.781958-1-vsementsov@virtuozzo.com> References: <20220211132240.781958-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0601CA0048.eurprd06.prod.outlook.com (2603:10a6:203:68::34) 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: 9d14c226-8b06-4364-f394-08d9ed619b26 X-MS-TrafficTypeDiagnostic: DB7PR08MB3865:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:191; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Uzi0Xf57CN1pRb7CxrADGCpdnI5/0gbMb3nxhhLt3si/UhHEg83rGPnJjENQdNG+STMsQZg7t9JPKuk0rCVMlyw4XWL24KfBdVEfXed1db1R8F+vMbixEybHEQdQ416Ku9g0YIc8OB+UHuECa8SZ5sxbrR2AeIVaehyYBUS15U8RKMmLZVsRgUcmDU6pa7DtCjg/Hq8PfWa63RyDIFwENqPZRFWS7Fp4zvlBAZusgHd1LR+GCwRRNIw88qxqqE4a202/I7vGZxamuRqiGH+vs6CJWRassFha7lrpyKG7Hb6YhsL966ubB4hXuAtZLkOCU3Sibqdo1U3p7TVS2Gv1p0WBldSkpDKH1NZ69lO0lUiIsk5VYXZZwYW8rARnx7ddFUwtMJc7Ali0KcQhJfGrs4XS8tkOQdQt8aLBkbUb9XKQU6FChDoAXDGdECcQAmxoCagkXDnQWlOFkYGJ2xw1xscZ60NuP/hr1bTzmR0filrA2a+b5KX5OuR3rZcInXmRv4TYcGJuO6cezLY/Ujwq+P//4ZDB2OkhB3buNTZgOns5tj3AE8pvRCEp3gG3CxBx1oZBHJaTb7Je7jA1EC44j/mtxgkxLLwt3zrZp0uu75w4qFM4KDJUlPleeR3hEfGQFU3DGbD1SNiglHVvNp3xptVDLjTy6+L2qFVo1qUGRppVBXu5AmyrxsuSJR2PEuz/Sw0CnAcnDixuYYyxrmHjCA== 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:(13230001)(4636009)(366004)(316002)(6916009)(2906002)(38100700002)(86362001)(508600001)(38350700002)(6486002)(36756003)(83380400001)(52116002)(186003)(26005)(5660300002)(6666004)(1076003)(8936002)(4326008)(6506007)(8676002)(66946007)(66556008)(6512007)(2616005)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VJ44APOF1Ilk6ByM5q5Ty8V0g1u9xZulEgbTBMC060nkvLV2jSOPIMywlIdHiS/ITelUb7Jbg3Y7n/ljfWBNZ7rQn1FrljnCtugN5Cl+m86uFZmoouLCFt088pQh6Uf4pMyY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UJXWFcNySIHwvp0QHuu0A15lnuEWuSRqn62RhRQ+mtqYhAVv1OpqGDmuYPz8G4qNEAynPIyg+TQ2dYtmkYlvE6QFybgaCzIciJ4sjUQ0lh3RmApLOh0NpxcBGk99H3UTLYIs6IRprIaFWTa26YX+5Rx20SL+SGTF9ClD4VQp3Mhre5R26JFyx/Hw8ummJit2j31Ca7qOt44xo1hjOPYLyKqz8Xfmg3b0G1GzZaa+MU1GYW/dw3e6LHw/87/5cKMwT95Z6y9TQ3icR95XvoCWBA8OFjMBxx29TSYsHNUYFoRIMbY+mZgW04cgT/IQwaGI8NnyTL9jQPdWI9RnU9LmAM3BlZ/jk5PLeLyNnxUzSS3iZ+PlC41bQHSumjhfvhssIoZPSrDa5cHTlmesrIYpQ+UKQb5vyLDdsFEeP0Fp/UJTMhtCyAneotWb2YjyppIyWMhG6dJXAQ6ww47aN0FZA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d14c226-8b06-4364-f394-08d9ed619b26 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2022 13:22:52.1517 (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: wZpnK8pa0iy4+i2L7Yd47u5zFljW0MKNorLywVJHBLuxuyxtIBosebnA9R7d7Uq0Y19QJYS1obgY9Q6L2e9eLQOcpSziWha41r6c4yYr0C8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3865 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe1e::71c (failed) Received-SPF: pass client-ip=2a01:111:f400:fe1e::71c; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-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, PDS_HP_HELO_NORDNS=0.001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Hanna Reitz Our two timers must not remain armed beyond nbd_clear_bdrvstate(), or they will access freed data when they fire. This patch is separate from the patches that actually fix the issue (HEAD^^ and HEAD^) so that you can run the associated regression iotest (281) on a configuration that reproducibly exposes the bug. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Hanna Reitz Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/nbd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/nbd.c b/block/nbd.c index 5ff8a57314..dc6c3f3bbc 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -110,6 +110,10 @@ static void nbd_clear_bdrvstate(BlockDriverState *bs) yank_unregister_instance(BLOCKDEV_YANK_INSTANCE(bs->node_name)); + /* Must not leave timers behind that would access freed data */ + assert(!s->reconnect_delay_timer); + assert(!s->open_timer); + object_unref(OBJECT(s->tlscreds)); qapi_free_SocketAddress(s->saddr); s->saddr = NULL; From patchwork Fri Feb 11 13:22:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12743464 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 C35BFC433F5 for ; Fri, 11 Feb 2022 14:05:51 +0000 (UTC) Received: from localhost ([::1]:43404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIWYY-0004W6-Kd for qemu-devel@archiver.kernel.org; Fri, 11 Feb 2022 09:05:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIVtB-0000be-Ui; Fri, 11 Feb 2022 08:23:06 -0500 Received: from [2a01:111:f400:fe0c::726] (port=41871 helo=EUR04-DB3-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 1nIVtA-0008I0-3k; Fri, 11 Feb 2022 08:23:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aMUhUQfKbys6PDGkWh3YWv6UNdJevmm3TcVDR+eLtS6JM6PazlJXzJZ5Y7g1htVWSaQpnx+Qg/ZQn8G39mqEwvzH0ZG/qDY0n7bRVbNAcafYrK8G1hm6uc/6oalbVr7fX3kVQSpHIVjB+z+O0hwBvFh+pf+iPR2LExMm7IUrXt2uqK6+gfqE4ZNAJ5Ox4GFQekdKcwmH2zdaMLM6A7rxdsuMBmJnznp6i2bREkMCOaRDK3F69T59k8hHAOIKJT1Xe97gTEuHquhQCWwZnhwP1Rbj7touWh4yjIRj4PQx8yhCkg+JJdWzO8eVU3tA3krvg52LUCwEPTAZm+JeWRq83w== 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=JX5z0MXH/QAuXwnb8Wtp6u4kvZbDevfxlyAen0yE390=; b=bm1GSHY61FREMwg71DGJFSqE+bjn6g0dUBMUt4qgbUnqFOsBgWAcPvBU/MCAmbfZ2lQDHaZiJ9Y92EG8tDMPQL5O0Yx1FgSkwd5rewg7ILU/rxI8iESJ3iCYuqnJSEdcMH4ToJAWztCoeCZiT8t4lF7ENIPqX2FpZuMlnIWs0hPlAXQYxEIJH6CBasdvbfJIYK4eB3nf6V6mtlOQ83//mR2CivS+V3H3ybfTUlJHGHE+ePehsx7EEitGvAlBk7dtlvxVwbax0ejm4OGvxspQPCgE4RHyDGZ8WzIN9fS70gEPQE1cXzPp4h/M/QY+huDCb3ad/aWZdI6c5MkOeyf+jw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=JX5z0MXH/QAuXwnb8Wtp6u4kvZbDevfxlyAen0yE390=; b=SzDJNSE11Yeqq26/YzrUmnAvhtJL2tf6wKnsarSuzigS9j3B+MBUorIIixxVPFZgmnZ534EQ2HH36OmoDTQAABUGYLdN7ByyJvwVL04jvCLCq0dbApIt+ckSxX6ihjpqXMzisnA6DD6D7eNn67Y2TfYC1Gt8EsKwTFOZXDex9EY= 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 DB7PR08MB3865.eurprd08.prod.outlook.com (2603:10a6:10:74::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 11 Feb 2022 13:22:52 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4975.011; Fri, 11 Feb 2022 13:22:52 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, Hanna Reitz Subject: [PULL v2 4/7] iotests.py: Add QemuStorageDaemon class Date: Fri, 11 Feb 2022 14:22:37 +0100 Message-Id: <20220211132240.781958-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220211132240.781958-1-vsementsov@virtuozzo.com> References: <20220211132240.781958-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0601CA0048.eurprd06.prod.outlook.com (2603:10a6:203:68::34) 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: 193d7bd2-4c90-4d8a-8ba0-08d9ed619b62 X-MS-TrafficTypeDiagnostic: DB7PR08MB3865:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k21PwrrSoo5PxH7gycgnAWcb/912DoF8oYtHLt8IAP5uxDujaahbzRlIqLkfl5AYjotauteIjHH2Hg47Zl78oEWfB9G8F7ophGF5Lmk8wpQ7OdVnScDzLxtUMbP0xdO62hxFLjOA6E+eZtWj3YEQs1zhZhtxykBclJOMw3tA/8mkx14P88SceN+MtE107o24tMaaF3dxOlkpX6YMgqmbILpudlLBy3gbpQHvLeF6KaymJw86oTNiM1m1gEBoEjoNJckxd/PmVDINDrJLFQsF7H8ehIjF3zY+6X78LLc41viUoBR+jZqUj/I91IcLP5ef3CKWojrGXoAh5fEtA2XdhEd5xUSi+IqNijUL8qsC6RQbM9UpVYQj8o3+g5VndVRHEc4ifZc0mRSJjzD0UQOm0rm4Fkx+O7Pps7Ezl9LL/Bbqv8qA17NCUEf25hW2y77LOiEbO4OZ5f49AYPlmXHirwik9Gs+WMa6oaSgjH9IkD6pOEI0fk5HQr1FY+glY6U3Nz9LalfUvOA1e56LfHTNvPvOfh5zzPL1jNi4iuUepQdcNoH2EECRWb95TTwh3EHvW5H0IaLf8qnFKqXyGATWn/Q81XLCQfYGvrjIUl3okvA+JZ9hC2Ee57C2L6esXu7t0trdibtkJKmbEe4BZSqxa2m/Edf9DqMMkTUveelvaSWu1uFV5ahcUAQh6BQjWaxEd1J6EnCbOBtccGmc+m7wfQ== 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:(13230001)(4636009)(366004)(316002)(6916009)(2906002)(38100700002)(86362001)(508600001)(38350700002)(6486002)(36756003)(52116002)(186003)(26005)(5660300002)(6666004)(1076003)(8936002)(4326008)(6506007)(8676002)(66946007)(66556008)(6512007)(2616005)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: egPcsE/HkCgy3j96mEa5BYkt/OvRCM5ozZ1azg9/C2V/cK8+UR95IG+qhFvOdIq1cEivQLo9OvDuCp4RDLW4OvKrwx9vWOunUPw+z6aMQbhgXjG7UadBBkHLK4X703g4RQJ2RTHfoaEoLF2epOwcptXcQ8o91PL2Klf+H54y+D6O7BglJz2Tii+JAJR1H7rlh74Ro3yTXqQx7Q6hSEdrrcxiIXji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M54+d40C4ks9LoyPwIn+Y7On1dRMutyo3pSLW65X7DRPhWvYNCfNemD1ccm/ufvl+Va37UX5m7W4ZaJURjg5AEX92FE5URHQJXs9W1gh+IB3wZBPPDUt3dkKyEZV2FzrCwOLc/ipX9q4lyN8rSH+y0R8/46RdZH3loa2N4nKHokgEp3eYAE7MB2e1q5e/asNsIOa+XRcv96p1Yn18r2d2oTbwlMvppB6AY9246HSZuwyQw9rQ1f7Vq5v7/88/DfYd6eKa4FMGtMQ/KrvofyUziX6prunz0LxAqa+vt/JsB/uo/QizeU3RimVB2dl0rq5MocTAB/k7wn9rUda3ff7oS4icA/NlEvnKw8vObdyH4NAno895qx3cyZnTc5gw3lpCqQGr9ONViCsaJ59w== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 193d7bd2-4c90-4d8a-8ba0-08d9ed619b62 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2022 13:22:52.5110 (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: QjAAxoGn1TFal9RRwIGcaiUmcnFqxIxs3O3tlelo7drmLPqnooriPdY0VD0pxI2o2EW4qFQtQevWKEkCDVFXhYTs01+VtSLPVP6NeS1ds40= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3865 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0c::726 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0c::726; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-DB3-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, PDS_HP_HELO_NORDNS=0.001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Hanna Reitz This is a rather simple class that allows creating a QSD instance running in the background and stopping it when no longer needed. The __del__ handler is a safety net for when something goes so wrong in a test that e.g. the tearDown() method is not called (e.g. setUp() launches the QSD, but then launching a VM fails). We do not want the QSD to continue running after the test has failed, so __del__() will take care to kill it. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Hanna Reitz Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 8cdb381f2a..6ba65eb1ff 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -73,6 +73,8 @@ qemu_prog = os.environ.get('QEMU_PROG', 'qemu') qemu_opts = os.environ.get('QEMU_OPTIONS', '').strip().split(' ') +qsd_prog = os.environ.get('QSD_PROG', 'qemu-storage-daemon') + gdb_qemu_env = os.environ.get('GDB_OPTIONS') qemu_gdb = [] if gdb_qemu_env: @@ -345,6 +347,44 @@ def cmd(self, cmd): return self._read_output() +class QemuStorageDaemon: + def __init__(self, *args: str, instance_id: str = 'a'): + assert '--pidfile' not in args + self.pidfile = os.path.join(test_dir, f'qsd-{instance_id}-pid') + all_args = [qsd_prog] + list(args) + ['--pidfile', self.pidfile] + + # Cannot use with here, we want the subprocess to stay around + # pylint: disable=consider-using-with + self._p = subprocess.Popen(all_args) + while not os.path.exists(self.pidfile): + if self._p.poll() is not None: + cmd = ' '.join(all_args) + raise RuntimeError( + 'qemu-storage-daemon terminated with exit code ' + + f'{self._p.returncode}: {cmd}') + + time.sleep(0.01) + + with open(self.pidfile, encoding='utf-8') as f: + self._pid = int(f.read().strip()) + + assert self._pid == self._p.pid + + def stop(self, kill_signal=15): + self._p.send_signal(kill_signal) + self._p.wait() + self._p = None + + try: + os.remove(self.pidfile) + except OSError: + pass + + def __del__(self): + if self._p is not None: + self.stop(kill_signal=9) + + def qemu_nbd(*args): '''Run qemu-nbd in daemon mode and return the parent's exit code''' return subprocess.call(qemu_nbd_args + ['--fork'] + list(args)) From patchwork Fri Feb 11 13:22:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12743465 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 6C09FC433EF for ; Fri, 11 Feb 2022 14:09:00 +0000 (UTC) Received: from localhost ([::1]:47602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIWbb-0007Wb-CI for qemu-devel@archiver.kernel.org; Fri, 11 Feb 2022 09:08:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIVtD-0000eO-GC; Fri, 11 Feb 2022 08:23:07 -0500 Received: from [2a01:111:f400:fe1e::71c] (port=25931 helo=EUR01-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 1nIVtB-0008IF-Ek; Fri, 11 Feb 2022 08:23:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nB0FYFA97dXKVlV625Q9a1J6p0LQtwdZxpD9Tj2LWBTYMdocirKbPL2VFDRzaqfyVLjUB7DT2U9AsEibNkjKr1Uue4LuGkTDu+w8j9U7mr3JmpOweqIRCkWyIehWccJ03aJxKDCV9XKtDUK7ltyeNZ45ygDEoPzTjveEUULiYHqXh2tHn/2GQP8aOjXMkbktjdOZ3Xxo8qtyMnuHF4WGiPh+82GIvGCwLhH2NKS30CQ0cPT1Fg9K1QlQUTVM0mlo1mQqz4SWo1pl4U8opDISU0HFfsbqvFsZRQb+SD0F3Jci02n2yB2v9bWMGButV5GfT6IHIQsnP72o9KDMI+M6Kw== 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=g+r7Jcl1f9liiDJ+itG2SdCjErdRw6UCoLXU+rXRp48=; b=X64qh05GWsQ+2ec0sm05fmViGK9HI6EU12CJdqHUkfLiISC76excwbGigG5nR6Ka2XLLarCk2TWO0j8/gaRSjI6n3Ap8N4fRHTXrgeZGbIQwGd+xSrRu2lbBsZzQw1BpGBvTxJ3aU8Ein07MRQ4qHej2PXvPOxxMqDSjmQ70yLkJ9iXUL9nZFnbIJX1rkhkmGTESgzgd5Xl7QoA2ouLokDBL/nEXTMj8NpWa1IOh3mZEfr8MyOTvodMh64mTNHIWVSIrWP0LQ+T0w4eWGfeXdL1P/9727j2i1BgZYCNZ2kL53PED+GQOVTwcfU8XJoYxPLr78ujhEwutu3gSKJ+JTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=g+r7Jcl1f9liiDJ+itG2SdCjErdRw6UCoLXU+rXRp48=; b=JdQ16TgGWhy8FVppkxDBFG80AwYao3/sKfViLTErfjGza1YJq9YSU4xs5jpj44tvHZPl+RxbdLhiyaDcXfTGz6p7smU4Ih3lqYLo1yhlenTrwcmYN9zhD8SDKEJ/zKbFXTxkk9kh4OfCD5DK8XSS0H2CYIBI5/kiYuIYCOqkETY= 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 DB7PR08MB3865.eurprd08.prod.outlook.com (2603:10a6:10:74::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 11 Feb 2022 13:22:53 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4975.011; Fri, 11 Feb 2022 13:22:53 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, Hanna Reitz Subject: [PULL v2 5/7] iotests/281: Test lingering timers Date: Fri, 11 Feb 2022 14:22:38 +0100 Message-Id: <20220211132240.781958-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220211132240.781958-1-vsementsov@virtuozzo.com> References: <20220211132240.781958-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0601CA0048.eurprd06.prod.outlook.com (2603:10a6:203:68::34) 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: 7a3f0308-a45d-4865-23b8-08d9ed619b9e X-MS-TrafficTypeDiagnostic: DB7PR08MB3865: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: 76do9+ZynDh2OMWCN/k8LocEvZtuCOUwoqYeEh9eWyl8HM6c/uMU32xDt956lfAJhc7E+uM3u6aIFw5FsWUwWABeGLDaM3sOBGpvXTf7LQI05pgFOQGYwUXzFjZkgKxmmNTt4K4sxQRjbh3IxXldoAnZsehPkoLOkzhjpne/XV1m8nx554LHx5Hdn+Jt4LwDs9b5gZ/oYrA1hlswfeaWXrr2HRhhIwIAXn28tPTDrWiAo53imIVIyov5cn6xTAfv32WfwAtFpXcmOjjOAwXMETTeaBGppJd9jqRwj4suP3TO89AcXvRSEK54UvrlBmC0vv/oFQ0L6TYb9nVQaEFIFVa9Co9snMG/xpxAZbNokkwfU0MHlhfSzoxM5v2vGvlYmXhbJS3jZVyZYDo1xNDqI9c2egsw75FxEeZorrLmZqYNH+Bl+EPY/SLjO6TqpC0OzE00yZtm1dhDNeyAe1vQQfz7MN+wHPBgeCebISwAzWKUdB5uz6irwXzvgYBRMa7Bc7Kd+eNYKTQwAGog36+9VY/8JUpGVC7zmfbhmlCR6h1ggGxpPImbt2dC01yzYddP1qmZ7w0LWNhbKamtBX5x5I1xf3b8BsndAkkJ1lLmAdeok57pX2fy1eg2oobYSTTNlRNI8KiGktdPJlI7mfMlroY21IZPZZjdce/6p1n+cZosz6tX/3iZN0ibzc/iQVnJQJ71Ds/fVfaty3MejrzgkA== 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:(13230001)(4636009)(366004)(316002)(6916009)(2906002)(38100700002)(86362001)(508600001)(38350700002)(6486002)(36756003)(83380400001)(52116002)(186003)(26005)(5660300002)(6666004)(1076003)(8936002)(4326008)(6506007)(8676002)(66946007)(66556008)(6512007)(2616005)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AYVZs0n5rAkW+3EaR2IDcnNxG945lnniJ8CuKVuBtIpqIEKHUxkzyH9DW83q2+qS35IZHFSj50LpJ0WjuWicm3zpPj6sLqPf093iEjspLz/08NiyjNpgV1HC/iYQDjCjxuHR56a8ADzfjj3jABFJoMBTg9dVzfo9XQcc6KdMU1uTVUpmKRyZDDSZjSwwf36EK5ZLwVH9GFIKJa1JMJ8hH7MugR/0OPWdocu+k/yVeDBBJEyWTjUCahz2JbYzHRTshIy28dlr5i1KqBpJfrI9PfBUHYuPvJV7LAOJE4fQDvxLfmWUX8JhUMz8OJqb5MwLF8wsgX9YMGjwkdOAhkMMA6FMkQarJuJXi9Y/eKC0/swGxOU7DV09pMwWYxvqMlYo3KnF2VShUaSvu0g4AfWU4FYjgA0OIQJ0fWnte4BOQF/MY1zJpOFHWU1qHv8l5pQPD3EmOqyrY9X8Tv3/6J7NrNZFuCA+dHiMSWtLGiVViexPStbulCMjt6PYdpCVqfvmmYcVUIk1xQzViiyA/m5L8NLyIE6trC/A+lwgykvS453qXhGxuMMOAhYafb3VXksATvyuqy/Gz3puwhNj5p5eJ0A4bwCifYR3MdLbayXLmmtPXDYAHfWlUCVxjf5d5k6f6MknxYA6WQastSxrCPGHz20pA40RFOgkDgeI3CLrUeWO0m2hjTfYyE5xZnwKjZr7AONcSdtdtTViN3aVR54P/MHzqltZPSp8wxWPvZhJY5sclfP54wr/vnI4dKrfRxsnLcukb/+H0o1zQuhN5qyaSau1dO6iAAXLxk9xB3AxZ/TKRXMQ2yb+26pTrBarYTqQqa/BupkwEZsfVUyWJI3PCl8iDTzthWSzLFsYaB8YYNoUg8Yuc6Pv2BfCjiI4rq4tlbwQM533QazikoFAwshCq/s9PBT8bxYdNVApQYPf2eOKEwtd+C9Zm+iyRtbms24YiRcG1a5eS57yLwvDohiLJUtg1H0NQOyVTav7+0gxODovseq0lP6dOU0zbgX2yTqbQNMM1T/wJjdXmukd6AohUWqiwzxI/BEiMBdT+4r8t8LbCztef4BTiWO1nj/HoHHM6eTHLUE7sF0AvPxndAQWp2+rriS9WiYpCLyvUQHrBcuUKhrQvNqoEdlgBh5mEOs+iye7WOFju9K2hJhCIHmJvbFvNQWdLVWiI0RbuaG+HRzMzJMwpM2php7Jv9dmCzfDKVi4gt7VTJ+wSnmMpxd/8I3JA01cyEcTg3GEYsDyefm56eyeikaGEcz0CQ4TCbEakcvxapvZ0WUGSvIQEcRdD99pbx8E7Gj64Sa4Ka0w/CYhK0O3laAUfJhv0dcRXL3WiXkVqC35tgbMpJNCjJwvOZP938aDdzWZC+VigXV649/shF2bNCaWGeQ+kUW5RhmnIQEFBqbubCtrqia4eYtqjHi8dYMlEuCP3Q+8Zu01KIYIsXVDUZ+JdyzXIQHKwVdENTKh2RceQ8XW30edNp+Dh1+Vp93aSv902hsj8HDmeAhn9lhpdppTuQ8StFio42g57trMlKEI+fLDYthtk+LjlJBfHE85SGvigp9AG2g6ecYr8ySJ3t0TzfA+RyvZ0QjAcMvpwQ8gYRnmeSzekR5h7p/miw1kyACu6uSGz1GhBapOyZezU1WKjuZOfM/XIUQ6xqMhE8vOVrBx2+I2POphCQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a3f0308-a45d-4865-23b8-08d9ed619b9e X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2022 13:22:52.9341 (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: C9n3+XmgYPzeUwOEL/bZLFgPHRi+fq5X+jah4T2KsMBidGWapWLQfjV+RewHN6jaKGx+rMsx7iXSDy0ymDrbbdBvkRvULE8A1rDSq/QplaA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3865 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe1e::71c (failed) Received-SPF: pass client-ip=2a01:111:f400:fe1e::71c; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-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, PDS_HP_HELO_NORDNS=0.001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Hanna Reitz Prior to "block/nbd: Delete reconnect delay timer when done" and "block/nbd: Delete open timer when done", both of those timers would remain scheduled even after successfully (re-)connecting to the server, and they would not even be deleted when the BDS is deleted. This test constructs exactly this situation: (1) Configure an @open-timeout, so the open timer is armed, and (2) Configure a @reconnect-delay and trigger a reconnect situation (which succeeds immediately), so the reconnect delay timer is armed. Then we immediately delete the BDS, and sleep for longer than the @open-timeout and @reconnect-delay. Prior to said patches, this caused one (or both) of the timer CBs to access already-freed data. Accessing freed data may or may not crash, so this test can produce false successes, but I do not know how to show the problem in a better or more reliable way. If you run this test on "block/nbd: Assert there are no timers when closed" and without the fix patches mentioned above, you should reliably see an assertion failure. (But all other tests that use the reconnect delay timer (264 and 277) will fail in that configuration, too; as will nbd-reconnect-on-open, which uses the open timer.) Remove this test from the quick group because of the two second sleep this patch introduces. (I decided to put this test case into 281, because the main bug this series addresses is in the interaction of the NBD block driver and I/O threads, which is precisely the scope of 281. The test case for that other bug will also be put into the test class added here. Also, excuse the test class's name, I couldn't come up with anything better. The "yield" part will make sense two patches from now.) Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Hanna Reitz Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/281 | 79 +++++++++++++++++++++++++++++++++++++- tests/qemu-iotests/281.out | 4 +- 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/281 b/tests/qemu-iotests/281 index 318e333939..4fb3cd30dd 100755 --- a/tests/qemu-iotests/281 +++ b/tests/qemu-iotests/281 @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# group: rw quick +# group: rw # # Test cases for blockdev + IOThread interactions # @@ -20,8 +20,9 @@ # import os +import time import iotests -from iotests import qemu_img +from iotests import qemu_img, QemuStorageDaemon image_len = 64 * 1024 * 1024 @@ -243,6 +244,80 @@ class TestBlockdevBackupAbort(iotests.QMPTestCase): # Hangs on failure, we expect this error. self.assert_qmp(result, 'error/class', 'GenericError') +# Test for RHBZ#2033626 +class TestYieldingAndTimers(iotests.QMPTestCase): + sock = os.path.join(iotests.sock_dir, 'nbd.sock') + qsd = None + + def setUp(self): + self.create_nbd_export() + + # Simple VM with an NBD block device connected to the NBD export + # provided by the QSD + self.vm = iotests.VM() + self.vm.add_blockdev('nbd,node-name=nbd,server.type=unix,' + + f'server.path={self.sock},export=exp,' + + 'reconnect-delay=1,open-timeout=1') + + self.vm.launch() + + def tearDown(self): + self.stop_nbd_export() + self.vm.shutdown() + + def test_timers_with_blockdev_del(self): + # The NBD BDS will have had an active open timer, because setUp() gave + # a positive value for @open-timeout. It should be gone once the BDS + # has been opened. + # (But there used to be a bug where it remained active, which will + # become important below.) + + # Stop and restart the NBD server, and do some I/O on the client to + # trigger a reconnect and start the reconnect delay timer + self.stop_nbd_export() + self.create_nbd_export() + + result = self.vm.qmp('human-monitor-command', + command_line='qemu-io nbd "write 0 512"') + self.assert_qmp(result, 'return', '') + + # Reconnect is done, so the reconnect delay timer should be gone. + # (This is similar to how the open timer should be gone after open, + # and similarly there used to be a bug where it was not gone.) + + # Delete the BDS to see whether both timers are gone. If they are not, + # they will remain active, fire later, and then access freed data. + # (Or, with "block/nbd: Assert there are no timers when closed" + # applied, the assertions added in that patch will fail.) + result = self.vm.qmp('blockdev-del', node_name='nbd') + self.assert_qmp(result, 'return', {}) + + # Give the timers some time to fire (both have a timeout of 1 s). + # (Sleeping in an iotest may ring some alarm bells, but note that if + # the timing is off here, the test will just always pass. If we kill + # the VM too early, then we just kill the timers before they can fire, + # thus not see the error, and so the test will pass.) + time.sleep(2) + + def create_nbd_export(self): + assert self.qsd is None + + # Simple NBD export of a null-co BDS + self.qsd = QemuStorageDaemon( + '--blockdev', + 'null-co,node-name=null,read-zeroes=true', + + '--nbd-server', + f'addr.type=unix,addr.path={self.sock}', + + '--export', + 'nbd,id=exp,node-name=null,name=exp,writable=true' + ) + + def stop_nbd_export(self): + self.qsd.stop() + self.qsd = None + if __name__ == '__main__': iotests.main(supported_fmts=['qcow2'], supported_protocols=['file'], diff --git a/tests/qemu-iotests/281.out b/tests/qemu-iotests/281.out index 89968f35d7..914e3737bd 100644 --- a/tests/qemu-iotests/281.out +++ b/tests/qemu-iotests/281.out @@ -1,5 +1,5 @@ -.... +..... ---------------------------------------------------------------------- -Ran 4 tests +Ran 5 tests OK From patchwork Fri Feb 11 13:22:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12743456 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 CF01CC433F5 for ; Fri, 11 Feb 2022 13:49:59 +0000 (UTC) Received: from localhost ([::1]:51420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIWJC-0007Al-Po for qemu-devel@archiver.kernel.org; Fri, 11 Feb 2022 08:49:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIVt6-0000Zy-ML; Fri, 11 Feb 2022 08:23:00 -0500 Received: from [2a01:111:f400:fe0d::72c] (port=1174 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 1nIVt4-0008II-F3; Fri, 11 Feb 2022 08:23:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mIj75+SsT7ApQr1Ag0ripICNzjvcJPs8lCYFctS2D3jaY0sARGHtrI9rqrhnundPTkN4RNuDZNWBwoTK9TGFFHpHzg2xTCh95IMynkYRn93fmq8fTRn5avbuMmXt0oXF/GPB/eyPPxQ1R9NjTLt9HnuuE7wZJd8pUfeZSnzpreNtfvlnKHK39009EZvnpicY4x+kHyKssHJg5n1ZCeoA2MtD8kMS+ZsAzXcZZjwIXPUMeGpI2AAhK9VRawQEjBN6N40HrT8O77OetlWvjjQWYMfOZUkHPS/rWayO/ihqAfILsBOk0NDWp4A+yHaGGgVdlvRmd3D1SeQ6LVNMrmL71A== 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=1NYdSA2BqiFRPV1gA+QTmOONRrO9CQ1qa7k9tbx3yPs=; b=Vg0M6u/un6B7b02ZVhszZ3w9Ve4njJvpt6672i30F9ziDjp3nEv8971mOindry4dW9PxsWKylS0Re9zHTKGEHMnG5bqV5gsHAjKAqJ6geFAwvyzkI4B6sVrCONiF1tSVKVX3TVXUEegWmEXWNgbjdgXOAOyApK5rogTKp6d3ByDs1HNbK4vCrRHWTTxuddTNEhwrzv3297vpE8FNfp8TuQ+HT/IQeabgMV+nnuc1gFZ0+avmw6AY1dErysGwTN6Z5gbHOtuPVFtn4SzN01kf8ydqOvjmGxZbrWO1F1eFEP8NjWEHVIhxT5h/ffG6TS3emQeRhYMkeAQb5GbZD43eow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=1NYdSA2BqiFRPV1gA+QTmOONRrO9CQ1qa7k9tbx3yPs=; b=BWZkk7orjOD3afwy07WhxQaPOJbCA8CcqiVczWUEoYcGFOG8diD9zXdiHRxK7Wa09b3ZTkdnThL+mRoggL2zGcqG5rpImeT/S0IvHAAAEvWNxgL/1VXLD5XiN/PY6pnsysQrGiX6RUXL9yr8iNqv7fN4k06BdFzYX6BzQVBTIhQ= 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 VI1PR08MB3357.eurprd08.prod.outlook.com (2603:10a6:803:45::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Fri, 11 Feb 2022 13:22:53 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4975.011; Fri, 11 Feb 2022 13:22:53 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, Hanna Reitz Subject: [PULL v2 6/7] block/nbd: Move s->ioc on AioContext change Date: Fri, 11 Feb 2022 14:22:39 +0100 Message-Id: <20220211132240.781958-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220211132240.781958-1-vsementsov@virtuozzo.com> References: <20220211132240.781958-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0601CA0048.eurprd06.prod.outlook.com (2603:10a6:203:68::34) 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: 1bd69a61-3a94-4f75-51f4-08d9ed619bdc X-MS-TrafficTypeDiagnostic: VI1PR08MB3357:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S0PQptqiu1sM6Do9ldynJs2np//71dqE6Y+CiXN6sbF6MwkQR1CuF54PEwDGEqszNNunrZO8VBdB8dznumNWYNrUIfUjx7zjL/n4hlP14IZ0RcXM4R3grFUpLUvIwV8s3CtHO0ypekF0yDKHyT+gh7U4+nsaoJuyjWRktei3Ud+SX91TT5VxCk/ThSm3Br7YDvyMTmOnkIxZiIoDSElLHoKQz7wrBp67j4QEbBMyWBxKG3F2Q7mhdyi/8N/mYOVYGhAxk9964abEOTPExtAnoPTEcDVQdbbcAIoRSdpVZzvxAQvQ6oSJ54xUoztQY7k7vgm08NSqRypRFcN2MNhiS3Egb9pCdOP6Z7mJ15Nz42xoM/qaRJdYiImcFIKtOGvB4xiDRxHST5RH/wVQ41RhUeNKUICUU+8t+PKevIPECUPEeePwHXo73Bm4EB9E0zKkzsd0S34IfpgPlLerbKBM7iaJUJxBLFRWo9WAGqNnbSNll8dDP1UlQs9gW7gPdnWERslvS16buqWrahjJasekC82I4et/RwHwvWQXIqtu//fudGXEx5xxzgjmQnuEheZybR5/KX/KRMrjiwl9F31GAKPCPba7kW1Ii/I/B4qGR9vtU58/UUHium5Jd9sMYBExTv46gSrhnxTcaKJ1qXlIR6S8hb0oikmgvzbEjz1IgjJNUe4Haw+zNf/foPoN28CO/8oeyLuFVXmxqUR0pIhWfs1JzKHfw8Mi9aMMmJltmrhTYTVBucjMIRyaXRz7HM30+XODcTv+Tj7mqjF3g5Whq5tfxxy6rrSGwnP3Jcs8Dmg= 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:(13230001)(4636009)(366004)(6666004)(6512007)(66946007)(66556008)(66476007)(6506007)(4326008)(8936002)(8676002)(52116002)(5660300002)(2906002)(83380400001)(316002)(36756003)(6486002)(966005)(26005)(2616005)(186003)(86362001)(38350700002)(38100700002)(508600001)(1076003)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-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gmXm3KOIrccxMbqFdAhN+ITcK8FI1YUJ1TLeOVCQUmdluRMW2l86KtdkrMadKsONeL4D3ZtzRNi+6+Xj+WFCZQoFDpb0ONOe78UYOCwGhiAhobp1ASL1UdK1lJq8ht4x/pTEkdaYOJtHBKHKsPNUCpPqqrrkUKMoJZ6OHs+TbHbv5wHZkhV6aEgvhA5CRd9Mac2qTZYlF/i6t4aQ3Uo72o6633xGXswIgj7h6gR5twwt+oyASogr3mUTtn3KHvbl9SemB9US51vUzpKd4bUnsxCY6MsfTNAxKHshNsAYHCI6X1BOj18+5I2uKEXcNF4Mnz4457A6+XaYkcISVyOkCrUR+Hqr/nf1+emIzlwoqbj4+jyCNoANLlQmV/CAkK4l+bfXaIl+LTDVo1Hss/3oAbunc2ibKGSaKAf/JXEjwXdJEdXh3gV6jF7ScNG/T2FwKt/ClGssB4cbeDHI6Nr9FlwbvM8yWK+RgDbNfbTXFBqE4ssUv6FKEZX1DpaSOMC+a90LzoLjtMT0woHIxT1ZtGGeICm7dM1rJQn7WPWfXaSD6Epsfh5/b3PmFCNWo/Kie3aeGGXmYv+DGqRIXHvaCcwMWe4//AzO+z5Qu6Djt4xgSstpgg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bd69a61-3a94-4f75-51f4-08d9ed619bdc X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2022 13:22:53.4184 (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: vdkQ4opgLycmWTI52bTsJNRouJpOUkIAD1/qIoSFE6cE0pZfrzAydHroD3F7Olc2Kmaxt4jFycZLbkG2B0HNj0ufLbD8219NksmmhOy7mXk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3357 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0d::72c (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0d::72c; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Hanna Reitz s->ioc must always be attached to the NBD node's AioContext. If that context changes, s->ioc must be attached to the new context. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2033626 Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Hanna Reitz Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/nbd.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/block/nbd.c b/block/nbd.c index dc6c3f3bbc..5853d85d60 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -2055,6 +2055,42 @@ static void nbd_cancel_in_flight(BlockDriverState *bs) nbd_co_establish_connection_cancel(s->conn); } +static void nbd_attach_aio_context(BlockDriverState *bs, + AioContext *new_context) +{ + BDRVNBDState *s = bs->opaque; + + /* The open_timer is used only during nbd_open() */ + assert(!s->open_timer); + + /* + * The reconnect_delay_timer is scheduled in I/O paths when the + * connection is lost, to cancel the reconnection attempt after a + * given time. Once this attempt is done (successfully or not), + * nbd_reconnect_attempt() ensures the timer is deleted before the + * respective I/O request is resumed. + * Since the AioContext can only be changed when a node is drained, + * the reconnect_delay_timer cannot be active here. + */ + assert(!s->reconnect_delay_timer); + + if (s->ioc) { + qio_channel_attach_aio_context(s->ioc, new_context); + } +} + +static void nbd_detach_aio_context(BlockDriverState *bs) +{ + BDRVNBDState *s = bs->opaque; + + assert(!s->open_timer); + assert(!s->reconnect_delay_timer); + + if (s->ioc) { + qio_channel_detach_aio_context(s->ioc); + } +} + static BlockDriver bdrv_nbd = { .format_name = "nbd", .protocol_name = "nbd", @@ -2078,6 +2114,9 @@ static BlockDriver bdrv_nbd = { .bdrv_dirname = nbd_dirname, .strong_runtime_opts = nbd_strong_runtime_opts, .bdrv_cancel_in_flight = nbd_cancel_in_flight, + + .bdrv_attach_aio_context = nbd_attach_aio_context, + .bdrv_detach_aio_context = nbd_detach_aio_context, }; static BlockDriver bdrv_nbd_tcp = { @@ -2103,6 +2142,9 @@ static BlockDriver bdrv_nbd_tcp = { .bdrv_dirname = nbd_dirname, .strong_runtime_opts = nbd_strong_runtime_opts, .bdrv_cancel_in_flight = nbd_cancel_in_flight, + + .bdrv_attach_aio_context = nbd_attach_aio_context, + .bdrv_detach_aio_context = nbd_detach_aio_context, }; static BlockDriver bdrv_nbd_unix = { @@ -2128,6 +2170,9 @@ static BlockDriver bdrv_nbd_unix = { .bdrv_dirname = nbd_dirname, .strong_runtime_opts = nbd_strong_runtime_opts, .bdrv_cancel_in_flight = nbd_cancel_in_flight, + + .bdrv_attach_aio_context = nbd_attach_aio_context, + .bdrv_detach_aio_context = nbd_detach_aio_context, }; static void bdrv_nbd_init(void) From patchwork Fri Feb 11 13:22:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12743461 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 A8477C433EF for ; Fri, 11 Feb 2022 14:02:45 +0000 (UTC) Received: from localhost ([::1]:38314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIWVY-00012N-Lp for qemu-devel@archiver.kernel.org; Fri, 11 Feb 2022 09:02:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIVtA-0000bM-Co; Fri, 11 Feb 2022 08:23:06 -0500 Received: from [2a01:111:f400:fe0d::72c] (port=1174 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 1nIVt7-0008II-JF; Fri, 11 Feb 2022 08:23:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bav1VtWRlFC+WKICAK9fa4COaWkLMN81msrTsE8Df9cTQAOU9fnjzoPztbZigiP89Ij17HMPu7zaNPx9fHabdTLscX/PLqqiggcy5mNd3DHd8AYOROMlEwq3DZQCWfyPcRUtN0YpEJamo8Ex8OimBL9p8vl0xGpHvjVyFBSYpyBUFRRAyBew9vJZYJSCOdqt4b1Uj7P5lIj/1WGGuqDaSKrP8jJCXjNTfWCohDeP+kVpAmKyC9yt5Yn6lKA/LBeoHMisyI+wqQHpW36RY1BpPevSp/XThVrQRDpVVxK56Pj/V+b04THtyO/5+EVtjGKgWtZoLzlG02gr66jdl6+w4Q== 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=8gLXUxXMjQLSnpkOFKVP9jMUUzno1SOvkvChwjqT/e8=; b=DryctyVG+3cr3NqVlISC1JlRphhYAlu6uZbBXwnG3AmJKmacoY9ZPCX21ruMKSGnyLS7qQvpYoj29Dr0KbHbj2uWIxEiTiyRYuGlK5XBlS76KjFP6x+qOt8Or1RZ1CeRhrK88HZ+4hSmCnBVvnp6WNxBrwdP7+i4PX9njPFT96ZHLkS1kIjqbnxIHfd7V92GlrQquW5g2tYGo3cnWypfP/ezAhYEo1Av78KCoIjOlZ4E6soJGLwSlfKjmeN6Itr/rW6VqlgrguUKmdmgUxFWBqfqaNDz8yM1DQf7SqTBITRVxJbNy5xJ5gHRVWtkTanDkNyGQ50rMuSdvcHCeq0KWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=8gLXUxXMjQLSnpkOFKVP9jMUUzno1SOvkvChwjqT/e8=; b=I7n8rlEc60n6y1bvzsioG/Vc+lZweHeagZepBZexcE8fKSpJGyy1AtHcNjbfSdgIUKjCT3JNmsveTEm9TkiB/21Vy0Sy0iw3fmKz58o2P3kSsNJKdLMgoQdDvCheq8kPZCTTEmKS9sCm+Kze1/JWaiFSm7FF7RXvXL9TDoGLQ7Q= 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 VI1PR08MB3357.eurprd08.prod.outlook.com (2603:10a6:803:45::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Fri, 11 Feb 2022 13:22:54 +0000 Received: from AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714]) by AM9PR08MB6737.eurprd08.prod.outlook.com ([fe80::49c:67e9:3e24:8714%4]) with mapi id 15.20.4975.011; Fri, 11 Feb 2022 13:22:54 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, richard.henderson@linaro.org, peter.maydell@linaro.org, vsementsov@virtuozzo.com, eblake@redhat.com, Hanna Reitz Subject: [PULL v2 7/7] iotests/281: Let NBD connection yield in iothread Date: Fri, 11 Feb 2022 14:22:40 +0100 Message-Id: <20220211132240.781958-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220211132240.781958-1-vsementsov@virtuozzo.com> References: <20220211132240.781958-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AM5PR0601CA0048.eurprd06.prod.outlook.com (2603:10a6:203:68::34) 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: ea70fffb-c8b0-49a5-99c5-08d9ed619c28 X-MS-TrafficTypeDiagnostic: VI1PR08MB3357:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: awgxjugs6t8L45NM4H7mNVrusQ1lkpyMWpnBO2+OolQ3BAvhqf27OnAGoettHZCMtNPC7+5MEJdXkTsN+y3Z/TcLyyTRS95yqY4OZbcjNVbjpWjkymI3NON+xX0lNKbQcld7bNeEHZVob8FRH7QcibHYSABNWyP/8My8+0oxTXfAOqK4Nk0FZlshjLdjxXOQ537ZF8y3Hb1aVXZyI09rgRn3hvYzWuNUfg21MydKV1F10jTfB+ZUQ48PwQqYmt5VoiFZM6qGTNFXc0HftC/J8T+IKc+egdfxb5PPPFCOjJ8j7FBxS3SLPEzqIPi+y/wAE0ykAxngS3JKhYGcmuqCX9gO0ToAmrQesIKRpI6rfVX5Sa/VP4REDDkF8mUCf7mwKAG9eYTAhC9vTsSeEnp8mLyXmPaFrDwzCI/+cosg40aJnP83c4bC4XOqRbD0J9maSrxJh9rLQ/QQDEw830BdwyNIRFiG4ZEPk9fvHpcdECPdZ4pkr1gQyXG4zasR4RfJVyqcRTUKTrTdCXxjxgmWtkdPP73Jq9cvsa/EVHuI36nDq4jXQ6wHJrArzM+ZTFSK9R1WHLHx2GJHER47uV+o6v0GF18kcuZvwpdSA/p2gcl7No2qXy/aTsvy/zYoxCz+TFh07fjbpjc/m92pZlybQILhEYZkZJIs7SA0Yz4/Yt67qoLFcGC2j5r1wREbdmtv9u45z0DHCZTzCI8PCm8ERg== 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:(13230001)(4636009)(366004)(6666004)(6512007)(66946007)(66556008)(66476007)(6506007)(4326008)(8936002)(8676002)(52116002)(5660300002)(2906002)(83380400001)(316002)(36756003)(6486002)(26005)(2616005)(186003)(86362001)(38350700002)(38100700002)(508600001)(1076003)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SNw4V9yYG4LBdxZGrN5eYv13YwV7OlpiRuPQ/VBa5kCxKFZfI9Huw+XWy4yUKcuCsOQwe/5aEiwJDZfyrXNyemyxdShABvayE0gzGaoa4eeZ7vBdwhiRH2ccUzshIcjowuEDxeZKUXQmmyhzH9jzd+7En+6BvPy0SITPnn7ZB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8j7wTtSNrVpjb0LCXmDf8g0oG1bsrqkIaLAxvwERKoEsY020U2idbdV9A8eIfF2S8Xv3DgpQCHScghTB+f8JRz/Kf0t52kMrZCcUgNJA6ZmmNCiPzWhV6BWlBPdvBry0vL0rhQcripM02GHmu7SgrnqDr/XBTFE4h4wWAmyarfIemeXoLjpyP2lbX2PcQjflfbJMht83MmNpIT807sCn141ZJUs9ZS0DvC9BQYS2stXs/ePP4fVpSefD51Iy47qtKUE3fzfPOpAteOxLEf/JuwD/85DlSHWFxqfqRv//k6p/R8MRmI1+NelJoBHHs97CxnkquZvPqAxrGzi7UDSfLqWKilX+vuiriBEX9FixgiBs/ruJmO/+XNNx0cvVpcR1DyOoSxLZzXZNN0ZiKe24SADI81KuS94D0oxzjGCNu6lyikrQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea70fffb-c8b0-49a5-99c5-08d9ed619c28 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2022 13:22:53.9496 (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: oqv7wsHuF99sPM/YJ8NsqLYqUGeWmPHrVeg4YljyPX6e3lF2EsL20znCwKjvFRrxc8c597Ns4iWJuoyolejrVBnJfvEvfyv/lSFmV5eXkJI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3357 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe0d::72c (failed) Received-SPF: pass client-ip=2a01:111:f400:fe0d::72c; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" From: Hanna Reitz Put an NBD block device into an I/O thread, and then read data from it, hoping that the NBD connection will yield during that read. When it does, the coroutine must be reentered in the block device's I/O thread, which will only happen if the NBD block driver attaches the connection's QIOChannel to the new AioContext. It did not do that after 4ddb5d2fde ("block/nbd: drop connection_co") and prior to "block/nbd: Move s->ioc on AioContext change", which would cause an assertion failure. To improve our chances of yielding, the NBD server is throttled to reading 64 kB/s, and the NBD client reads 128 kB, so it should yield at some point. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Hanna Reitz Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/281 | 28 +++++++++++++++++++++++++--- tests/qemu-iotests/281.out | 4 ++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/281 b/tests/qemu-iotests/281 index 4fb3cd30dd..5e1339bd75 100755 --- a/tests/qemu-iotests/281 +++ b/tests/qemu-iotests/281 @@ -253,8 +253,9 @@ class TestYieldingAndTimers(iotests.QMPTestCase): self.create_nbd_export() # Simple VM with an NBD block device connected to the NBD export - # provided by the QSD + # provided by the QSD, and an (initially unused) iothread self.vm = iotests.VM() + self.vm.add_object('iothread,id=iothr') self.vm.add_blockdev('nbd,node-name=nbd,server.type=unix,' + f'server.path={self.sock},export=exp,' + 'reconnect-delay=1,open-timeout=1') @@ -299,19 +300,40 @@ class TestYieldingAndTimers(iotests.QMPTestCase): # thus not see the error, and so the test will pass.) time.sleep(2) + def test_yield_in_iothread(self): + # Move the NBD node to the I/O thread; the NBD block driver should + # attach the connection's QIOChannel to that thread's AioContext, too + result = self.vm.qmp('x-blockdev-set-iothread', + node_name='nbd', iothread='iothr') + self.assert_qmp(result, 'return', {}) + + # Do some I/O that will be throttled by the QSD, so that the network + # connection hopefully will yield here. When it is resumed, it must + # then be resumed in the I/O thread's AioContext. + result = self.vm.qmp('human-monitor-command', + command_line='qemu-io nbd "read 0 128K"') + self.assert_qmp(result, 'return', '') + def create_nbd_export(self): assert self.qsd is None - # Simple NBD export of a null-co BDS + # Export a throttled null-co BDS: Reads are throttled (max 64 kB/s), + # writes are not. self.qsd = QemuStorageDaemon( + '--object', + 'throttle-group,id=thrgr,x-bps-read=65536,x-bps-read-max=65536', + '--blockdev', 'null-co,node-name=null,read-zeroes=true', + '--blockdev', + 'throttle,node-name=thr,file=null,throttle-group=thrgr', + '--nbd-server', f'addr.type=unix,addr.path={self.sock}', '--export', - 'nbd,id=exp,node-name=null,name=exp,writable=true' + 'nbd,id=exp,node-name=thr,name=exp,writable=true' ) def stop_nbd_export(self): diff --git a/tests/qemu-iotests/281.out b/tests/qemu-iotests/281.out index 914e3737bd..3f8a935a08 100644 --- a/tests/qemu-iotests/281.out +++ b/tests/qemu-iotests/281.out @@ -1,5 +1,5 @@ -..... +...... ---------------------------------------------------------------------- -Ran 5 tests +Ran 6 tests OK