From patchwork Wed Feb 9 14:02:52 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: 12740327 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 B753DC433EF for ; Wed, 9 Feb 2022 14:29:52 +0000 (UTC) Received: from localhost ([::1]:36850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHnyh-0004q4-LC for qemu-devel@archiver.kernel.org; Wed, 09 Feb 2022 09:29:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHnZE-0001Gx-PQ; Wed, 09 Feb 2022 09:03:33 -0500 Received: from [2a01:111:f400:7d00::715] (port=53856 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 1nHnZB-0000MG-19; Wed, 09 Feb 2022 09:03:31 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxedCkW+ORLKyKXFi0AlJl9JHJgWMUFTAXbL1/kTJhjQYGOMJz+8HJ96sXROiYTXG8sCPRtdl3NahOAC+7b/+HWFxFu1VjAyXn8MgC2LcLQFUOuiaKodxSMvf1ZaosX8r1piveA60zgEQVLHO4/tqDn9+QcpAVh4pXo4usEOLk+wP3fJT1ppoX8Jm1aDAmCLr5XXUVM/4VA/Nv8gLSaDXHcTcu1OWFkAu8YA1ZAuBDctncqH6VUxC/u3SY3UmaqY+xtb/mhj59eryIOQj802DLzaAEhRnhJJm3efcKaU+bA+hIWmqXjT85KeElOa8SLDeHT3Qar/BknL5ISxuPuB2w== 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=P12LQb9jGsMmg00WQJi76iuYrjvnuO7LGuStrhvOVU0=; b=Hl0veHdynVMeGt1jK7PdZOLvyR8P4S03pjx5IH/6n06exhbKRKPxFGJWxTv94LWyigJ5yxtWFGOIcunSTrj8DXIWdZz5cVlfXQxMDznon/euqL4rjTVOGxKsexS7+/HLimTlpFCWS1tLflfxTCmaysn+uIBEk6jZW/GyC6+5s65E/lbsBOClI5eyEugXiWd8NN5rUYdbZp9X3g8rrmVPD+oxhUW5AU3SZzD0X5k53GJqFEBiy0lsHuvUxeKhaU8whibaW5dToPzYUti7nR+IkcjT2jUECAn2iNPdF//sEoy6a+3y2i8e8BK0jHetdP3olSMHBMacu+/nhBaG/ailxg== 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=P12LQb9jGsMmg00WQJi76iuYrjvnuO7LGuStrhvOVU0=; b=LCTg0iEGaweIubGxTVZk9gavPIdpUX0jjd7QfSTiGPKfJXQ3uykRPXJV4IhOMB4VOTt854K6+adzgesCzULxZxKLaUn23lrQDVqcCsEryDmgTzG0zlOd9XTWEtMqhVRJA37PXbfA/jgCaNW33SwM8ZX0qU1HVE+TuJatGY1ntRw= 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 AM8PR08MB5698.eurprd08.prod.outlook.com (2603:10a6:20b:1c6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 14:03:11 +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; Wed, 9 Feb 2022 14:03:11 +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 1/7] block/nbd: Delete reconnect delay timer when done Date: Wed, 9 Feb 2022 15:02:52 +0100 Message-Id: <20220209140258.364649-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220209140258.364649-1-vsementsov@virtuozzo.com> References: <20220209140258.364649-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS9PR06CA0192.eurprd06.prod.outlook.com (2603:10a6:20b:45d::8) 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: 4aa1f47c-f3f0-4ca7-45a6-08d9ebd4e84a X-MS-TrafficTypeDiagnostic: AM8PR08MB5698: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: xEylZpPQw9N1b1Ms/gcqbD6XxOnhS1FJFNmPNJBjZBT79Zy+2IU1tdyD+d1Pi9LHCWMj48rApAXWQ5nkBq754uQW8cLGaKRdnJl+gUUcohP5PYLRZUllSmyJBVcXOBcw+N5we9iPDTMTvvxsGPtT80Y5wCufDheU/Z82BMF+6aq5l07mZLjRXfu+zIuGuBSNFXi4SXsQYm6CfvvAXT3vV0OGzU8hkU2XhNC1w82yDada1dI0B3EFrhzqQDSeLaJwFDL62xyRG+wtCmqU6c1R8+P6X4D4A9QauQOeWTUz881WTzWyh42Y3i7E9rsvAgL7sk9rNBh8V9CiH3r7rI+QJfa2p4rqsy8AgZTIFtaHZHAv2yItqV+sDeGw1nI072Z+9nQE/qE7FxkdEQ4gmP3xtMdRKqLx7+ynXUZju8j0LQmAnBhvHl5CL4lCQA22TWa0Of0f1PHCUvuSu/z7KiabKC/5IkLSRYVnkncnetUyb2dwRKmcLiC0e4klRiNFwGUQzcT7bQ1Kd1k3FkKjN3eHgwp0VW3zQNKM9UfuVBNDL1yFTVaxOOkHSt7tA8NH2Gmr0w2gJpFGdQS1WmYeWTSYH9sEkb/qR+hBavhlr+cZzQYOJdz/KQUciSNApCLVDSmHIp6Q3ZXveDW4DNaKy1aFle80Asweb/0v5RqC3S4ZqKMel6s5c1k/uEKaKT+U66/h/Oi0hHNCHIU3wLkCnhfB1Q== 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)(2616005)(36756003)(316002)(6512007)(83380400001)(2906002)(5660300002)(6666004)(8936002)(1076003)(38350700002)(66476007)(66556008)(6506007)(8676002)(86362001)(66946007)(38100700002)(4326008)(508600001)(6486002)(26005)(186003)(6916009)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: i5yS0WNWc1HLlgLK89aSwR81p4WTR2X4xbQlDpHj3ap0olmWdQVFM3MjSJIA4uJeZm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+QzwqyJFl9zJCNRyTVzBXr8y7lZfnif+7Sy6K8g+50LxqwWb3tZjx8KxbPsmk0xqxWAC8l+DeVgc6KzEQfZmf+5EuUV0ojiaFPoUBklPGj+gjS8eNRj80BZX4ROBwJM8mmXfwRCiVmPVrYeTIDOfGRnBM2uzZhWHO7HLaEiJZdbJb+sVMYT8qiQm0n24xNNpRLkavWugF/1DQulNBRuuxdJPN0IQP7a3rmLrKkCccekTYc0+At36tS5J6ZM4TdPjLE7j6t0OVMPU74Bo/CzlVDF8KUvXPfQpOxpYuvcEQr3/gEnrnwtdgjD/YPumr/I5bSN9CNG2z1d8T8wB1syV45hEMBf/y7vy+1gKkZJAH900j0D9OtSKsxdPP5ZUSsheJvNhR55qmXkCPdb35MeeNsntDy5+gt6VC+oI+hvTwMuzRIqtpLSVS8dPdhBbTOo1fpQYvQAHMdSq71Rr7NG1OY6fc/d6qG3Zt3nbYdBsqj1uS5QjEdsUTmWLEVfQv01ryYrOaUdJOm5aM7Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4aa1f47c-f3f0-4ca7-45a6-08d9ebd4e84a X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 14:03:11.3505 (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: 2sDSljL0ktZ5o1QsMMOaBgqm5/QhF4IsL5v8vC+fALfVFEiosIt4gtirsZ/HnKYW0N52WatjLVsru4lJHN/OQxieNkFCwWwfiaVTVXHlf6Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5698 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::715 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::715; 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, 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 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 --- 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 Wed Feb 9 14:02:53 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: 12740329 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 77454C433F5 for ; Wed, 9 Feb 2022 14:31:45 +0000 (UTC) Received: from localhost ([::1]:41278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHo0W-0007rH-KV for qemu-devel@archiver.kernel.org; Wed, 09 Feb 2022 09:31:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHnZH-0001J5-RQ; Wed, 09 Feb 2022 09:03:37 -0500 Received: from [2a01:111:f400:7d00::715] (port=53856 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 1nHnZF-0000MG-Ef; Wed, 09 Feb 2022 09:03:35 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dqUAWXhjcRe44Ji9D7kJSDlYSrxeXq4GGtWEuio/1H3NyFwBkKtKgDN0Je4uAw5Qtd/euB1Ol2VZhAuGr/s0u/nIkpdzC2jDWlslWpKdQ1LXnVj23sciqyzF4wZLdzl/kQBnbYA65R7EBU1tp5qgLILZg9J77emGbIu2s9cNkVhyIh2hW/qhLXcoDcXc3wg1YFBY8k2sTDUpcFoKB2G53+h+ggV0ICLlY6hAsicwGv0EehOIM7Rn5oWSSygJmLBi8CW6AanN/UrBswv3IhkhaBQzILYo7Jr1FoUtJbpZqW8qyr39Eo1/uUZIMfLY2oYi8R9fpLf6S0/Qaaz4DE/9Qg== 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=w+yzq0CQ0cXDxU3zpY3JBGHeGHSXeRDv9oKe4GeUxmk=; b=aaP4TDSBE6B7/QXEBxmwXi1OoXZjld5ekZG4FmV0NgGdZ542AOHJ/O0YfRkCbjGS/PkZAkpJRMn0ijQGGB8YX+TaKOXlISEyFPQ+dJQYkITidBmT1GSPmsjXBcsXfc2zDSJZ1GwiibUugxyVz1+GRGaVMs8Nsa4kpzmSi/8VxdnzYYZV9Sp5DF8N14hBDXEjNQV4l7Esm31MkEcnsQcvDrICqh4VflzskqNSKv4ZJ5ACYIhzLFXgRFMU70PKXQG4WIHBea3IhOW3kX3HKmnUyRpmsAsdPfLdCqW7M+p/4Lil9lJ52rI6dbebvMmNhCqNbr56DonnBklmGFS1XxW0Xw== 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=w+yzq0CQ0cXDxU3zpY3JBGHeGHSXeRDv9oKe4GeUxmk=; b=vvQNAtoZi7F6ZFfTOKSDxNnnHwnG5P3MQ9JsNshfGt7jop4owU1jPcHFJeZyND0St3UCSyxpWki3WACR/7t+wPxCBEMOxdV6yheKpjmrhiqLmGxeK7cK+SIzjSMXDuC6dxIgWQv5MTdM4F5bKEGcHsrPaE5U5mUM1Ke/SN2Mc7I= 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 AM8PR08MB5698.eurprd08.prod.outlook.com (2603:10a6:20b:1c6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 14:03:12 +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; Wed, 9 Feb 2022 14:03:12 +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 2/7] block/nbd: Delete open timer when done Date: Wed, 9 Feb 2022 15:02:53 +0100 Message-Id: <20220209140258.364649-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220209140258.364649-1-vsementsov@virtuozzo.com> References: <20220209140258.364649-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS9PR06CA0192.eurprd06.prod.outlook.com (2603:10a6:20b:45d::8) 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: 7d1f14bf-cbed-4beb-7b68-08d9ebd4e883 X-MS-TrafficTypeDiagnostic: AM8PR08MB5698: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: PFrHj230eH+2TnxmNm+PbMnoYygpqR0GNqdkvMPavb5ShZW37U4z9bvY8LZnoA3L7pRwDAr4SA2M/Z3BGqob+o2iyVQd6hq5i255MB6PxaVE7FCqdg+qY3SAhSq3Hcb4fQy1ptt5CnC34z+4dH4EBMCumXfGaHnCFAA3CCqinb8tPMWuJGbigerVl060QD03gh131dslHLzWaHjn/QS71BSA20yD4Km8xqiIATCkVy+Gh0IPY0WQBfw8luRNHKyqd8mwOC9HWX2G/kBtnC7135fNXtgOkXqLi7Z+U2Zm8uhEtWIoHOWqlk6u1ay575tobnE8J/uuoBnFLJTGydYzFPV+09Gur/z6//G5IfpfxyXvnMZNPrZ5thlo0zBXZI5dK2e2i77CPhBq4Tek6Sr795FfYbVd+8LJTVQfSU5Y7dR05DE7SNmuoRgw9ZiKFpDXECsqHsWYhnx1BYJPifNECl4Zzdh54SSoaHkQLzybCXUNrGo0R3O/GJrvE3fsODdvYXq67BwcyYb8JkzewrI0QpSJXY6h52D4dJ/o5nv8rrNY2AQyKQLBj/T5KdQfnF58imqIuk2h0DJeKQKbWFB2eIC7I53H9W/InoAYnKg9+gqaOQYEGCbWtup6EucQnMHw6uBaIQSziqi2bDHuwetmVLAUQtdSVb+GddY42wEbQg1+MA4U9B2JxK52Dntgv3O/2dE3/KtpiClHlEzxj0Wkbg== 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)(2616005)(36756003)(316002)(6512007)(83380400001)(2906002)(5660300002)(6666004)(8936002)(1076003)(38350700002)(66476007)(66556008)(6506007)(8676002)(86362001)(66946007)(38100700002)(4326008)(508600001)(6486002)(26005)(186003)(6916009)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0L3s2y2lOOjhgN2D8uy1T9e0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PogWYvwPE+xEJZsZQuKo5c1mKnRx56x8JRldH7qEDTtgCm3mkEQRjF7yYf9tmZ1rumCRb2Sov8oeth987JC7mUYv/h79lQUqXwIfHwgFum5zNrBZVs4YwTqASSQz9PVLwOMYkm83OkeBMt5QjBZsXtrXn47kxSdW/4/HMyeI0sVah0Mjm0xMqEiYc0oi5pfYgbIEV238lyhSxMSHli4tbf34FGE1rhcQI7lZBeKqn/QFwIIPJS6MNmujvZno/0x89Cf1XTJaFz+LUjWpDeL12CRzg8Fl6eJd/EnZ2ruKNVd3ymqVSGvc6YKutLxWLPYLUXzVOca7cWsNx7xn+7m0bwDuwma4Pmg3ggi0/a4A1MYir0fpfFvYGcHThXt0RkXprffEAFlxN92D8HBS8bLf4xeMXZ8b5BeKQMxtIle+AqtVTFPvs61LkqcwItfPl08625RMJbGrrquHfJteVKLsu3I8xOrBQ4T9mtMLDN3MkHp5J/1ubtHiISj5i3nFkRh2TxIe+uecHVfP5VZiAAkNG1YvqxkrUNMGwbIqO5OEpabmzgxILZkS2Y75IlFsQcQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d1f14bf-cbed-4beb-7b68-08d9ebd4e883 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 14:03:11.7098 (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: Qbq73cDirp0Q5tKFW3ZBgETP4Z/jZUd2HikrrskaKW94TV78H64yB1UkjYBu5KJ4Se6t/zSrJrUelVN8mLKY0QnappZX8BtC2kZMiIdn2TQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5698 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::715 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::715; 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, 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 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 --- 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 Wed Feb 9 14:02:54 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: 12740360 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 B3F57C433F5 for ; Wed, 9 Feb 2022 15:07:04 +0000 (UTC) Received: from localhost ([::1]:59128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHoYh-0007Mi-SK for qemu-devel@archiver.kernel.org; Wed, 09 Feb 2022 10:07:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHnZP-0001Np-Aa; Wed, 09 Feb 2022 09:03:44 -0500 Received: from [2a01:111:f400:7d00::715] (port=53856 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 1nHnZI-0000MG-Bg; Wed, 09 Feb 2022 09:03:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kldd8Mt9lVjN8047ZbQl0MF8NIju0tjSNdnBG9zg3IU5m6nQJKX3HzGtCBT6/Fvl7pCULC1gZI+05ETyJ9qVpZHmLg1tbVxxLOzJM+7LgRIj8H9PWOnBWbmLiBdVeAaw2o1ktTKjM+3DuC5/Xjm3I5DVlxldwVt2ODVwcXu50XUOjXaOGDFc7Ld0l/oo6V/xeZ3VjBaciN/FrU4ZPvxt8F9Ff6i5VOjuBe5VJyZi40Vp/8LYPOI5WNe7KJviI4UtCpfEz73eDhkPTgdWhvwMcecTiIr3/T6v+7PD1i50/Q4LDsOQvDTjZJcbR1O+6Lov5j0Tpzs3fQoZ7LiVX0gaEw== 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=UKnnQ521wHQXoS171jQSVPN5nLAsdXbzPJyY12zHwxY=; b=hSY5YR8X3Uo+CchNxLnewxk1oT8rolMr6B8v7hD6iHpolkrh7hxArm9gSeU5Kb8TccCWNVrbJCt+Hy79i/t6A5DTUh2XoTM2wegwS3vPiZceJunxxzX7wNxR0jErJ3bTd5EcCXortaS0hxjG9uj7q4g3+nwQgFoMqUaTXKsHrg6DOKEn45yOVv/phDKsU6IRVXcaKWfXMUzYzmOmx582KryT7cgOB8dN+8Wmq5n94FGEkwMZC3FkHW99fVZaw3zPonBcYy2JjOGn2Ye+Zryymvhbjvr2iokixP4IKeriFGJ2jz38mMuHOmmy8UW7T3HUDhavcRzeRqsZG4FXR50cFA== 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=UKnnQ521wHQXoS171jQSVPN5nLAsdXbzPJyY12zHwxY=; b=fS9/O5UL7bjDtkimY+MfyLGyUEvR+p+k/ZaY5t9oufzuzu6FfS/Tpsb3LJCBVmB/xJNsliriHq0jOMyPALYztHcUEuHLftbguTEKlm4t9MWXpaEeFmuqcwIs76p7QGbooCP2nLef9EbbQsK1gdCXtyB8ZcOFWATEX49XwPi3FmE= 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 AM8PR08MB5698.eurprd08.prod.outlook.com (2603:10a6:20b:1c6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 14:03:12 +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; Wed, 9 Feb 2022 14:03:12 +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 3/7] block/nbd: Assert there are no timers when closed Date: Wed, 9 Feb 2022 15:02:54 +0100 Message-Id: <20220209140258.364649-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220209140258.364649-1-vsementsov@virtuozzo.com> References: <20220209140258.364649-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS9PR06CA0192.eurprd06.prod.outlook.com (2603:10a6:20b:45d::8) 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: 5329fd48-75fd-4adf-4ef7-08d9ebd4e8ba X-MS-TrafficTypeDiagnostic: AM8PR08MB5698: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: OfKD+EVguit1+ozCYgAE0Z4QX8i8oV8myuZ9veuKbeVm4vcUnUMuO7/B2LpfrRuJW7LrlWqrRbHUsCbU2YPNybCBQIFXqKDTWT6354T78Ct2wXHjDFg48yqvC+B2Caf9n7DDgykmOkJIjsrMiIE0/fGMy8zf0yyyrGS4z3BTxv0lfFkR1bYBK1SQTJpQF8bkg44IIiQa6UuKeaj7ZxDT2x6h1U1bV+X+9VPUNDhjpJFXnBnB2pxS1wooAq88SbgTRqVou8wJ/7aZlGtFJAmrmFO0KAk6Wv2bc57k1IP16Ocap0h7NNMdQeanDIYmi90Iv+yNDgFtqzGe6+dvBq/Ll5FaXpfZM5NK6XUYZRb4NZRw6QYTnxM63P85Tg86bEXa4+lQ0cIfTJCNuJ+vaYsrlPy6bLwPnQUafkuy3FFD2rf8hUAjJ1lPyJwtWc19+J4EAyoC8ivCn7R8FmrGl/JdbKl8az8m/6KGpdPGUrBcrdhqdHCZgV151/vX40oWyryv/8OPTew3YgR0tfje86yv9PdpMmMgyPOKA4rTB8njDpxbRocbevLXka5UJoa9qCHFF6xLt4dywWw9RzLD15cQnb/8nD6dHc9HpEGJccQE8OyuHaXhVqAoqccT/jOXEJ4v0ictMN62iAqqBcYfESuWsN8GYXnQr4HGdQZxFcPe2jursn7rCu1rmgt8yHMUpsgSLJtjAQvNOkbPbZ297W1yKg== 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)(2616005)(36756003)(316002)(6512007)(83380400001)(2906002)(5660300002)(6666004)(8936002)(1076003)(38350700002)(66476007)(66556008)(6506007)(8676002)(86362001)(66946007)(38100700002)(4326008)(508600001)(6486002)(26005)(186003)(6916009)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ul3Q3oFgJhIjxsa0krLDsIgHL8ivoIxKTOkvKfMtReIqKZj62YkY2Mbi5Rzq8YTU7Jxq2+sMXt6UYbBfApfhxG8tHae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+Q5/qnknR78mH6PVvLou2/mM0lW5ogoxzzeaOtd/WjQmt6JJ96rYZp3S3IKHWTDKqfAb4CjOwmo3WiOOO0kJFggRgkTzKBdRTqknDM5e7Qbe8dytpUV2zNl/e+zAlT/WGvD1XsDxk1M5tFvdjGrJd0w6ib1JCky2RCVrUs9t2vGkKKuUkXEGkGPqA1621J4KalYAzxM1KckyXk+J7oGxwloxiZDOpNBqVGDOzmA3qc/QunMGVKhwfaZNQeUcaK1lbLNyeg4cLIg/DGEAHd+hCEr0Kmt1wuZqcEAMKmZHvD3uOf6FZoGGNBGkMkB42ApBTcxAovc6mCZ0Pr6R0m4SiqAH0UBm3d6Nq4Xztbyr8n2y1TPWSlzGIMBMoIikwJo/KN7bkZ0C52zQNM+oRcmJxE+kpW5r6OrivzZcT0sEQy9ETA3wPrxguXkQep74/lFRdLTU31MpZgdAz4R59fG9c2e1LKiqiF2uneK3U1WVlP+CCWNd8+J7YBqrY8tVbH1EjazoO7YYB7Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5329fd48-75fd-4adf-4ef7-08d9ebd4e8ba X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 14:03:12.0535 (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: VltLQwpp0el0m33SUgQ2PvokHlQpWkDXvn3v4qL/ggOuX/ZGL3/Ox+ANrrl70esNI77rbtmiKVsosVnxFI03x+8AJmLPPx+/X1ryBlwSe+4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5698 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::715 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::715; 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, 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 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 --- 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 Wed Feb 9 14:02:55 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: 12740349 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 700C8C433F5 for ; Wed, 9 Feb 2022 14:53:54 +0000 (UTC) Received: from localhost ([::1]:40548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHoLx-0002aQ-6Q for qemu-devel@archiver.kernel.org; Wed, 09 Feb 2022 09:53:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHnZS-0001PD-4x; Wed, 09 Feb 2022 09:03:46 -0500 Received: from [2a01:111:f400:7d00::715] (port=53856 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 1nHnZP-0000MG-5l; Wed, 09 Feb 2022 09:03:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ahwrsSxxets9KFY77LCi28Po7JCu9s1fmyrJswBGv/DyLmphBBTPgBflHljcJpmp35/cDMYQ77EQkZWZXxWxShfft9MT85X6q5hCVx1bxrz69t7IINTPH8nMq8Ml4cHOiUh0DuS3EXKEgqelwaz5IGKRGhmI0pu/lwpfJo9TUSNUylshHyr26khx9o3C3t/2XZFXBk+CFwC98ffs5TUyNBm+J60CvHqErnoZhGfhh0TycWMQHTGRnbUh+ZKONthFSHCu0oLHZUe76HhhowPWzmXuDzcO4xVzdBAzqNF5dGAPJ5xex0A80QuOfT8RtkXkjN6PS5uhTkx8yBQGUwI1mw== 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=WK9edGt1q6cyVin2k5QTSlORQ0xxXKO4xMJndvAfEqg=; b=ZCKvVxK4ieOvAONeTzJpX3ZlMaOxyixFQ+tvCNytfiI3/NQGSXuo84ZtrUzd6YBNf2REav1z7NjVPlnijvMP8xvqxiaZGeGvyCjsQ4SU5YIMKVTHaoQW7xp1nWhO60xbYpCGH0BhbNWASOzLZjtC45KkCBCecubPWC2+XtcmdBPd7QZczSHZYyM4aUjNDiGJia1X2+AwR/Av/rcUTy624KejI36zP8fnzxdVN75B52ft+M2VCa5rKn55gownsvOc9xUty9UB68v81QFu2dt01JoU/bZvlh9w7uF2rKWgU0p/FRzi79vba7oyBUMtgoA2UQ9Inq+OG+Jx3cg4YF9qvg== 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=WK9edGt1q6cyVin2k5QTSlORQ0xxXKO4xMJndvAfEqg=; b=mw9vp+5u/UaNsngL8v5d+sCODkbo5Wyptq9+Desdmi35mEyp5MjHqJFMvRAHtk3Vu+WSYJVbj0pT/yYhxBH6LI7H0BXiTgSy7CVIebESGCh/N/UN7eRHYzMQQMnSIuln653v5rlLGj8TcMEO9vAh520dAYR61s1/Wiaaslrrlpk= 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 AM8PR08MB5698.eurprd08.prod.outlook.com (2603:10a6:20b:1c6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 14:03:12 +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; Wed, 9 Feb 2022 14:03:12 +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 4/7] iotests.py: Add QemuStorageDaemon class Date: Wed, 9 Feb 2022 15:02:55 +0100 Message-Id: <20220209140258.364649-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220209140258.364649-1-vsementsov@virtuozzo.com> References: <20220209140258.364649-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS9PR06CA0192.eurprd06.prod.outlook.com (2603:10a6:20b:45d::8) 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: 7291e80d-a2bc-4445-ab83-08d9ebd4e8fa X-MS-TrafficTypeDiagnostic: AM8PR08MB5698: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: JjopW2FzSZXCgnDdUjX/zFXRVyeumZYrgu6jMYpq7Fc6NU+uesr4oI12NJB71CU8RKQQzzVrL33Np6gACHSMD+5MQKqkSRAMg8jcOt1GoOkCUHNl0UKCzErhQgVK2TiZwNtx8sPVksBNKtXZXLwqoqZWHb6bqrclSezooyZjm8IONAohOjfRKIN22fZs6Nf/4g1Zzsp9oIYXCuM4OYBNL51IVkxbAWEGJYKU267zXP29qwhJi/IektLjhO96nd1P86LRLbks/jjtHNUWUQjSyCJ228M3g71mZqJOhvEQmsgGRV9daXiw02xGLuZE5qSIBs/C2XOJ8caz060lvcZ/M1OcNN5SjRFrGSX4D50Qv1V7Q5pbioqhkQ3woUMomC2heFthFmk5IIjxpqD3M+c6L9g82vqs5LuJa0Nbzs20OFgGNJsLdOfaKLB9scYa/DmbELgskprnWqv8hRJCM1b5PdrJKjizv5K3rktYMBt9mtMCF/M+2sprbqUmzar20qAql+PtThgsJQlKwhluIXjSHg7xq9XSRBUEwGn885aIQyHRVfvL3CNscNRmYR1LO6coNnvNAL5Ychjg5xWFhKs4aGKrQ1fcCZ65FSlQ+XZ1A5UetySE0tKmrs2pU2ihHhoQp2UqeUH86WfII0qwGidzh8K+WU8ELCeHfsf2SSP0P6o/KfVJTi3sEO5wWRxijjvvuXk9Sie7lMTqxP31bzPciw== 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)(2616005)(36756003)(316002)(6512007)(2906002)(5660300002)(6666004)(8936002)(1076003)(38350700002)(66476007)(66556008)(6506007)(8676002)(86362001)(66946007)(38100700002)(4326008)(508600001)(6486002)(26005)(186003)(6916009)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ARQi1gTpQZByhvTm/v5fUjobjWmFGgTyzphpXVj2AT2CN8U1uEDi/MIulzOetw6MmaXWs9+OBgdxVhHTsc1lt43C9nvSZGPl6OmmBLm8OIWqDn/AluOqwupz/baWVFnAIHDm8DN3QkMAQbujwPz/pqSqDDiB/f4GcINbw9PlaZrnklz0MfnNL+8TpkaKRonCthO7dQXJcY6bqH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jdcipugpO57lkdVBKnd/NDPUZLGy3BN1vCtZV0E0/P1UHuVX/jHBdpAxZnwVqZnIUoGw0/UkNjF1qRb1LlPjrypGyrjpJXg1ZYP2dLb0xbMFTdAKbHi715KHcWSGZihUM7u2hVffGwGUa/bR3vdQHxLTE5OPX7Qt2eGvhmL0qJNmgOAVD0zVI/q+74dCU+fvuuTlER/4pK03xZHF5m/wwJekV3QE0kN3JYt0GhztnlBKGFOWj9sqJAb1fWHhCKDPzarxVNq3JRf349dEVkGoYI2XeemM/pd5x8gzWYUKI+nbd5KoK30vWkVwoOmfW/x2QaJ7841jn/bm2icI9Ch9If2W6xoYuVaTI1TuBwbRkhK08yhm5dwxriVU+CAahB5feCeP8h/F+A== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7291e80d-a2bc-4445-ab83-08d9ebd4e8fa X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 14:03:12.4753 (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: A9aqn5I18ybC/nVtBGw3+7FQxZuoQitihZ6Sw4475Mz/Sjx/8DjtLxqtOdUbDcbOCUc/rXX20Age7F2d4P/6E9HoATEeaG1vJpxJHvaGMaw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5698 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:7d00::715 (failed) Received-SPF: pass client-ip=2a01:111:f400:7d00::715; 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, 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 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 --- 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 Wed Feb 9 14:02:56 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: 12740323 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 8B2A4C4332F for ; Wed, 9 Feb 2022 14:27:43 +0000 (UTC) Received: from localhost ([::1]:60622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHnwW-0001nU-TM for qemu-devel@archiver.kernel.org; Wed, 09 Feb 2022 09:27:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHnZD-0001Gu-OX; Wed, 09 Feb 2022 09:03:33 -0500 Received: from [2a01:111:f400:fe07::716] (port=28271 helo=EUR02-AM5-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 1nHnZA-0000NJ-V3; Wed, 09 Feb 2022 09:03:31 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WyrJ5CfdajTqjZ2HfsGuj1rojEb2nfuEZDHliu82Vdl0KVTvFAMhVosQlCHN7CoittwijMjU6P/qNnKHAGB9zjSm2X2MXVImYCHrSCabARH5ou9eEn/UuTRufwCaAE8+0whMnVI9h9XYFjUQCdqWD3VS6gVZ2lHRM6fIAhdiq8N8NkNy+XkhGLQ+1sPPDCmutOb9iKIAhRS1ueJXjYJmWX4ZE5mgBhLvux+RmqxJ1xmZmLb/lKCGFvYlj8OKB8WXu2Kt6ryKj+rv0GG2kYQEopQxJW/3VCIEQxoyCFs2t3phPymHxPor69f/GSXcA7YAdJESqtPFuMCWE+JzwDYipw== 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=58SathTNiJjLK1kvKcTaLJEKMQFocyHEuD1xmtF3GXI=; b=GJMtVS4YI4FDTI86bKwqsp5CsI6+hf0eMCfv2I8xwR0S4kU9HUMAi0CWxzD9IHBDNs52qjSF3waYml0QjWpaWdgpMrk6ShDvg7Tuw8waAnzL2s8Z2gPIyUQehRSJ0vrX/A7Kx1X7IbrF+sGDEYcmS4wok/FkLr036Fyrx6ffKGZk11Wz+/8S9i6MHWATTesGa/YNhjZKS+j9iA9e58kQy5l9OpytEYDcmut5QJid2TF/ruAHKBG9Qkp2wPnQ4VNO/Tm/v5avQyTjEea3n4Ie2KlqHJGHwDDDpDmJUfueANMmI3ZBk/PA4d7kIKiX49gtlhIxvVVgqsEuW+zf6EdlTQ== 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=58SathTNiJjLK1kvKcTaLJEKMQFocyHEuD1xmtF3GXI=; b=mMZ5Nzeu6p+mCEgQg5WIST0RETpCDPGo24DnH4Iom4SzD0N9Y42ENS20qMU6/pfH8UH5mYg6lrpG/nNG55zGJOW/rEBZ0aPEg6nYv+4ZWYnlEMLz3WFZx8S2zZAaMbs/B5ai8myZu707c/zdeMI4x1z9T5yN4t02sNufYJr+KzI= 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 DBBPR08MB4460.eurprd08.prod.outlook.com (2603:10a6:10:cc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 14:03:13 +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; Wed, 9 Feb 2022 14:03:12 +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 5/7] iotests/281: Test lingering timers Date: Wed, 9 Feb 2022 15:02:56 +0100 Message-Id: <20220209140258.364649-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220209140258.364649-1-vsementsov@virtuozzo.com> References: <20220209140258.364649-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS9PR06CA0192.eurprd06.prod.outlook.com (2603:10a6:20b:45d::8) 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: 0962b4a2-f720-42aa-1cab-08d9ebd4e92f X-MS-TrafficTypeDiagnostic: DBBPR08MB4460: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: ruHxTRh/FjaOg1yjPCdenefbkJlOEQdL1JjwExYrN8n4Fo8FQioj/DpRRTzNMHcsfWdkCdmBZ7CcowXb76jOVvpgGOWYsaEdzY8yXQ2GVz4+W5utfuUVBMsGxJgNTyX7y70CD5kewRvb3W06TpBqj8UhVoBpbQwUVV0OMUkw18wGzb7MzJ8pdLFLo+ZUvoDUIHl1ZF7kUF8ImrSXObFEc2ngNijRjmiQ9X9uNW7oEjUvzB6ILBfheX7KhFBMswAxwBRIBmIy6TkTd4mobbqIJ1M2jS+tsx6VaDTU3g7Z2aQNuqPimswdtcrwSU/Pxk6Ep5EThdjb4Ou+WUiBgBrqK6grUF/J1wddtQWWBijLRqQq2RWhMe0S1vDWhOJ1OS/EeSE1M3/lXCWeJUilcNiQlPMT76ZtMR5XUkoaWF7fsyHmeZkghQesfF/1+P1CMWEAkp2JmnV/pJuzpbuVDJoAUX5Z1xXSw7G55vP5X8pIlpPfzqJzgsdqzNLkz+ewPHdloTbGh5U0YcdnwP2KwylTKbi/9BB0INoQp+6Y3EMPNeP63dD2SG9z/Pnp3Mtoqeo11l1gUwUCYq463/hwVC0Tqo0tSDKXpacERpsy3Hsa7a+uQ9z8kYPZ0fQqnFuU7tXg2CqsJVlTs7/nqz70u73jd729AOaEf+4+PTcMEczbpRPn4D5PnqRiNcLtgcV/xNL9iU+TOhtZHG/DsqMUtVOPiA== 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)(6506007)(38100700002)(6916009)(2906002)(6666004)(36756003)(316002)(66946007)(52116002)(38350700002)(6512007)(508600001)(4326008)(6486002)(86362001)(2616005)(66476007)(5660300002)(66556008)(8936002)(8676002)(83380400001)(1076003)(186003)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IeL0p/bOfd7vA5/AJo9NfM3og0GI+URg8U6kPSK/2+3OLa0k5HUXudctXj8ocGFeVo1DmeMSPMQ1yyvnfqqZz5lwhR7u2huFLel98m88RCqnyIaxbimvOCTp2listhQQBnXfBSK/UZ4/tyJdxHSvr+jFI65jXJh1FpWpaMMpFGweJFVPXXXn+yCUuR3pQO679sTlwEnSZEGqcSuTfnCbgh/metWeB+jw7Crdsfh9Epwlb6RYqQIM0ZJPp13W4kZZnTmH2LlceL7Ewi0jTOvyKXdbU2hUwot4VENrnYK6XL27neWxWlWuo7F08XVehj8Xy8Vyp+Zx+OABFJdyTMeuw9Xmnk7RULu54VH8nL11/E5X+wvTSrluZujIcFj+TBottJbGtMdl/FL9FWnlGA2hvz0wgbQ/xx0KblMcBA1bu7Nyg9l4Qa8BWF0d8Ig4SWopUburrXYYbuebcXasmNZ+SLPFS49/AfS9XCmjYWy3aqTVnKqJ1P3TU9rJxXAKyNUubpZwNFd9WFyFb0AvuJ5vK9hIPFsC7Th3WQQ3HvytMR4f23UX8QvtAxGA6RunMr6+V0Ub/o2CtC7RpoWaTnj69Ri9VBCr+GzZ45F5aLLgYyuXDMpUMco2I/Qwm81TeVKbNDc5Gm3NmoOcYXtTXTfMARVVFxsqhgSyqrLXdkDwieEXctIf0KpjxTbHeQChWStk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ebd4e92f X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 14:03:12.8814 (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: CxVgZwmhkGsgysk3AlWnizDCwKJwzDnB9iynDZMUfwCtDEzL/cqytfPCk/kxTFErAS0TR/whqRfBoaXGgY4pp3EY8rGZFjzOhlQoGdL5liY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4460 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe07::716 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe07::716; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-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 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 --- 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 Wed Feb 9 14:02:57 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: 12740331 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 9B25EC433EF for ; Wed, 9 Feb 2022 14:38:00 +0000 (UTC) Received: from localhost ([::1]:50126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHo6Z-0005cY-7Q for qemu-devel@archiver.kernel.org; Wed, 09 Feb 2022 09:37:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHnZI-0001Jt-Ev; Wed, 09 Feb 2022 09:03:37 -0500 Received: from [2a01:111:f400:fe07::716] (port=28271 helo=EUR02-AM5-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 1nHnZF-0000NJ-OS; Wed, 09 Feb 2022 09:03:36 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FY6ckh6NCcXUzmnxRYjgx4z/WA5GmS9Ozv6elcOpeTADAQPOTMnG7FP3i36l9IyqSCh+dXAHZrK4r7oqzHp2USu90U2nu6DrxPk7h3JZxHI2K7KxbbOyG/uePjwi8HhgoRf+aolKulExtRFV6BAdLLQNPqiA5r5kAQ2+iHDmND8vCLqY8KbF0mVG/3bPFk2HCltLJCaVruUvicaljbR4zIjSbPcnribzVpLnXuViqkb8geEjzAUUbfB6uEQQByldGvELPqBtsCF3rXsl84dXEVfP63rlGd5bZrEURGRfAmy54hrzNcb1NveIYJE0aZHpt2+7LJWaM0yRq8bOpXI1iQ== 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=i9sLHXOJKkg3+df3Zt0LlqZDxDZw/Ifb2V+YvYYjaeA=; b=JQJ13OoGbhIYBrRRqsDEL/DnjsfNYDq48S2eg4FKQ4Vo+ApDllAASqLnz1HE2RhiY1ilheqXgwGr+cDptIYJaUge2nYGNKLuK9KoLjKv5QW7LiCS1z7Y7FraDaqnC+wCTwFFiYLR3XqR5lbp4IvDTExAZBkGcWo2oV3ffy3WrCjZDJcX57+VZ7WRiztEJ6g64LHEZogISo4orMWD9ZZ4/xrf/Y7O1B3vyc68u4wNmlB8ISvGPqyzBhxLj0xlYoFfHbAw/UdvcN6rFhClBIv2BV9yObm22+HQC8eNfPP5oVX6blW/1iwrNB/fvHJKNiA6BClVLjwMyPKJE1z3zRWucg== 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=i9sLHXOJKkg3+df3Zt0LlqZDxDZw/Ifb2V+YvYYjaeA=; b=JLXGx2qY+kqCKc5TAWT9NlQM9RUERG6tWqGoNzjcJ+A3Gqv4tE1wVq/0mg5e/VxVXP6CAAClI1tFMhaZ8akTgEylz2uY/8wrmxzdLtdtHDHlzbrqklsyXtemG3BI3kXKh1J58MdHpdNQNnWjuvHMS5Tr7EZoSd1ApWDa5XtZUnM= 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 DBBPR08MB4460.eurprd08.prod.outlook.com (2603:10a6:10:cc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 14:03:13 +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; Wed, 9 Feb 2022 14:03:13 +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 6/7] block/nbd: Move s->ioc on AioContext change Date: Wed, 9 Feb 2022 15:02:57 +0100 Message-Id: <20220209140258.364649-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220209140258.364649-1-vsementsov@virtuozzo.com> References: <20220209140258.364649-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS9PR06CA0192.eurprd06.prod.outlook.com (2603:10a6:20b:45d::8) 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: 746e8821-d5ba-4853-aced-08d9ebd4e976 X-MS-TrafficTypeDiagnostic: DBBPR08MB4460: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: ofS50hn3LiL+Hwf1DUOlxWuuwqnNY+rw0/x2qgQKXmBzSrvWH0h2VSI3Lhw0II6GV26ZIZRwpNNAZ/afA+Ut9HGUYPjDMMb6RrCD6n9LCVUXPO7UwEbQUdqyUT4LjphPrn8H4zA/2A1j6uao0/l02kUTgqATewnAo+Zvp+ZQEIm4heefrwwLEfrNYkWK8y0bExLLksTcS2WEYJSFDQ1DVq2lc0b044H7fl6sx6AZiE7zgSzR8eLhDeTq48tsYKh5Y1yyczvcWPj11drQgVv2TvtQn95R4UO3+InJG/hJEgaCG8DGHef74Mxivp1Y4YOUe+vAOI/sy0o48rC/S97/TsrQDzCmv3NAvZHlM8dS3haTsgNQtRHhXcRen9wS9AdME6+2jPGQJKSAlE236dSu4HzCKWOeguNIZkExCfBha5PLa2l6ox4YRBPbndKyeFEYa1ijlk73UbmVe0rUL0IE9nnxSbanrUkQJzy4cnqPPVi1lXT7X2GU5LkE2R0sDsmGj/8l9TvLFhaFol50RI78/X/ov+N+srXqx3Uiyjk8QOlGG1bRX3fcNsW4Kqm94svrRZ1XVDXJ+VAzxc6SBArAAFb+KFVguel8FyvUZHv2O03tBJoBDuJe1r+Aqdn4I9f93VqRewYqyVxbfS8NN9H6du8olareOV+/jbbf2TZeLOcpfOy7jFkv6GtIEZWyk0RM13e41m1uzYi6yDShDojX6coEcMnbWLTSkmboTmNQq4ngLt4FaPPV4MP08H/XNh0S/0yeIdbTaKbce1oO3jo0xzwVFeEWbEf0Os0YRpv6Gbc= 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)(6506007)(38100700002)(6916009)(2906002)(6666004)(36756003)(316002)(66946007)(52116002)(38350700002)(6512007)(508600001)(4326008)(6486002)(966005)(86362001)(2616005)(66476007)(5660300002)(66556008)(8936002)(8676002)(83380400001)(1076003)(186003)(26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5pp9rGwBiNNzhv3Q5XlEHsF499BPQ+Di8Jo4syIVDIFNksVF5DOBG8mMieyI6CJgq1wck910IGc2uQrBk8yHWVTB2ItPaG+QfIUti7h1iR0nYjqc0+NwLXb9GufBF2n5Dh4wnDTJkrLfYq6qH9lLT45voKLxaAUo0LHzU9oXeyl4NjgtgAilI8Ojjlo1GwDW3d9FE+2/JLxZqzfLTOJFT+y2MG7yQnUS9RkAv1UrJTGsKD7DfpY6gI+Pil3MAl7whU3jwq048nZ7+anNarPj/xS+RURF71F3sn0KND6Ox8XHWz/7sgeThS/j2hK8zBxpgbSjCVbN6sOweVULLG7sRQdQRh7Q6FipX+KkUmETyGtG2V1U4RnNh48rzJtXdNBNxaPwOtiy/hiKvPS0If/xFRYcJmc/faCFFpMB/pNG9cG/7JwCFviJtuiOX3e7GAaR0v8Y+p3MhTWb/Te5xxn+YJlWvwBlwGKlrft0T0g1d7qcGnEAixbrZqCFpGEW3lh9fZ4rs8mNC3ggTHrWTyM1xuxtSsNFY+BQHtO6pCN/fuS4qOKTycPf1pgxOveGsdQwVpcmZb0EbgVHNv4rkJtsMidLZttJWqGoFuKHpO5WMnUpqEoSm1zdfZ5uVlu5StfFDh97wEanAN33m/MbrsG3Rr0xt4MQQrVchTGZg5a/4S/GIiTeYwUQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 746e8821-d5ba-4853-aced-08d9ebd4e976 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 14:03:13.3504 (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: kiyozlHyPTMlC3wXYwpUkGM9wt40OlzABRZpC2e6az8egJzx5/6BKat3xV9Sy+EcUxygire83kBKtIMVdcbhfvIL7yUwDBxzMXO0e3IsJp4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4460 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe07::716 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe07::716; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-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 --- 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 Wed Feb 9 14:02:58 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: 12740339 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 4FD1EC433F5 for ; Wed, 9 Feb 2022 14:45:06 +0000 (UTC) Received: from localhost ([::1]:59124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHoDR-0003Y0-49 for qemu-devel@archiver.kernel.org; Wed, 09 Feb 2022 09:45:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHnZL-0001Li-QR; Wed, 09 Feb 2022 09:03:39 -0500 Received: from [2a01:111:f400:fe07::716] (port=28271 helo=EUR02-AM5-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 1nHnZJ-0000NJ-5m; Wed, 09 Feb 2022 09:03:38 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i+bv8v6ENXVTYVYPFnmfpKLasn73SlvQ/zlDcOgwQymCUCPTyCI6rDhlYsVdstASidpXhDnE6NVXDkkqIed3FKMDwsvq5vFSvxKCHJWsZ8u3g+MAmcrHd9qWx4IGjM2ZDDODhJMK62bCTaWp5236pm4R/4OZ9Gw8Y6JsDm+4nmKe0hYqtwxZyyMpLD39F6LL975PVRubwzcyjJX3aIko4K/6meUFWcz7P7f5MnPZF3YzwEpseWDmieHpOZwZydmhFmUeWtg71RYAeCZwrrb16AyTs7mKo5B0cYrqpUms71AkenqadiuY4C1Wad0r4HmmXaHUATC/ok68sW/I7MosxQ== 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=SiR5f1LEZiOIyA8eHKsqtoRFzNR3nbBjrifBJqJ3OSU=; b=A0nbybTCvGvdKzAnFF35GoPAXX5gD9b1wb7TT6Ysg8vGeMH2e/OxyopqfF78dRjLCtx+dPI6b6kZ5zL7KfsyogG4T1QJ1S48cgOSg7nDNuS6B09LXWUNOou4fTv9hva3jaeJmI4vQ0llvrDIF5rEG1LS55CMbPjVUreLrEpUikwyk3i5LAVbEI5C29h/kkEG2d7IYJ4QPW7h12wAvBOfq1kNYnIGGxZHJAt3v1PFdcv/CLPyuzju/3U7Nv3m0a9ofYKcfuD2PGycU5ZMG0rcx/QLTp7YhTXi1Qz056L5RHOnv8i4QOkDYrMKoC7l90fdVOXBWpLpG374YyHp9QIyjA== 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=SiR5f1LEZiOIyA8eHKsqtoRFzNR3nbBjrifBJqJ3OSU=; b=EB/SeUKSYRO9Qzx0fYhX06+DJMlM1BHD9Tx28xeABOgYBC8kyZikquNbIWa7YhCsMSfyF+Gd0e1cK51UNfezFIHC7AAV33dUi+Ml71fdsG1zGgJLOPNb/Mdnd1uiiiMb6o9LApXtk3XCsmsmONhbnu2UY3dsFUVn0EnDlapNU2E= 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 DBBPR08MB4460.eurprd08.prod.outlook.com (2603:10a6:10:cc::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 14:03:14 +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; Wed, 9 Feb 2022 14:03:14 +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 7/7] iotests/281: Let NBD connection yield in iothread Date: Wed, 9 Feb 2022 15:02:58 +0100 Message-Id: <20220209140258.364649-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220209140258.364649-1-vsementsov@virtuozzo.com> References: <20220209140258.364649-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: AS9PR06CA0192.eurprd06.prod.outlook.com (2603:10a6:20b:45d::8) 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: f165f321-5079-42e5-0981-08d9ebd4e9b7 X-MS-TrafficTypeDiagnostic: DBBPR08MB4460: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: mW3HzwDrzs/pATh7FH1wpA3gQ67o8Aj9IZqfm93qFDR/m/3a2JzBvrWpRDImxzGptUVbVgGQYhh8W843xjKc4eTebtmYibHDhh7GRA8PiEBjGILnNm+Zumw2+Kz6lB0XQEyedXHuRaa/a/xmayGezSCnA2QP3qjibk/uLYOHRIYv7ka8Hcby9imQFr7QpohsXCX1H76j1CFDdp1ONE8cVr7I9wbPK8rHrO47lhJYrIhKEkeKswVocSMLFOIBje+YNXC/KTvUpKU3boNVu6dgFq1NVtcWy/4pEFAvQhbO3EGpPMLxQqJW9Q3B75XrLU+9KRoEL+h8lHBFTXb0G962y9ICeeI6ZUT5qspc1DCeB4EHuLDJ/EgcEIB3CMTxG5ZKDI5DzDVGn5/SpUaS7C4yeZmbRRydtsA/tIv/+idkzOvGiUcKD0BR2x9V3akgbKnGAlzryUG1FtzibuehVIwRXYiP+8W7XBR9mcCjvVepOY5bS8pZT2Sq70UEvkEkeSSqvNSh4Z0jUOxifnjjzROl5NP166ylwsOGYizpSJXEQuzNt8hEB5Zovy5CFbrftkqvJuVsj/D+I/i4T/dwBLCv+yIw3MEuVg32ULAo5QGQoQ/05tOBoWKu4f69JbHcoVe/gEQ/7368J/5UtPObAh0gwz3fzD2nkTerwn7GFA5uWfea4poR0s0YJ4gEvNr1PY7YE8Pk5BEbyisvvyEHaB71jA== 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)(6506007)(38100700002)(6916009)(2906002)(6666004)(36756003)(316002)(66946007)(52116002)(38350700002)(6512007)(508600001)(4326008)(6486002)(86362001)(2616005)(66476007)(5660300002)(66556008)(8936002)(8676002)(83380400001)(1076003)(186003)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pesGNgTNNPaEpHe8cOrldJPA4iHWMkq8zkee9kGssvWSMU5yJ3Y2d5Oq1RXwplR3NjYez11YuO1F42Cjuttvzt7CHlMBzYQpqWFaABwOoc7uMx4Rl4D36y4dDimColD58nnk58A2ianbIvVDrPjzoAd7N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1Qaz1B5D2bPKw6TmwmakXZYlJzcBSAHP3atMqKkTtQLEc4og9afjnnDHXH59PcQW7An0zT854uFS7XAeq+F12PRNxlWTRPOQFOad4aO514Iv3qcQUEPc9D98NHRtD9uqA/3vzrVpCaYdyjsCghkA2BrefFrR/PHvB2ZrYjcQfMa7Bphvn6RwCMW3FrdwDjLVMQnu4dcVPw/GyHycOzrW7gNkrUv1gIpWTyePN2h/K9J2LgOhB4MsebJRaL2WZajPzMcSCBtN1NzuSTJrCUcs3/xNaigODHS1wB/ADOWSxL+lGzkm8T0qB6RxRbr9n8jRWGXlyfGasugsn0ecTzOf3qakMxqvDMWjo/wdcU6rJJ0ippOdNWF4/+fZ7tbc7SNAdAmuvu+4kDpILOuE+1Te1j6fACzFVJ6lvUAyF44Lh+CyTebg434XSBRjJBF8rJMMzZGGyRVg== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f165f321-5079-42e5-0981-08d9ebd4e9b7 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6737.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 14:03:13.7878 (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: Kf6EEV1plGjqze+CgW/NsItJXr3AljLMLmSytJI8VkMNRj9xgykPr/9w43jY9u5ZXoiByKU+v+kENykvfL3lgo94FAJ/nfsJ23uIxm0e3aw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4460 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a01:111:f400:fe07::716 (failed) Received-SPF: pass client-ip=2a01:111:f400:fe07::716; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-AM5-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 --- 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