From patchwork Mon Sep 6 19:06:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12477251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A1C4C433EF for ; Mon, 6 Sep 2021 19:09:36 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4EC6261051 for ; Mon, 6 Sep 2021 19:09:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4EC6261051 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:57448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNJzq-0007tc-7g for qemu-devel@archiver.kernel.org; Mon, 06 Sep 2021 15:09:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNJxc-0005XQ-Om; Mon, 06 Sep 2021 15:07:17 -0400 Received: from mail-db8eur05on2098.outbound.protection.outlook.com ([40.107.20.98]:34209 helo=EUR05-DB8-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 1mNJxa-0002G7-4K; Mon, 06 Sep 2021 15:07:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LPRXeNNdISanqEZtbdNfWiRnMO5Tp3r+oADXKw5NLLsib9wR4xDOSyDsihnLxe8StvqLUysp4z2ER17so5Jov6P9bvfq6piN85tOn8FWIOTp14Ea357eZwecxY1MdlBKfYsL4lp+Z41SuoOn19Z3lnTM+I4UhiZANHfsXZcejzVN6a9j/bItyMvI8fmHDw6GAKkbhNHy8KeubIa8G8jB41wwhzLVQV/3/hYvqwORfOak28PlRt0S0tfujrGy3nzzyKeUok4gep3+kpp1D2wGGcEBdeGknMplqoBs+UvNQvaJAKs6yyDBCosahebVXnruBEtwOBFYFAePKuvOdjbEIA== 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; bh=p6A6rdt5gViLesmH5ovI1+VQkhBE9y0YSkimt38CKWo=; b=CpdscptlQ5o22/cokwXq2UdZrB+2hEVnefx3z+GH2PQyX6oYnYLvKVvyw6RCnxsqFbEyypfUd5xfbYmSt1VBER5cIJLDGSY/qcGwLirZPjZ730wKwuCrMx7wdbLNdvWsu/TG7YRP6DrXp7OE2ms+E9zrckwfNvb5zA0r6wGrQ+aKsnYaKv0QGkYO5B2Oe9YOdWWckezDdFtI+m+pQS270q2ow6drqsfdLz6e+2Hj4F79nYTo3DPk2B56CKXExIQk0RbSiNXLZgB8IOYRFwgcClqBs+WX6rUbjUXIWDWNX+AbNJvNkkq6o3d+36y++778jJWIK3bX7QcSa+Ntx8YxLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p6A6rdt5gViLesmH5ovI1+VQkhBE9y0YSkimt38CKWo=; b=oyr8xzCvpyG3PHzD3+xWD7m4z+kOrS4MorehQ97Rnk6S3x/0ShC+fX4xvQE9Fcvfpg+N0fccGgGm7MjxEd/gA9j0H10bNE4V6Ey0BpTSeNX8rQQW+59zAUB9xu29F5oD6GI6iFMm374THghpqqu36cwgV8kGPo18fKhD8zYbRK8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6038.eurprd08.prod.outlook.com (2603:10a6:20b:23f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.24; Mon, 6 Sep 2021 19:07:09 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.025; Mon, 6 Sep 2021 19:07:09 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, den@openvz.org Subject: [PATCH v3 1/9] nbd/client-connection: nbd_co_establish_connection(): fix non set errp Date: Mon, 6 Sep 2021 22:06:46 +0300 Message-Id: <20210906190654.183421-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210906190654.183421-1-vsementsov@virtuozzo.com> References: <20210906190654.183421-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Mon, 6 Sep 2021 19:07:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 135c5abe-12cd-4188-6f50-08d9716986c2 X-MS-TrafficTypeDiagnostic: AS8PR08MB6038: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rNoXdSx8wOd/xglWE951AhA7v6xvoif8sLNTUBGO7WCTT1teGmp2qe+v5+0qkm8qHVvQDr8Hv1+CEOIl6OjojCO6eExebPIY8MtHuw7FOA7KAK6kN0DGkKRWksASbwPvkMi5sH01tHgB9sFq0m5rgni/040eotwVv9nb8PkAiOzrKtvfLJ5Dt6pN6iVhYVTYcdzzl/Ep7U/dMETWeQIa7IyyAslSl6D2lwbXPfrT88U7SXoYo4HqfTqUpbQ3uyZBRj3Qi93TgbUIFpcn87nE3IvYNuN0OAe8sIFXsE17czwaeJxuCJcIWe5de6DO8ggHTslRSQeg9o4Vxv5bZmJk5L/5WKA/nnHxwM/AUC74anTDuQe8pir4aTuoulYaN6ZrzlJqHAZwaX3epxiwx5+hgPhC6EVDze/a63pltv7kysZMLOnZAcx1lxjegFJj8l9QrbPSm/+waBGTlnjhApXbL8KACeigzWg8U8UlTFvM469bNmrguxF89V3sOxW4Cv1WDZY4dXunzrN3SLCuKiMW5/WXcFn2gj5H0wSrSfUiv07n6CBTzbsInjvfCYcya5vTeXvnO0jR7ThzjXIfax1IQijEUaFWECg++DvGpENYbo63+GBwGhZD9ocvtnk3v6qDfbNNMsnZKjjRkjt/7xxCwwSZ39dUWAy1oSfa3YxvxlVMllSUZdH34SKdQZCAhSroK+GEypuIYAZLH301YPT3tQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6486002)(6916009)(8676002)(6666004)(2906002)(956004)(26005)(66476007)(66556008)(66946007)(6512007)(186003)(5660300002)(316002)(52116002)(6506007)(4744005)(4326008)(508600001)(2616005)(83380400001)(38350700002)(107886003)(1076003)(38100700002)(36756003)(86362001)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0pEZUuyr+eL3ZfPXhMcB3XeAqbgO1aXzpEN2AcMclE2/uNOrTGGmRHydmUHXRJx2eMaf4eDb11IUaiQpsZ2CLPTiD3MCD2YRIxOmPqLKAQyMPVCPqgEz4OpksO8bNTqxZpalVRKO2vH5JvZRULPstLqsk4M/BGNwnXyBvpcLFsqrwmb1L7liGPz3HfWKtLRs8ThRPGa0DYe1TFgx/09+lPWtKydzWtPKZ6+MQTjsX8e+CDVhO9l9yvrF1J8l2KUumkiIjHuKJBjNygkMUfgCmj5g6yOTy54sQNueSDKc+luCP9zAKC/QGLyhevXaCY5+NzSsk1AKlU6YYRFktjpKHbUKwd1FSQmoD+NdKV/MtMtiU83/AuO6fDFg7pIt7krG2Y7eHSxeOzAhCSjWSmWABm4wpV6snXbugiue3NdZMa4/SESPwE3jQezWxIK+p1UnA4ApORjpUAyTM9WGDHVi7DvBN+gEIvqOt5Sabtc9hO89ypQJSzM8DPWIlTZ//BkkUhfLdgT7kz242iWUkQhwEf3M3mXPNy2QykVCrBzZt66dMPTjhYqk9/0ygBemcBCxYhRj3Ai08GDfDoMp97ZBupKIBcUFm6h3X2baEH5XdHnExW+C3qNxQX22euNIzeMRYH+j1U+hfUcOsD/GetZe1XgnIrCi35N8am19DIW6fS+C8wz1pFWRfYE/ggieZ2QujPZlGPQCJyXqYBcPKO701G6L1K5AXT4BrTwfF6fi2qLB+rclQ4NGCzxyqXv+E/b710Jfd9uen3mahLKjSJd8xC51WXKs+9jjrLNYmbd3WiuPq0Wtl8TZDIqzmmgAT5JPPTu1ZV2MunLhDOqnZcA+sI5cnH29mPd4LXfvminRdVQcaly37QttOQSk1qMhEr2N30gID8DkMAnLtLIYpowd2IRhAdig62XGtKaBZD6BmXvTTTZDPB21SeAiIu5NpwyGHxWFCg4BWUtN1pfSsRTsxmXD7IjMS4hpb5fl+0/cTgeikGpnzZjYK26E5OMoGNVVxeWuPZ+iDH45MeSJW0gPf9fqnF/Mz81l1gWK0Sagg/40srSfrXGzfKsm9k1HdMjlKbvdy/HvZszhCF6JHlL7cR6hGnOmbMyS4MoH4TtfZlVo8MzfJepaWJ1O+QVSeSzhiTNZHcnr2KPsX8AgYKXQZdxemYQlprCOTd3+C2aTPvRSP8fCVJtRhA6qvEsOK4DjHxk0pgSvtCg7fpoigKwIB959Aige5bzPr6qBMSJEeC0uFuKNi622o3yttgOq4rkDIvCpYYwecJidVjOiNW68ydHXeHRy5/9wShc+R4RhC8scsB8vVN8LNf+a90V1hsTr X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 135c5abe-12cd-4188-6f50-08d9716986c2 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2021 19:07:09.8260 (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: ArngqNIlUiOtz5fJnfnpDCKkL3PJnVyrOE0M6miOxHFRAXYZfAk/+dYDxpE5QfMOyvsSk5opwXT2pAwy1WDLrgwgeu2wuksFxoLSSGtg8Do= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6038 Received-SPF: pass client-ip=40.107.20.98; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" When we don't have a connection and blocking is false, we return NULL but don't set errp. That's wrong. We have two paths for calling nbd_co_establish_connection(): 1. nbd_open() -> nbd_do_establish_connection() -> ... but that will never set blocking=false 2. nbd_reconnect_attempt() -> nbd_co_do_establish_connection() -> ... but that uses errp=NULL So, we are safe with our wrong errp policy in nbd_co_establish_connection(). Still let's fix it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- nbd/client-connection.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nbd/client-connection.c b/nbd/client-connection.c index 7123b1e189..695f855754 100644 --- a/nbd/client-connection.c +++ b/nbd/client-connection.c @@ -318,6 +318,7 @@ nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info, } if (!blocking) { + error_setg(errp, "No connection at the moment"); return NULL; } From patchwork Mon Sep 6 19:06:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12477255 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19A0AC433F5 for ; Mon, 6 Sep 2021 19:11:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8D68761050 for ; Mon, 6 Sep 2021 19:11:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8D68761050 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNK1s-0003UH-PH for qemu-devel@archiver.kernel.org; Mon, 06 Sep 2021 15:11:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNJxe-0005Xp-Np; Mon, 06 Sep 2021 15:07:20 -0400 Received: from mail-db8eur05on2098.outbound.protection.outlook.com ([40.107.20.98]:34209 helo=EUR05-DB8-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 1mNJxd-0002G7-2c; Mon, 06 Sep 2021 15:07:18 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jDg5kgKsMFPhEfJoWnbTYkYFl6EgVHgGuVgWXCbfqLetMzljYACJ33WD8pX0N/9MDpsPNUx9qg4VuKvVcB+eApN7h15Jt69MQIjGbN7u6/b2MdtfwSCflxpAl7A3ic5K+pA2URbMGqcyl+3QIteefD5vTaFP/reUE+pgvNFY7PYf9oWwS+1fEA4BJu7DEk9RyEWqqtvrKtpu81ZP3DNsOxKepzCjPX0lkWKWmTYRxXIjX/Drd659zT0smS1We5iURUBR5Dky1KLZZQLvuu+7/bByjwOHWTc2otznhKpTeW1HH+Pxsq1MvWAayQggRndao0e4ii+TcbHy0Gvty61L0g== 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; bh=BEQwbTZlOqPDcxNMMLcIltkMeLrNM/cwUcQgrQjsA6E=; b=eEnpbwo/N9yg07G7MCY1/hBgXpfuFRGeY/bii9yniYGO6DISurYEzmewJSUPGhFeU36jC046yLViF6sgHOahdxRVYl4wiZdhSqBm7kb7AibX0s9O2112VfGrWgyEUQAIuAWMKhEeSebtktq2nTcIZOkrumrNaqM3lPRovRAWJedQZgkbbG7TS6aFnNf4xA3Inpk7LjTLZ1WJaLdfmcGzVUYlMH69y105SeaCJmmdrFyVusdh5VvIffCC818cmphFXRGtltw1jMKHpHk/xJjpHllIM118kjl2KiRkKmlrYWGbZ0hNGXgXtn/P8DjKTAw8J19iQsFLBiIbYOC3DtQyUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BEQwbTZlOqPDcxNMMLcIltkMeLrNM/cwUcQgrQjsA6E=; b=qW/eynf43yhrEbJNlSNskhLRelKpjEA6oh9YKt7YfdDTuJcvQD47wVXs9ANIVKzCzDeI+XOf/eLWnFdDbyZXyx+S11BgciDQnf+xOTUBbKju0WIpgihCK6ClMj4H2TC0PdwCtbkkmjXNpzFNH+45AY5xIDRoYeRPswq+sI4bOQc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6038.eurprd08.prod.outlook.com (2603:10a6:20b:23f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.24; Mon, 6 Sep 2021 19:07:11 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.025; Mon, 6 Sep 2021 19:07:11 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, den@openvz.org Subject: [PATCH v3 2/9] qapi: make blockdev-add a coroutine command Date: Mon, 6 Sep 2021 22:06:47 +0300 Message-Id: <20210906190654.183421-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210906190654.183421-1-vsementsov@virtuozzo.com> References: <20210906190654.183421-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Mon, 6 Sep 2021 19:07:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6df0692-3a0c-4a44-b71e-08d97169877a X-MS-TrafficTypeDiagnostic: AS8PR08MB6038: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:254; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /hU71RukdV7jPvsC7gbYKRzq2hFar7riWkEdvNSqxAss8MdhBDLTbPBHrpYw9+iv8heajD2nemxBq12o8pHAyuJYD47XDrbf7du4uy1BqkuL7wPiQzwIyuti61OxhlSkfRaTxJOav7KAcKymruxBaj8cjxQDIT6IKyTrUgmN70nFeNNZ6O5pYO2/7v5n0H+lFooTtcIrkkfXYiV/+Hnf+iUTmfZYM8Lc2aOnhh1fuVYA2rH0IFI9kvxIjG/PL28VYR+0LQrwuBz99RkWSj2/1/4xW+zdmOTyzMOl8EUNfA+ke9ZC8vHAemq9yCE1EtwZVWQKjsTdLH5tbGZ/kjF1/j+ELEz7W5Tj4v5RtdIiE5o/+He1s69jDEYEONmZlYKWrGe1IG8hj7+lcZ2aavoYf27t8Q3dzeHndnBiv8uSyb9LqHNb6VmPFG7hTnRUTlx7flhchsyaTSsOmvrV2otn+rkHkw9tuujV7oRhW+iXFpfum0+rnKwC7CFAoPlU7BHITS5J7+ciWLdOw/JVvRg7QeD/kS4S3zOdizRfwCwV1jiNDlSl8muxrDUgQSICccnPhHEqNQZle5oWlmDo16jdsl//fOc7WLj8h/xYorUqogt+iszvL39uSDfvq6eGX7WosjCbCUOjCUe6wvn5djLhGjjvxjYn6KfFN2gRgnrX7SEQ04BPXuMdVIm+7Lm5ogAKensCeaeWxzzmJAClmvFfNQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6486002)(6916009)(8676002)(6666004)(2906002)(956004)(26005)(66476007)(66556008)(66946007)(6512007)(186003)(5660300002)(316002)(52116002)(6506007)(4744005)(4326008)(508600001)(2616005)(83380400001)(38350700002)(107886003)(1076003)(38100700002)(36756003)(86362001)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NkooaJrg7i2JdGGDPkEIajwLJMLbMINLxCc+dammQ8rxGH4CyGF8QRbRi/qac8zWHTcK9IbdNwJG439ngc1VqdMr/YOl1VGBmzr+kxuK1TcrMtb/5Vry3Wau5FPJndbuOZESBK6u/6UFzExCK9rjp/ZGnKA7zcR53IN9r5mdJzoGYN/YIDWe+tq3zy5oAfad5hmQKGjRiFHPhF9fvZTj2xKIhOQ2mR239sia/TN2Pdfm7uiq2lrL3JyXWKHf1UA1YIaxUVyAnxTk5s0yWVEJXjv5cRXRu9Pc2ho+Una7ELsYO1JLofueGdX7tudcoZxCZYzm4GF83HTQEWRLhOBNczsBmJ4xIoVuFYCeTkqSoWHiiMQh43ldEhtZkpQx2TYCK5nHTQwzRrU9YmUh8qSU96jb5O/k7mbC+lHzgfa+3dqZgXnkRi+yTUFrVsusmyolNp1siHZv8tmDB+94QiIv1RNr4ZKE6sL/Hbeiz98XzEGpXZfW3/WZmJxtCuXToyVu9oAuKfYyjTt9AqC7PWGwjH19zz42XuBZbCSWhteAMP42LMqF5Gk0ngFgxeEpRDRBubLkkidnJunvkF34J3fD47FSyGtUUvPlNGGqxfGa/om00zWvDFuRDd3u2RB+9t31Suw352dcVFNJAj+cJ6EAYUgioWG2CzcjixMUanVa2zStKG4pM+1J93KfnvdqiqtjAJ+wuVW8jHUWQrwVGz7F+HNpZoJ1rmJMBSAqMz4qQdd4Rzfpzz7GQTbzjWtqonbykCV59VGViRcMSSEv0q09/ZcbaFbyI+rdRRJHTGRQF4zYoiUS5it84umYLemkKfL212SyFAXVj3UHCKdRepmhJ5zQ4e5NuKEbODTNH4ouo94gPFZkNW+Q92oVJnFVQV91jVeARmwQFoun0ZOuBEo3Qs2kNc/HJb/zbNu11S0QdHMqRmvrKEDlZaTvg7EXuukjvOBcBgDxWYFOkx25akClJgUo3AFrKH0hBuCIyczyzPooczl6W/kUHUj1P+90DWbXZGlxX6DRvqFCpwUML6jeCej0sGzIS2yxB/gNXeufd6jpycMyASXNhFamAxo804YwmVqzWEWu2cOy4MAlvz5+9hHefgn4TSL6dtw1BL+AU/hTmt15AuX2XHOpRUcFFTs/uPDVVu4g5X+s6zWqSAqjtKlRGocboZXdvuZ8MMk/2FAE3EDFK3XFf0h5elQIMkdUT2sG/enZIGoCpCRKl5Ljx6FmduKhzHuhyi/fp4ecOuw1d8QhZnQeHRFd8QaBtHbcaqQE9dkINuco+p9hU8QBpzrD8d31ei5Iv7Aj4Sw/flsVjtUQJo5UMIuxj7fG0irs X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6df0692-3a0c-4a44-b71e-08d97169877a X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2021 19:07:10.9690 (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: OitCPoZf/++jU3qTFAWOh8CNEWTOJWPI0Mjr8KSK1g8qyW+YgAHw0CuvtDphGZI1AuS3EUnh1o8tQ/rlxlERISsUjhc9Fci9I2jfWrngLfo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6038 Received-SPF: pass client-ip=40.107.20.98; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" We are going to support nbd reconnect on open in a next commit. This means that we want to do several connection attempts during some time. And this should be done in a coroutine, otherwise we'll stuck. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 06674c25c9..6e4042530a 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4219,7 +4219,8 @@ # <- { "return": {} } # ## -{ 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true } +{ 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true, + 'coroutine': true } ## # @blockdev-reopen: From patchwork Mon Sep 6 19:06:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12477253 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41098C433FE for ; Mon, 6 Sep 2021 19:09:52 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AAD5A61050 for ; Mon, 6 Sep 2021 19:09:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AAD5A61050 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNK06-0000Fi-S2 for qemu-devel@archiver.kernel.org; Mon, 06 Sep 2021 15:09:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNJxh-0005YG-Ox; Mon, 06 Sep 2021 15:07:22 -0400 Received: from mail-db8eur05on2098.outbound.protection.outlook.com ([40.107.20.98]:34209 helo=EUR05-DB8-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 1mNJxf-0002G7-98; Mon, 06 Sep 2021 15:07:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q1VShAPTCASR2q6orAYhjSTUcgCVe1YsckwD2vnErj6SxOsNUksNfVmK/XZO6QD03WnbZclo8YjchYoCNyygCxO3uG83peldTk+ERUv73APDbSVKp5v3ga/2cbsuIw9IW7lRmb4W8RXyWA/s467Ob2ut2mpLFumNYjczQf60cQ74ftcrpGykwgo8MDIGM+khCkt17W0zzQynQ2PwPPuR0uPmfc5VTNj6rdcFzAFCtblJeeieo8rWjuoT9tOTezPvWVJtcQ2fLyfT8vN/ybQIh8376adpT5b9Qt5OZEIEbfBuYUMwuxcLlUDO32kUyZLU1SHYJfsaewgH7Fwt8ZCziA== 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; bh=ya1gebwDhN1zv+ILH+mlU2bpF/HhqFfKifxzMrBTwrY=; b=OQzmQpNFEMgY5g/EONGZHAZjl5VjIw2ln/EC/ja70//YExGWcyfeTi/SwocCBiFXYAHAnx4LSsX3SGIrs8aO92vQ3HYBN4Djr2i6aw6ob2lZUKRp1g8BpOx4eCyyhJtuz2g2MMCBntIllqOLv2uTQ9SEfZE8I2GkDhDy3LKIdNIGhht8T2Z7uhf0m8ObGVUkkF5OmU6jierFQ5sR9nYc4ALkYJHCTTrc/k0+4DOxhQoigRU3mRgtwX9mcEf0TXhJi1GYM3WBsr8z+19fs8BvDYwlDleizR7zaZPJgPTYmE4rrWkVTmnwTv2fM7xyvQDDxvIzRb6NxuJc6skwUIajEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ya1gebwDhN1zv+ILH+mlU2bpF/HhqFfKifxzMrBTwrY=; b=R5blL1R+XbZi0gi4CNiK6Qj2l/oMrrSfAqjGAU3qlt0B0pMLPbCP1KSqm7PX2MUo3VdrtetVFHRKEljxQ7DhmctJCpc88wmuRNL+FG9CzWNgShIC/c/l3+kX5U4h7mUdIFTeEk030XMAsmYxFCFswK2EULhVI+EPI5ZUO1yecTo= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6038.eurprd08.prod.outlook.com (2603:10a6:20b:23f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.24; Mon, 6 Sep 2021 19:07:12 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.025; Mon, 6 Sep 2021 19:07:12 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, den@openvz.org Subject: [PATCH v3 3/9] nbd: allow reconnect on open, with corresponding new options Date: Mon, 6 Sep 2021 22:06:48 +0300 Message-Id: <20210906190654.183421-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210906190654.183421-1-vsementsov@virtuozzo.com> References: <20210906190654.183421-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Mon, 6 Sep 2021 19:07:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 43724654-8ddc-4689-255a-08d971698827 X-MS-TrafficTypeDiagnostic: AS8PR08MB6038: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:126; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u+Yp2yxC0TcPSpOtp83dNY0rd5Doz4ug4rTusM40cZnPID8hmAudxBiCTX4ft+YC2Yjfn+N0Tz15/6CRHqvDDRpJIXS4Dl8q6JRLOiidkyxjrN9NJSrAOehwNNZ2WchlJRfH+GicQL6njEqj8lsUzmHuGpIhbN4TjtROj4y2xAggGEB5gU2+0xUcVWdWpNkxjoHF4g/diVnxwAEzJWsBnrFjxyJUE6U4pNgszz3Resrf4/WMJjRRzi81vmIjF6S+PTki+l7yN4Vq8oQ4Z3L9t3bPFEoARszA+RsysodVieZTodOKEkmfDkqFEbfSTHP7Bc/uZfM2wtjhLm30lgE7/TPLogHLtRZ+WM81WLzKoXdNdD4TR6WlZ2WfTcjFI8pxmN8qBVXoxAgQVKcDxCdrBT9PbirD8YZT6neDoEJpO0ULG8tZ4rIdrrO+4z41UVNnwwsxs4hYbB7hdC7LstYUmBPQWXTWck9wXSltZoUkjYVaT343FchzFrR+uh715/TizFIzd8HQVeF8BviUHCpUACkUQcpMJYZcaYgasOZMuVqG/KZqmVmjOGzz1VyPP0J7TuIvDsWhiDmChIOuE1Zev+Z8TmU1rxsb3EjjzUerhPJSJ7bwhVLYMi7cIj1ZsWA89gv2MAJVct8rxRpJ+YYGwNIwM4kpFxYzvs+Rh5I0u0R3Fx7HRVCW2YAOCgQKyNjhah/C/B5n/HbgFlt50xn4Hw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6486002)(6916009)(8676002)(6666004)(2906002)(956004)(26005)(66476007)(66556008)(66946007)(6512007)(186003)(5660300002)(316002)(52116002)(6506007)(4326008)(508600001)(2616005)(83380400001)(38350700002)(107886003)(1076003)(38100700002)(36756003)(86362001)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qmcu1b6B8R2U92boNKu47OYsskUZkPWIsIdqXuRZg38sQF3EjO9NGK7pygetx7Mg5rfaq/ViaWnBrx7WWQ54N617j8mQVvtzDRLPThPfhZ8klGNC+WPtVjD8pj0qwh89i6xo5P2QnKzJw4oBpYsZBKRj8/uk9A3VmvxVFRb0AsvsHkO35pU9gMuPKwduP9/Xmpn7bfOoQqMG9UnjFpJV0vKA07bAjokKFkfyGOPCzsfXM9Pu4VOj5mSnoN8wlQi4P+t1Y1lKPVcE2mUWVSZ3pCRauUW8ps/UdAqE4Lwbf8rra1gUT9cGYKftG1im5d+1JP/G8u/lizAXRRSFKCDbA71srhOum791Hv+XZK+XZLgtDUNCJIbqrT4GMjHNx38dPwhUSZxmowy0swE3GiUt/q8mPKNsEXUFYfrJ6V3z/1PacXLjtYQrJEEumJSdUHjEHrP6+g+tJ3aiHaWYlo02kWJf8NhqX0rtl+otJc2M/H2x/1nD4UCh/edu0zKp1U5Jlh3d+9ePenv7EDIZGC1nurDGiqSs+Zsv3V+MWQtT8GXOf5E2BJcJlEu3pLYaYTIbCZQt+eorLoWuMez6Z3h21ar0XcZ2pCDVF/W9TuMBOCHQK4CangBUs2S7ks5o2SedlbpxEtYKNwr+Iq+Rme3dSvpw2/kiTqlkN63U9wmBI5zJY7Oik5DuYJMGfRVfxUCfxAE/Lt7Cq2oa2iP4QJjOpyBUVu9gYadw67qO38ZdhvgEBKLux2Rpe5ncAnmjgbSy6iLjdOLsdYlnTmwhD+rvp2IGRqnyWK0royiDZUYSllsGEaktg0JNwJcjA379jJBMUYnf8rEwMX7Xt+2oi/uPmwOwcF4/SugYqQONYUKwGWAbXjIFsYDt3iRNBimCafxr6g2Y7GCf4Ecid5cH829HlBRCtsZrcgK8yJKygaT7+cgQVVoNFlz1/Kl8dZhOR9v3Aq/Tpajw6Zk90+Zpg8d0LjCqW6saFGWU7WyjD217LKHezNmGh/kuO13E0zCOLVMf8stzuNoLmJM3L0ss3xa/DPJ3XHcvP0lMqGc8+23A1NVRv6/peb4FrhK9tbxuJ+cFgLnk8vYsjssztIG5V2qPvtYzFyNvbQNHlIuFkZ7HB+qkxVnWNnsX5qyp8mRC/oZs7KKWHj5GHP3QbzzE6HbDA5C7o+t52erUcTD/dtk/hpUs9/fQUXK7ih0kuePXo+qgoZGoqUAHUkmsJ7gArL9CHascK14xDORxw4pqWcvoeAG5nz2fKrFvdSPRYlOwFoHyLPbXsfvtxaqHSsoddiWkf2F9/91xteuEIzEDyiMhRA8t9AQ1DaPAkZhw6+2VMosK X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43724654-8ddc-4689-255a-08d971698827 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2021 19:07:12.0811 (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: 70yP7KKiqJRF4u9yuY317uyj/mRNih2/QdiI93yWPXmoAnz167g1caZV1iuMAEYefk01WLqVv7vnD35VAdRavJ7e6uHqe/xeZW4+Iq+xaN0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6038 Received-SPF: pass client-ip=40.107.20.98; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-DB8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It is useful when start of vm and start of nbd server are not simple to sync. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- qapi/block-core.json | 9 ++++++++- block/nbd.c | 45 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 6e4042530a..30d491bcd4 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3994,6 +3994,12 @@ # future requests before a successful reconnect will # immediately fail. Default 0 (Since 4.2) # +# @open-timeout: In seconds. If zero, the nbd driver tries the connection +# only once, and fails to open if the connection fails. +# If non-zero, the nbd driver will repeat connection attempts +# until successful or until @open-timeout seconds have elapsed. +# Default 0 (Since 6.2) +# # Since: 2.9 ## { 'struct': 'BlockdevOptionsNbd', @@ -4001,7 +4007,8 @@ '*export': 'str', '*tls-creds': 'str', '*x-dirty-bitmap': 'str', - '*reconnect-delay': 'uint32' } } + '*reconnect-delay': 'uint32', + '*open-timeout': 'uint32' } } ## # @BlockdevOptionsRaw: diff --git a/block/nbd.c b/block/nbd.c index 306b2de9f2..38a503102c 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -80,6 +80,7 @@ typedef struct BDRVNBDState { NBDClientState state; QEMUTimer *reconnect_delay_timer; + QEMUTimer *open_timer; NBDClientRequest requests[MAX_NBD_REQUESTS]; NBDReply reply; @@ -87,6 +88,7 @@ typedef struct BDRVNBDState { /* Connection parameters */ uint32_t reconnect_delay; + uint32_t open_timeout; SocketAddress *saddr; char *export, *tlscredsid; QCryptoTLSCreds *tlscreds; @@ -218,6 +220,32 @@ static void nbd_teardown_connection(BlockDriverState *bs) s->state = NBD_CLIENT_QUIT; } +static void open_timer_del(BDRVNBDState *s) +{ + if (s->open_timer) { + timer_free(s->open_timer); + s->open_timer = NULL; + } +} + +static void open_timer_cb(void *opaque) +{ + BDRVNBDState *s = opaque; + + nbd_co_establish_connection_cancel(s->conn); + open_timer_del(s); +} + +static void open_timer_init(BDRVNBDState *s, uint64_t expire_time_ns) +{ + assert(!s->open_timer); + s->open_timer = aio_timer_new(bdrv_get_aio_context(s->bs), + QEMU_CLOCK_REALTIME, + SCALE_NS, + open_timer_cb, s); + timer_mod(s->open_timer, expire_time_ns); +} + static bool nbd_client_connecting(BDRVNBDState *s) { NBDClientState state = qatomic_load_acquire(&s->state); @@ -1737,6 +1765,15 @@ static QemuOptsList nbd_runtime_opts = { "future requests before a successful reconnect will " "immediately fail. Default 0", }, + { + .name = "open-timeout", + .type = QEMU_OPT_NUMBER, + .help = "In seconds. If zero, the nbd driver tries the connection " + "only once, and fails to open if the connection fails. " + "If non-zero, the nbd driver will repeat connection " + "attempts until successful or until @open-timeout seconds " + "have elapsed. Default 0", + }, { /* end of list */ } }, }; @@ -1792,6 +1829,7 @@ static int nbd_process_options(BlockDriverState *bs, QDict *options, } s->reconnect_delay = qemu_opt_get_number(opts, "reconnect-delay", 0); + s->open_timeout = qemu_opt_get_number(opts, "open-timeout", 0); ret = 0; @@ -1823,7 +1861,12 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, s->conn = nbd_client_connection_new(s->saddr, true, s->export, s->x_dirty_bitmap, s->tlscreds); - /* TODO: Configurable retry-until-timeout behaviour. */ + if (s->open_timeout) { + nbd_client_connection_enable_retry(s->conn); + open_timer_init(s, qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + + s->open_timeout * NANOSECONDS_PER_SECOND); + } + s->state = NBD_CLIENT_CONNECTING_WAIT; ret = nbd_do_establish_connection(bs, errp); if (ret < 0) { From patchwork Mon Sep 6 19:06:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12477259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C3DDC433F5 for ; Mon, 6 Sep 2021 19:13:34 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8DD1A61051 for ; Mon, 6 Sep 2021 19:13:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8DD1A61051 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:39862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNK3g-0006c7-Pt for qemu-devel@archiver.kernel.org; Mon, 06 Sep 2021 15:13:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNJxg-0005YC-JP; Mon, 06 Sep 2021 15:07:22 -0400 Received: from mail-eopbgr80094.outbound.protection.outlook.com ([40.107.8.94]:32928 helo=EUR04-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 1mNJxe-0002Fk-SR; Mon, 06 Sep 2021 15:07:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P4Vrl83jK96l+0rZRSglNnR3Fp0xpfPiUGV/Adj8GFD8v3OvDzzGy64Chy7KxJs2+jxtW55qyIAKEpHdTvaXQCq9ivMgNOQcM+et8vWLRcYJBdPKoS3GncUwEjoUS7zlkmP/R6i4OUZ+T9XYijCJCLmTuNqv1IS9E8YfeHVIsg5U3nILb12CP2Kv22FchEXd/HR8p4UCc3uq3s+jMKs9g5tj+wS+xHtkfnJpOL6gc8HpzWdonuWtqRAh96RVQZ/nvS+Kpun+81NgosZrZYKFQKUdoySiPA4o+SloLULtDy52P4wKt+HZZlvBMXy+6YOdsytbCUsDWi3lQeTgZ2DMDg== 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; bh=olhceEPcDgwANKJ5IyWrlE3Txa+c9J8WUlRSe3y66yo=; b=k7BZLtFcmWEPqqpULBrEIKSih5D1osOLk0SeO9JUFFgOBOmQJJludsZBKLhtvd81srCpr390K7tHzPVmLwN3p2Fc98h0b8e1Pz3MeevEOT/QhFz5ma6y7DUCVSVdgodiPUbYepL7z7Y4MngiEp2fPiPsjfrpcQMHW9816U7gJMOeWKd16JLraONTm3YI/6ipIVfCSR2agLuv35wCtzNI/XLwS6OuLWmVKtGiNxVjxiowhJ42wyqG6SQFlbddCcDUseKUPJ4UemSKpHqU43stXm7Yhc2H2PoSkYGhpTWwoE2vz+otyOHdShOW1LqxPp8TK17sO//oMO0gnzFbAjAYJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=olhceEPcDgwANKJ5IyWrlE3Txa+c9J8WUlRSe3y66yo=; b=GWAOlEjlUClvYpykPYNL1y+9bLk3Q0bWw5qiS+ngak/MjMEbLJxfMymF0Ugs3ouGXJBHteOxXG7FIQpoK7sObnRrhTqHCZ1Ms3EUNqUgUOzOPKImEeZoB/NKs77EzEKKD277iJ3yrgaHCxuAFv17z4rkTTidOjCBvHZnpmXRMNc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4849.eurprd08.prod.outlook.com (2603:10a6:20b:c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.24; Mon, 6 Sep 2021 19:07:13 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.025; Mon, 6 Sep 2021 19:07:13 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, den@openvz.org Subject: [PATCH v3 4/9] nbd/client-connection: nbd_co_establish_connection(): return real error Date: Mon, 6 Sep 2021 22:06:49 +0300 Message-Id: <20210906190654.183421-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210906190654.183421-1-vsementsov@virtuozzo.com> References: <20210906190654.183421-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Mon, 6 Sep 2021 19:07:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1928ad7c-8532-40d6-fe6c-08d9716988d0 X-MS-TrafficTypeDiagnostic: AM6PR08MB4849: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1OGni1z5jyzWWZOszkFGYSan+lyTRkiDH3aZJ62DGLhv41NKRuq6U5dx1yJu4dRH8EVAoi0teIJiIKzksBp/vQ3+jQGZy4IVDfA7kRnmuL5YoXBHg7i58rbIX4xf5fTofcupG65EOdxhut6Ee45O77dSO3mNZXuVqTLzp6VQrDdT3UxoG/GO9JSYu5pZ26RAqhjIer3LiCaKdj8gtTdY8IbmiFzQurJBYCHrnDUfIw6LMbPsvndqBcpwEhHSmBzRIkdal/F2p5bP1oJSugCoZRqcBJm5vNr10N8yfOLakfHtZ4VbJyAOJmt52bFIhK24Fese/Nfsd81szK77y1ME75uWMqhT4u7tP+MwwxSiiqmqLXlwuv4rAY1jLz5rKc6ww++vKd6pXTowH9iUzVzoi5D2Tn9aQ0ccqYTMNjLEveQqHkXF9z/bqgioQKWI14MgtaBSzo3e44fzGnPtCiqbT4WoSqWNY+VL7X+Z5cnoOtQCjNV1AYbBBgIXqMrUz1k9bq+QWC5j284WY7FaerPBHsRBr0AQ5kvEs+DyNNOAwtHnkcnD3LS9KvrPjb4m3q41dr/8xrqcFxwgbTkGHFlhVyRhB2jAW24a99Squ09qOjdkVNsE+HUW1x3QfYJRs0PDTXSsC0B0160PL4Ymje/USxJCBIQz+IALRY2SQRfzVbWfnd7AquAtJIRr+cLTxdVBw4GtO1hUxsjg3Uvh0FTIPA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(346002)(366004)(396003)(136003)(66476007)(66556008)(38350700002)(478600001)(83380400001)(26005)(66946007)(8676002)(5660300002)(1076003)(186003)(38100700002)(52116002)(2616005)(4326008)(8936002)(36756003)(107886003)(6506007)(86362001)(6666004)(956004)(6512007)(316002)(6486002)(2906002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kXLXUw7fzowTWx2LjU2pG5IqZaERSva9Oq+QQw6V1S8WAzMhLdaNw7cA2ZnUqQPdv0znyPnxhoVFhsv8Gg4cBWJ9L1d8L8syPLdU2/jHHf0xeLg7jSV10ZrmqC8vy8rc6jyU4m1LH8w7IrGqm0s8P/uUKJW+sZg6xYsq8WM7JKxFPjua5Y4hjJU6RK53dJwIbgxZwmSpposScVWrKiB9htiNoRu7DRmUiaflIeUSvm4Xy3rPMfMwpk78Cm/2WZp5dYludKOwToxmAmuAYft8mdpjNbOQG/ydf48d/jdjvyXcI+b5mDfJsRKUcvER9cBEVfLDKqM0G9qem5YAygQo4bO+DExZM8JWULIHQTmdQEL9B7Qw7n8zMvoS+YbNCBQdLk3qbc6F3eFtgoCiEU5bACzaTX1IpyRRAS/e9y0DrbxiUjE0x6sOnPuPQrSEdPqS4tWdjgwmsCzKEX58a82hVeN7C1ONm4EgQcmBe/WAMox6N3SUoUsBDPMSej0H6OEl/iLWnQaSvclramRAx1IwB24oh4OQx4Ef6QsqffofgBHFaRelYUs2by/dDyMe4wYRhxkpchQGvalfnj++XSeMtQgSaNFsXD8Oh3MxTB5mjKISy58UDJgJ+3bQcxNvEVBIIv04ZGxhi8jKGN+8fCMuObhSGMOgSElVvV7O69FLbRdPm5uB9pzxwCEbYUxV1eU9/j+VnmLWjGqMrkEWSmuPlQVmLaq7ioKtcn5UeHQTgUIA+JIWUQm5WjKVRZ1AmaMSmZbBn9QghJsszE6Sxcjqjw4nWM0I7NFBkdfdu4FsrIoGRgXSg/CicbvXg+vVWl9dYx+nqz1+DcdTjmyTqeYl+aBsLo1PWXOedyn1FBtAlE1E/QTRJGdQYuG8iFboFi491w8GTM7RcNan0O5JVkXHe8HHob2XFUUpbc+JrjAMJl+I5b37Gc4AkQJ6SjKTeov1hDwaFr+2aekV66APOosxBk9LQl2BxMjGB0ywQ9RS1nHmQOz3p8T5OR27vuYIYSxMZKiR1jzKhi63Jmwi/BoVuDQId8u84Va1wqjbjLRCi9e5KtqnQtOU0oVvV3dXs/9LiDe5Ocp1EbEgYeAPRTK7Ic34+NgpkuyJCE0i06JtFn4IJNe6GAD5I+vNosY24wMzUXZ2fVchpZrtH+YzNL+ezvY91Sw0aj8zyPzlBjYrgcwjWM22e2EPxlsGZOjyDtpiKJrZ6AGrSIkQKTpiZAwYmqB+YL3/xKY7E2r1qmSqiVhW5HD/Vm6izFWC79vXJ0M5Dv8x9Ybp9oSksGBbvoEBLY22PyRr35qgdyLiiHdWPKVeuecyqV4B90L6L8WtWw1V X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1928ad7c-8532-40d6-fe6c-08d9716988d0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2021 19:07:13.2012 (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: 67rPNnq/JKzUmMDQroDONe2qqyirw0xjQO0F+HvlWB8eAqNVAej7QBHl7pnxuARplkFWTPdg2lAvkukC2w7q2DGsaiCvcnuXfGXo9M4BRc4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4849 Received-SPF: pass client-ip=40.107.8.94; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The only user of errp is call to nbd_do_establish_connection() in nbd_open(). The only way to cancel this call is through open_timer timeout. And for this case, user will be more interested in description of last failed connect rather than in "Connection attempt cancelled by other operation". So, let's change behavior on cancel to return previous failure error if available. Do the same for non-blocking failure case. In this case we still don't have a caller that is interested in errp. But let's be consistent. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- nbd/client-connection.c | 50 ++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/nbd/client-connection.c b/nbd/client-connection.c index 695f855754..722998c985 100644 --- a/nbd/client-connection.c +++ b/nbd/client-connection.c @@ -39,16 +39,18 @@ struct NBDClientConnection { QemuMutex mutex; + NBDExportInfo updated_info; /* - * @sioc and @err represent a connection attempt. While running - * is true, they are only used by the connection thread, and mutex - * locking is not needed. Once the thread finishes, - * nbd_co_establish_connection then steals these pointers while - * under the mutex. + * @sioc represents a successful result. While thread is running, @sioc is + * used only by thread and not protected by mutex. When thread is not + * running, @sioc is stolen by nbd_co_establish_connection() under mutex. */ - NBDExportInfo updated_info; QIOChannelSocket *sioc; QIOChannel *ioc; + /* + * @err represents previous attempt. It may be copied by + * nbd_co_establish_connection() when it reports failure. + */ Error *err; /* All further fields are accessed only under mutex */ @@ -170,18 +172,18 @@ static void *connect_thread_func(void *opaque) qemu_mutex_lock(&conn->mutex); while (!conn->detached) { + Error *local_err = NULL; + assert(!conn->sioc); conn->sioc = qio_channel_socket_new(); qemu_mutex_unlock(&conn->mutex); - error_free(conn->err); - conn->err = NULL; conn->updated_info = conn->initial_info; ret = nbd_connect(conn->sioc, conn->saddr, conn->do_negotiation ? &conn->updated_info : NULL, - conn->tlscreds, &conn->ioc, &conn->err); + conn->tlscreds, &conn->ioc, &local_err); /* * conn->updated_info will finally be returned to the user. Clear the @@ -194,6 +196,10 @@ static void *connect_thread_func(void *opaque) qemu_mutex_lock(&conn->mutex); + error_free(conn->err); + conn->err = NULL; + error_propagate(&conn->err, local_err); + if (ret < 0) { object_unref(OBJECT(conn->sioc)); conn->sioc = NULL; @@ -311,14 +317,17 @@ nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info, } conn->running = true; - error_free(conn->err); - conn->err = NULL; qemu_thread_create(&thread, "nbd-connect", connect_thread_func, conn, QEMU_THREAD_DETACHED); } if (!blocking) { - error_setg(errp, "No connection at the moment"); + if (conn->err) { + error_propagate(errp, error_copy(conn->err)); + } else { + error_setg(errp, "No connection at the moment"); + } + return NULL; } @@ -339,14 +348,23 @@ nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info, * attempt as failed, but leave the connection thread running, * to reuse it for the next connection attempt. */ - error_setg(errp, "Connection attempt cancelled by other operation"); + if (conn->err) { + error_propagate(errp, error_copy(conn->err)); + } else { + error_setg(errp, + "Connection attempt cancelled by other operation"); + } + return NULL; } else { - error_propagate(errp, conn->err); - conn->err = NULL; - if (!conn->sioc) { + /* Thread finished. There must be either error or sioc */ + assert(!conn->err != !conn->sioc); + + if (conn->err) { + error_propagate(errp, error_copy(conn->err)); return NULL; } + if (conn->do_negotiation) { memcpy(info, &conn->updated_info, sizeof(*info)); if (conn->ioc) { From patchwork Mon Sep 6 19:06:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12477271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ED43C433EF for ; Mon, 6 Sep 2021 19:21:23 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7E4A860240 for ; Mon, 6 Sep 2021 19:21:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7E4A860240 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:56122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNKBF-0000nu-AS for qemu-devel@archiver.kernel.org; Mon, 06 Sep 2021 15:21:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNJxk-0005Yp-6G; Mon, 06 Sep 2021 15:07:24 -0400 Received: from mail-eopbgr80094.outbound.protection.outlook.com ([40.107.8.94]:32928 helo=EUR04-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 1mNJxh-0002Fk-UH; Mon, 06 Sep 2021 15:07:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SoqpLK9ds1l3F3l9/knD4KXmtaw9DuF9YclG7O4QBHJUzpLpHeE78nFDMtswHD7472n5DhDc4/407N4tn+dtAmjhH2IGNQCbbjT4v+p6lgYRYy/hcdGQm8+UvZ3WM4NmiOABl3ByeLQYp28ee7y8dB77wKy3QOSRfsfQD47vFVNGayqp37KvM7i1yfN4zWzT3iVq3F9uAFxX6mkPLactMNV3TjYqh4IJL+8QHcl7tNKbLHG9Qi1iLBDHpFO+Dz0bJFSGl9FCCDEe92PHhG/kea+PPWxssUQ4ywoM/8y9hjkA0nujrUvkLcY7TPvxkJg7DzSssbNTNoDdyoZTWIJnUw== 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; bh=PBowHRJXeSxZMf/TC7/DloqiOgMrP0SU5ZXOb9raffw=; b=NENRV4mPbaKjx12jie4+K4DYmkKRhXreqpzhelrXrdTIScqsfAt2jULmng3Nn0qQKbCcb6Y9lERRwTLQk4n12S1cUsbwtXRKv2+YG63dgUhYXs6cr5EvBdtZ7/YSy7sf35nYlQ9vWwWI27PbIIyfSf+XgJaUCkXlUzQBu4T6XGO2cxWhK6ycsSuUjZozi5zVbuQmmQam6UH4WqTE0gvhHIa4NmtQW7otMDdJAldwxB/91QU/IAYzaFsCF+eCL8VOgRohMY0WwBh25VeTlzaHASTDifoc4WI3GLrzEAQZ3bsfRg/tnEpLp2s29ce/wbhjD+VcYEfch94cTPe2M84rOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PBowHRJXeSxZMf/TC7/DloqiOgMrP0SU5ZXOb9raffw=; b=OyvPBJfpWs/q4NuAHK/YNT2hsmAhjjOWK79zYhZAIM6gKOfm/qkzzKIJETYEFzIKqwxFiDRIPfJ+lX8TlLGuUbBDgzRZOfyBibeziGbkYgoiO2HK1RXrcnidMPAMO0ToIndwHQ12qT/BC9pQJ6l1yURQCpqQozrTrIbfej+EikU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4849.eurprd08.prod.outlook.com (2603:10a6:20b:c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.24; Mon, 6 Sep 2021 19:07:14 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.025; Mon, 6 Sep 2021 19:07:14 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, den@openvz.org Subject: [PATCH v3 5/9] nbd/client-connection: improve error message of cancelled attempt Date: Mon, 6 Sep 2021 22:06:50 +0300 Message-Id: <20210906190654.183421-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210906190654.183421-1-vsementsov@virtuozzo.com> References: <20210906190654.183421-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Mon, 6 Sep 2021 19:07:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bd5e259a-582e-46a3-3589-08d97169897c X-MS-TrafficTypeDiagnostic: AM6PR08MB4849: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FXaMSo8AdJw3L6hms93BHIbMcaXBS0tEqP8zJAEJX3Opw+6HXrSXvYFuduznQposKekLArbWysGQUY//+HdI8sSm5BMt68PWfz9W42+daBvqTbjuQiLyw3RtkIYFq3ENRalRICpbghbtLWzetYwifnDHBR9vJBKc8xcJQ5wbo6eIFXBYjnGTzV47wsFp5f0NOu6Hj7rY1Ue5lvlYCYubonCzgPNrdq7nKAdk3loPbqSp+KqfSoxEdAZM24ckfJTF6WrjrqPBNfkVQxOb/Td38sZkItFGxa9i2VbYq6tCdz86cDaa1gkkC5Hb1Bc+naU7FTITvJrwLSLrf9vIg/dxP+KtW/absM0JF8dGTDTPEOK+I9GrXc5q2TnxEmgd4e6jvMmPIHHRQHWxAoA40USy3H4dKks8536I1aFqnwhcPxZssz6gSmbNBMFabOH6m0ySlcFeE6vj0I6MTFm9wRinP+VA4zd5bFOmA4UJYEs8k6p6SYLDbPT5wjPxBv1TEkqOv/Ko5+o9xTcj5UsQhP4N/hIcMVrLt9bw+pQn3qgNSugGKfQXgVJSh+H/PMl8Rhbswf6cjiAPw78JRDVZ8i/T5uemj/n+Pa8QwJQ4r1KmS7pY/N5LSyt0+KCLL5H3MxRoym+ornUaQw17mb76hAtdK/ubi51SmoJ5a5YxgMf4v2zfrmZt/uCIsQ8Os8yqh3YKeoWC7W61gUOniLgRpagsxQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(346002)(366004)(396003)(136003)(66476007)(66556008)(38350700002)(478600001)(83380400001)(26005)(66946007)(8676002)(5660300002)(1076003)(186003)(38100700002)(52116002)(2616005)(4326008)(8936002)(36756003)(107886003)(6506007)(15650500001)(86362001)(6666004)(956004)(6512007)(316002)(6486002)(2906002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vvacEpoOKUQdBQ9acD/sRKwNKcqJ3t+Tuul/wNO5/OEEtCslsFxC0KKUzvDBRkS/7kDAQkCPxIX0Jx9p9XbRqjDaO52jz5B4fWJEKwvxg63VPMuKQo185mTuPYzfEUnXAO4yYgVXuVp9uRckuPJZmqYsMMuqYoJq+NoeK2wmibDOGrq/R3eF6lizREd0YmbP0ZL57w3ub9fYbJaE3LqjqQlbs6/N+gwqHguxO+mllD2VmRl2E3Ihpm6QeCccxMzHYIS0n7fNKdLPqz5SXB7SidsUqAmy/LOCFGjMnR5eiwAL3BimHJexo+4geTXJd1PLwS6FnqAahMznIuOEKIA8RLu50egH74Usl0BjVG/RkKCwbdeavSsh//IgCrFXyGQKjgwHvglZYfBZbkQD9ObXE1qA0w3xGsvQjSYdnq6mE189cgLphxKlruX0BHvSVtQZT6xizOICUl4fg0OLvbYRu/eKDoGq74URDnb8gHcPstJYmpyEK6UX1AMA1+bkUcA23NaFtzyrrcsLx/6sqTrTgOCfMhIOj48TaP766PNZRA3O4atnxnz1AA22GxLmVjPa3esW49zJcRaSj5UacX0ao+2VgiPebOR97wmQVR8fraGk5vyo3zGcV3jCvrSxiz7/4nEhIRQiDkBJ9ZiROgPL0aBfmI0oXaQFE23EXgxJEziMZhaUDJCLpGrfe9792k1UEBsk593gez+nQbq+CFuuMpmT8Y9edtSj/VdlyHDdF1RM6SoAyXuGmyF7nj0y1ahRXZxR/JZHdVcKpFtxgkjQwuLLn0ZtvNrBof7mtxMYwSa0NGhqUjWWjCEaTYqKUmCCQvehTigqyMtSUaHDvD9K2xkwo47KiS+5M6nOFbO1eynUXajTTqxlXQFEdRPtwnuAJUSBzHk1D6UpcpRrxgnQ7J8cVY7BZd47x6jujNsF1LIw0VPZ8fMzWVJjXf7mfB1BEfq49qQJOXkHV5P6hwmI2qCk76C17b1hqvEWwzyxHZCzteAp85YmdSF7OPFX10SiibE9P+FhOiS/1PUQJdQpY+xy8Q4yGToZvXOwauFuoMtxXZntr4y0NvyP9hqDBBHPmP1ba7X0gvDWLiAuVClxO2oYRIRL/bz6hrsmSli1/0Pcm8h/KRA8je8CZDSoMHTswh67X4X4pmnMTWtLGVVh5X0/Akkc5xcaYLV1CnlF2bqKD1RlXdpnbKEDGXSE+rGHXfpuWD6gtcf54iyYAoAPm2NKqnETkBk0eO1W9vnsAaTn9p9C6YNnOhEfweyJp4p4gOl8d8rRdHFHvcsuqmhkzTo/ELeIaFjTsBmS4SdJDrQ5f89nApM5sqFPc8Yiz6YY X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd5e259a-582e-46a3-3589-08d97169897c X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2021 19:07:14.3332 (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: wdA19VWm3kL484u5hoHYJK8ZcqevVX8yQY6wshVTIqT8KOqhUUzgt8LXDQNOT38dhXV3CN+Z1+aYZtrj9H+EhZOS730HpFeSMXJlC5gyEQo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4849 Received-SPF: pass client-ip=40.107.8.94; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- nbd/client-connection.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nbd/client-connection.c b/nbd/client-connection.c index 722998c985..2bda42641d 100644 --- a/nbd/client-connection.c +++ b/nbd/client-connection.c @@ -351,8 +351,15 @@ nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info, if (conn->err) { error_propagate(errp, error_copy(conn->err)); } else { - error_setg(errp, - "Connection attempt cancelled by other operation"); + /* + * The only possible case here is cancelling by open_timer + * during nbd_open(). So, the error message is for that case. + * If we have more use cases, we can refactor + * nbd_co_establish_connection_cancel() to take an additional + * parameter cancel_reason, that would be passed than to the + * caller of cancelled nbd_co_establish_connection(). + */ + error_setg(errp, "Connection attempt cancelled by timeout"); } return NULL; From patchwork Mon Sep 6 19:06:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12477261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 464BBC433EF for ; Mon, 6 Sep 2021 19:14:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8E52661051 for ; Mon, 6 Sep 2021 19:14:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8E52661051 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:43352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNK53-0000Us-HW for qemu-devel@archiver.kernel.org; Mon, 06 Sep 2021 15:14:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNJxm-0005a4-E5; Mon, 06 Sep 2021 15:07:27 -0400 Received: from mail-eopbgr80094.outbound.protection.outlook.com ([40.107.8.94]:32928 helo=EUR04-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 1mNJxk-0002Fk-SP; Mon, 06 Sep 2021 15:07:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a3kvCc7QpRKd493AhOGIuF+G8KfV2VciYPPAra3FpZNLpdsA3InFMCyob0Keie9CUtuPRM7i7Ki4RWJ0RHgzEO3e5EueEW9jG1YxXLo5UAMmzcvLxobit4/GX3br8iW8flBnE9FYBleJZRNGSaZVg41DADfm9KoLVfe36VhgsacdW2jWnIOoNiNi+SHmRnO0wAgX/NqMkBk6HN+jeqXGOUGHGhIlJUjdTW8+R2sbWGK2DRIWpEjeB8No8n3VNYt3KsFyw6G2MRYPGndyKJasoE3GYSKp9j+LgccyuH5VrDVPjxEsxIGZyDzOiYsRp5Ti0MglebdhDHUxDXdTyGafBA== 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; bh=zMF/6wu1+dnI35RF1X1ZIDaL5AGb7fYHv2cyajliO1w=; b=leygk8ELtjzS7A05/pzYrWen/5204kB9LvWkVDlU8upG2DZ5J7yM61LrGM1WNJPjc0vT6eaERWF7EbGDe0dBiR46EG/t/ScUk/nIKEmxkWOq95VCfIRd9OSwg6zV9BOIY4y+Ba3GPrE/oepzDbYFihsvot358sfG0RiQda4xU/wHCg7BQWMSaYGzyq+K+8C4bJM6lybZ1zrCyO2+rHjpad9p5UGONAZZu/js49c9kGsvNxD8gBrtTT+gmFBVtmRj7BfehwfYBKLTh95xHp1anaW8DykChmjeOeEWTSTlDdOYqzxhrFHe5zbe2lJ/Ul5U48LEpTcnmpdYu26B06YZyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zMF/6wu1+dnI35RF1X1ZIDaL5AGb7fYHv2cyajliO1w=; b=f66JQ99I6Jh4vym5VMlNANGXfPd6JjeozyqK6vN7h2ae3G8f+f4GqDwDa4W02srhx9UrOmv83/PyJpaE43Al5MD0FQjGKBjY+TDSSyiZlF6NWWZa3vaopw5i/xc2uJbWhr24fjDH9V+0JaXcckJ9TUgwhlSAPLwGmArc3hS6c0E= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4849.eurprd08.prod.outlook.com (2603:10a6:20b:c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.24; Mon, 6 Sep 2021 19:07:15 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.025; Mon, 6 Sep 2021 19:07:15 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, den@openvz.org Subject: [PATCH v3 6/9] iotests.py: add qemu_tool_popen() Date: Mon, 6 Sep 2021 22:06:51 +0300 Message-Id: <20210906190654.183421-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210906190654.183421-1-vsementsov@virtuozzo.com> References: <20210906190654.183421-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Mon, 6 Sep 2021 19:07:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4504b478-cf4a-4334-c7a1-08d971698a2f X-MS-TrafficTypeDiagnostic: AM6PR08MB4849: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wv3Ubdlae9JEomMUP9QVKKjPDfI5/5NY++h0C3bl2iSy1TRPi2Hq1fJntvWMiTz9L7NOYYdfFgesFiwtXrKizr3KIRgOoX4fuSf3qxO+30BYNpGISrejSISpRsrlhR2BSJICiQLlAGFD1ASRKXJ1ERk8ysFDnAJQV5UrLxNzfUrny1hO7mlxBvT1Gpr9a2OBuOJJk/t0c57PC1biVnlwI2yDtrY+GHcqMMXAeTtoXZCIbqnImEH3n7Exp7yIcpvz6B/oRXOoBk/FfgEGRTuB6OWT5tYOJfQQqOM09S9k5+2uY2MEop/w9eBRVlIFkeibPhjEmqz25hJ4wMgEriX00dXHL2919+TpzXJNoaMtMb54a9ZWygdnDHJoGhwZOlm/VTlsm/fmWpZGvpbJb/zteGAMLhfn/2cGVQvPAKbH5UR8ItmsozFzfF3sDB1kQOfqU1bO+l3b80H9YkRzoK70e9JsWreKinqqDWfL3p3pBDeYiOOUeh1H2rK1aU96+CxrPxU6nlmooka+JJDUWqbolEZ6KEksa5zujarHXexmzNPp7HF8OhQaFnIpyTluBjSZ3vj29ynFK8O1nIzxz+aPVcvLK76fetD6uKFjOxQLTyXAbVpJ7D8n4Lxft2s59VNUJf2nCqivY2bLLuVDqPV4bIhwhUveuIiZ0rWWQfMhKRF7JwC/GRA+lif9DkXOVzPKlb2uCHfvXDOdWeC0B6R2Ew== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(346002)(366004)(396003)(136003)(66476007)(66556008)(38350700002)(478600001)(83380400001)(26005)(66946007)(8676002)(5660300002)(1076003)(186003)(38100700002)(52116002)(2616005)(4326008)(8936002)(36756003)(107886003)(6506007)(86362001)(6666004)(956004)(6512007)(316002)(6486002)(2906002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YE/yZYN5Nk0C7rHSfruVL6nHwerPH3GxIjD4/hxfsojUhc1PTPw7e9zGuSkSY7UaLfXpBDoKPeVwXKkioeVVJz2Jy8Yrgt11C4jhQb0+ozTgbGAwyqRLZ+1VIqDyfCUT63kXH49+HbUzg8cEd16JbW4WgxW//oSH2W1+sXp8hHoM7lYBoIEm3O2I+6V3C8kO0f0zLWoKxd7e5GpHKNPhBmuhDAVIAsBeBBFW1qLzTCCgRg45a6r0RikJLyMqBsmJoEJrBqHKmbH+yJZ76ueG7pr4P/CU27bikMfpatLB24/9SYk5ncPPQMimzw3uhyF/q+6b9+mJyVvab5Pjwpyjt0f9v1I7h8cJocribcoRbcneaiyGLv1I8tg84X7BhsavLVW98r4PS5n8u54CxQAEn2GsQrc1NOE5hsVx0zicyoFhVgntx21A+pJ78eQ4UCM3ImwuwRJSKX75zmQujrAirYzJCziKCezL/7u4n65CN7ZqllIpWB5iWnY7b7F9CM/fbSQoZ4ID4f/PFIgI/wbdGvGw1ec05mGpAssAM+TMq6NibzxilfAIVP/JfY1fP4nYNTTQDETPWByru0+K4tKsVSui5z/pELPTKUdr3mvwjDr4u9OUU/enkFgB8xah8dYLXLHz/J0dXD1gofYFSHt23XKHLdbaSKh9/XazjG+QvvdzCsKIsefSwkSSGP0Q57SzPEbtezE90PpmP72fAMj89//0lo3kQSPNEbjELenIXoZo0pFvEEa9vgLvcm6GchWg+19ZtaOqSXJRZ9Yg/BqmstmuEbDEgXSj6C5CfeeH4a5EGRKfVa3OczNWXwPapdnb+hYY6rJDNuOhUlg5HESCnfNvw5gNOQi4H25cT0kKvbvyNXdWjw6Fvx5/INDQo4Q8klDOKks3B886fEGjw8OOXhE1bdHsFnZM+vhS3C6dLX3F5qTI209nMNRo2REUtIEn+BLK6cXeYvDMZFnWatwOrf1JHMYlk8flFINwOg1o/w7lQ+CgtnjyKnJHZwE0KgYVfp4Yr01hufrqCunNAbcY1MzrZ8vz3exKI3rQgK+loZWVbpI6vPAexgJdwERpdmwch1vgpSK0QXRuR7l4T3ix5fEBaZVif+z6EJlXSTjyInw3/MJ0c6nCpJsFj7fZ8kDRbAcL3JzoVs3ztTc4eig8kWLEkKsfNzelaqP5j86XzFqXSToPm5X9wseyPzAwZUHvMz+88AG445YLugSgjFE5RdpjzXIx28mRtDBbQzIucl1dcriJZEq/EdAfBHBfOHiSvSZy33Z+6Fx2yw9a95OBZt1L3sji7yc6MmBtlQQl1dA5M649CdLJgunjoYb8rPSo X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4504b478-cf4a-4334-c7a1-08d971698a2f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2021 19:07:15.4901 (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: h57R3jsjvJC/hMUHe1Mr/wjB9gZE+UoSQiTs1DMx80cJL3fHFrEHzet2k+4Se3Mq5bQ/L4/nLkr+ZDs4GTr5QTzYA81R3mixmhQbtrnOTq4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4849 Received-SPF: pass client-ip=40.107.8.94; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Split qemu_tool_popen() from qemu_tool_pipe_and_status() to be used separately. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 89663dac06..b518545c09 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -106,14 +106,21 @@ def unarchive_sample_image(sample, fname): shutil.copyfileobj(f_in, f_out) +def qemu_tool_popen(tool: str, args: Sequence[str], + connect_stderr: bool = True) -> subprocess.Popen: + stderr = subprocess.STDOUT if connect_stderr else None + return subprocess.Popen(args, + stdout=subprocess.PIPE, + stderr=stderr, + universal_newlines=True) + + def qemu_tool_pipe_and_status(tool: str, args: Sequence[str], connect_stderr: bool = True) -> Tuple[str, int]: """ Run a tool and return both its output and its exit code """ - stderr = subprocess.STDOUT if connect_stderr else None - with subprocess.Popen(args, stdout=subprocess.PIPE, - stderr=stderr, universal_newlines=True) as subp: + with qemu_tool_popen(tool, args, connect_stderr) as subp: output = subp.communicate()[0] if subp.returncode < 0: cmd = ' '.join(args) From patchwork Mon Sep 6 19:06:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12477257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FDF2C433F5 for ; Mon, 6 Sep 2021 19:12:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B51A961051 for ; Mon, 6 Sep 2021 19:12:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B51A961051 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:36578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNK2C-0004LR-Ut for qemu-devel@archiver.kernel.org; Mon, 06 Sep 2021 15:12:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNJxp-0005bE-HZ; Mon, 06 Sep 2021 15:07:29 -0400 Received: from mail-eopbgr80094.outbound.protection.outlook.com ([40.107.8.94]:32928 helo=EUR04-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 1mNJxn-0002Fk-1Q; Mon, 06 Sep 2021 15:07:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HnqeFSGyFn8WIcZjvIxCLpEKGH+C4bvUAsr6CmacmyuyE1rovFNQwwYBdNVxBRxptxxc9qqAii7LVnCuhMPVW+D+BBSX1Ii1BVyKyKvoH00jAtMU4du2MiCMe+a4oOLf1UeQAMZdqiKYQIWk6JQi0QTINyf2Rm0OnzXjq7sY7ALQl+gohUzuxVdx3Ko8tvUirS5q+C9G4Aou18wCQ+vh8ShAocfuTbjmqg4zFELN8ttShCKspblKQX3DCdFD4HU0UdXMe7w3eyFy+UFBCeMDr3ffoJObUDDYrLDWgq/wiAMquSDj3AyhzCNmUgnJcQKK5Ne62NvfZsZgQwDfWkwCQA== 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; bh=QYwyXZ4lu8PCqVuc2tVoVFwh8E/nuIT35XSCaYWP5Ng=; b=WEcDZEei4X45aHmWYQP8vHuMoRA3TMErpN/5Ptntikgamrhb1aruzGBMpZimsEQQSh+DrMvXEZgoxhHrwyDnPazG/NFXBh7KVZaLfyJ4s6iev8OwWzXrT7uSsD7KPCOTUiVv/Ca829MhXy6mGlOPaclsYKRBawG2psI3qwK0BicCOkS2qet3cXN83Vd1noR5Fwd54oC/LFNplWM5NYZjJdAu5QUmTVBGf+d7yBz672TV8aFm3eKepTLzXGDk5nB/VXDzcWzD8ZupjDuhTCdzSGrRs0vDenkZwRlWAJuf/C5uI3uJJ94gn1f2gyji3QtQq3cuzJxH73pYBwDnORKL2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QYwyXZ4lu8PCqVuc2tVoVFwh8E/nuIT35XSCaYWP5Ng=; b=glvIUeNp4U66SM6OK3DeQXJDdRgvR4vpKRGwRBGAhvQ5mxTpQWXiARF8OkiReOcnYU4s4ZVARTihXZlGoeP94Jxkmm5eZF9ma8tDgbdV+NgkmlEgYWLaZAn336sxQHie8057Sy/6BjxxLcv1C0zplnwART4Lhh0GIgpN2NX6ajg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4849.eurprd08.prod.outlook.com (2603:10a6:20b:c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.24; Mon, 6 Sep 2021 19:07:16 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.025; Mon, 6 Sep 2021 19:07:16 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, den@openvz.org Subject: [PATCH v3 7/9] iotests.py: add and use qemu_io_wrap_args() Date: Mon, 6 Sep 2021 22:06:52 +0300 Message-Id: <20210906190654.183421-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210906190654.183421-1-vsementsov@virtuozzo.com> References: <20210906190654.183421-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Mon, 6 Sep 2021 19:07:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ac51531-1694-474b-bacd-08d971698add X-MS-TrafficTypeDiagnostic: AM6PR08MB4849: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2U7bhn4ZLn5vSc87/Ue+Dricm+38gg1hg+iNzBWALxCOotD0GI0TpjVVcINz3+1ffgpDxEGeAPzGXcO7J7ZFaWwLlcp3rriYy7BDYysZsaRT0VppI6tHXnpFBDWWTFDknwTJwEflJdtp3QayVCfdQ5dND5McDN+AS/3dvRmZD7cqY8rgS5nKA7NLdBvhxS/ku9b1CFUDeFTPYZTGuBdluS7yCynTJQyzIb9Em25tTU0TE7hw655ETM7tUvow9mxajs1Izm68U4joYfDkA7nOFDzpHSjd+d2EyBwjMetEdBXaryqU/cB7ec28me/5jjRXC9qLSqBh/eAoj9WiRctePnj9aZYMat+x7p7uHnwZ2Q8cY1YQtJnai+389yKcjAgQ/OeNZc7/TdhVyN5h0mPzVZqJkPhKYlKeO01aZ8KWcnatjAlX/5ILBqPmtZ/dbSb82tV8G0NCUI+2xWJq9jZ714X/ApXhvO5DSRqKXVFQ1pk4eQ9tKkk8cguW0Jxw8bUBsyDbMJiGv0ptX6lixu/9w46GzbTfJA2s9EE6Z48NAd7oPfYTpVe/P6eT7fnm8pWGJ+MB8EFkz59tEYERNmG06qxjZY4D/kGjqMH7eoMaegMeRBD/y0kAw68FlzYw0nZjiBCFoytcogatHiFTNGUdJqDsb5sCoGfwdz3EheT82FtTyPQhMXnLxPU6RWaROn7GRLt/WRfTREAzue0z36rPCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(346002)(366004)(396003)(136003)(66476007)(66556008)(38350700002)(478600001)(83380400001)(26005)(66946007)(8676002)(5660300002)(1076003)(186003)(38100700002)(52116002)(2616005)(4326008)(8936002)(36756003)(107886003)(6506007)(86362001)(6666004)(956004)(6512007)(316002)(6486002)(2906002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G5ZUv8fM95m4ypg5k8y7GD7R2Rq4VVBcisjU4UbDbGZgNMx0Uxk1pco4hpDdVpHz3h8E9DVTc6b0g4t9nFG6siawmzrX4iZRULeHaebI6MiIpUaVCjqCQwRz1t3R8112it31YCrWuFVLjW4YKfwQkiLDNyBW7lIO+p0UOki9RgcDpT+a4hptNW9jGZ7w4OcfXM3wRC7B0PdMyX3ceV13R/iHpqpQshAYJ+ox+/YIwbNwPFTLPQJbn5tjrQOmG0kW4liScPxElP7HeMSkEYg6XMgG/sZrmjXus8AWBKdYOg2Z1UqHjoEW+VeiF3QH/mOp531zfr3ooKJRiEwt8g6sQgONRdA00Hr46PfoXfbXJKw4et+54rAjDgCvub6nrPQatAj/ejkVtQu6QoUVwuqTpJhIOyxo10La4FEAl306RkFEFkAelATkCEZfCQOJoldesO701WkXQ+s85Spn+eYTBNTiQZsIJG2dxberuLMbVhYMv8m8Ob7V/pChX7tMtcM+LcUoUwNOszvvWDQ0xhDn8LGeSie/3dRBmg+a2oGN1RdHjkSqBGHdaJaJSncGjVJsfhqAaBlfu+AzgLENCQ9P1tspjtHXqZIM9XHH8XSQY61bdAhDbfbzAPcd2S/3pNIIGOfA5GrT10rLr4A1bX6HOPYjrzAPDRuNh/YxBvKA5Ld6og/aBvcg3hi18I4L4rxlt3rlG2qXpCgAJEEZ7zHELNnSSyS9CvubaD56SNjxlC47qyy95dml3OdTjfInVAZRfSfa8oBlfU2vaJnQObGTIw6QVpVKGlTiDmBN5qT7p5cBOrPEf/z3IyqaWTl30y9eaVzuf0O8Ph4mfIQ5aIxh0psMGCxuI1IuxiMlErO1OS80Nl0ZWDxurXchlIZr9g9GGQAcMBKw/3zQ8Bw0Qq7mXYKfG1J7j1kOIMQC2ZFZMCEu4UMW18bNx4p8TCMkQQ1m4L5BNdPWXBzTmacUqd0onrv4bFlnfp/VfNt5k2tPUyVSgJpAz4n4N3mVBL4FExlYSGXmzGQLj0EOrJSTbfjppQ9Gr59KfVfGxzwU4eumgDfb/N0OzqAAOQrS15rSN8jsEz84RRLWfkKWmsCT+IDlxsMl94CqEyUgvsiCkmiCIEYnnBWroDlVaaCYhKT6DdHyVpPi806+PPG9SGbfbw41LNNvK+KnRUXVRO2wp+263kFFRB9q4zgbPRJlan7m96dTN8iqL5fcSjqyiXwaPmxW+0iNGVklfy7fppzdrxYKot81vh6l80P7cNr1hQB4mFGwZ9Ng0ewmo7cAhGv97s94JJmU6z0nLEWpLlVrGWfFdo7m67oS8siIUXcABR9w6wRL X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ac51531-1694-474b-bacd-08d971698add X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2021 19:07:16.6311 (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: fWW3yMbDeUpjfBDc2uwADlH7gQOzuegA39es2aSySOznYxTnMgIWSDJyo7hj03Yo8jpEiEj8vPSNkUohzzg6nnnTuMEKrQ4UlTJmOlSFxNw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4849 Received-SPF: pass client-ip=40.107.8.94; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For qemu_io* functions support --image-opts argument, which conflicts with -f argument from qemu_io_args. For QemuIoInteractive use new wrapper as well, which allows relying on default format. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index b518545c09..3b7b57489a 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -208,10 +208,17 @@ def img_info_log(filename, filter_path=None, imgopts=False, extra_args=()): filter_path = filename log(filter_img_info(output, filter_path)) + +def qemu_io_wrap_args(args: Sequence[str]): + if '-f' in args or '--image-opts' in args: + return qemu_io_args_no_fmt + list(args) + else: + return qemu_io_args + list(args) + + def qemu_io(*args): '''Run qemu-io and return the stdout data''' - args = qemu_io_args + list(args) - return qemu_tool_pipe_and_status('qemu-io', args)[0] + return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args))[0] def qemu_io_log(*args): result = qemu_io(*args) @@ -220,12 +227,7 @@ def qemu_io_log(*args): def qemu_io_silent(*args): '''Run qemu-io and return the exit code, suppressing stdout''' - if '-f' in args or '--image-opts' in args: - default_args = qemu_io_args_no_fmt - else: - default_args = qemu_io_args - - args = default_args + list(args) + args = qemu_io_wrap_args(args) exitcode = subprocess.call(args, stdout=open('/dev/null', 'w')) if exitcode < 0: sys.stderr.write('qemu-io received signal %i: %s\n' % @@ -234,14 +236,14 @@ def qemu_io_silent(*args): def qemu_io_silent_check(*args): '''Run qemu-io and return the true if subprocess returned 0''' - args = qemu_io_args + list(args) + args = qemu_io_wrap_args(args) exitcode = subprocess.call(args, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT) return exitcode == 0 class QemuIoInteractive: def __init__(self, *args): - self.args = qemu_io_args_no_fmt + list(args) + self.args = qemu_io_wrap_args(args) # We need to keep the Popen objext around, and not # close it immediately. Therefore, disable the pylint check: # pylint: disable=consider-using-with From patchwork Mon Sep 6 19:06:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12477267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CB06C433EF for ; Mon, 6 Sep 2021 19:18:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id F307361050 for ; Mon, 6 Sep 2021 19:18:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F307361050 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:50338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNK8w-0005JE-3I for qemu-devel@archiver.kernel.org; Mon, 06 Sep 2021 15:18:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNJxt-0005dl-Pq; Mon, 06 Sep 2021 15:07:33 -0400 Received: from mail-eopbgr80094.outbound.protection.outlook.com ([40.107.8.94]:32928 helo=EUR04-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 1mNJxq-0002Fk-9e; Mon, 06 Sep 2021 15:07:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F10w5x/MtjbX1tYz+exga8fw+x8mkLwpTgawSoA77uda6TGiDE2sSBdydArwBSsNMkHCkfw9dwz8X88XMRUfDQa5ctHPBVsuc2+hae4IYj8AFgS89tp2/MiESmb8z2a0Sq8fgP9x6LNUH+YOwYlsNkAIvHA7juLOCdyA1ysw4Hlu21BWfLM12OEAekXnbEFGSr6gfMCKFpmiwrfD6K/0Wb70ADwxYcdHCESYTmIf1p97D/wsojsKCrFyEo6u810cqnRGujy4No0diC6D7VNpJU2QiqyFtBy+UYGIz+QENflUYb3E6x52/ixvHKV62MI8iII9U4oyEagDhgVzUfYS8g== 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; bh=quuh71NJ1RhvlnxDiXWRJepUFiqTf6/wjjdKCEvqNCk=; b=Etsytc21CXQGucGTjfbbtsYSRs2xl9hRFJqQBX5mEB2SgH3sbwzYJDU7/rfsiuvoD6bvzaaGoHcyi4Qf/SBcSx03XuieLdzjW03cuUdfUNgoCg3a/DSyvN3/BsCG7jUTMtf+tpAH2j2kAQT+WQySmhN2yRKuIq80N3ZVD99NeBEYaPKl4TphbHWfgJJ2o+WbkLeXLvAaOKfDDJuOUtBNZ57q+iIAqi8TQ7cUZpn39lSfZt3POC0yFvDBhf+WKN2iGDQFyml/vGQ04Mb+rdRsfLQVV7KPzGW+CPOVHr7W4ghQYLeVI11jLCJAj/VIkihQZbB4UX/k0hlCfKZ9O/H+bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=quuh71NJ1RhvlnxDiXWRJepUFiqTf6/wjjdKCEvqNCk=; b=lGVmdNXOOpStbvXfbEwCzS5s4T6PSJ9C9KtYbfZYRvLWtYTLtmqeNcq8GwheEQingTt9kVeR0DsuqC3jOCfJPkLy6AYXi5M2ehmljdpKOaoBQUYVVxHJwBvumJOTLvXvewq5Y0atGzr8AqxDFO9yn2mj8Gi39j1hS5HiABwDxqA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4849.eurprd08.prod.outlook.com (2603:10a6:20b:c3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.24; Mon, 6 Sep 2021 19:07:17 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.025; Mon, 6 Sep 2021 19:07:17 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, den@openvz.org Subject: [PATCH v3 8/9] iotests.py: add qemu_io_popen() Date: Mon, 6 Sep 2021 22:06:53 +0300 Message-Id: <20210906190654.183421-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210906190654.183421-1-vsementsov@virtuozzo.com> References: <20210906190654.183421-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Mon, 6 Sep 2021 19:07:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6eddb842-6bbe-4dee-564f-08d971698b88 X-MS-TrafficTypeDiagnostic: AM6PR08MB4849: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:317; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P8JSCrrA87FhDhgilI6FkezKTqMwZZ6o/JbZwAG4lNSkBSs8x5oSsd3wCpxKze7n56fYgPc+RQwRd2z/EDPj62rnyw8fS+auR5SdSUwO5l4WAbF1NDVd6EpxH1CCm5p75cw48rrpBKYIqd4rJlQcMpvAx1t+3F0ZjyuCh0DKaUWL+JJXUkdLVA8uG58Yt83YmIM6bN68hT6E6HY8Q9V0Vz9pWx98BTnr915iAyZd+Jfgat37mO08mEetPaQxO8yN782XLjwig5TbcGxveqyhUXPdaVodYFQYHh43+qYv8sOJAxGdFn2/ZoBpcZCA96kgVPtxDcXnAC2kQ2h2pY8Y2DDFEkCXfITBG9nus7cb6v64Ov5JKXrT54x4vo2ny6chS2wSIn95jD2aCI3raAIgV49JwQf7BXhIzHpLHiVaebYYkLpE08IuCVcPQ4C1Rk7yo48IE3BmPt+6aTxKwgtYBnnjrBBBaI2bIenLRVsAOXsus/+fqiflfe80tk9prbZUuD/KME0r1nCgk8naJYpbEBiLOnSGDrE8iKV6SwYq0gNSGGfZIh9CsmHPbwbHIA9SeBystuG/TN+G4gZhqicn678Zz3d5lRBhfEP+mHNno2qVCV7cUhVhQURUoUeWZ3SZfbdqB3fqzqECXeik5NgBuMU+17Uy+jprwWett71rbxVsCv6sp5X8rVr/0KBTNaxBij6bGsulD7yqEDDociMlIw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(346002)(366004)(396003)(136003)(66476007)(66556008)(38350700002)(478600001)(26005)(66946007)(8676002)(5660300002)(1076003)(4744005)(186003)(38100700002)(52116002)(2616005)(4326008)(8936002)(36756003)(107886003)(6506007)(86362001)(6666004)(956004)(6512007)(316002)(6486002)(2906002)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vJ//8pMNlcr0Om9WKUkuNTNtlD/0Xcj067g5BxK/qxEdOtm8Gmg8AFZcMoQFX2l+WF02ws+5Fc50uXdQfiHnL4XoFL3Ql9BhFOXhsCaTnF4oYRryL/Wp276UmS5cSbE0lyFeHe085jqp/YlaDb+RS+3DIzKte4sQZRJ8a/t5ZPNv3t1mvH+aShPUuykA++GfpNj2wmLBt60a507Z9ZQZ3KltzuzapENlk2epkXZ6d1FwiXp+NO10nsEXvRVOvu7WEfXDJlakuLBqY/13t7bBbhrf2EXGq1JVfcl0SS5okpu/Xo8fZP43asmzWH+3FfEcvRXmlwYCyEMx9eSP8d5+yl8yP0zb0nbiUZPQ8lAgBYnkQEzPzs4AJ9Ffw45+142I92tXV8VFHCjEVGqomzEExfdLvk9IPSNiburBkSjp3SuvrFstmhfi08Bfcxh9iYeSy3+D4OcO23RPEIRo5QsBdJrdoha7oVz63YEVtVPlDZrC0oAdMYCrjnndBJu6+PhxQT23KMcfTnu3AgeL2Sj1rxxtV4u6MJ8fg4LgkmCs5DLT+8mGaJ4lWAsjZV3mhGY0BZ3Xs5j7YGw1L482UE4ylvvIctOoGjMH7okctsxF/IiAtyLW01vzo+FKXUYymFLB3j494lF3rPR+xMBeJtwQTSz7JPzE878MGyWqoH9gBIASrWeViuxFklOnBvmPUYGt2JA3UFmtGmCAz80y5otwHTB1zmjei9ThH3J4LpTvckHHBTZ38PGUXiorVLw/V8/136M3EBieIPTcGSfx/LgjkgFla0EbxiGU0cLaWvj1dbrh3A+tVxAzT+NKQcVOhXohJng+V1AH/X+07bmLOAYu8yqb9fFyO4DlZqWnDIT1EjLzKtiDf+NM5cgu93Kzaqc91k8vYxnzonDjq394L7jfwxFK69s/YbTavuM1jrE4XbilpUCZqZamaa0Q2zCzHv0K3RNC3gvGNmbi8an+mFEEqhL2vKphtANJ3tSAHyg1MlmVrxxS5fKe4xDC0YcZTuZtgOx9HRpoNzcBsTOEsBDgDTX7ShR5Zqo82NyfE2QFHimilaYE+K9anvV/6/Fbft9pRrU8SCe/88harInvpFB79oQKNFktJ4xX7RCLp4YfaUFcBu4g/0QBjKTo5LczWMb5tosTALGsGmVtcYm2bZquzjV59VxBzb3f8EJq9E6b+mpiF+D/YG+tLo7g+uyMy1vWdPoPT9nvVtXBOOUy04TncpOMirOoPQ0ecg3lwVReeYUErhTxGZtD9UY31LXVxIkoqXwR7T8UJ4RrKJRHkSlyUhqT7l4E0ihxOXNQi/e9xw/Qc+5gWXU5fYbnPDqTpZuV X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6eddb842-6bbe-4dee-564f-08d971698b88 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2021 19:07:17.7482 (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: gBwea2e0Vku63iqK5ol901WLkNrIcDW3TuY7hjlRD6u94GFxZP18rGUTrWAZob2CDQgJC9/dQoZ8tq6MEgnPw9ruw2v36934jCMi64OUI0Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4849 Received-SPF: pass client-ip=40.107.8.94; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add qemu-io Popen constructor wrapper. To be used in the following new test commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 3b7b57489a..be53c8d5ec 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -216,6 +216,10 @@ def qemu_io_wrap_args(args: Sequence[str]): return qemu_io_args + list(args) +def qemu_io_popen(*args): + return qemu_tool_popen('qemu-io', qemu_io_wrap_args(args)) + + def qemu_io(*args): '''Run qemu-io and return the stdout data''' return qemu_tool_pipe_and_status('qemu-io', qemu_io_wrap_args(args))[0] From patchwork Mon Sep 6 19:06:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12477269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34AF5C433EF for ; Mon, 6 Sep 2021 19:19:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B3B2661050 for ; Mon, 6 Sep 2021 19:19:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B3B2661050 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:51730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNK9G-0006Fk-SN for qemu-devel@archiver.kernel.org; Mon, 06 Sep 2021 15:19:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNJxl-0005Z7-3Y; Mon, 06 Sep 2021 15:07:25 -0400 Received: from mail-eopbgr130138.outbound.protection.outlook.com ([40.107.13.138]:2000 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 1mNJxi-0002MH-67; Mon, 06 Sep 2021 15:07:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P5Atf2Urls8TjfISmV2qu17vVw2JsJJfkMfxkP1NzECn/Ea6zkIMxROkKsVjWs1V4m+VwtQnr2FQN6oNA3i34EWxLtVScW0/g4GOPKXsPu+298owYybcmviziYFSokudB3sl1skvdCxiRi5oKPNiPUP6GXIlQoumJ3+Y0d947p1x3OXT1bXJAxYgOPLZdONmaNOsLoFnyxWiLp+S0sFvV0fddMVRspiSqbmZfMcV7WPEVxHZpJJi3fS9sttb8OfOdPU2Lhzm82sXqsJgLahBS4pnmzRzgz6Nyfa69uRwAOFbqKzIYIUSYdaZ9BXE64vRER6Qs52MIWmpEECZWRCB3Q== 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; bh=YidbdpkNEm5RnPXwbgrgp3i+KGTTTW5UUMZ6PKAt2no=; b=ne2rmrmEtrYMXyXnTfLD9g76D1i/auYGQDxc8foldp4XJv7k3lb9dkLVOmKQru1li+Rt/dZ0w9HXljHXck0IgkEgq0D1x7u9rb1tBimCsbdAqHxhH973HxJFxv8JeY/OYg7JoTAnBvUqHAsmonY88qG2rEIJL0xWi89cQQKQJXENoWT/Lb3gdmQLMndxKjJb+FPH0mp18ZD2vWF0uRzhPqhxi+fOqUYqtxl+LuMpGx22+2BsOl2CQLITwbkeCT2qyLUbzEK0QxAS3RBx9rJmvSpr9E1KsPhYPO23N1Atu4NzIF5X3kwnQepvhPp42FbZ1HLhsGI0LA/jLmbWa53T4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YidbdpkNEm5RnPXwbgrgp3i+KGTTTW5UUMZ6PKAt2no=; b=d+fKpYA09F/ih56lG70/8qDTPejhWLg5KYN+vIC3RbQ1XbrSe8SrIIusXFSAnesWKbVIVLqiBTYJUJdNxw78oh1/N34U8l3Y/YEaqi15b2TzLhxUX8kiC4CqTmjcWaQjtyYvOHF+FwMVForbsG5ieguAiwmGQDM2/XjvSMBLO4U= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB5256.eurprd08.prod.outlook.com (2603:10a6:20b:e7::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Mon, 6 Sep 2021 19:07:18 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.025; Mon, 6 Sep 2021 19:07:18 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, eblake@redhat.com, den@openvz.org Subject: [PATCH v3 9/9] iotests: add nbd-reconnect-on-open test Date: Mon, 6 Sep 2021 22:06:54 +0300 Message-Id: <20210906190654.183421-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210906190654.183421-1-vsementsov@virtuozzo.com> References: <20210906190654.183421-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0302.eurprd05.prod.outlook.com (2603:10a6:7:93::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Mon, 6 Sep 2021 19:07:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc0869a7-bfa0-48a3-caef-08d971698c32 X-MS-TrafficTypeDiagnostic: AM6PR08MB5256: X-MS-Exchange-Transport-Forked: True 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: 3uyuRY3fk2Y5BWHNIGxkVkAUF+LsLdSeX3JH1ncpNiboxupIou5H+jeW1MEN16obosuEdt+P0SjvR8JDisVTXr7AHZm6TpCLbcvUdqjCx8wdd+UTE90DSUrEB9i7R6ei6cDco2xgwICWpzXXLZ3+BnZ4oXFPWl15BwT0NRnuwRdY0iddQ0peUHu+j1rxxgQDNQjsLG/5euf+NUhUpqMHnE1ZBrm8PX6T7dKWCI5rGDoRXzgggRsa4ozTcdnjR5xf5jDDLzEPRQJJJhLe/W+XSgEMQ1RZiRdSIxwRhgdc0x8zvs8Tm2M+Z3lxO2GhgSipbF/iGz0n6BblQqkrH8I0Ki9JmBtho/8oOQ9PaHxZpnLjAo/FwHnFpdrQp+8g7Zfd8iO8Ol6+vDh+Ln+ByxrKNmxgPfJ7k1WTxToQG95X9FxliSm1m5ssa96gtCjv3Cjz8tA9uzYK3WOU4XzOmI8eeuWobChwAqnXe8D6YmhYJB4WBBWgDMScJmBdzSsDCVlQ7YXMcNzOMlWBe5HehPuQpB54HT4jiyG21icN811+IDJgphCQHNvJ3hIfiOF7CaY2lM2sJFljm4d23zKpWvv29YeKHkm5gbBNBHrEsr2UeAJWcXehhaPg91zhb3lzSIylqsfXfmZ3weV8NgFat1O3fjf2yF3NbqFG5HD4DnPhJAYS+VOxHJxafpVaLUljN0IiL2ZZVWkeKqSkhK9wlvwY4ww1W+duslQmAbSCPPdoT+pz9Vjf4RVlbLrfkP72DiwK46+ChMNxNnbCMF7L1tTVz1zq1BaucraVUFicQE2P/IQB6uubi2QfGL+5JPc3W9n5c7dBx0ZasyyPMJNmVqA1Qg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(39850400004)(366004)(396003)(346002)(8936002)(26005)(6486002)(6506007)(4326008)(52116002)(186003)(66476007)(6666004)(66556008)(478600001)(6512007)(2616005)(38100700002)(316002)(1076003)(6916009)(86362001)(956004)(2906002)(66946007)(38350700002)(83380400001)(107886003)(5660300002)(36756003)(8676002)(21314003)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6mESC586ewwnoTXi4ORSqXgYxyiduFiUt9ePRjd+yrG4xImsfi1ZKDmjFScrgaoFLifVc0/85zh8FxUu6E2BKmJZvyDxMJrpUenJuqqt8Pq1H3mN8cJwqXn9bxpXljwdkg/Ku2tIEmng4skXIYHjyh4Rsf+RmpML8YTKksn2jfGw4uMbXGdwK8uvk/946A9+vK/tzrkY3sKTMLr9qdjoZgsabv1qlvVRp+wrCIQcr9A4YUHdRCl58egfiOy4xQOirEKjoZz2nzcOt2oIOutWFKeN5fa41AcaLP5kg8/TDxc1qEiu9r5prFPwAjGuOGR9vR5o3E4sb8pEofpgHX3eKqmXZcuyM8e1PXghc+ziQNvfIadGEbwECdHt9W5rlzJ8HO3N43rAAp9rj8cgdijBqypnM4RRPscMgafaR66R0aRKW6sMkbOLxVQB0/bLC3TEUHK9g20h7ArWyD5iLWeni5uUwvbjhQ9Mh3oOva4i0asSQJdSL4zB9msDDcSZ71RCvASjWTLfJEmZGFj4OhfRJz4sQkBXKXBGWoEcRLdE9yZ5d94Hltzxe23bY6UsCCUp9BYLFh0mWgmFhBUKxSUdWGMV+x7MITMBcVD11xfG4WzSr32g53vqMeZxAIX3RQBO84P3VyW8IiAky2PejI1G3TCz42Cnz4VxKWt566cB/C7WkKCoR6Kh4GREKDvzuw8gz17mR4zZcAFKbveU6uAFlTJd0mbVsrQJXv3dwHYrtWGwLWQYJzN+YXHLhIb2dTpojqOBh8bDHOi3p+Z7AEigGk1iHACmmxvt603N2ULT9ticCpeuOsFAIZH+av7eU3VDfr0T7YHa/YCg3OFRbMlsPf5NDiAM1hgnKMdIIRQKpMz59VmJEmD6c/NKB46y/eFb9H96yvZkYa646YfGROnWYrtRWTtjMxIoE6xmqbAcYj+uTtjtxyeFl0oj+4nDhC9u0nmsD39Jv0f4lmyLyIpBIhkv6qS5Jj/ooX8+NnSKVfNyS0gzZTwnxXnX2FSByT8eJr0XGo6TYHvLIKQVTpg8E+QVSW0oZXjH5jEaA0bWu8SIRFPNUH9RnCqRguq9S0VG6OU4tRQ3TNfqDl1p+mRepLtYUlq3cKRfzogg2TWFm/v33bU2PLuuRvlYaeTQvbMUPJtPBcqrhp6NrIZ7SCD9oEResB2H2uli7utWGd/8gZTPWtOqw6RG6/Qwam8UatDQ4cjLjRUR7p9QUIH/th3QFqsZksu4swvzoUZmz8cSUv/QWNOWYfrRg1uQeD2YzrpdqrrF0pwg2g2fDtoem6ErE5ri2rLIGhlZNSniO+ApAHRCiOcXYUC3zh3sBz2qKK4Y X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc0869a7-bfa0-48a3-caef-08d971698c32 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2021 19:07:18.8992 (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: MoEbTcwrf1nAFc5uZW7jleM507eF+m7ehHuLDHY6el2dIsLMXmIhnJ8NKcHSVUaJjGic65GqGdd8J2TnUEreS/Q7Pr8fsMWBfUGAY/UFHZo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5256 Received-SPF: pass client-ip=40.107.13.138; envelope-from=vsementsov@virtuozzo.com; helo=EUR01-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Vladimir Sementsov-Ogievskiy --- .../qemu-iotests/tests/nbd-reconnect-on-open | 71 +++++++++++++++++++ .../tests/nbd-reconnect-on-open.out | 11 +++ 2 files changed, 82 insertions(+) create mode 100755 tests/qemu-iotests/tests/nbd-reconnect-on-open create mode 100644 tests/qemu-iotests/tests/nbd-reconnect-on-open.out diff --git a/tests/qemu-iotests/tests/nbd-reconnect-on-open b/tests/qemu-iotests/tests/nbd-reconnect-on-open new file mode 100755 index 0000000000..7ee9bce947 --- /dev/null +++ b/tests/qemu-iotests/tests/nbd-reconnect-on-open @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +# +# Test nbd reconnect on open +# +# Copyright (c) 2020 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import time + +import iotests +from iotests import qemu_img_create, file_path, qemu_io_popen, qemu_nbd, \ + qemu_io_log, log + +iotests.script_initialize(supported_fmts=['qcow2']) + +disk, nbd_sock = file_path('disk', 'nbd-sock') + + +def create_args(open_timeout): + return ['--image-opts', '-c', 'read 0 1M', + f'driver=nbd,open-timeout={open_timeout},' + f'server.type=unix,server.path={nbd_sock}'] + + +def check_fail_to_connect(open_timeout): + log(f'Check fail to connect with {open_timeout} seconds of timeout') + + start_t = time.time() + qemu_io_log(*create_args(open_timeout)) + delta_t = time.time() - start_t + + max_delta = open_timeout + 0.2 + if open_timeout <= delta_t <= max_delta: + log(f'qemu_io finished in {open_timeout}..{max_delta} seconds, OK') + else: + note = 'too early' if delta_t < open_timeout else 'too long' + log(f'qemu_io finished in {delta_t:.1f} seconds, {note}') + + +qemu_img_create('-f', iotests.imgfmt, disk, '1M') + +# Start NBD client when NBD server is not yet running. It should not fail, but +# wait for 5 seconds for the server to be available. +client = qemu_io_popen(*create_args(5)) + +time.sleep(1) +qemu_nbd('-k', nbd_sock, '-f', iotests.imgfmt, disk) + +# client should succeed +log(client.communicate()[0], filters=[iotests.filter_qemu_io]) + +# Server was started without --persistent flag, so it should be off now. Let's +# check it and it the same time check that with open-timeout=0 client fails +# immediately. +check_fail_to_connect(0) + +# Check that we will fail after non-zero timeout if server is still unavailable +check_fail_to_connect(1) diff --git a/tests/qemu-iotests/tests/nbd-reconnect-on-open.out b/tests/qemu-iotests/tests/nbd-reconnect-on-open.out new file mode 100644 index 0000000000..a35ae30ea4 --- /dev/null +++ b/tests/qemu-iotests/tests/nbd-reconnect-on-open.out @@ -0,0 +1,11 @@ +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Check fail to connect with 0 seconds of timeout +qemu-io: can't open: Failed to connect to 'TEST_DIR/PID-nbd-sock': No such file or directory + +qemu_io finished in 0..0.2 seconds, OK +Check fail to connect with 1 seconds of timeout +qemu-io: can't open: Failed to connect to 'TEST_DIR/PID-nbd-sock': No such file or directory + +qemu_io finished in 1..1.2 seconds, OK