From patchwork Fri Apr 23 21:40:23 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: 12221787 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.7 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,URIBL_BLOCKED,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 3C284C433ED for ; Fri, 23 Apr 2021 21:46:47 +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 BFEF961027 for ; Fri, 23 Apr 2021 21:46:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFEF961027 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3dN-000358-Nj for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:46:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Xm-0004zM-E3; Fri, 23 Apr 2021 17:40:58 -0400 Received: from mail-eopbgr10127.outbound.protection.outlook.com ([40.107.1.127]:4578 helo=EUR02-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 1la3Xk-0002m3-Qt; Fri, 23 Apr 2021 17:40:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LTjkmjd9CKbDHH4dCjxDiiH7r+C9/DnwWgVCCI3kObROKuDuqozFkYQpOrHE3vCdaNDryvOaWTyHhdmPn0XxymmM3O/ZnIHaQA+JerZH/G3q3kf/u12CH1fN4WikUjH4FsQ46s9AV117L5UvnJ46C1rvDwyBN0GgnQ/FrHIl0HugKLR3bcat86+vQDc6mCPfLlsELQERT6dDpd2VHx2NVNxaXxjnBIi69GFhDt1qGbpqCGkVmo1l6DTul5aoo7iK/TzgDVENs+MZuGanvzeUEJk9Eiu+lJosZwXC48NCoKDIb2jNwTG+dM5L55n0+JMw2JUp1vja4VArEO37LBCLOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H/+shfLISwkOirf04DiUtMpKyo+BE3BeVeHJm/68kK4=; b=S+VCv/CDxeRwFE2ylOCcBjt/cxmT5V1JHCmX1Kt2yc/dPeHyBhY5ucb7KmuIBbjXkD+1TPnI5nEDOV33mYOU4dBCktxcftI2F7Qo7U5v3RP4y/HZV4BCq0+Q3Z84iTdRxgHRaDuk9Ey9SgD25NaAsnYzHS++GJwvq0Buvj9Gr2zhXhaUHqc0rNGmf4t1EAwubBvqauRTmOBdr3fzhpwfNuoECNIldPR8deC2pNonkgCGulmoO4XZDS8Lwz+Rd9mPqnboiAgLksmHSgfxrvK0mKUsowRZWZOEeU4m7/DwcootsQSutHjgYzuhSWPuLf6kItkIKxdh7yVFJqdzr53bYQ== 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=H/+shfLISwkOirf04DiUtMpKyo+BE3BeVeHJm/68kK4=; b=qY1X52ZcI+T3AVMdcazLUAvXIycUElUhNJxFEEVd8a+UyT1lZKTKf/BAnEpgRxPKSwzihW8aFulnFf7UZnhA6zOT2+o/dOI5HQ0JHUd/jwrn1xKQJtt0zT336/5vsehuV8WoRjuFNwV8J5fAH/wexP0n9NVTwvZLmP/L93EAqhs= 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 AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:40:50 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:40:50 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 01/11] block-coroutine-wrapper: allow non bdrv_ prefix Date: Sat, 24 Apr 2021 00:40:23 +0300 Message-Id: <20210423214033.474034-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:40:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9be8727b-e055-4481-b89b-08d906a07652 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:608; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sbxw4ihFd44Y/LI+tHyjNwU9wLQLpAoJeUNTK6O/z8IrWYPY5xb6ds0L9REnZmQdbSKZtKn6/G/p9Obaxuxqqhf4CerBxU94I9Z21/vdqOfRIifCHmqn40KjbnGKzXCUyqyP8WjFlGkv4S8tgizxvbbkbzEE0ZBSE/k995tbSBIyaX5QCiCtP5+CTcWw6mlA49hZVzCm7sTT5tQkgDZa/9W0Fpblm4luSO5KQ0f71blZv9IxXOlOutiSQhtU/Ni0aDK1KWn4QoFEXY13FXE2Kq6T76U/vKs7Jt4Z+Yq+l4aK8rV9hqoKL9L5Mz1aqgDmgxo4cYo1EKO2TLGoHNNha4x2v+hAJWXZHQ1UT+1SKFdZuxPxuocBLh6WJ9Rk4gOWvpyo0w1Ljd5xCYLfxB8bSEzZEUBzAR4oTVQXqtjJgRcAtMztxXeqq+s9O2kpC2o+cLTT01leOhuHC7DIa6zgUlWJHG/9CGQIaM27tOF4nOhubNiyavPEaEqcHpLsswVfv7zKcI6FLW2vFbOFI+yLPd3noi4sAUlCbGf2hm1th5kYCy6WyOGxP3SiMNInAaG11hVwo/quobtvFqgG20rglaTmYoa4bXpijjyP+ux4slJLfSaRhFd257ClaIjEgJ63jPdjj4wj0E1j/9IxS99Xy00XLTfiBQTObRjKC4NBfauDxgu1LDRrkGfbtXhP3nH6 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)(366004)(396003)(39840400004)(346002)(376002)(316002)(2616005)(26005)(956004)(83380400001)(8676002)(4326008)(38100700002)(38350700002)(478600001)(6666004)(5660300002)(86362001)(186003)(6506007)(66476007)(66556008)(1076003)(16526019)(6512007)(6916009)(6486002)(2906002)(52116002)(36756003)(66946007)(8936002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: mBbow6aqQTyS4y3QCDsWfcAjs2XVeQeUw400PG9BW+ZypVJ5oB/v3HE00rH2ek4ryU9lPWWtXywCP7YYIQY5FOl9gdpcOqIex4G9Wp+k89iyqzkondyu8l+TZ+NzdWouySR92IR+LCa7GDiWdZWaWoOmh63UJkoeMJEy9f4rYfK+wfdRVybYaI79xzvbIm2Z4mhyPmp0rDK2+xuX06p5WzSMyEEansqvVMkL+fqQkuuLU5az/hwI/e28Jv0n4t0dZWDNsMMHGc1E/3ExF7ETPmSfqo9FcilSyI6oS7dyjr8gwqyEL/+8PxyYkeUodwoQIvgUb9Di53EkspgBOYsBo5aplKFp6j0pnCBkzmEGFYiEH5cu6dWXJWGOJyF4Tt6aB5+P3EuCD+nYZAqYAHK/bKAxsIXj2FfWrlYhLXbOrqy8Csvs2SYvQHBo3zygYuKRNcSaShismvYP/WpRXoPh4PvQyTO37c7KqF2XrLhY1trhSFdWkbmSqRO7jXbKqsrFQoK5BZ6opr8BNUwfFhDyEFgGx0I5Sj2RRL+plZaDWFOewLQXmEzXDOHgIw/jCHs3rRXpD2Hp306m+H4ouCq8mU1lv90XhJ6x5MjGr0ts4R7Ry41Ne+KUSXG1PP1BjTDIWRJsgJw/LAmr3mJRht8xANmfWj24wjAKkW4H+hhMlaNDFmTCypXNEhNZYVBY0bomA//teE78U4LtPjUwCj/FT1VxQ5qHY21qJyasTY9dFYJrma/y6KY1REtlxmxMvD8pnztagZfYFK/pvLU47TP/XMcmgOe1SoBkuBLPXLk64KXHckSW4D+O5fDJvvKcMR9yK8TFQrpeJ7fDb4jtmoVLBclKWzPuNSJ8FRHfvFJZKQTTYyWnhu/vOJ7t/OHg6w9Obc8sX5a34oEe5d45rX05fVo3yE5MbSNygFkAjk4MQ1JQRdg4Kq0rZxesvKTXaX+tCAwyIvYzclRhjIPUe4SZVRjzOc5mNIYdGu15cD/LtyfFV3n+Ejf/cHHkDlfqPprDz3v6Z17KEK0R2zIMe8cCQor8J7+SXUUWmLjw0vFDYMgp8SG2rmoQG1VNFh2HHHDDef7fjsGOLS1bUAt0sRvGoHVEnKSPM4w8//0uMgne2Fm5AUVxXLYKPOTNjibafULf6kqyNlx/IN/RMfldxS7w9xv2hk0t+8elHOlNkIbIIq/fKyfDl5+IqkIehIfbozR80UH/P9nzPzjvkyGGbDQPMpHlK3A3esLFa6LkASJ9s1CQ+FD5UWt/zSUhYD64fNytIzjTZJLrBA2QPqPbhLM5Yaibxckt1vXZ2PJ4pRKTjSm0Zgzd3K/z/BHq1mkqiP+z X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9be8727b-e055-4481-b89b-08d906a07652 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:40:50.4479 (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: A8S+nkdw0cojNbIA03yrv1Drz2fUKgS0jj2b+I41bFRKkL5jDzf7WKsLejI1z77f4UT+oDRPtFIbKzqQhfqkfn50b+DPjknXQzG82oN/ADo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass client-ip=40.107.1.127; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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 reuse the script to generate a qcow2_ function in further commit. Prepare the script now. Signed-off-by: Vladimir Sementsov-Ogievskiy --- scripts/block-coroutine-wrapper.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-wrapper.py index 0461fd1c45..85dbeb9ecf 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -98,12 +98,13 @@ def snake_to_camel(func_name: str) -> str: def gen_wrapper(func: FuncDecl) -> str: - assert func.name.startswith('bdrv_') - assert not func.name.startswith('bdrv_co_') + assert not '_co_' in func.name assert func.return_type == 'int' assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *'] - name = 'bdrv_co_' + func.name[5:] + subsystem, subname = func.name.split('_', 1) + + name = f'{subsystem}_co_{subname}' bs = 'bs' if func.args[0].type == 'BlockDriverState *' else 'child->bs' struct_name = snake_to_camel(name) From patchwork Fri Apr 23 21:40:24 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: 12221795 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.7 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,URIBL_BLOCKED,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 8013DC433B4 for ; Fri, 23 Apr 2021 21:50:18 +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 DE3EF613B1 for ; Fri, 23 Apr 2021 21:50:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE3EF613B1 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3gm-0006qB-Uy for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:50:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Xp-00054o-4k; Fri, 23 Apr 2021 17:41:01 -0400 Received: from mail-eopbgr10127.outbound.protection.outlook.com ([40.107.1.127]:4578 helo=EUR02-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 1la3Xn-0002m3-5d; Fri, 23 Apr 2021 17:41:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ocOGPggbfTqLV6JI9IGTea8hQvSFWpRHKBPnFztarbNyRZNX4nMz6INv3qvelsDAraogI3cLA6l2T8mdYlnTNj2D0thBou0zpwdcss4XqtnhcuL9iq4J6DZt+t26rvoKRX8i9v0kU5v6oGq8M4bMhnU0M7FSB3kcSidcIazvSWQQKRgjuCb9auz3Iv7mXyVhqtJ9Pg/GS/gHGh7z0teAJa/NYHdMUxsl3xp9qPktNebhxfawpNez9/SGel2N08+uS+I9Xl3ZXY3ksi41iBpopH+uqhW1Mo5NFUU3fhsUHoJoaRfLv88Z42JyWChFOzpOToe+j9H74SlEUIgvBBY5Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DMChjD739QMrUMm1Mr3NzNtwTiX2w76KyRY/366ZKRk=; b=jqeBTq814I0+BPoE6Fh3OYstp5WPCrergVqktclqEG02do/Fx9KRbHfO49eD+6SPZvtF6Qeqq8ZWhJEgYJCyQosRhKmiirfp+f7QW1FXR2rzMKIjCyNOROGj5D9tznAbS1pvqyVGUVDRGPJ80Olq5SvbUZA24zUFaBT66E4Q6vm4NzvzS3LGvs6ge0hXctzLTtpHVbVRlqoqMPXuCYn2ZYSNkKhxoPVVM1FqljoW9WG2APZ6ObrURsR1LJYjltMOM5lKy7AnVcerNGpG5dzDP1JOZQG5EbhXEM4q70ExuwWRsulHDHDVyguv7tImdT6TaajPEWkQXPKna7rIOVp1DA== 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=DMChjD739QMrUMm1Mr3NzNtwTiX2w76KyRY/366ZKRk=; b=sE1tmAVvk2MFdi3j3bDWlZZwuua8/qqaIBQrZG1XkItHp4gOrO9JU81YP+l9SzzIPJ8DR1smKDGrB/f5CJGpZ80BTf+x4OPeoSPvEOCy9OQNPNwSMOIE/WBCZVBMoY78bxjV+m0fDxVwbZw3xYYeS1h1FVihklRlSeRnMS71/aY= 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 AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:40:51 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:40:51 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 02/11] block-coroutine-wrapper: support BlockBackend first argument Date: Sat, 24 Apr 2021 00:40:24 +0300 Message-Id: <20210423214033.474034-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:40:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 19dbf302-a582-45b2-1218-08d906a07736 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:644; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0dFLJngvP1PM7Jr98ZnkmN1J0Eit5bPsl0sW3CwBPwJTcL3+hchF1XW30EkPl/zYdFcwSPlDEIoL8f8eQcU1dqTIBkMOaXBY4pDrX+YleAO9gkI1/AIvQJdsq8FUzg3/C6StR+rxEwz8tWeFva4SCGB/GyjR3NmerC6XdBgmyU1lOfjGN3kA7vcQq8ybpXVi98CWQ3pEGI2jagbrCb31uvBQF/Om6qdMa6WCArOi+MliR/EYxhlkyXsjcn/ONdtR8gq8Z6xCxbA/e3d/OSTQj2UXLshE95z2TEHxIvLVuumki26EMvu5++3mK8p6MLTydUeleaYr+GgyGb93OtY17jPSeRXvkatvhycuJNnY4oTgW/dRV2CvIXkX01A0PWUVz7xfi83bLMm2x5plxO1KuFMnNt0fspnz/hGi++Xm8wl8EwSy1fk38q7BdtSKNIKKGZCR+MQkII2X+VFkqxt1jygFRfNbn8R+Y9et5c7zKCD27K0c66eMLxoXEELL2vMsOgIbSLTjtpC7grnKKV8O1VosTe1KypkyYPqQtrb3+/Sn/+Sp8cP0ARidbaRbP9uwD1u/t1PyQdizKCvhvjhMtPJZps6AYQwlaDXMjnmKWzQNspaujRhA8+sngUNp3X3+LkxCgMnRDEs1Oju0K4PQb0KGVfbwol2bmgnapvrRBNr3beX63rjiuCreKI93uUHR 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)(366004)(396003)(39840400004)(346002)(376002)(316002)(2616005)(26005)(956004)(83380400001)(8676002)(4326008)(38100700002)(38350700002)(478600001)(6666004)(5660300002)(86362001)(186003)(6506007)(66476007)(66556008)(1076003)(16526019)(6512007)(6916009)(6486002)(2906002)(52116002)(36756003)(66946007)(8936002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: FcU/Ds8LxdrkYebeyv/zgL/t98hnpsTsFyZK8MOKB90jUvdcc5FuXZLdmIN/qY1gBqL7ul4VoVSNq67g2mlPrHxt0VAnGfvJIRudUSBt3CxhdBXARN+KSQLFRQkyantLroJNB+b9rx/wOBAV/esc5uHwStPBplmbxBZ3KsR5rIJbHoyxJXJ0ILu/O8From9s0ZiUjFKENtT1hEDodp5dFVBZ5ia0apdRT7OQDiHqqXYtdeLodCzHLLxJlL6Zy6zFd41ItktgoBJgv/UkV0D/Hu0FlryNIkqqN3QJpezS17TyjgseUCd/lT2soHtFc1ExmCTlSlRbOTyWC/7afQqRtGbRndBgF6Ffg7OcQHgQYeOEHWAIVf4Wkyf9u0DOuz+KROlyexnkfk8Rxg+JHu7fyknh/PXow24JM8ilifvXc3Gp7wde/7MYmSikSgKFKr1F6JpFfi1aueGN7oUfEx4wSXTf1DjkGrEn0Zqdn5Fb+61LdSVd5J31KGAMzH9PflPa/bpn+hgRjVbJmMgmNNtcop1QFVplzQtYEKWRCgNuaO4v5n5pS1GQYHKhC8OjfpiTlJyGfDrb0e/0CwUzQdV/C/qRgvHjDVuuRFpMv2KRRViudiS5CCmgnn1hwEp6Xit65ejV9rDetTB9rHS3IQA6wU1LzpxY1cJ16CVaGdAxL9EtBmhhJnixAdGpmEPFxgDxHds08kFKcvmWXFFoCkpz5DOWiGj9rKPI1gYiULO+pQLDKTil9kZ5Z0BmHBRKY+BjMNQdB9BRQ1FWxsjhOXp/uWxwu9c76hbLeN7WUuUCeYiiLzaWUHL8AM9PFu/99pvOtkDbTAIWE65aWyEr23XRyAn8ryswBfmax2GaaJerFlguazxPvHs0jqYx+JLsv3WA1V7sVq5WGFbHy7PzqNpkSSSEkxLa7yo2dsnc0k/UN2wSkZe2R42rNMQ18aLbl8tO8hG9av0P2ngeClIDrYQA6XNX0hCofKqlxT4g6KpoJmxeRBlS4Fx6dtouiT4kbpgZ6IaB3w4YNHBay7La08DWe/uaQtLYLN6G7oBfkMdiH63VbNyhD8UFkcZaiZAk78y+pxRQbAFKC6jC9qMKoaOKUw68KgasMX2MjXW9jbqiTSWMgHpSbmGTKjUdc+mSBzEKUB7SC8YUAFKf9ImQOxJiB+at9m6Z7l3i+acCu6/9RYA0TKPI509m6vQM+N5mUD0jQASqmTHTLQz/Gx7zN75p/+o35jNRRjyLqw1mGdQ/P4Xrqc3MvTyqehAImoIb1ZMZbrGRLYwnMEYDEtRycph+aNPwTCCRz8oG/jX7DSXVuQ1dTUqKXBqaRFhDwn/JB0oL X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19dbf302-a582-45b2-1218-08d906a07736 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:40:51.7816 (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: RJy0zCW3H089Olw1GxXeQDXhB7HH1Q12zt68pZYDg+Qa9Lo3EQSxvH+S6neekPjYLLem+oqgPiEdLOHAGdW/nfsIx6WGDe0VBgYoeTJkWiE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass client-ip=40.107.1.127; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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'll need to wrap functions with first argument of BlockBackend * type. For this let's generalize core function and struct to work with pure AioContext. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/block-gen.h | 12 ++++++------ scripts/block-coroutine-wrapper.py | 23 ++++++++++++++++++----- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/block/block-gen.h b/block/block-gen.h index f80cf4897d..c1fd3f40de 100644 --- a/block/block-gen.h +++ b/block/block-gen.h @@ -29,19 +29,19 @@ #include "block/block_int.h" /* Base structure for argument packing structures */ -typedef struct BdrvPollCo { - BlockDriverState *bs; +typedef struct AioPollCo { + AioContext *ctx; bool in_progress; int ret; Coroutine *co; /* Keep pointer here for debugging */ -} BdrvPollCo; +} AioPollCo; -static inline int bdrv_poll_co(BdrvPollCo *s) +static inline int aio_poll_co(AioPollCo *s) { assert(!qemu_in_coroutine()); - bdrv_coroutine_enter(s->bs, s->co); - BDRV_POLL_WHILE(s->bs, s->in_progress); + aio_co_enter(s->ctx, s->co); + AIO_WAIT_WHILE(s->ctx, s->in_progress); return s->ret; } diff --git a/scripts/block-coroutine-wrapper.py b/scripts/block-coroutine-wrapper.py index 85dbeb9ecf..114a54fcce 100644 --- a/scripts/block-coroutine-wrapper.py +++ b/scripts/block-coroutine-wrapper.py @@ -42,6 +42,8 @@ def gen_header(): #include "qemu/osdep.h" #include "block/coroutines.h" #include "block/block-gen.h" +#include "qemu-io.h" +#include "sysemu/block-backend.h" #include "block/block_int.h"\ """ @@ -100,12 +102,23 @@ def snake_to_camel(func_name: str) -> str: def gen_wrapper(func: FuncDecl) -> str: assert not '_co_' in func.name assert func.return_type == 'int' - assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *'] + assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *', + 'BlockBackend *'] subsystem, subname = func.name.split('_', 1) name = f'{subsystem}_co_{subname}' - bs = 'bs' if func.args[0].type == 'BlockDriverState *' else 'child->bs' + + first_arg_type = func.args[0].type + if first_arg_type == 'BlockDriverState *': + ctx = 'bdrv_get_aio_context(bs)' + elif first_arg_type == 'BdrvChild *': + ctx = '(child ? bdrv_get_aio_context(child->bs) : ' \ + 'qemu_get_aio_context())' + else: + assert first_arg_type == 'BlockBackend *' + ctx = '(blk ? blk_get_aio_context(blk) : qemu_get_aio_context())' + struct_name = snake_to_camel(name) return f"""\ @@ -114,7 +127,7 @@ def gen_wrapper(func: FuncDecl) -> str: */ typedef struct {struct_name} {{ - BdrvPollCo poll_state; + AioPollCo poll_state; { func.gen_block(' {decl};') } }} {struct_name}; @@ -134,7 +147,7 @@ def gen_wrapper(func: FuncDecl) -> str: return {name}({ func.gen_list('{name}') }); }} else {{ {struct_name} s = {{ - .poll_state.bs = {bs}, + .poll_state.ctx = {ctx}, .poll_state.in_progress = true, { func.gen_block(' .{name} = {name},') } @@ -142,7 +155,7 @@ def gen_wrapper(func: FuncDecl) -> str: s.poll_state.co = qemu_coroutine_create({name}_entry, &s); - return bdrv_poll_co(&s.poll_state); + return aio_poll_co(&s.poll_state); }} }}""" From patchwork Fri Apr 23 21:40:25 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: 12221781 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.7 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,URIBL_BLOCKED,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 A3973C433B4 for ; Fri, 23 Apr 2021 21:43: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 2301A61422 for ; Fri, 23 Apr 2021 21:43:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2301A61422 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3aP-0007fp-97 for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:43:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Xr-00059d-JG; Fri, 23 Apr 2021 17:41:03 -0400 Received: from mail-eopbgr10127.outbound.protection.outlook.com ([40.107.1.127]:4578 helo=EUR02-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 1la3Xp-0002m3-Se; Fri, 23 Apr 2021 17:41:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G37ej/4ibdu/aPSuEpe53LsUwHZWAAe+Cienc2WeIxZvyf8r33mx7v5e0420UginZdT5DbSnDgxQEbW4shL7TMiEthnbZWDP1DpMO6+KHwnPAWqe5CIo4Oquspab2NDMyY1Ih9hUkKBi7KH/m5AmsU43uCLQ/VGh7yBeMe2c/JjDf3QIAwKMl9Gi6PHGf2YkcMaEhIdeBOxGKAzl/cWyvrADLFMYqWBOWzvXMK6KKvVILW9cEEt1H1fjx/rNe4cIAquKJlDqWtuGAF0+jmKaYEtbad7gTfn4Utp4ESDWz8WjhxLPbR91juHR7OAnsNBCx+jkN2xRpB6N5c9M10Fbqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oClIb++B0YTOqk4pQmLVyyga4dqyaD1gPwycgKzpWR4=; b=PrKFzjT/W7oxT5X7EXFIhDMI5T3+NPBmSQyDnGBvQ+uwQa14n3VT1fTjFtUGXzkEI3MgvzVWqi9wmp+2s45uJDQo0de0BTk0/G/P3CyqXTzzrjnpIEsilLNiuK2TiklKtGVgQ2yHSVn91saGMxAHyO/Put0mC18tAyjSCjiIp0xfYOX9P84BYad7K/KB2aVd/o8vI63iVxAIRUzSn8OEbWGQALi/QpC3AaS/hHG4DBUQ83y2yTiuflOSv/CZi/fKniI+T03xwZTlEA1jM9zrXnFXRqp1XzzeU+K1AdqeypmV9jtQd4qrwcylfkuekTp6rLA71xZkq7pPS3nqeHyxVw== 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=oClIb++B0YTOqk4pQmLVyyga4dqyaD1gPwycgKzpWR4=; b=LevsodCku/AmPDmoRmZERPuef9oX6cZWQcpR3WMEO6dZhNgSrqEhO4E3AxsRbu2WDQTwgDZaFz4N3z8/LK/UWxs83S00PViUe/gioqh0UdbUW/hi+Q7d5Q9ANIqiQO/BOdAsIAz/BqxoBNRrFDOz1zi6MKKwhlLcTHDkYdVUPqY= 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 AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:40:53 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:40:53 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 03/11] block/block-gen.h: bind monitor Date: Sat, 24 Apr 2021 00:40:25 +0300 Message-Id: <20210423214033.474034-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:40:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a9ae1ab-e7e0-4f48-f406-08d906a0781f X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:326; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sZ4YmqViNcvl0OSFbqkFxxmKx/fTUHv4TwJhqSZm6NcLZzi7NFYISaAq+19RGFz2PHpJvfU7Imx04jkokzJBuvJBLusLZlTEoaNlYpvbBnAMN0sHBxBzQ91OxRtP6EzgQMT34sqNLm1HHFKeezghP1l0Fpth6JQLQFYtBXaTxmadsiT0Lotp1Z/Hp8vPal6rOcav/eJgwWktZj/wfn39h10e28rArYuQfti3CAMPuc5Wbj2t0TjJkX29lN8l1U1sCLRXD1LpNSczZtVXJqIF6Dt6CQUNw2PWEEkYP2RIfrHeyeMXRoF+1xNbP+S4/1eAUP+Vyub/h6ghKaQoDCEXfAMoz9niqzu9zXgMl7Vpw4O3fnNQOR43TDfXmbiNrZuF7hsWOXsIiiVJu1iNPeOPdLjrfsfMssRH8dAAF7DkW+80FiOPR4oKki1GnJxytP6F425EAQWlYSk9KCMEn0Uj082cAqJvtXA+lXV5UUM9+zE1wFgrad1G3fp7jsXo87XpsGg9TYvk2qU4ffBdBLsvtnLA6Gh/xQ2XSwO1Bxc1IfYAMMgNPakvCmZaVtmSRIetKZXNLxzKwrEhomwHIt+Fp6L9ush90uCRWFwMZUB/n8i9kfpN5P4pQc5Yhd2WIcPeGFSOyLzuMQCXDeKp8AF9idQ2gemfV/zJpW3Yxzyj6uqxEXuOBn5zCY1i2kdd2PXv 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)(366004)(396003)(39840400004)(346002)(376002)(316002)(2616005)(26005)(956004)(83380400001)(8676002)(4326008)(38100700002)(38350700002)(478600001)(4744005)(6666004)(5660300002)(86362001)(186003)(6506007)(66476007)(66556008)(1076003)(16526019)(6512007)(6916009)(6486002)(2906002)(52116002)(36756003)(66946007)(8936002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: IJUHTq0of/EJxQTVlvdAo76GjtOgFLmZT+iZPl3Upn6FDvyVGbzQKwj6KqtS1d/JqdPk47C8dWlj3LW5Hs0jh176b8bgtsHfc8gHk2qVEHqJtCSkrkZ/It+DZn02kU58EYpxqoj5XBaQ7KdERrjODksK1AM9+Knm65WDjbUQ4394FSjLOessHQ4tL8Yn7fARZ3BJpPbtPOOJANpzh8rCqoRrrg7WHI0eo8yCHpl8zPqvUkqH0CkHijLbzuHKHld5W3VFS2ldCcf8J3E3EMgvOOXYssOnhtx+iHbPUQI8KHwMA6SmmbSuR6V32y/nzHMI3MFU7yag9tN3JwbGJW/u/ale7lPQgo6TP8jWiMJ0opeYtK3Ifvpw+va3QNz4rA5hkAB61Mpuhd7oW1i4QuqmHEfFGgQHHai0YcXkkdlt9PkVhGua9xWZ65LZsJyUy6uw9VyR7at1qRNAOD71/tjQTMyJboYdtcJM5uZeF4yHdkAmZque5WgNcLAY1HiwP7KqARvKBg3+1i0rayYnqE6meTnL4/X7OBaR7aY8fzDPSK9ed1JttKVMq/zSKWWYgcToJwglVyWbpQNOdgGGX8MxJHb94XPD8Z6pPm1ODWRFperM3jc0bCidE/xarhbTcPTmsXeC3hzoTCRkUMtjbmGTxfJeaN9+uK2agywfb0KxVV6S7PJaAfWvCEqvgFe6hcNm36Gcupaml1uLJA8ZnSrWy8vWGsuu8VZIub50DZfJM4HC4kdaS94v3IcFwc2b4J5+K3FnPSCHi3KresIDQGgz0xLckMHkZ0o6X7Z0sUQN/Bpy2Ve65YC7+krzpk1I7B23fjSj/l7x+oc4kc4RNLPTqjFjlP8SdGijP4T4LiqeTwRiS9mNSwhtSlSAUxNBgDkXjF7uS/GoYdcPhB4aL8qczj8n/KuZpSPWrEQxybqVOC0IR34DrsUEwB3umMc2ab/U7U0sGcC+XjbG+IbrL4vtl0rSIpI2Rh7TtT0kEgH0mOieCyQS2ofNFR02WSvIH9mZmVomxMiKoVVc3sEbzlbnzso9VorLDyHl0hFHiudSuHO71lKKHY4noEtBPm9GR2bqy51U7Z7OBCWGVT9uI7wsYbhvzUCV16o8+vOFkVdDWU8xerHN/xI+TQKzVI+099NPuCC5ZkiBdM8OsVw3ZIqgqEXloqbrBo8eTaqKu6o7LhQqUDBrF74GBUw1TtqKELMzNQjOax5/0QshPHjggmq2psKsgBaDOVdlLlMZf52j1Qy3WBm0apnNwlzvXTyrKXIW+QrMngiq588wVuYpNleLFxiVM0zhav8xJ5LLCvCfhTN9IAKrt9XOubMcF3AFq/sE X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a9ae1ab-e7e0-4f48-f406-08d906a0781f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:40:53.0883 (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: P1UxnefKeZPcDmZ/IrV8O38mWyAQfZ25PEBHcaqH19AB45ZA+8g1ijrCKsZX5av7IJ1zs4T+GDRuv/Ra+z4OwPNoXocpbDZNk9V12zWDhkM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass client-ip=40.107.1.127; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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" If we have current monitor, let's bind it to wrapper coroutine too. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/block-gen.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/block-gen.h b/block/block-gen.h index c1fd3f40de..61f055a8cc 100644 --- a/block/block-gen.h +++ b/block/block-gen.h @@ -27,6 +27,7 @@ #define BLOCK_BLOCK_GEN_H #include "block/block_int.h" +#include "monitor/monitor.h" /* Base structure for argument packing structures */ typedef struct AioPollCo { @@ -38,11 +39,20 @@ typedef struct AioPollCo { static inline int aio_poll_co(AioPollCo *s) { + Monitor *mon = monitor_cur(); assert(!qemu_in_coroutine()); + if (mon) { + monitor_set_cur(s->co, mon); + } + aio_co_enter(s->ctx, s->co); AIO_WAIT_WHILE(s->ctx, s->in_progress); + if (mon) { + monitor_set_cur(s->co, NULL); + } + return s->ret; } From patchwork Fri Apr 23 21:40:26 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: 12221785 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.7 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,URIBL_BLOCKED,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 974BFC433B4 for ; Fri, 23 Apr 2021 21:45:54 +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 0A65A613A9 for ; Fri, 23 Apr 2021 21:45:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A65A613A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3cW-0001ua-VV for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:45:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Xu-0005Es-9e; Fri, 23 Apr 2021 17:41:06 -0400 Received: from mail-eopbgr10127.outbound.protection.outlook.com ([40.107.1.127]:4578 helo=EUR02-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 1la3Xs-0002m3-AZ; Fri, 23 Apr 2021 17:41:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nLe1VJ3bs35SjeXidCy8Ty167ATkaSn3QL2X7qU0ULqYKkdaBf3LOjf2V65cUwNwvuWCNJkT2vpAXHSjSNhTotzq/eE9K262U0U3s/Rb24/PxnjBCJc3Cms3Zm5hMwoyZEJGU4D3a+PgoFi33libNaip1PjjzJYB0zB5TJ2e55TxXB07tZScwZqGbABK6dC/VUiNC7jRs33ecaB9PLHsCTdhaoYuSukv4aOJh2rRJtRP3Oj/btrSHtUgINXbq+sznXX9wI/CnBqDfV+2pkM36gz0UWlwMFM9DK0xl5hqWjTJVfZ3UIw98fYVEHdtNd5MSciisb4axWgh8v9K0Y25uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l0CLww6oHv816wdkB3jTEGI4imhm6esyB1dev91jFnY=; b=ANbxNhtcaPSaWGsH4F2pyVzS/M01KdtyX+JQ5QTDXCL0CyrVNoWoNkiWKrMtKUvZUWT27TdSZ0mhvLgc7BDEqSZVIzN47KBiT5d2WtgvxDRPpOcF/4GCJ0cTXtZzMB6kGBhpMIlP+E3EyU3pQc+UwgyHzvp94AL4qT2H3GKINfaRngq6ci0phbnEeh6w5iSS2RYqtociGihEzK6xheK50bnUeIe46F91pninzOaCyN97JpnZKKfAhUsiiM2Tk/A6jCvB9pyGrUjUO+QZBfUuT/TXqNtzO+t2iO7MJIL3o4p/rHsDHb4gooD41KnRaYIZ8o4uShjygIojvLG/kuYrrQ== 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=l0CLww6oHv816wdkB3jTEGI4imhm6esyB1dev91jFnY=; b=cJHYALsT+m4lbQKfyyF24QU/aOD9Xdx7jvcy5iiEg/25gcSwfn3k6aB0NqdaR7ySieqJad1wAQi9SuymqO6d927cX2fIQwny3kbj96+6Am4cnfnv5+oGLE9/Gc6Fy/LV0RcCApJCkkak2k+8MQ5yn5DOQTgeeuSyzwKjKaZ2UYI= 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 AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:40:54 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:40:54 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 04/11] block: introduce bdrv_debug_wait_break Date: Sat, 24 Apr 2021 00:40:26 +0300 Message-Id: <20210423214033.474034-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:40:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5f579041-8730-4aa8-98df-08d906a078c1 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:207; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vpmtg/Ic8fWL9SZaaJ8BsnE+QcmGI7LapeapejMJAEXL0dWODZezT1MtxRxhteh19KrbOSjToMLpygXkkR1mLGJVbWDV0F9q0oxqaASyb0+XqXHFx5r5IcZu/ONkLgwe4sIO15Xd9BQogJfGNe0FJQmDWidzk1pI0LQSue3wrlZ1i9k72wM3gyQ0bolV9BbuXsq5+c2ldENz6zQTm0d2XHtsQt1pOKUPkC1NXq57TrtvVTGjn8EANFq4AJaibAxYaTZSDrIBARRITm3zoIOoOPfFQLvwQb3wtPt+O6rOHFAig0rBk0A671RnYoIAYa06U8Zg3LY+DiUrEvDC0xuermi5BA4ybblBV/gJAU6778JrRcnY9MWSYgp1+Dll5abj/MC/1zm0Ldq1Qu8cEwKM2Psw3aLNAzlb/OJW0xxOO39yL2/xZhShtK8KVKAkEgb3kR46VrEsv3TR6r7NBQkWT3jpZ9p5+AEQGXhyxyubZlmtF1CsvzdwV1PvWQntifNRvKO/jS6hL9H8B3Ptrbh5gP3rN0BziNn94axLFXp4UjZ5rLLe4ELFhFhME0f9r5h/538oqyA8EpZmZzc+eWdFHCbN+yC79tYzQWNL/VyKbGnXi4+CP3Ui+JSX3nE/XILO+hgQs5RVkGukQjQWyj7DxEBZ8NsBL9Jto5hldLY9Elybo03S/8K8YJiR0EONse35 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)(366004)(396003)(39840400004)(346002)(376002)(316002)(2616005)(26005)(956004)(83380400001)(8676002)(4326008)(38100700002)(38350700002)(478600001)(6666004)(5660300002)(86362001)(186003)(6506007)(66476007)(66556008)(1076003)(16526019)(6512007)(6916009)(6486002)(2906002)(52116002)(36756003)(66946007)(8936002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: tArxdz5zX7rMy9cEHxhZrwahS1jTFuQavPFkd4vkUH8V+CatRQ8hLNOI/I0fEO2W2Wr8ZH+TldmTFwTVWUlnzBj21+Ky7bGRXyUM03nxTrYu+JRRrOKMe4b+nBPkQC2ABPouQjQP4hbZeuj5nPpq+LnOoA8vJPECeuXgixVCyiuQNNSmch5T3eUKFsN+xpP94ZEWpPi3pa2IFdDnnUt+bsINKVCrFsykM5KRmDLd6ENx3HBpwRAW685N5E0g4mwody8anIUSuH1DDCv0r+rxaiEHhNKNtJrOpPMpYCLgZAdWEpOM4mHqx3+BfO/e4uly+nE5u+s+qn3uYKpMdkoukaUTKxMHVasNJeh9wyXNMvSzqdUFtdj2OBANRcbJpYyO3gVh9B06q1KQNctV6Kr2d6hJyGEOjMvKTZdiXKHA177IBEdu6dBVSNdWUv/9Dnp5jac89Vxr+5q5uYbcEotj/wTAWJadt2VA7d5s9MtxIuXmCGoMKDqaMXN814WVYutRFYnQsCOA8tsLh8WPbiTiVFnKevRMIENbjDbQwEPHbHo5IulnK0KUMZJk/HX+gWNOQHq/J9csC9Rc1CMN7zSUZSN2ygdzYMJTACOZY+kn61tChYilED7RMDBZRPIL/VqsGxaFvIcmSmft7zx4v6j6GbecKTfl/inseEMrpVGqxOi7AX4uQwxWiOW8r3Bv3GDXh+f9s0YqnFToUxAZkclEXdiSGxTKlKsq7NKsP+w5ASno3UAJVlxcMuBZMysWoUhdReMc474W7kURgo3i+HeyHvEmzJ9yVz5agqgmtNpKIpzXJFRTJrtjSicHJqK+IYJ+uJW/iDymL50gdOkmfoJtfnkgc2kV0QgLg5UNrY/i6oIhiCzgfLlTz618mKiwQlf4ZeWpXdG8kTceCbco6yDpTqYNa2fPKwnUr47/rDbrGQqfoMYargPVQEEaejsX/MgmUu74ch5xFx2WKCazpH8MIxV2rACB4eN4+knYqbNW67xa1VR7sc4heit83RuZH12V3SN+iztcbolJWo7gn6Hl1tPNmrkKHMr4bKXaDLUgp7HN/poUhjR+w95Wm1vAiyBTECRoz5pT3ihV2/MB8vjo6D/VNIuQtC9Mc9KBeCL0SuTNrfnNtjmnXvZ/dT5l48M0fEJt0sYiCYsO5tnsdnX+MsOTgDzOJLHLXjGP9HfrGe7HTHIdNrBAxbXmylx4rKTJkMU1ESowUc0hHvZ/awloAddCAx8aNNeSlt9F2ynpjS6K+2cWePWLhMDoOCu0Hz3/v1NS+jwVqCZFz68H8A4y8j1Z3mpKodZwxcEb/wWaQ5m2yVT1y8JSoFPxEpeoVNfv X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f579041-8730-4aa8-98df-08d906a078c1 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:40:54.1447 (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: Q24vnySDV0sZKqeGHhyzonShsnwBCv61NhmrnH1T1JqsAMLHg36EoTg2n4NoX60LdGrybgN/1GpudvS5uF57YU3ixydryCpVcHi1pFtjZt8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass client-ip=40.107.1.127; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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 a handler to wait for the break to happen in coroutine context. It will be used in further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 1 + include/block/block_int.h | 1 + block.c | 11 +++++++++++ block/blkdebug.c | 16 ++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/include/block/block.h b/include/block/block.h index b3f6e509d4..e133adf54f 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -648,6 +648,7 @@ int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event, int bdrv_debug_remove_breakpoint(BlockDriverState *bs, const char *tag); int bdrv_debug_resume(BlockDriverState *bs, const char *tag); bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag); +void coroutine_fn bdrv_debug_wait_break(BlockDriverState *bs, const char *tag); /** * bdrv_get_aio_context: diff --git a/include/block/block_int.h b/include/block/block_int.h index 50af58af75..89e6904fc7 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -502,6 +502,7 @@ struct BlockDriver { const char *tag); int (*bdrv_debug_resume)(BlockDriverState *bs, const char *tag); bool (*bdrv_debug_is_suspended)(BlockDriverState *bs, const char *tag); + void (*bdrv_debug_wait_break)(BlockDriverState *bs, const char *tag); void (*bdrv_refresh_limits)(BlockDriverState *bs, Error **errp); diff --git a/block.c b/block.c index 001453105e..3ea088b9fb 100644 --- a/block.c +++ b/block.c @@ -5702,6 +5702,17 @@ bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag) return false; } +void coroutine_fn bdrv_debug_wait_break(BlockDriverState *bs, const char *tag) +{ + while (bs && bs->drv && !bs->drv->bdrv_debug_wait_break) { + bs = bdrv_primary_bs(bs); + } + + if (bs && bs->drv && bs->drv->bdrv_debug_wait_break) { + bs->drv->bdrv_debug_wait_break(bs, tag); + } +} + /* backing_file can either be relative, or absolute, or a protocol. If it is * relative, it must be relative to the chain. So, passing in bs->filename * from a BDS as backing_file should not be done, as that may be relative to diff --git a/block/blkdebug.c b/block/blkdebug.c index 2c0b9b0ee8..10b7c38467 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -57,6 +57,7 @@ typedef struct BDRVBlkdebugState { QLIST_HEAD(, BlkdebugRule) rules[BLKDBG__MAX]; QSIMPLEQ_HEAD(, BlkdebugRule) active_rules; QLIST_HEAD(, BlkdebugSuspendedReq) suspended_reqs; + CoQueue break_waiters; } BDRVBlkdebugState; typedef struct BlkdebugAIOCB { @@ -467,6 +468,8 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, int ret; uint64_t align; + qemu_co_queue_init(&s->break_waiters); + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); if (!qemu_opts_absorb_qdict(opts, options, errp)) { ret = -EINVAL; @@ -785,6 +788,8 @@ static void suspend_request(BlockDriverState *bs, BlkdebugRule *rule) remove_rule(rule); QLIST_INSERT_HEAD(&s->suspended_reqs, &r, next); + qemu_co_queue_restart_all(&s->break_waiters); + if (!qtest_enabled()) { printf("blkdebug: Suspended request '%s'\n", r.tag); } @@ -922,6 +927,16 @@ static bool blkdebug_debug_is_suspended(BlockDriverState *bs, const char *tag) return false; } +static void coroutine_fn +blkdebug_debug_wait_break(BlockDriverState *bs, const char *tag) +{ + BDRVBlkdebugState *s = bs->opaque; + + while (!blkdebug_debug_is_suspended(bs, tag)) { + qemu_co_queue_wait(&s->break_waiters, NULL); + } +} + static int64_t blkdebug_getlength(BlockDriverState *bs) { return bdrv_getlength(bs->file->bs); @@ -1048,6 +1063,7 @@ static BlockDriver bdrv_blkdebug = { = blkdebug_debug_remove_breakpoint, .bdrv_debug_resume = blkdebug_debug_resume, .bdrv_debug_is_suspended = blkdebug_debug_is_suspended, + .bdrv_debug_wait_break = blkdebug_debug_wait_break, .strong_runtime_opts = blkdebug_strong_runtime_opts, }; From patchwork Fri Apr 23 21:40:27 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: 12221793 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.7 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,URIBL_BLOCKED,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 99F1EC433ED for ; Fri, 23 Apr 2021 21:48:57 +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 05D6A613A9 for ; Fri, 23 Apr 2021 21:48:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05D6A613A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3fT-0005tZ-Oq for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:48:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Xz-0005K8-7e; Fri, 23 Apr 2021 17:41:12 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:24032 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 1la3Xt-0002zb-MT; Fri, 23 Apr 2021 17:41:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jqKvhcdy6LHjlBfZKNDJKSE+Asqpzqi4z1YCBTkezEQTJ/hh95IY18zvCWt63nkGnm6cVefTOPqRrfdLhuE66or5SgxqK85g/vCYibr27P7gjtvs18z6BQKrY6ZIrpBMEOyBgn+4sjE5gl9qd6WtLVHnUJSixCCqT9eS/P60MzkB7jrdUtnVpH69d03HXkWF9R0k2NvpDcmxdME2EriD2BzkP5mhp6PcqwuvJgv/AXKj3LR8NjKC/bwNP+KQyTtsk9KMfnuBHPqX8pb3x/+/nxlRPnZPT9QhPWqFVL8xx6zUIzgQf/7xvwkVsCOPu/YMx0Mc7D63Sp0tb+K9DQUt6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TiMBlb5YAksGckFjOqZA4SECGLoEWuX1V5MaI84x2Cw=; b=MxEcNOqa9zY3eF+PCjTkFpxUBNbFyHeQwEtaVGyMoqod6cNmHI3yQpSMLWdqv8DL7v1PABgZCeOvuF0c4+JUvGGW37ERDXEZIkkutP7uAMsRieZHErq7bnAHONcsbJ5HnJMOCJx8+uxUY+8JA/O+jovWBU5dskgziOEa77HmJuFcxEQt6WhzvcV5Y59esBuUl/vKIfWiXsKGhmFy6HVUCJJISJSoRsGPXn+uzTJ2ZU5U2isAK4CwDazklrzC78xlVihzkgBgvx+iQ19BMjfkuCDXsyqn62kpgc5XzHwiOqSMaldRCNtKiXsh8aVK/iUR5o9t6Bzp+C63Asphoao+9g== 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=TiMBlb5YAksGckFjOqZA4SECGLoEWuX1V5MaI84x2Cw=; b=hzT/c4jA/hhLoFzpwi2a6MZHAe0Y2gecv3hEbCRBIgA0Laszw8bLYE1eAr72qOHuZwmhq8RMgY9Sxu5sIFLPu8fG24ZtM4AI86hmbVxspJs7TT7L1nOR84Av6UWj7l647zncTh7IBXfBcULd3iH4RUe9zuKgpNMMNOea7ylGOT8= 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 AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:40:55 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:40:55 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 05/11] qemu-io-cmds: move qemu-io commands to coroutine Date: Sat, 24 Apr 2021 00:40:27 +0300 Message-Id: <20210423214033.474034-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:40:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 250ddf78-d393-437c-74dc-08d906a07964 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bhWIiNc8LvVLgxAyZBzSGCD0ayTvrwhei4MpOPCDHfEH4xX/oJNRPO1xwD63yAXuFsJfiuc4lqFs/YX6JX6XsQp//fIirwsH7MVd+myMYM0weL8IY4dz/zKQJ2p/eZdDiyRUvAv4rwjXii12pEVzZw5INRXHUnCD1b1PL2BzXFcn79cGImlOKV8Zmjv5f47sfybYxaRHREhPOeMLDgKffpCkNWVHn5BfSHcVjGViATsHOwwenrHywOkLcxjtmVK+7/Or/gGGXBGhfiWVKU5b9UwXCtFjrhFyC0FbOYfdau09gab+dDBDyQtNqozbXSNpkI1rbP90K7U4/HEbHlCSvMWUyHtXX4cygYJkdIaZ7O+PQgorjQVkvK7sbJ343yIK15t7iMNNRp1rx/5M9/dzcIy/Jhj0el11OpsqO6JJkypnpqtVpfWaDh5+j85DuoNA/LoZl+XOiVxm4v9thx7Z0B01AslAod/TlAoaijsygzYYXFKqwCvoudl8eXq5WrUNmBorMvHyXmoz5+BrDIDvkSnf+rJjpKMyt4pK6qTGuVsRYnHz5h3qmITWxCKtb776YkceyM38kdeJrJvkycjfvs3XaO0ugnFhaxr3XeWajA7xq52/HIICPKJ7P6vmAGWbw/b91iRGsLeuU0990f2uCwpfdN3nSGE6n6+L3CgQ/5tfpd9+VGXOI/6qxsNJmvs2 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)(366004)(396003)(39840400004)(346002)(376002)(316002)(2616005)(26005)(956004)(83380400001)(8676002)(4326008)(38100700002)(38350700002)(478600001)(6666004)(5660300002)(86362001)(186003)(6506007)(66476007)(66556008)(1076003)(16526019)(6512007)(6916009)(6486002)(2906002)(52116002)(36756003)(66946007)(8936002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Pi4DbhgpZRO2jSIcCEMKbJDKr/YGVIhg7rnN3T8lYLY0tuJd+7aRuJ3FYJRvjHEBadD+RURimyadipWHdUexzK538A+tde30O6dXNJ+5AFQamlgHC9dxUq5NsM1KWyatMLhHcgU6F0KON3WRTJ7jx3DOlHXV0L8mBZT1MUn+AHM41t6AWWnK4afbPDL+YfDSwM37WlymA9aNnAAvO9u3BYyQwz64RFYRKkZGHiwf20TfhVO13DcIUYq14GBbvEXPZQnr5YGQhjG6rdyERRTy9uxWRrmlkEKkIa02DOrOPwtV4jIcsLCxXTBMDoR0abfTeIIriHqbJLn3OkScjZ4VJy1XH2dn5TRyiu5diQ/HrsxQE0hPtFqAbQ7mdwPm5nTjaYcN2S2E93i2rKAnJAtbmxZAvgx0j5ZNh5/LJg3srqvPJFTc+xbbvRA1V6hNm0MchAIjn4bef6LENad8FuW6OA1y3CG+8EfzCVRdR+8leXPHvOdKBOw1MLwsuRGYXDvx1/QG6WC0I+YU/omIGmIqYoE6bdOwiolo+Y53gNnPxAyQvTVw6O+d12GC9aml+Mr5mpzYmpbt44fePtNw0fbCvVsxTGzFMi25nP643/nyWA3Uqg5zaRlNCUHGBRs6mzfRGm2aMYumjI46vYcIGtGakTNW/dasglbD4S11nhF4O5jzrmDi4i87P2NkHUe10VsxbIr0fmuQssn0ZSFgbjAyAiIFbsBExehoNmhRHDD5mShAylokEmlQxVVXqbpQtfw3yXtsk9IdAGRGaWEqlsESXtoKRtGj6c46PSCmGlylJmPJTFnWHyX+x+Fhm54jyTBRM2QvoGnHoShwafWwuT8pw64nfvSO1EP8l406/drH31orYXKb/f2UuqvN9q2puc0eg+uhaM9yJtbZetqndi5UkhV+TrmTNaYDya+YH1JZHw1Fx9evEucmc6YtwkO90xBH1p3SM+8+16dlOzzzn2xEr2+x6oRGrBsWoRnYNBMSAH2Sy6o7/uN5hCahesbm8WexmVBQnjfU1Iyqm/bzAG73kPM4dZgJ9DqfJTdP2Fzx7sQDp5JCqTgNSgRXMsIcfYkl07bqfwEOiIrC/a454gA+QimyMl29diDle8F46t7MBUkKWv+dz+EOpWZj/r/VyNRefgOSQghM5z5bjF4g9Gyn2676sLnQ2Y1CsvubvB+41eK4MI55gSGGLs8P2n++Tlb0El31PzrcBOvj09KNHmIbBaXrDrFvztm/qyigjGytrKarSrqz7m/brJ6QwAe4oFcDUMMR10YgmMAn6m0dy4ZOiaQjKxw5OkdDg97E/oe21mDojppicbwK0O5CkgmVaLnA X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 250ddf78-d393-437c-74dc-08d906a07964 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:40:55.3176 (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: WMK1OsHtw4KrY9so85H4A1ehLNpKgWsRg6YeBX60oukaaQk4VQ+m+Yai9ox3NLjzCBqIvShwny9Ib+QsY9zYevj36NjIwPuR6WAFCmr2QZ4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass client-ip=40.107.20.117; 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" Move qemuio_command to coroutine with all qemu io commands to simplify the code and avoid extra explicit polling loops. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/qemu-io.h | 9 +++- qemu-io-cmds.c | 110 ++++++++++------------------------------------ block/meson.build | 3 +- 3 files changed, 34 insertions(+), 88 deletions(-) diff --git a/include/qemu-io.h b/include/qemu-io.h index 3af513004a..71cca117b9 100644 --- a/include/qemu-io.h +++ b/include/qemu-io.h @@ -18,6 +18,7 @@ #ifndef QEMU_IO_H #define QEMU_IO_H +#include "block/block.h" #define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */ @@ -45,7 +46,13 @@ typedef struct cmdinfo { extern bool qemuio_misalign; -int qemuio_command(BlockBackend *blk, const char *cmd); +int coroutine_fn qemuio_co_command(BlockBackend *blk, const char *cmd); + +/* + * Called with aio context of blk acquired. Or with qemu_get_aio_context() + * context acquired if no blk is NULL. + */ +int generated_co_wrapper qemuio_command(BlockBackend *blk, const char *cmd); void qemuio_add_command(const cmdinfo_t *ci); void qemuio_command_usage(const cmdinfo_t *ci); diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 19149e014d..adc9e64c37 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -555,56 +555,16 @@ static int do_pwrite(BlockBackend *blk, char *buf, int64_t offset, return 1; } -typedef struct { - BlockBackend *blk; - int64_t offset; - int64_t bytes; - int64_t *total; - int flags; - int ret; - bool done; -} CoWriteZeroes; - -static void coroutine_fn co_pwrite_zeroes_entry(void *opaque) +static int coroutine_fn +do_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, + int64_t bytes, int flags, int64_t *total) { - CoWriteZeroes *data = opaque; - - data->ret = blk_co_pwrite_zeroes(data->blk, data->offset, data->bytes, - data->flags); - data->done = true; - if (data->ret < 0) { - *data->total = data->ret; - return; - } - - *data->total = data->bytes; -} - -static int do_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int64_t bytes, int flags, int64_t *total) -{ - Coroutine *co; - CoWriteZeroes data = { - .blk = blk, - .offset = offset, - .bytes = bytes, - .total = total, - .flags = flags, - .done = false, - }; - - if (bytes > INT_MAX) { - return -ERANGE; - } - - co = qemu_coroutine_create(co_pwrite_zeroes_entry, &data); - bdrv_coroutine_enter(blk_bs(blk), co); - while (!data.done) { - aio_poll(blk_get_aio_context(blk), true); - } - if (data.ret < 0) { - return data.ret; + int ret = blk_co_pwrite_zeroes(blk, offset, bytes, flags); + if (ret < 0) { + *total = ret; + return ret; } else { + *total = bytes; return 1; } } @@ -654,38 +614,22 @@ static int do_save_vmstate(BlockBackend *blk, char *buf, int64_t offset, return 1; } -#define NOT_DONE 0x7fffffff -static void aio_rw_done(void *opaque, int ret) -{ - *(int *)opaque = ret; -} - -static int do_aio_readv(BlockBackend *blk, QEMUIOVector *qiov, - int64_t offset, int *total) +static int coroutine_fn do_co_readv(BlockBackend *blk, QEMUIOVector *qiov, + int64_t offset, int *total) { - int async_ret = NOT_DONE; - - blk_aio_preadv(blk, offset, qiov, 0, aio_rw_done, &async_ret); - while (async_ret == NOT_DONE) { - main_loop_wait(false); - } + int ret = blk_co_preadv(blk, offset, qiov->size, qiov, 0); *total = qiov->size; - return async_ret < 0 ? async_ret : 1; + return ret < 0 ? ret : 1; } -static int do_aio_writev(BlockBackend *blk, QEMUIOVector *qiov, - int64_t offset, int flags, int *total) +static int coroutine_fn do_co_writev(BlockBackend *blk, QEMUIOVector *qiov, + int64_t offset, int flags, int *total) { - int async_ret = NOT_DONE; - - blk_aio_pwritev(blk, offset, qiov, flags, aio_rw_done, &async_ret); - while (async_ret == NOT_DONE) { - main_loop_wait(false); - } + int ret = blk_co_pwritev(blk, offset, qiov->size, qiov, flags); *total = qiov->size; - return async_ret < 0 ? async_ret : 1; + return ret < 0 ? ret : 1; } static void read_help(void) @@ -910,7 +854,7 @@ static const cmdinfo_t readv_cmd = { .help = readv_help, }; -static int readv_f(BlockBackend *blk, int argc, char **argv) +static int coroutine_fn readv_f(BlockBackend *blk, int argc, char **argv) { struct timespec t1, t2; bool Cflag = false, qflag = false, vflag = false; @@ -968,7 +912,7 @@ static int readv_f(BlockBackend *blk, int argc, char **argv) } clock_gettime(CLOCK_MONOTONIC, &t1); - ret = do_aio_readv(blk, &qiov, offset, &total); + ret = do_co_readv(blk, &qiov, offset, &total); clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { @@ -1047,7 +991,7 @@ static const cmdinfo_t write_cmd = { .help = write_help, }; -static int write_f(BlockBackend *blk, int argc, char **argv) +static int coroutine_fn write_f(BlockBackend *blk, int argc, char **argv) { struct timespec t1, t2; bool Cflag = false, qflag = false, bflag = false; @@ -1235,7 +1179,7 @@ writev_help(void) "\n"); } -static int writev_f(BlockBackend *blk, int argc, char **argv); +static int coroutine_fn writev_f(BlockBackend *blk, int argc, char **argv); static const cmdinfo_t writev_cmd = { .name = "writev", @@ -1248,7 +1192,7 @@ static const cmdinfo_t writev_cmd = { .help = writev_help, }; -static int writev_f(BlockBackend *blk, int argc, char **argv) +static int coroutine_fn writev_f(BlockBackend *blk, int argc, char **argv) { struct timespec t1, t2; bool Cflag = false, qflag = false; @@ -1304,7 +1248,7 @@ static int writev_f(BlockBackend *blk, int argc, char **argv) } clock_gettime(CLOCK_MONOTONIC, &t1); - ret = do_aio_writev(blk, &qiov, offset, flags, &total); + ret = do_co_writev(blk, &qiov, offset, flags, &total); clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { @@ -2283,9 +2227,7 @@ static const cmdinfo_t resume_cmd = { static int wait_break_f(BlockBackend *blk, int argc, char **argv) { - while (!bdrv_debug_is_suspended(blk_bs(blk), argv[1])) { - aio_poll(blk_get_aio_context(blk), true); - } + bdrv_debug_wait_break(blk_bs(blk), argv[1]); return 0; } @@ -2457,11 +2399,7 @@ static const cmdinfo_t help_cmd = { .oneline = "help for one or all commands", }; -/* - * Called with aio context of blk acquired. Or with qemu_get_aio_context() - * context acquired if no blk is NULL. - */ -int qemuio_command(BlockBackend *blk, const char *cmd) +int coroutine_fn qemuio_co_command(BlockBackend *blk, const char *cmd) { char *input; const cmdinfo_t *ct; diff --git a/block/meson.build b/block/meson.build index d21990ec95..27e11aa199 100644 --- a/block/meson.build +++ b/block/meson.build @@ -114,7 +114,8 @@ wrapper_py = find_program('../scripts/block-coroutine-wrapper.py') block_gen_c = custom_target('block-gen.c', output: 'block-gen.c', input: files('../include/block/block.h', - 'coroutines.h'), + 'coroutines.h', + '../include/qemu-io.h'), command: [wrapper_py, '@OUTPUT@', '@INPUT@']) block_ss.add(block_gen_c) From patchwork Fri Apr 23 21:40:28 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: 12221799 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.7 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,URIBL_BLOCKED,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 7B964C433B4 for ; Fri, 23 Apr 2021 21:52:15 +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 E0FEC61468 for ; Fri, 23 Apr 2021 21:52:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0FEC61468 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3if-0000Op-Rt for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:52:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Y1-0005Lx-72; Fri, 23 Apr 2021 17:41:14 -0400 Received: from mail-eopbgr10127.outbound.protection.outlook.com ([40.107.1.127]:4578 helo=EUR02-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 1la3Xv-0002m3-5Z; Fri, 23 Apr 2021 17:41:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U0Qmx74U/2ocJAuK0z8Njscj3WeKGMV7GgQPg+1hkoqJ5/keYzxlYyNvE8ukSSDnuCNAI/6s39f+AyhHrpN9Yk7m0s9rT9tTpu8KegpaYEt6JyeGVUW/jp6pCB0RuKSdkSNF/9nwVB5dR/u4RNIG5RF0bi6wU5sf8RKQ5WB9iRNLA2s2y+dExuTSYznvut/9NCMXpvPF5fVZMBW3oEYFGvuTvXzlKnKYXfR4kxhe8RHCiIRS98Id8FBN+m+45Tdgk7+3M/gAlw+CEqeAfKJhRnFyxlwMfTpY+VSrWvom6HV+mLSWTR18qRcxpdv5l/hXApsfInL/x5JjQ9ExIQ7WlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ejffH2BXeykb0UAom+794M1nGPysIzTmJ5B+o3zqIn0=; b=BDZkoI6Gb3mWO8DOr8SOvPeSF8hPLcV6wt25kUjoKkwXMeRj2QD5VLIIbcFKxwK7QXU/haH7WpOvdRwSTxpbU4em4/s0VfNcm5oEKH57Hu6MzM2RMf3HG9tzFyv2m4L9xy0i8r8dwFKmj+/HWnxmXOYwjNt1L9ZPHul6JwbYvhoGf0qs7NxUVGGhdVy7lh5XjimhvPZH3D/gMCigQ43NSK9crVnwANYWNV2wfvPaXEJs0dJGtDY7RkKtprmnVwKAI9x6leayC7P58Q7q2UOcDX3fN3VKg6zR5sBI9zB9USk1/zXmy3/HR+pyz3AaMFCPhJqula2aTrAV/6dHFTIYhQ== 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=ejffH2BXeykb0UAom+794M1nGPysIzTmJ5B+o3zqIn0=; b=kKQ0VApCyiz5h6zMZEAtdLcuEZCCYWcZ7myqakSiOq2Z5/HDZ9W2YY2BEO/zVCn8FDaSoEYtYWYBOCx7TKH6M5v4Zf/jHrAqwhbuPwq6l0DtWesxlKx8Qi+sbp/G7XpVBmC5L67Il0XK8qNtqWPKgf6A2l88Oy5tA9nNLeQKtng= 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 AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:40:56 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:40:56 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 06/11] block: drop unused bdrv_debug_is_suspended() Date: Sat, 24 Apr 2021 00:40:28 +0300 Message-Id: <20210423214033.474034-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:40:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3101813c-db26-4105-b9a6-08d906a07a23 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:265; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RDRZmMt7Qyhb/RqEFuFjbx2WzH5ZgTqkE0rVeuSxNZWAAE69fxmbKXFXaYRd7cfgxNueA1eAXIGA93/jFojMj39Tqmyyio+xck0/FZOwa+2W2yRbyMJynNW+Gx97K4ICDKVTsVU0dETL36dySHJWTkjHFGSoYgEbhvJLwLBmfFcAkTHgaacV8E4YWBelP38VF6m/PBQKRE0MQx6pRni5IDCZfbyWDT6SFRjZwuAnfHgwPOe9bPBa4Hgddd3GC0l/3mqZ3OQwZ2sjeqTSkIqdWK0RHJLNWILpcAx3sOs1VblUtJ8TkqP6sVvVQgZdfjP5ERbKgt0Dc3nIyy/Wlo6WBCll/InORE1wiX4NvPQ2hOmzBevzul+oE8aaNrgsDH74XO+BYj1uJGEu5OZharSi+XeKl12DM69GAeYxQXTIul4DkmdYITNCBNP1n0kV9bjy7jXchLoWrnqx5bD3m4ss1SFVnhuNInCH+esJQFZ7B+l95UJVfpdR1w0Nij3DU4JzxIGOTQOK8cNOJ1AiFSnqnZ10lkYAXu8yJEG+yBUlXYsWHrdPeo4VokCn3optWkuJTw20Vx/ZwoEieCKoqVtPp2CczxBRQ7F1GzRfZUW+XC9VVx+tulrlg/ylugFscuhBGH4oWSH8aKaTODt6aP53dug3GsNX7No33pjyqy/tQ01BuFNoZF80YLP+jIN4rRjQ 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)(366004)(396003)(39840400004)(346002)(376002)(316002)(2616005)(26005)(956004)(83380400001)(8676002)(4326008)(38100700002)(38350700002)(478600001)(6666004)(5660300002)(86362001)(186003)(6506007)(66476007)(66556008)(1076003)(16526019)(6512007)(6916009)(6486002)(2906002)(52116002)(36756003)(66946007)(8936002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Ykw+BAJOiEwQT5EWiHPqOOnRrLvn4IXw4XfCMQMoRpYgKSlQhpWffUj3EOsdVw5/0dlDDxagwfk/+lo6JS6AmIqZa03Z2PlwEAzUlSvaP+zjslKV3RenD0P4ivx7YM+huGqfWvvkN0un3LNtX6mgM5s9OPifDgHOLUszkNiSgOTERr0cPc4TENziXwQuhq8l6kRcuu4FI3myVIwxmGaIF9z73YLUxhnx2GjLxmnrlLyqT6m4gQZSDpHJAzJyS4LKuHzRl0eYjreQd6A/ppIH4V4K1Lr9R/aIROKRG6kEStRN1TjJ/z9wEB/sLLP9ufr+zX9BH12Kdk6efPkkVCJ/GJkMSuN7teLC0r4P/CIWCApAoJbTEhQh+/h+sZjMeggziDrmi5Z9V8tI2yfCLktFiRHakwUuXLr7aibGcqxhQ77C5sahlWrUrK9nYIFS0H+g/KjOoX9IohgYOLvb4GVuK5MzZs/74IOZ3pYniEnUpzobIJh9NRNxJKsQCbjlB+uHhKCaHIkQG+X1sw15mMtpr3o2gFdTOxf6AYS/iwbZ9iFqDnqnUmF1huV3FKPi34WtC/iVwXsnnkA+WocYgx44bKm9sHQTdc6qBVk7eKUHKPjn3NjoVEvwbJsZa5Mom5+zT3Eunokj+ardZ/SzumNFuFP0Y5H3AjC4LOuGoJfBv9AhWHlyn0HXTzzquGYBCIVeogTUBAMORIG+0ed8K+1RqMc1JrotfFenW57RzE2vWo595l7emKw8X98GleCYT+Sf61H104NbH9jRcb60z2ucwbExKutBv8MEz+M6yC8UT2qMWE3vS6Q/gnyxIzugvCabeGjYjnzvpcQqA9Cme4P/3dr9guiZ5GxPlIOx3wQST0jkDHPrDXdu1A9G1reSI39FnmBDHmgEbf0ZTKu1DhKJGUfENJnB6aw2a/6iCu45byZXxKUr8iSCFv1/KU01a5XkceFfU7IRH11/LgU7MUSS/amHFUv+/HLNnGJJanNQsTJNJMZwMDuGSrlzXubWiil3DQj+1ScW974hxfBQs1WLYZqMQymi+sz766GImM3ivUhuBlgrcWSyA8lIDKOMgcqaT5NAdKyOcnwzhuBjDmESZD0pbuLZtGNx2u2QuMiej13ZopDbJvYBDLod0JL8MxCH/zA+2eSMH84A6ZsxFC8RbCovrHKnVAIzpHMC8fHSh00KIAmB/ZnaKuvcaDuWTYM8jassDRp+1i87M4kpOokAJfLfIfmLp70+f2whhA9gxn98LV5QR1jUkYd1gGROFW2ZXYAn0uWw2HyoymtL7S2G3MtdtRCoQQ+BpqHdRPCsrqwpk65A52Ks3bjwmeERMPuY X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3101813c-db26-4105-b9a6-08d906a07a23 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:40:56.6378 (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: RDiFJsOKsPAA5nT7YrfEGXidElataM6/FnsIg9YNgM/2obU2AgmeblFlgUBOcuC4I/132pT7vg5m9ArOpo9OOhw6gz1uyKLY6wuboRa0h8I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass client-ip=40.107.1.127; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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" Now it's actually substituted by coroutine based bdrv_debug_wait_break(). Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block.h | 1 - include/block/block_int.h | 1 - block.c | 13 ------------- block/blkdebug.c | 1 - 4 files changed, 16 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index e133adf54f..fb1897c1e8 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -647,7 +647,6 @@ int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event, const char *tag); int bdrv_debug_remove_breakpoint(BlockDriverState *bs, const char *tag); int bdrv_debug_resume(BlockDriverState *bs, const char *tag); -bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag); void coroutine_fn bdrv_debug_wait_break(BlockDriverState *bs, const char *tag); /** diff --git a/include/block/block_int.h b/include/block/block_int.h index 89e6904fc7..592acc960f 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -501,7 +501,6 @@ struct BlockDriver { int (*bdrv_debug_remove_breakpoint)(BlockDriverState *bs, const char *tag); int (*bdrv_debug_resume)(BlockDriverState *bs, const char *tag); - bool (*bdrv_debug_is_suspended)(BlockDriverState *bs, const char *tag); void (*bdrv_debug_wait_break)(BlockDriverState *bs, const char *tag); void (*bdrv_refresh_limits)(BlockDriverState *bs, Error **errp); diff --git a/block.c b/block.c index 3ea088b9fb..f026d710b7 100644 --- a/block.c +++ b/block.c @@ -5689,19 +5689,6 @@ int bdrv_debug_resume(BlockDriverState *bs, const char *tag) return -ENOTSUP; } -bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag) -{ - while (bs && bs->drv && !bs->drv->bdrv_debug_is_suspended) { - bs = bdrv_primary_bs(bs); - } - - if (bs && bs->drv && bs->drv->bdrv_debug_is_suspended) { - return bs->drv->bdrv_debug_is_suspended(bs, tag); - } - - return false; -} - void coroutine_fn bdrv_debug_wait_break(BlockDriverState *bs, const char *tag) { while (bs && bs->drv && !bs->drv->bdrv_debug_wait_break) { diff --git a/block/blkdebug.c b/block/blkdebug.c index 10b7c38467..608d1d5bd6 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -1062,7 +1062,6 @@ static BlockDriver bdrv_blkdebug = { .bdrv_debug_remove_breakpoint = blkdebug_debug_remove_breakpoint, .bdrv_debug_resume = blkdebug_debug_resume, - .bdrv_debug_is_suspended = blkdebug_debug_is_suspended, .bdrv_debug_wait_break = blkdebug_debug_wait_break, .strong_runtime_opts = blkdebug_strong_runtime_opts, From patchwork Fri Apr 23 21:40:29 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: 12221783 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.7 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,URIBL_BLOCKED,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 D7700C433ED for ; Fri, 23 Apr 2021 21:44: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 2D45D61422 for ; Fri, 23 Apr 2021 21:44:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D45D61422 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3aj-0008Pl-A9 for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:44:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Y4-0005PJ-6Y; Fri, 23 Apr 2021 17:41:16 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:24032 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 1la3Y1-0002zb-9V; Fri, 23 Apr 2021 17:41:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rp5iKayCgK6WprJnDKhQwY0E5PWDlFgfe7yI59lq7Yw/QZVpt7d5P087E+hblDOgCxPm1L3KrWvlC8EmzCVT/biUhqOHI12KzcduSzujfu9abkPb1C1C7fnpQERT1rIEwazN3kaT3sic1SbQZgmyh45JK3w9HkHla4WYHQc0GRQob6l/gwFtyxjchYpDGbd6mMqyn4ZABmPRCZ01ETN6rYMX2ylKZ36IhcMeYt5WrAih6ehpnYRapUQ8A7sQ5wNtpkNTkujBoDXAMRBCH4Sy6dzdE2WJvynwYj9iMAYCh6yXsOnC+Q8oAXkV8xSWsfv5EoDrNaplPsH+uSyg3ataZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oCEqDlvTBQuq9v/8SnyGp6Fw9RvKpSnEZq5+/YBNFtk=; b=aHDISUZV+72suT43bRCKfy9iVMlWVCB2DJdGLuJdYKIhYj3YqRTP6YRwOt+w3WAZSWpNorbTv9dd/2FRKRzDpgU1BdMsiE3xWhN0cafvAluJZj0GVk96T0r3FgPXjZorR9+VOE6KOc+ZzxDKWh0DLw9p/MfAyZiAJmgszt1EVhjBI8uL87Y5QVsFeUh2RX3jivTT52SeH/xNpswyZ5yax28d875Ge9WKEb+byQZsbbUN0midFN1HwLWJJxbHxZ6UfCEk2u0TVUqzyVrzl6LU9Ovgl9izRS8GRW9Y8FuHtkC3j3tMD5vQBXvZbyIKKXj8Gjw6mDn2dgP1C892AjTEPw== 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=oCEqDlvTBQuq9v/8SnyGp6Fw9RvKpSnEZq5+/YBNFtk=; b=qG/XfsVKobIitytkGPz/vlIVnBqwXONWMnmcP1uc+EGCHb187y+g8U8FgQ8q+TO4hx0ui9hNv5cu/98w3NnB0N3s7IU5SPjvpR/KdkRUpu7xXni7VEw8XAzazr0cYV0JCjDVTKoZaXmdnXBnlHHdLvDxWaNOqhaSVkicXZjq9/M= 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 AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:41:00 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:41:00 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 07/11] block-backend: add _co_ versions of blk_save_vmstate / blk_load_vmstate Date: Sat, 24 Apr 2021 00:40:29 +0300 Message-Id: <20210423214033.474034-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:40:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f54b5879-31b9-43dd-ff0a-08d906a07af4 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:176; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xdfW5o4CfD3ZGffvNkqHgnWj3DxEuUw2yl9fR+dvo1xdQkXevnSy+me4GZfkE9H6b6q9bBOIF5XjtXtSKpam9feMmwVzDVFuiMle4kggfFkzzyJXgaBWqKxEseKlMs/KWQhh7AzgEDmPSqNz0g2RuY9qjsWflpDYNIoxbbdk/lqxRuMyL6sJYzC2VGXKvC71P+U4+chhxBLEWBbuJaMQ99LI9yAscUc2/2f0hG30MT6i6iKK/nVkmXjj393Rn/VbaRCGc34aNazWFTu3TbTgdlx6EYmbPF6kHOZJ5xW2r91JjMCJCgg0B+LkLTXac1mDOc4CnBJEdjB+eDEKEuucRT/B3qtzYoGg5cOd/SFsgGqygGq6Yly1Bv07vUlUSjVTKBOn/b25Qra4Zo2ZLoSJBU+mWDWHdpgLuokAunMteVPZrSg9Ek1fkHlmVZFR0JWB9m5fk/8UPkyJfv1C7HejxpvfYytTrV4ful6Gcd7Escy9a+XCWuAbI8fQaGVotnEbSw0gWrx+CR3ydwJn/KFrStnjXFlxO+Na7QWeWs27U4FMQpCZMqPJesQVbMUiAVItlI5N6KZFBjoU/EyUZXovYwEsw+hdAufHgV102sPy9UrExA1RWKe9ARkpkqzCwEtjq73ixXzJ3tInm7hII3JfqL+mOpfH+YIDuVmKGBzu5UnhkMviTeQFqzUsjvC3yAo4 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)(366004)(396003)(39840400004)(346002)(376002)(316002)(2616005)(26005)(956004)(83380400001)(8676002)(4326008)(38100700002)(38350700002)(478600001)(6666004)(5660300002)(86362001)(186003)(6506007)(66476007)(66556008)(1076003)(16526019)(6512007)(6916009)(6486002)(2906002)(52116002)(36756003)(66946007)(8936002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: NILAc5NqzL4ZZKAl8/yxqfGmWavPDglqqhAbDaZPjb8aZZUblJbfsEsg0HT0ay3dEwmH/7JxgOBNkvUWVh9gzDk3iR4/FV+MSAC9v0JXr+06WuhljZ1jxleSRzJyhrkf3D5n2tqKhl4ROpMtz5WQhY0LhBNJi4yQmwd19z+ivXe88V1deNdesICVwRYbv7rCs/cuHDRnK8ybm61GNq7gTXtWFJhenPCv1eiSYUv92aR4fpqGY0UJDgUz+vje/zwsKbNjhzknKEP+gwYr3WMYeGfpq0atY40MFgJQHH+eLGTG4Ys8IfC73A3wOr0pNrUhWvmGmF00Q8EJc0IbI1RUKtrVNbbKNLajg0HSXcpwhSxZuu0i3FmzalbOshx9O6XIdyAEKHmuTs9yJRFXL1GQF5pCgODHkAoL19866ZATFoS0gSg+hZeBKLAuvYc2ldKq1ISboj81llK9GVhcZ4mn0fQ10p0dGzoKuHqNHmHb+BeUYeOTsyAwktg7kkd9eiaiSQOeXKY/0BEucRPQ9cPX7K1zrAptwYZp6kBzn/rfmEsH0bkNsIgR2MbmPnHNy20SVt5bE73R5s2fh348f+Az5rJwvxFDUzAInDC+3bZGLSBStUFszLVq9IMN04dBlWDBLJ0UGSJqFJaPRiq0PR4Z1j/F0qMyaMuBEKh3WswpBTLF/0I5TLafBz6gytEwYlFrrY8+v+QD8fvF8nrIlTCNpYbIxn49kYVH+i6OvuCf75iGw5U9E1SkOxLyfT8j2x6vgzjqV9hOF9uVF2rAb5tBfs1MuFQh+LcytRVC9+TAcmT4WF1QJDayyMGzdvSHOoVH0F2n4k4CzaTcs3oGl3rNTftKxf6FYyYk66tYQVoijSHL2R0WJGCMOBoxVmsaFTkYUilbnDNbsJk+wDQfpCa/FTUJKuFgL8FWRKGIpV9usCVVHr+ypmhPf5AQ+lSh25uooql6oUgc1Tl5Wmp6zhYnlp06QSmv3eBrXu07v8gvXa6GTJ4XkqCyPHOf4QiFhHp2TVywgaAEwz7iLzmkxWPSKuyW4iDC3vXYwDfb2YeT284mak4b46bpoA29euwoMcnjzJQIL9m2jhKY1J1Fii222P3Lr4xk+Cua619ye3yvDcTSkSHKfJCA8yBhkY4peo6xIJycCcRdyh94/EV8DVWHML2WYN5SdI5EoUha31WktQB/825cO/KWBcrIXzG452cJ6ISszOXFUtr2biGOw73jF+VnXJGBTTOAXqivLlWMplzw0xrycfGJ5EfPOLt1LsTelAJXMZIZV6uh9aPs/gs0ZrosUz0LB7tKFyhGPi4l2MAH1IMi10+2+3tWRdufP+jY X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f54b5879-31b9-43dd-ff0a-08d906a07af4 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:40:59.9149 (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: USogeLixi/pWqq/J+9rOelVkcNs/7MT9V4aVDrIn3WWTbvRye9FLwkHvB1IkrXWf4CN6o9ASdPf315aQK7JjzS/UfjJNV8709FPvrYjeFF4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass client-ip=40.107.20.117; 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" To be used in further commit. Don't worry about some duplication with existing blk_save_vmstate() and blk_load_vmstate(): they will be removed soon. Note the difference: new functions returns 0 on success. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/sysemu/block-backend.h | 3 +++ block/block-backend.c | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 880e903293..8676bbde5a 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -245,6 +245,9 @@ int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes); int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, int64_t pos, int size); int blk_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size); +int blk_co_save_vmstate(BlockBackend *blk, const uint8_t *buf, + int64_t pos, int size); +int blk_co_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size); int blk_probe_blocksizes(BlockBackend *blk, BlockSizes *bsz); int blk_probe_geometry(BlockBackend *blk, HDGeometry *geo); BlockAIOCB *blk_abort_aio_request(BlockBackend *blk, diff --git a/block/block-backend.c b/block/block-backend.c index 413af51f3b..d7f91ce7ad 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -14,6 +14,7 @@ #include "sysemu/block-backend.h" #include "block/block_int.h" #include "block/blockjob.h" +#include "block/coroutines.h" #include "block/throttle-groups.h" #include "hw/qdev-core.h" #include "sysemu/blockdev.h" @@ -2227,6 +2228,42 @@ int blk_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size) return bdrv_load_vmstate(blk_bs(blk), buf, pos, size); } +int blk_co_save_vmstate(BlockBackend *blk, const uint8_t *buf, + int64_t pos, int size) +{ + int ret; + QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, size); + + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + + ret = bdrv_co_writev_vmstate(blk_bs(blk), &qiov, pos); + if (ret < 0) { + return ret; + } + + if (!blk->enable_write_cache) { + ret = bdrv_flush(blk_bs(blk)); + } + + return ret < 0 ? ret : 0; +} + +int blk_co_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size) +{ + int ret; + QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, size); + + if (!blk_is_available(blk)) { + return -ENOMEDIUM; + } + + ret = bdrv_co_readv_vmstate(blk_bs(blk), &qiov, pos); + + return ret < 0 ? ret : 0; +} + int blk_probe_blocksizes(BlockBackend *blk, BlockSizes *bsz) { if (!blk_is_available(blk)) { From patchwork Fri Apr 23 21:40:30 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: 12221801 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.7 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,URIBL_BLOCKED,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 98114C433ED for ; Fri, 23 Apr 2021 21:54:08 +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 0841961168 for ; Fri, 23 Apr 2021 21:54:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0841961168 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3kV-0002L7-6Q for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:54:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Y4-0005QC-Pf; Fri, 23 Apr 2021 17:41:17 -0400 Received: from mail-eopbgr10127.outbound.protection.outlook.com ([40.107.1.127]:4578 helo=EUR02-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 1la3Y2-0002m3-Hy; Fri, 23 Apr 2021 17:41:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=huAQsbI5GfcC7RvM4QQJfp4axFt4U/EFcQrUdwaCkAC7bqDqaB7i959HQAIVEOjF67B8iqwBUQoyyAIsRPOC2nVDgdjj4CW+fha1C6YOMqIL9n0C9ziNHbhlTAjN3v11xgzJmI6TZaTC189eTuw70MOWh9i3DVIXfRH+TbESsuv4/FtycFc5DApclMUA95B2Jg3Aw4E8OQZG4H66f9NgzvSchPxQaeIh8+EtfWG/0QvuSHeij4hUojagZwOb/kY6npWIL6X0fAMhjInAqoI1ZtaAHWaJ1amHThsYx/uVJbSgVKVj5SqTa1z36z9En9+vxNISw7SCTL9s4bsRrIIKzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BO/I4/5TnuZIUbHHKjcpuazN6wnPTuFmreRjtJbukXM=; b=PsBhcAunxHg/3jcRwjrz+kKAmC//Qy/md9yr57S+UH8Ta7j+Z8WOJeC1yI9SwxOyXdE7Q57OeGjcjBnwinUKIl7ndGvX1jxkjBIoijoTkf4P5x+Co/RmjKUYx7Ul8EWCrYExYjNw8uiVN14ri/tX6yzXypAmZ0Bev/EU36gLIFEau9a/Wh+xHV6FLdlE6QgluSeznpgX9qO9ciYaN3mxHpgF/UAGl+tyP3l71E3twKdfUHSezeKNwK4KEij3H/You20/dmmlTz16srG2FZNiCU638igW6FTAuXlCTJXfdFuzzeve+/YSZzp1hOKrR1iZVuBaR3KKLc0QBYt8uTX2Mg== 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=BO/I4/5TnuZIUbHHKjcpuazN6wnPTuFmreRjtJbukXM=; b=sggpkhQmb6U4XlXoFItTPT5L8QTD1XkHaHcXwKaHJu9efOyAa8k9d/KxI5wvUn9/Un/6lHPCG8k4W0PGsJMTE7gO8jlofGaHfgCGitV7zKk8bUUwcbc7utt8L9cAqq7qfdSxQDeeJJZ2oOeljOhT6BLrFfA727kD/isYsCsdb+c= 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 AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:41:01 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:41:01 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 08/11] qemu-io-cmds: refactor read_f(): drop extra helpers and variables Date: Sat, 24 Apr 2021 00:40:30 +0300 Message-Id: <20210423214033.474034-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:41:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 89f50103-604c-4c8e-0bc7-08d906a07cf5 X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /dPw/W6tI/N/VMHbSGv6z/IBHp+423f6nItxoEi0MTEZOnw62CrvrqlFNXvuiCYcXY8U/AlfMPhZbqwxruRQvzPO/zHs70YWB/lL7bz+SU/L9opfiK381iRctDvswBxHFkgchFduWoz1YzfOttYo1itEfhjbpLGUEw6Cu3GSrg+qdGvtpH/8Mvr/2NT9qNgrxMx73GAT+Q8WJ3tpClLtqLijjn/6KgzufCkN7CqXONdIXDYoidjGGQg8iKcFWMhF/ZDsacBn1+lqqylqSazoyY03PU/uv2+lIM3eZqdY/Tr48/vxmYO1L80+UxGj7h0S1QmvmDQtLYzFX3VhxTtvFS7AwVceEe0dapay3OVtolaroU8+slZMbTWSGEnRHd72pO9r86N4vRXjPOg5pdw2R2t6b/hHJZYVwKpjQmgQrYNN8IcnTNR6aSb19XceWwFz1NmfmwvqplimuOr3nvtuFca2KQRgYAd/E6yEuHQcClCqsiGMWOqze8yaxjOQuBxOHTgPm7v0XaXAX7c4KjFpHQYL+Cax2j6QMPS84nwJZ7FFBztiErW4OTR40uVQkQQXtv8IiumshHaBW/dG8gF8GuqeOZ4RglbyvWR6wLDpjyjh53alspkCcZ19c1JrBdjicP0yTYPyCyt4JzjuV2jpyuDCE2ewlFcM17zLe4SBPU+cj1g905VAqt6HbZ/69r/d 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)(366004)(396003)(39840400004)(346002)(376002)(316002)(2616005)(26005)(956004)(83380400001)(8676002)(4326008)(38100700002)(38350700002)(478600001)(6666004)(5660300002)(86362001)(186003)(6506007)(66476007)(66556008)(1076003)(16526019)(6512007)(6916009)(6486002)(2906002)(52116002)(36756003)(66946007)(8936002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: KeVfvSxHpFv/sHMNfFcKVW0j+4reInaAiAWIYy/vJjZtZenjHl6LK/GpfrL2XLQGPRCxUiA9omP3gvOHn37uhwlqVxvdjS8Cjw7xU5/rwW91jqQl/hFdXPmq7DyhxA9PRa0DMKEoEWR3MCPih2oc3molajgccm9/OZpy1k8GfdXkWXbuAnciooEPYzKUwqd+pFtVFhqXP/HLp2KDYv2tGB71jy2PHwgMeluKV/1ibj3YTTjcERCQssUiIzZZ8DtVXoZLBokEsL5Dfwe07j2KYi8tWHW83dXwJIGiLw/eIivvhk7G2HD0fYGV8TaGL/nWyU6wBOShYXF0Iihtj+grNZdOBKZXzXSGjT6qp9TL9zfAyGiTISm79gyS+VbNGHeZaGhujDrdSZR+ie3odburjnLYId0LHqZUcYNm1wTJ/curo0GYyV9bc3Tf88olTrf/FqCrrsOUrbzHSaetWW1IhlWxHsEjz/dhkTltrTgR+Zx7pHREoTXO8V3VAGZz4ZKXsyT7vv6re6+VyDj8umDwbyy0GR8yZwoCLOUTTCZyWJ9ejUng6TNPDtkfOY26IPnjJ/7nP5jiNcbyFyJhlD2NCX92oEQG5Jv5SNBhFY27Xa3xAYOov1MnWcdjA+8VpCM7dVLqEcHyjw7CqxSLveVCbRUA7VZ19oYKTgjuZpbgAUQ4KkTEA4NBTrU9gr8gHVklnUDyMCCyFfHr0GRraSotGGU6djLQg1PxF7GlWxlBNuoVdXVtb1jZaFOyMYE5bEsqleSuUa71iHf45HdjZ6EKlyDUKfGtC0+UhJHYeQzjE7iYKPyaT2vMUUc1yCCxK3jyQxsECvufVF1iPEuyOaY+mMXoIqJk/ElfLL7SkO86HFErpwMAEYwVBRR99Fa7RCI4oalrBb0e/mu86G+H2pUUlwGDnbJUa/vtyCWDekFjbqeSAooopoIFurFuj6UAQJu6peTvQEIoMVJA7qQs4rqESnqv47Tr2mKHHQBb5Xc3A02tbozUmDlwBjWEezNBYqF60qZ9K6mkaGOlHwolY3auFbeq8jvmI6EMvSQSJBRxAru0Nxf5ZxpE8gvhx+pgdae8vJY0OU72px8ySFjoYAaoJJSFkzlelsC9Cfi7JJ8Fh4+kYPfmDeECqJa5RM2MhYRswKPLPleOBnuzV6+V2M1bt+mnXIo7i1NccgsqUPAY8GVqzLmpx+gVpIvOOhusdipJcIdlFsGC7LAFXq6L7ygQBCAxzEtLJlyn/q0YrPioOjwgx2h3pa2D1stSuBywxeANLOKEZzRxYi+5xJAPvoDNN2ws7EKNi8c2s+SXVLxr2J7tAHCGh7J2h6beilpHGrQQ X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89f50103-604c-4c8e-0bc7-08d906a07cf5 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:41:01.1684 (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: AHkR1f07OtuXpmej63/haAiCk9q+tc+YRMp/NPuS/+7a6BLZgmSa1rJzmie99oNMuocGDHWTXknpoXNpXZyylHeAdLKp3BfOpfrYZPgdZCc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass client-ip=40.107.1.127; envelope-from=vsementsov@virtuozzo.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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" Now all commands are in coroutines, so we want to move to _co_ functions. Let's just drop helpers and use blk_co_ functions directly. Note that count is checked at start of read_f anyway. Both blk_co_pread and blk_co_load_vmstate returns 0 on success, so we should not care to set ret to 0 explicitly. Moreover, no caller is care, is successful ret of qemuio_command positive or not. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qemu-io-cmds.c | 44 ++++++-------------------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index adc9e64c37..bbebecba55 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -527,20 +527,6 @@ fail: return buf; } -static int do_pread(BlockBackend *blk, char *buf, int64_t offset, - int64_t bytes, int64_t *total) -{ - if (bytes > INT_MAX) { - return -ERANGE; - } - - *total = blk_pread(blk, offset, (uint8_t *)buf, bytes); - if (*total < 0) { - return *total; - } - return 1; -} - static int do_pwrite(BlockBackend *blk, char *buf, int64_t offset, int64_t bytes, int flags, int64_t *total) { @@ -586,20 +572,6 @@ static int do_write_compressed(BlockBackend *blk, char *buf, int64_t offset, return 1; } -static int do_load_vmstate(BlockBackend *blk, char *buf, int64_t offset, - int64_t count, int64_t *total) -{ - if (count > INT_MAX) { - return -ERANGE; - } - - *total = blk_load_vmstate(blk, (uint8_t *)buf, offset, count); - if (*total < 0) { - return *total; - } - return 1; -} - static int do_save_vmstate(BlockBackend *blk, char *buf, int64_t offset, int64_t count, int64_t *total) { @@ -667,17 +639,16 @@ static const cmdinfo_t read_cmd = { .help = read_help, }; -static int read_f(BlockBackend *blk, int argc, char **argv) +static int coroutine_fn read_f(BlockBackend *blk, int argc, char **argv) { struct timespec t1, t2; bool Cflag = false, qflag = false, vflag = false; bool Pflag = false, sflag = false, lflag = false, bflag = false; - int c, cnt, ret; - char *buf; + int c, ret; + uint8_t *buf; int64_t offset; int64_t count; /* Some compilers get confused and warn if this is not initialized. */ - int64_t total = 0; int pattern = 0; int64_t pattern_offset = 0, pattern_count = 0; @@ -780,9 +751,9 @@ static int read_f(BlockBackend *blk, int argc, char **argv) clock_gettime(CLOCK_MONOTONIC, &t1); if (bflag) { - ret = do_load_vmstate(blk, buf, offset, count, &total); + ret = blk_co_load_vmstate(blk, buf, offset, count); } else { - ret = do_pread(blk, buf, offset, count, &total); + ret = blk_co_pread(blk, offset, count, buf, 0); } clock_gettime(CLOCK_MONOTONIC, &t2); @@ -790,9 +761,6 @@ static int read_f(BlockBackend *blk, int argc, char **argv) printf("read failed: %s\n", strerror(-ret)); goto out; } - cnt = ret; - - ret = 0; if (Pflag) { void *cmp_buf = g_malloc(pattern_count); @@ -816,7 +784,7 @@ static int read_f(BlockBackend *blk, int argc, char **argv) /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); - print_report("read", &t2, offset, count, total, cnt, Cflag); + print_report("read", &t2, offset, count, count, 1, Cflag); out: qemu_io_free(buf); From patchwork Fri Apr 23 21:40:31 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: 12221789 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.7 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,URIBL_BLOCKED,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 95C52C433B4 for ; Fri, 23 Apr 2021 21:47:18 +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 25595613A9 for ; Fri, 23 Apr 2021 21:47:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25595613A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3dt-0003VU-A1 for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:47:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Y8-0005Tf-HX; Fri, 23 Apr 2021 17:41:21 -0400 Received: from mail-db8eur05on2117.outbound.protection.outlook.com ([40.107.20.117]:24032 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 1la3Y4-0002zb-V9; Fri, 23 Apr 2021 17:41:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kwNz+SbL3ftjVWjAk7BebGMopZV+i+Ajf6ziELBasW6dWjRjaQ6ssSbDZBXtPZw9vt070voBrZ17oMhHM9uSowUmI22F5JnQtH7Sf2hxs/fKZGvYDg6t/wc45sZRAOWR0ITqvR+tpcfO2ZbuAIkjJtNBRGc64Oy1D0eCGVmi0Uf9AE7mv5zlpVdlA1a8qEFJZcLgrZCZSRL7YfDdQWBCcjzhRnD4hwMsduRhVbckms/CuM4HGTPlDXjyzw/JuhnnJHW5Iu8v1PZZXG5aiLRe75Ibf4BGQhXRqyJHxYwrHM0tT4RVvZYnMGEj/n+fow0jZJKSQOS+zxre2UWIa7Zl4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d6aWC2ioIpnfTC9mp4GejIEk5Vp5y8012RMNfuTSg9Q=; b=aBMW0aNN9IbkJCJZVWUJQvUx3xbE6Es9uZu4iKuTYIw6iG39Mfk7aUJq15/pamHg9IECi1yVdKgT1T7FG4d4LQ4vt3LiQMz4Cvv9PQfFFBEBtQ9qYNSqpcbSlFdsv2wrio80Um1CQ53ytdECQA8U3qYtqTgvOi8USQo9DmqWMPy4XrZQQ2WLiQOQhnEVwOYwyqhfK79pFdPI5hCscJVZqRuMokGaFJd6tXS34i7bN7aMfmo4vnBpZ5d5FM0oNDVhae/XtQbdA2TsHitv5z2qsiCzkUSjCp2ZFSjmQRsxXue5GAJVm/uJcN4pQRIdx+u90+SBVjYAOvu0mRl10s28eA== 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=d6aWC2ioIpnfTC9mp4GejIEk5Vp5y8012RMNfuTSg9Q=; b=YxWuHMgWhkDUwf1kXAWO+jfhlQ+2xwTQTd5HWvRupxIKBTNiC5273bNq2dBelivPbE0MYo/ni6jRMHQR+kQZh7s+T5qUD+LJMHAkvM7HPdUBOJ1urZ4HFUC2iJJqMplYNAmDukpoX8MsC9zG/FGnF3bSaAcglM7I/x99Dy/sm7w= 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 AS8PR08MB6374.eurprd08.prod.outlook.com (2603:10a6:20b:338::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:41:02 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:41:02 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 09/11] qemu-io-cmds: refactor write_f(): drop extra helpers and variables Date: Sat, 24 Apr 2021 00:40:31 +0300 Message-Id: <20210423214033.474034-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:41:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7c6c101-544b-4fab-29dc-08d906a07dba X-MS-TrafficTypeDiagnostic: AS8PR08MB6374: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vwISwx5Iv3ZDRzRkO+yy5oN11AvNZ1gJ1FvITRehDHkHs6UpzWvDGMhzcJz6wUZcdD6pXbwoEqGLLZf8sIgV+2tmtedR4Gf25vxV3uw6jen6HrYhCfYMM7FiGtvoOfNECbWLZpazFBtUD7m3SFnt53rffRjBwJwbbu/bH4I9t79Z4KtpJKfpo0IPp7kZG04Jvk1oMKYQGT0jnx5N1cy4qzqVlJs15wPwb8IXsXKp1jk3dfudp02UoLubLThzo/4djdKSC98RQD6CeEiYxSUjDlH3TB07todxbh2rbNkRvH/Ekeg7ZR4BITRh0HR5ieaB7EZGF7AzcW/JBHEoSaQM9AmjR8pUfvHY7ZDPS7JMFgHvCDwNDhstZjfWgaENMj9h8R6ZdWyvFV9dly8v7248e2+KCjOQe1UpWKzcg/eozwHLnC7aoXlISAbzFoSCz2X88Zm0i0ZMGgckNz5EQEDjkCV+Q11KyHQztZgfdi84nRVdwp6aL6ovt2EOlg52wKL5/pu55p8iQYokuc2N9Mlbp/ygkRL9Ak//NWvd5cnV/LH37crIOwM/hjUjfggeW/70ui5tttNywJWairNjlSj9JE3rFdsYrZk1vX+iNZTz2g51kCxrto7a4ESrejb4URTmCDgksOGnVwyk+ewbvEgUQQ9VR7v1Jv+oTIXNI7qLZT3cN7ZaiwTOvhgx9FyvcXUC 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)(366004)(396003)(39840400004)(346002)(376002)(316002)(2616005)(26005)(956004)(83380400001)(8676002)(4326008)(38100700002)(38350700002)(478600001)(6666004)(5660300002)(86362001)(186003)(6506007)(66476007)(66556008)(1076003)(16526019)(6512007)(6916009)(6486002)(2906002)(52116002)(36756003)(66946007)(8936002)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: PsAOpbTXn9s6TSZHTL2+txHmw7D/Zefv4VZnM0kkhzKJNYAsbNOjMo1hBfMOCHybY0RXpUDljUjIiZfLH6OF8Ee4v26VJnoTiBnJjDDI+P0ByPUUV4KMfjsp3GW/5y57kq3HrXnw8oEWn+GcypWr4eLWB7mahHjjv+dl1+Oh7X+iddhzA1elzKWBH2wHxvTnzf0uFI2tS5kyl/IsDuA3n35TmJL+jaeyAR2Tf9xCEPGvOA7WNXbOIDKxTNVJnDQu0VbIrO/VFOIbe4iTl9br3ZUl9UQt8bwxqGiBXpfDN+wCzot3waZ6gTaB/ixloy0dYYnbBhsWW93TrAch+wrEmllkDNCx5MoZqHVuWHm/d2xcWtYQGhA6soIuZytxwGrdvdEeyXE8591Rp6u4LgUe4NlA104+0Zmrcz4CyI3QpTDp2o1+U1GZW3LhrDQ2aOly9z91madieYMNAuVmo+sCUqsc/xw6Je/nDwyn/RteXPC2Tz/Y1SWuBciJbxWPSiD0uGavQQ0/k0gDAiJHn0+o7MakfHV5orbyovDszSsGyV7VvGlDLD/CC/8zU9Q3XGogZbWnDTbU8t7bxAPfXlZmLo2lo6ataJF0okdvl73Yq1vZdMMMzFjy1nhIPAh3kkfTD1PasQbpsTgvrCSeXBcPGAhbonwjahwReU8caurFgMdipTm4/Pn9JsrORo4xgZJlnbwxa4XcjI2kQ1GjvSz52lWxsHpBB4SHdQiVgH1YscpnxhQN888TaOuuGZN0IaWRNzSCCa9akoj4wQP0FYWtyYyerQLj58GGoW53JmWEzemxhyDUJtTUZ06SPF2HmhYLyUZAJGhQWEN2HixF9ydW9FHfTIk0argyTW1snY1Mdkj8njJMTZLwr/QhQ8b+zWxW4W5s+mnmdEro7My1OxTjUyAteYb2OFfkhySC1NDhM2oUOZq2xi+/90w89pGRmP+p6pn0Vhj/udhJoF6ZqdkdXXWEzGx+F4FVFF6Mzs6BwwwTr6L+x/f4z0oygyiFT2NGcBO4YkDZjlf6RPP+3h4gC+wIKvmPJ1F9J3kKoElhOI5uL9aq/i3LYh1Cbi8ciL1goKStSEuGPhTFqNIsI6T/2e64Zn8g96fVV3iKIaQV0iFo5bed4duRa5qoHXaF6mdCeD6tL4C4WDD+47UNkWirHs9QN73WMEnSL5k/htabLo0LgxG1ErdWZ1ucuATQLhNzQNHobaEM8cVU2GvRXSUS8nMRzPwK3dMH3PqzEj31Gx6IqdYAK5VDLla6xLD9ITjZe2u+/ND/j3NsY6SlIVKKFyS1rn6YNrAqkJPZyRncRUECm+lkHhC4uXwHI6v9TnE5 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7c6c101-544b-4fab-29dc-08d906a07dba X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:41:02.5055 (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: Mq7OaO0rhdlBZh7dJew2Hu6llUZv9IIybrlWWKeBQUdDQEo19eCPpBeathQ/caIwwHwj0bZNFWdseaNZi5EmHN23ImVapjRZhTzT7mpjFJQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6374 Received-SPF: pass client-ip=40.107.20.117; 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 in coroutine context. Let's call blk_co_ functions directly and drop all these helpers. Note that count is checked earlier in write_f, so we don't need the check in helpers. Also, both blk_co_save_vmstate() and blk_co_pwrite() return 0 on success, so we should not care to set ret to 0 explicitly. Moreover, no caller is interested in successful ret of qemuio_command being exactly zero. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qemu-io-cmds.c | 81 +++++--------------------------------------------- 1 file changed, 8 insertions(+), 73 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index bbebecba55..2f0a27079d 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -527,65 +527,6 @@ fail: return buf; } -static int do_pwrite(BlockBackend *blk, char *buf, int64_t offset, - int64_t bytes, int flags, int64_t *total) -{ - if (bytes > INT_MAX) { - return -ERANGE; - } - - *total = blk_pwrite(blk, offset, (uint8_t *)buf, bytes, flags); - if (*total < 0) { - return *total; - } - return 1; -} - -static int coroutine_fn -do_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, - int64_t bytes, int flags, int64_t *total) -{ - int ret = blk_co_pwrite_zeroes(blk, offset, bytes, flags); - if (ret < 0) { - *total = ret; - return ret; - } else { - *total = bytes; - return 1; - } -} - -static int do_write_compressed(BlockBackend *blk, char *buf, int64_t offset, - int64_t bytes, int64_t *total) -{ - int ret; - - if (bytes > BDRV_REQUEST_MAX_BYTES) { - return -ERANGE; - } - - ret = blk_pwrite_compressed(blk, offset, buf, bytes); - if (ret < 0) { - return ret; - } - *total = bytes; - return 1; -} - -static int do_save_vmstate(BlockBackend *blk, char *buf, int64_t offset, - int64_t count, int64_t *total) -{ - if (count > INT_MAX) { - return -ERANGE; - } - - *total = blk_save_vmstate(blk, (uint8_t *)buf, offset, count); - if (*total < 0) { - return *total; - } - return 1; -} - static int coroutine_fn do_co_readv(BlockBackend *blk, QEMUIOVector *qiov, int64_t offset, int *total) { @@ -945,7 +886,7 @@ static void write_help(void) "\n"); } -static int write_f(BlockBackend *blk, int argc, char **argv); +static int coroutine_fn write_f(BlockBackend *blk, int argc, char **argv); static const cmdinfo_t write_cmd = { .name = "write", @@ -965,12 +906,11 @@ static int coroutine_fn write_f(BlockBackend *blk, int argc, char **argv) bool Cflag = false, qflag = false, bflag = false; bool Pflag = false, zflag = false, cflag = false, sflag = false; int flags = 0; - int c, cnt, ret; - char *buf = NULL; + int c, ret; + uint8_t *buf = NULL; int64_t offset; int64_t count; /* Some compilers get confused and warn if this is not initialized. */ - int64_t total = 0; int pattern = 0xcd; const char *file_name = NULL; @@ -981,6 +921,7 @@ static int coroutine_fn write_f(BlockBackend *blk, int argc, char **argv) break; case 'c': cflag = true; + flags |= BDRV_REQ_WRITE_COMPRESSED; break; case 'C': Cflag = true; @@ -1013,6 +954,7 @@ static int coroutine_fn write_f(BlockBackend *blk, int argc, char **argv) break; case 'z': zflag = true; + flags |= BDRV_REQ_ZERO_WRITE; break; default: qemuio_command_usage(&write_cmd); @@ -1095,13 +1037,9 @@ static int coroutine_fn write_f(BlockBackend *blk, int argc, char **argv) clock_gettime(CLOCK_MONOTONIC, &t1); if (bflag) { - ret = do_save_vmstate(blk, buf, offset, count, &total); - } else if (zflag) { - ret = do_co_pwrite_zeroes(blk, offset, count, flags, &total); - } else if (cflag) { - ret = do_write_compressed(blk, buf, offset, count, &total); + ret = blk_co_save_vmstate(blk, buf, offset, count); } else { - ret = do_pwrite(blk, buf, offset, count, flags, &total); + ret = blk_co_pwrite(blk, offset, count, buf, flags); } clock_gettime(CLOCK_MONOTONIC, &t2); @@ -1109,9 +1047,6 @@ static int coroutine_fn write_f(BlockBackend *blk, int argc, char **argv) printf("write failed: %s\n", strerror(-ret)); goto out; } - cnt = ret; - - ret = 0; if (qflag) { goto out; @@ -1119,7 +1054,7 @@ static int coroutine_fn write_f(BlockBackend *blk, int argc, char **argv) /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); - print_report("wrote", &t2, offset, count, total, cnt, Cflag); + print_report("wrote", &t2, offset, count, count, 1, Cflag); out: if (!zflag) { From patchwork Fri Apr 23 21:40:32 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: 12221797 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=-15.9 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,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,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 656CBC433B4 for ; Fri, 23 Apr 2021 21:51:28 +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 C56A7613A9 for ; Fri, 23 Apr 2021 21:51:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C56A7613A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3hv-00088R-0U for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:51:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Y4-0005PG-4a; Fri, 23 Apr 2021 17:41:16 -0400 Received: from mail-eopbgr50133.outbound.protection.outlook.com ([40.107.5.133]:45636 helo=EUR03-VE1-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 1la3Xv-00030s-N5; Fri, 23 Apr 2021 17:41:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WsEH8taf8pkKS0lpTQSYJq636yw8yq6OkaC+mIPtFLjsg0qsDQErQcJfYh5pwq6MGiLce8MfuF+gnPrPTPKQZul/FeqOx9aO8mdv87nER6Jq6pmJoEQwkPyJMaPZiuUNRvD/bTGf4OHLyB0OemQeoXbDULsP3lLNm6mq1LQmv0vvn2RHdPEox1cm87hhm5g6xUZvq7a3huC0Na/YYLgGje4QicE9806iAhFfWOD+PfGVehf0/B/bpySrBiPUntKD913uMQq8awjYNKQq3f+JjMhN6TG4o7Im6CTylHiHqFpnVpdvrh6oLqJUuviwp+vVm9B5/H/eQSsNIUWFKIRdKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5U7Nc1aPIlQnCyKW6p4ophwtsRUazbAv+D9rQ5anEAo=; b=NR8OZOs4MctWJ5mBRj5zgDf0tqBVZvceOh4OsJ1wedFA5Xywpz3kAHyAmbEIsYOcgPakcU0lyaxO+N0hJo3Wm9fIAt0jwAzkw+TTZHcjZ7E23rpQYAkG6mzCBQlvYLOirqYEAIHVdrUExYUa3xin2ezKj6r6NWuBPIobEcHOiNdVHtsIYFEH0DC/ndSOZorALi93+0kF2mVqLNBo6PgSYOHMA/xVsCaIBPcIozqtNTVkSUVwo/8gCmS1fzWWUiVjh8n1vUABy1ubBHQRWIwFRNdLSv7e8cutpqjrJGXxwZdkwJTyd/COtJrmrfpRmZBLB5lldltvVZRND444lBAUqg== 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=5U7Nc1aPIlQnCyKW6p4ophwtsRUazbAv+D9rQ5anEAo=; b=lWs9yiSndv5sGIISNy94s/i4tEbV7jhX0cVH9AbcDKuJkmXzLlwY+rj7x916LK8eY9zV2BFxeP5S6o0nZisjQ+44qDeXu4z4bElHy7xOkJJ0CiDKyBihcNVEBpFQ/dcJSJQp9B1qfpfRcvPZp82eJjPgtXveZh57IJl2f5AJ7o0= 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 AM6PR08MB3221.eurprd08.prod.outlook.com (2603:10a6:209:49::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:41:03 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:41:03 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 10/11] qemu-io-cmds: drop do_co_readv() and do_co_writev() helpers Date: Sat, 24 Apr 2021 00:40:32 +0300 Message-Id: <20210423214033.474034-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:41:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68b4c489-09c1-4b10-ed57-08d906a07e82 X-MS-TrafficTypeDiagnostic: AM6PR08MB3221: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:12; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DuKIzRrvWsXowwS6SNvYaWuynurRnvHSBd2YAbgFEl/Wav1r4UpdbvahZNcHxDc2Rvb9H1cfu03/W0Fm4OjALptIMUdK+Jnpki97VwFDbmPcgtAVRFco9hE0THCTzRtAaiXm16zhcl3qmcBVg6vGM47Ir+eqzKRN+lMzZr6BtsTXa7Dz+gsi02VY8jj0brJKV6vf/h4TZtgd8uH84njPTtg4554aQf0jnb6CCQ/BgTPaXmbmIeawu+P6CjsC58uxZdLG312VFxPtk28YRGyo/vIXxbyphOv4gs7dOrJyxJXYLBkbMgMv7r77iBAyLP6tVvJ54xeeqDw9cv8YQsgy/ALE6GTUUbrWO4Qss9KL/BNVL9GmoktPMlzfXoFq8jgYnDjfHBVMVu6KjGEnYD6BLug0LQZrOAzS8TxFM8/4me3o2VXiqHYiAQ34VnMX4EqRqbI/P9UmWXDqx/eyUvluORoFe3vqWmF9egBp4tAtwDx5V8NMao+AEaHovO1xsYsZS0iTLE1Um+d5sXD83Iqcz8cPRt6DOTqcEdvy1zhfzyNVRobdHDtIWXvwb2ROt59f6xnQkJVm9BlS0OmPPKijajONzTbeT55+49rWJbo8ybrsuW2vNZLaoqrE9nareDkQ8BAFeuwwpxMJgssSdYK1iCYY+spUkixZzhqWrjU6F2E+1McWJD7CzI2w8SDPYh25 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)(396003)(346002)(366004)(136003)(38350700002)(83380400001)(38100700002)(8676002)(186003)(36756003)(6512007)(5660300002)(26005)(66476007)(16526019)(66556008)(478600001)(4326008)(66946007)(6666004)(6486002)(86362001)(956004)(8936002)(316002)(2616005)(6916009)(2906002)(52116002)(1076003)(6506007)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: cWEtJI6KmV6XV0ZGatU9SwMhiW9v9HqB0VAsBgZqfKtV5XF0l4mwAnkO1av2it68h3YvSOr0qvy+1aq1j3prDZVhsHjfrgzhdxlRcQyDWbYYk5A/Gl0FAuBWKcLNP9F8wclgfLK5s48rdRU9bPE9vtzICmUf4k1+rns5CANd22jj7IE/2qenRJfBBSexiAhQpGdYspjJBpXrgxbaNGEP/S6FF+dgnZtVMaWNRepG6bu3kIEmzwxuotztO1B+z/GiTesEcZbrf979WE6RjaYQpyeIt1O73WNL3Gf4GRyhE8NQe7beOZh7kofY8npzt0s1ZduA8bia8n3Z7UCUFbBMFLgbSsXBSDvjidwPrCyFmnE2T5KbbmO1jiLBNRfm3b3OH/WsS/N48xZCsvS8453Jh/RluOQxck3vE4rH8428IF+BVNMxmzPV0q21v20pUyEb9bscKx+nQMDQywxn3tosVsutCwZrQAmQC3h8SxLo7UCJS55VMxlw3OfHGHm8ofrgEDZRPSJS5908yPiUxYUSB43sitNh2hwk5GPTsv09WVqGq3nbSWHUT8ice2BZ0hXwxiVB3ksa/HLawApbQzHsGzh2W2/dGSbUN+yR6NIuON4ydbL5dV3LSxOi/y1iKP7j94SKNDUdYAyheqK1acTXyItBTH/tooghnCOvAj2pILnCmgOyLgtuS9R+RoDAatqsUv/K0tWWDfDQRQa0WOVhvVrOa1/tdo/d/ArRpw+FXamCr9QPLBJ6rYEn1F1T50T5+Tm0h24jabgW8uL/ja2lt0EXW+lc7cp0B6J/pNFBv5a4ndJRo+aD3IokcQvqSh5uurc6JVjNTK8GA7xtU+9I3gPTg9Aq8zryRXgu8JH33yZhLDD7ju9/Ys6mpnz4vY6Drx3onG0fSBCz/TLyay0YsxZNnPBuEzOjPPuRZI9o66/kzz9Pabi6jnJx0TkNSjqDpMDrbMtjKSnH+zTIgpii3luHqcYN8LaEjKwfZmmaj+ZvbS9+ijcTQPz2x/owbuGLIGorM7p0ySwNSDPQO7QL04GHyv2XBqQmq8xFhdzQuBhYsDJcIPFFpddkpSkfoth0EZgLjR3JlukA0MZd7IRkCnPxUEgC6EIpkZ0jen2Xw00gCMqJJrpqoIWkutopRw231X8y5RqtQdw+Wgbn9VHboBkRJbK58OmcAxz6ZsMiJ/XcieNdtBQXRbW13Y8Xsb9ViDbIj1SuN6RZuML8WHzkwuYKarBfoew4ggiLmSisk4RKLpj02YXwrEdYqtXUVaTwODSjofk3epu8+MWZTc6ciSxhdy2YuCWa6tU45JiGpm5D6CZ/lFNW+2LE+Wux/A0p X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68b4c489-09c1-4b10-ed57-08d906a07e82 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:41:03.7799 (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: 3bt0sV5CUyVwOcXWYTVmXyasmdvlOVgWBRoi9moUEz/rWWCZujWqh5N1HvClVG/WCf4VTTNGP1xkQUBn5YtXK20VadjyaSwhJJRZ24AQq5w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3221 Received-SPF: pass client-ip=40.107.5.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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" They don't make much sense. Call blk_co_ functions directly and also drop some redundant variables. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qemu-io-cmds.c | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 2f0a27079d..9a0e5322de 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -527,24 +527,6 @@ fail: return buf; } -static int coroutine_fn do_co_readv(BlockBackend *blk, QEMUIOVector *qiov, - int64_t offset, int *total) -{ - int ret = blk_co_preadv(blk, offset, qiov->size, qiov, 0); - - *total = qiov->size; - return ret < 0 ? ret : 1; -} - -static int coroutine_fn do_co_writev(BlockBackend *blk, QEMUIOVector *qiov, - int64_t offset, int flags, int *total) -{ - int ret = blk_co_pwritev(blk, offset, qiov->size, qiov, flags); - - *total = qiov->size; - return ret < 0 ? ret : 1; -} - static void read_help(void) { printf( @@ -767,11 +749,10 @@ static int coroutine_fn readv_f(BlockBackend *blk, int argc, char **argv) { struct timespec t1, t2; bool Cflag = false, qflag = false, vflag = false; - int c, cnt, ret; + int c, ret; char *buf; int64_t offset; /* Some compilers get confused and warn if this is not initialized. */ - int total = 0; int nr_iov; QEMUIOVector qiov; int pattern = 0; @@ -821,16 +802,13 @@ static int coroutine_fn readv_f(BlockBackend *blk, int argc, char **argv) } clock_gettime(CLOCK_MONOTONIC, &t1); - ret = do_co_readv(blk, &qiov, offset, &total); + ret = blk_co_preadv(blk, offset, qiov.size, &qiov, 0); clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { printf("readv failed: %s\n", strerror(-ret)); goto out; } - cnt = ret; - - ret = 0; if (Pflag) { void *cmp_buf = g_malloc(qiov.size); @@ -853,7 +831,7 @@ static int coroutine_fn readv_f(BlockBackend *blk, int argc, char **argv) /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); - print_report("read", &t2, offset, qiov.size, total, cnt, Cflag); + print_report("read", &t2, offset, qiov.size, qiov.size, 1, Cflag); out: qemu_iovec_destroy(&qiov); @@ -1100,11 +1078,10 @@ static int coroutine_fn writev_f(BlockBackend *blk, int argc, char **argv) struct timespec t1, t2; bool Cflag = false, qflag = false; int flags = 0; - int c, cnt, ret; + int c, ret; char *buf; int64_t offset; /* Some compilers get confused and warn if this is not initialized. */ - int total = 0; int nr_iov; int pattern = 0xcd; QEMUIOVector qiov; @@ -1151,16 +1128,13 @@ static int coroutine_fn writev_f(BlockBackend *blk, int argc, char **argv) } clock_gettime(CLOCK_MONOTONIC, &t1); - ret = do_co_writev(blk, &qiov, offset, flags, &total); + ret = blk_co_pwritev(blk, offset, qiov.size, &qiov, flags); clock_gettime(CLOCK_MONOTONIC, &t2); if (ret < 0) { printf("writev failed: %s\n", strerror(-ret)); goto out; } - cnt = ret; - - ret = 0; if (qflag) { goto out; @@ -1168,7 +1142,7 @@ static int coroutine_fn writev_f(BlockBackend *blk, int argc, char **argv) /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, t1); - print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag); + print_report("wrote", &t2, offset, qiov.size, qiov.size, 1, Cflag); out: qemu_iovec_destroy(&qiov); qemu_io_free(buf); From patchwork Fri Apr 23 21:40:33 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: 12221791 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.7 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,URIBL_BLOCKED,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 51B3CC433ED for ; Fri, 23 Apr 2021 21:47: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 C94AD61467 for ; Fri, 23 Apr 2021 21:47:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C94AD61467 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3eG-0004EE-Vh for qemu-devel@archiver.kernel.org; Fri, 23 Apr 2021 17:47:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3Y8-0005Tn-Ry; Fri, 23 Apr 2021 17:41:21 -0400 Received: from mail-eopbgr50133.outbound.protection.outlook.com ([40.107.5.133]:45636 helo=EUR03-VE1-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 1la3Y5-00030s-0a; Fri, 23 Apr 2021 17:41:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GhEpdzXKayfvQKRAjtJkILfn2Zca0HIEi0ugWlgFRQOiPpxJRcfwIQqlEg3+WmdIN6aprquA+psNRjMzyfET787Bm0yEfG6RS9QZI28cxZUldKcQdJDNKtXXQZdphnMXCDJSdOXPzRKWOvDzB3cS5mHFtS+GEshNPDGeCxldXLxtt6AloicZH6jlMF7pJQNflutx6t7MKF9pnOoKPyPAj3Aauu+oXEMKieV1QDS6bG/QxnmKjqQPwOfoXGx3Z4m+uBxJjrNrkpfme1VMV7qm2uBoMqXWU8F4eZmR2NYL/Vj6MXNC5mZM5J09CDUONiw0hPlm7qenB0cOK+9pTmOJFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IgV3SrP/KLLv7aHId1Od/9m5zdpjlJgeA+DWHphVYyI=; b=SF/sDHIKgKBI9FSkXqhn3/247uTVpjtGGcYl6Gh66m2t6h9Dz7N5ZeLt0YACGxID4Lq7IZFdNM9dWh4zumDdKJnMMl3BV+Fx9X4ZLtPpmrO6/Z60zzc6ecZLrg96TjjhMDhyC7h3fGR3CuQ7Ig1JKHB2AJ/QxV+X6Pzb7WQKhaLphRIAh2sK39fcYQDc1kgkUJP5Y9UBz+N+SAt8+yVbMND4ofC8iHpoiUqtwIczqWx6J/i6lAJQFPD8d+HH5Jm5RcRG4gFveNeO/XLw3Jv/B0d4ZMbOXYH9SdHsBFxQjVUYJ2aNOaQ5MO71kJYhVcsPNBxbQr0jBsPcplXu48kT/Q== 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=IgV3SrP/KLLv7aHId1Od/9m5zdpjlJgeA+DWHphVYyI=; b=XrahQSbpTBaY8bHpb87BeDK4NvIjps/8ZDZrZVP1ercgpw01Fyh+AHrD/62jMyKI1VzxeQMlwGL1W31VGsZMxQGfJVAUfwNGTYTQvFMx0w5jCRpMWMj2YwLMky7ymZMidprNwZ6nZRGGyMlmwVh+j+bpZfhfpaasnFaBoDl8eGo= 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 AM6PR08MB3221.eurprd08.prod.outlook.com (2603:10a6:209:49::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22; Fri, 23 Apr 2021 21:41:05 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::b403:c1a9:6bb7:133%7]) with mapi id 15.20.4065.021; Fri, 23 Apr 2021 21:41:05 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, crosa@redhat.com, ehabkost@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, philmd@redhat.com Subject: [PATCH 11/11] block-backend: drop unused blk_save_vmstate() and blk_load_vmstate() Date: Sat, 24 Apr 2021 00:40:33 +0300 Message-Id: <20210423214033.474034-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210423214033.474034-1-vsementsov@virtuozzo.com> References: <20210423214033.474034-1-vsementsov@virtuozzo.com> X-Originating-IP: [185.215.60.222] X-ClientProxiedBy: HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) 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.222) by HE1P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Fri, 23 Apr 2021 21:41:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f50a43f4-5296-4d84-0078-08d906a07f27 X-MS-TrafficTypeDiagnostic: AM6PR08MB3221: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:265; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xaf9wy91OQ10Vaj9adi/9uO5kIj4v6UZgAnnMd13sMrWsitAG7LrLAdHHLdDsOyOVjOQGFf0Q1VWuJOlQ7UL2tDgZhtLTggwShX+kNq3Otkq9JqK2GdE/yqWTR3LYvmfN1KMoRZC/eEVl92g/sWcosSwSe8gICnVXu9Ki31kn7+O168T3l/ZPfJp697l5BkzJSr5Q6yDdkK2UKrPYDPZR7+I4tUMeItNYs2DWLEIR5WlK4Td99hTS4rMcDeLjNFXbmGMWW8JQ7hLl38+tFacv/Yz6+OV1VjvbS2HJyLgcFYMTXkMqRheYh3KrnOx9PDMpIvG1ukv6Wh1T8YbpNUJxOJp6MPSfQ8FP3HAF4wOlzOqRRCVIdYL3SqKKVkSFg95GAm4OkmvzvINaqR/hhlM6UJFFICSpTchJtvLWOAL9QscCZOgnx8RKmNTQwFXkCx7gMe6nwpibDOWjhDkb/RDGlkzkkiYI1lrCryPUBPFQn+YT0aPx7/yXHnOY7DYkjLxjjUrBzNUsPkav+q/5+l+3oY7op0wYwzgYACKNXpNG1q5Db5ocUuW9Rl09js3U2CydKEFlK0RnCTWtHWZSpiPhUESrHeNmyAu4PKjiSSlRodnfabWk2/kE/FMkRqu7bDqSamXP/306QkD3lAyuXBvUsZeOY0E75AhkOAFxF0QPetMkEJnFhu7ARUjcvjapaZU 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)(396003)(346002)(366004)(136003)(38350700002)(83380400001)(38100700002)(8676002)(186003)(36756003)(6512007)(5660300002)(26005)(66476007)(16526019)(66556008)(478600001)(4326008)(66946007)(6666004)(6486002)(86362001)(956004)(8936002)(316002)(2616005)(6916009)(2906002)(52116002)(1076003)(6506007)(69590400013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: x/2aTH8gzISi/ZtwQo0JJ9a8UiH5ZX9C5dlK1Yy9/hPar8fPnuCkRBTQA2LuEG7O+aFQ2gIVn8isuRLC2z86ZM9wNz7+U8nfBQqEppWO4JbaVdbQHsw3Rs89nYcvZ+M5KoWNjlCtfyFIhdsS0tBCuKa7f7POc3CONBCj9wtvAH1poveUnHqlGTYtIiobS72ZMwS+k2lzNIf4xnwE/zmEg6qYDo73YRYo6E0MSb4J8sHeoWKFWEuWz5hypd7P5Gc0sJ7L5i11Ik6z4E9BCQV499DHdwdX8i3JUKuA8b2mgKSjOobjroFWXfhSAT1XawedKdESeJh1OLS1aA8gORkhvjzdYpcOTLq5w6UhWxwNUbCvhO2GnVacqFgdZwo/85OPiG4QMkXearBtUGWIMImjMIJVsrAD4ibMisMyjbQC7RggfdKHF44jbCEC39lCsAjIbroPLDh5dc4LmEmIrL0K5kMRAhPIMsEWlupxE8+G87vq8MVDCd+MQ9rb9+5punmKtZiz0X2r94RAb/fUyiC1u4cLpVgvuF2WvJuHSGjwlNPGOykaC2IMoBKIatEhn4LQnY7iHNsytUw93nhpsLC8DsyoRuVvIXUZuP3u7ZckA251L5Rn2FyGVKGb11aQJpc1EIjQfv6PNGbPqTgMabdY28aJGzNjnL/lNjrYu/t41RKcsY7woFJ6J9ym+dW/cVw+mpYf56Bh9sjn8WZrrqu+UDllwkyA6Z9LVpB81JGeseGmYX4ya6qtDqWCO80JR5CZwc3vaRdm3v3m9h6tUOxtleg7slsYNsiNr77mgw2s8FOFlYLcw8uGRe4HK0vwAUE5l9gnAZCnGXtgNwBBgSQPDXHzCqI1228DOIDTFXtTEnfxwcxMYUjSsqKSeLueYQ7HS6+4Wtro1Nv+XjzlAG4b4raz33aVu6eF8Y/quWFJDSdtLcp89zpVonnFJvHYzkZ4W5GWfVFYaZR5896aIXxJX+F1/qcaQkQ6bTfTO299pbbyTUGMp080PdXZjUnYlPhcpAzG0C2Fc7jVNnPwv273jwnQAZQTO08RFbbhc7cmvNmVljiFgm1GjGtINHN9Uda5esgZj4BH0vTGAieGAYlxYiHlNmJa8UT3L1HWnM8PkgCO/KL1YVWlRkjux+k6L1zfIfW7CPKa294trb6rXYmThXaHGGjbblZqPrJLI9gCdPySEgUoMGfG3AgrQRW2M9tuze8gib69VHSLWvJENIQP73aMCyq+zN0vAtCEuiAiF+2aUpugR1GPYJYnQz3CQwRHhiqfXhU5P62kRB6R2dmd3Au3uS1FZFQY6R7JLC/+s5hthZNg8IEcQhS+V+wT4oG6 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f50a43f4-5296-4d84-0078-08d906a07f27 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2021 21:41:04.8612 (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: BwVUjKbNSlbAybWbKgmIE5JqJI0g9qz9ZBJJLjw9u/wwD8wpIejfWRZbGg4pLVRodeg4yghAojwFWZM4Owk4IN5aqmIEz2PlyUqR/qWGENI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3221 Received-SPF: pass client-ip=40.107.5.133; envelope-from=vsementsov@virtuozzo.com; helo=EUR03-VE1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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 --- include/sysemu/block-backend.h | 3 --- block/block-backend.c | 30 ------------------------------ 2 files changed, 33 deletions(-) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 8676bbde5a..14cc410244 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -242,9 +242,6 @@ int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf, int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, PreallocMode prealloc, BdrvRequestFlags flags, Error **errp); int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes); -int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, - int64_t pos, int size); -int blk_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size); int blk_co_save_vmstate(BlockBackend *blk, const uint8_t *buf, int64_t pos, int size); int blk_co_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size); diff --git a/block/block-backend.c b/block/block-backend.c index d7f91ce7ad..83aafda791 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2198,36 +2198,6 @@ int blk_truncate(BlockBackend *blk, int64_t offset, bool exact, return bdrv_truncate(blk->root, offset, exact, prealloc, flags, errp); } -int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, - int64_t pos, int size) -{ - int ret; - - if (!blk_is_available(blk)) { - return -ENOMEDIUM; - } - - ret = bdrv_save_vmstate(blk_bs(blk), buf, pos, size); - if (ret < 0) { - return ret; - } - - if (ret == size && !blk->enable_write_cache) { - ret = bdrv_flush(blk_bs(blk)); - } - - return ret < 0 ? ret : size; -} - -int blk_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size) -{ - if (!blk_is_available(blk)) { - return -ENOMEDIUM; - } - - return bdrv_load_vmstate(blk_bs(blk), buf, pos, size); -} - int blk_co_save_vmstate(BlockBackend *blk, const uint8_t *buf, int64_t pos, int size) {