From nobody Wed May 8 05:30:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1627930599; cv=pass; d=zohomail.com; s=zohoarc; b=M7rCdlP8mXPdlGNGTmz4Ktw20+QijiphxGHbWhKww3PdA9th3FD1sWppFK8bZxc9jM46cGaqVK2dQMRz0m+QIzEMXshroxNVyyuInWkeQlOdgAgL9N4EaVi5/yZLQFvCURbSzfxMELQo1L2cEFMvqLtCz+JM/BoZEpUBJJgGTTs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627930599; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MucbcBTCBp8tc0cZf0YiJ41WmFMJ7c7UGBvOfdNNX2g=; b=YAp56Uh232mWqA1uTBC0elN1+dZaBWnrXC7jumUlWmM+chwdR/15bdl75HYE+zHB189RUfXX2oL2x7uPPbRbhiexlOf977Zz2NBoFw0bXIWaNTC1EpE2QP385x8ryPaSPB2qtzBP1HNwyJWSUReGv6hk/GDibxDUPCUtwNnpWbI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1627930598927119.11404045691438; Mon, 2 Aug 2021 11:56:38 -0700 (PDT) Received: from localhost ([::1]:52902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAd77-0005Y8-Nv for importer@patchew.org; Mon, 02 Aug 2021 14:56:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAd5M-0002Uq-83; Mon, 02 Aug 2021 14:54:48 -0400 Received: from mail-vi1eur05on2137.outbound.protection.outlook.com ([40.107.21.137]:42689 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAd5H-0001pD-6E; Mon, 02 Aug 2021 14:54:46 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4405.eurprd08.prod.outlook.com (2603:10a6:20b:b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Mon, 2 Aug 2021 18:54:35 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%8]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 18:54:35 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 18:54:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JUoG6MsX+HboUZT2VO/LieGHB212Ibjnk/IHvsfGsTDqm8gPhM19JNaphZIVt/dr5qOggzhTaiT9Wk0w/dIqwHbcbL9Se7e6snXiQUL7y9GH1dWaY5lstlXnI672Ch/jMuJ+kQzZWvXd5mLPX233c8N8Ncec0o3kjoNH4089Ai1ybTZRA86vsmQQPnIt5FagrEAIZeFJKKT0U/JDWNlXjFQrIUbRrzmrbqgHHCDkCPjGX+CxOwJ0WaW96pi786Cdawx7oU99mtXBj0LHkaKYk2Z7uYrdddAAZBXOQeBoVwzGIgPE5uCp6pbrsIX9Q8alWCrYjZu4RVo9UTlEj0l09Q== 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=MucbcBTCBp8tc0cZf0YiJ41WmFMJ7c7UGBvOfdNNX2g=; b=ba1JzAt9VPEYpe6g88S7Tn9s/Gw4CaOJ5KnPVzyFKNsCRk1B1OMJTTkM9ksfqsvpmErN12k76cDvjXffMyQtNSCsHhx1wvjuPapD9jDNlONgQ7sZcYVGXCtdNicxawDJuW3XrOiudPjTHuTSBJxDavSOYC2b81k/fNCrNWTHbYEg7hnnBNDDh/62POerhhQ63bPaNtfR+WZbCBs8WdgdDAowrBa+hNGbrepeG6GegiL/f0crfb/c9rxSpYL99S1EjR0NDfngl4iZm86nT9X316ON+M/CAiAZv/1w0Xp0YvvCzyHIgSfmuwpKSnSxlxFYKKUp7fhXP0n6r55H5YGlDA== 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=MucbcBTCBp8tc0cZf0YiJ41WmFMJ7c7UGBvOfdNNX2g=; b=dEXbg+1tEGdX4miGSBY2fvXcsmHbvCnBCIwCLp/DyXNUv8o+wntpiewkYdPSOGTiyZuXAPQUaNXhEqM1Ga5swEcR0QnErfKaXMwJmurAUcSZzLj+hINj1t+xtnT+oMumzyrQ2uDBVq0tk8jwkKVQJ7pHyFu9nZuIvLAarbAgW5c= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, ehabkost@redhat.com, berrange@redhat.com, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, den@openvz.org, nshirokovskiy@virtuozzo.com, yur@virtuozzo.com, dim@virtuozzo.com, igor@virtuozzo.com, pkrempa@redhat.com, libvir-list@redhat.com, stefanha@redhat.com Subject: [PATCH 1/8] block-backend: blk_root(): drop const specifier on return type Date: Mon, 2 Aug 2021 21:54:09 +0300 Message-Id: <20210802185416.50877-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210802185416.50877-1-vsementsov@virtuozzo.com> References: <20210802185416.50877-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 493359b2-e534-4966-782d-08d955e6f8c7 X-MS-TrafficTypeDiagnostic: AM6PR08MB4405: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:913; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ffJfbLrT9sKwzqoejZN4Vh5AW6coFvgvatCOACNKM6oh6qfQAQ+7SUnV929DWRAdOJI8UzIbn7FPBq8h3u5YnmeISaHFLXM4NcbzjSCsFs2z67KNfdzaLxl7DXJyJqVeR9yQTt76Q8eztsGhqNU4Z2pK2aKIuBsAkCPGYhFwlZcOm0gbyvSa21zqizMjaHqP1cXjTuo5DKtfgziCLJNKvz/2biFzgapjrK/uoL0djKPrmfpuR2zFS+HI/H6GsH7NyFo3S1M/fo556I50KPaTrJWyAhmllkRMDlS/Nw4dkm9ECUtwgYEmtBsu8ziXDXWHMhclv1XTBImbcRcL9a6AjJ5Y4ntBMYGn+Ro0GMyOmBoxovasgpSA9mnGCS80ip+zZ0tNS4f9aN8aRw/YHfagQybRueB9oCvtoM2ASCfyWDWRStf8KHkZqUvwOa7a2Wsa0F9wk0Hn9Okx71wWxhArHkcOqf0OkW9MtMhBaa31igZwZgPsK/9vhttjH38M2yJ96g02SROLdTlgx1xLSl6QHJJxYKYsu8U2BU8M1muPtzWILa/rPAlxp+F70L9EVyCSOpq5hz40o8QI6WPpKw6Ml3HkpAHBnKK+WJdGEesIeHKNUV0pS7wu/qFMxaj17eGleGOp6xwZa3ckArj0sfmr1UeJEampjvVUk8PjSS2k1G0bJhNl5laOt1DS2viSnaBzibnr82I1snnRNN6hCqlGFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39840400004)(396003)(136003)(376002)(346002)(186003)(2906002)(316002)(5660300002)(26005)(6916009)(2616005)(956004)(38100700002)(7416002)(38350700002)(4326008)(36756003)(86362001)(6512007)(66476007)(66946007)(66556008)(8936002)(6486002)(478600001)(1076003)(6506007)(8676002)(83380400001)(6666004)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?jOX86tNqfPlPcFHkwPTDqlV3mEO5Zju/42C+2Wasdd+183wSMTIB3VryMWn6?= =?us-ascii?Q?znwQrzUtEdmqR54i3U+wQb9soFEG7Dus7YVdoDDRwFQUqn809y4aML/QEsVl?= =?us-ascii?Q?bOlIBBscfsEf8QVzgHlj3P0EyWv0w64je6h/wPxeUrNGUud9/NtuZmCIkMwB?= =?us-ascii?Q?VpmEBP84SYSrAY5iKyBOutGj3IxrhgcM9HddlJ16VA8USW9Cg/Fej7jZHl0p?= =?us-ascii?Q?aBk1Pc/QBFGru8A48j9qnhyGPOYY0sdVVcUq4XoI1aymQPImsMmBrpv7nu3g?= =?us-ascii?Q?cYnCu6p1FC1dtP/pMmY5h8szvpvGP9tbxFyj+D/BgOoMaQvx6bV550sGTtVJ?= =?us-ascii?Q?SBMgHeIIYtxcOAFYCI6/h55/uqAw/+w6cKzzn54GHOwThUPYS2+w3CvLvrLB?= =?us-ascii?Q?TkWQd2iB3welml/XKSzi/kNJmMmOuN5V3YSjFYxY5p51J5AV7yfICG43NTQd?= =?us-ascii?Q?lRSUkT8kCa6rouQVuyCW63biRifvxcqIP6j4A2unJoSNGkMr9M/oOthstw2t?= =?us-ascii?Q?D/unWYmZmnpdalnaL+fxmW+Fo8hh6kjIbzyh4GaDZVCdM0LWls1JOCQh3JIy?= =?us-ascii?Q?rbNtYW1Q3b3SIGrqex2/4tQIgeky2PRZe38Pt0EIQJeZACm6P07vAclcBmxf?= =?us-ascii?Q?1p2ptzK20pLEidUyERzqNtOv2lsx4WF5eR6fo3p7ftQVvmxs28FLcXGfmlkT?= =?us-ascii?Q?WFpqHRQzbeNGiGVUH+dsI3oUaWU+o/dyEei0RvF7+2ypLzJtdkkXCe4neDXd?= =?us-ascii?Q?K5NBByfeI4S5j0JeU6X3GrtqLaIGjU9HA6tFTDu/1MfGykTmQDq8+Ef0sZyz?= =?us-ascii?Q?5BP7GbJmFvuLkIS60wfLzFTPv3ilJzqiD+PEZNGdQoB3h/ZYWrOrrq1jINHI?= =?us-ascii?Q?TIUosXoeTqP7ShBGXpNaTrMjpf5ji4GmmzuqUhMZUFhpq5G+EejGNdEC1id9?= =?us-ascii?Q?MOtoHUbnhh5TZWra0nwRbgjJq81eiqp5NyKX651oXgR5BdkP8H/G0lCaKQnq?= =?us-ascii?Q?/8naNnVLLqA4vBFNFvoD4c3xmkXhqi0E/dM31j7c6SeFmbephNO1uUm2J3Sp?= =?us-ascii?Q?qamBC4Wz5leDoy3Fu6cKLE3lTL5/1PL0rGVTanQYg/FiUcDz8jncLN2zys9p?= =?us-ascii?Q?j4iB/08UPPpvtwTSO2SCF2majDpERh3M4lFjnEReOqQO0HqVzkUy/gQucqF2?= =?us-ascii?Q?k+6D8J/CuTEhSGRnho9ZfNcQOyQYn52xdL0sA6Iss7Ozi7PcAHNDPX92GNuV?= =?us-ascii?Q?e1GCVMkBwMTmuOFltYukNPwe6K0xu141ZMBx9/60kYQlzIeS+z7RJAqzzm4j?= =?us-ascii?Q?qfW/PYC3xNvbB5LYUUgTqQA7?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 493359b2-e534-4966-782d-08d955e6f8c7 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 18:54:35.6118 (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: pPjaDWoqtY33n9N3PA+jyDbyD+lRPA8l/ZjESPHaF8YRTJfRqTB5IREvcCkoKfAL9ivqCPmZskmncn2syakFvk34T1Tam+AYNdpGb9IWN+w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4405 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.21.137; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1627930599656100001 Content-Type: text/plain; charset="utf-8" We'll need get non-const child pointer for graph modifications in further commits. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/sysemu/block-backend.h | 2 +- block/block-backend.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 9ac5f7bbd3..be03301123 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -270,7 +270,7 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in= , int64_t off_in, int bytes, BdrvRequestFlags read_flags, BdrvRequestFlags write_flags); =20 -const BdrvChild *blk_root(BlockBackend *blk); +BdrvChild *blk_root(BlockBackend *blk); =20 int blk_make_empty(BlockBackend *blk, Error **errp); =20 diff --git a/block/block-backend.c b/block/block-backend.c index deb55c272e..7a0a1e1ae2 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2455,7 +2455,7 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_= in, int64_t off_in, bytes, read_flags, write_flags); } =20 -const BdrvChild *blk_root(BlockBackend *blk) +BdrvChild *blk_root(BlockBackend *blk) { return blk->root; } --=20 2.29.2 From nobody Wed May 8 05:30:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 16279305292161014.57614630693; Mon, 2 Aug 2021 11:55:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-435-KGF95qNPMgqZNe8gTuDFJA-1; Mon, 02 Aug 2021 14:55:26 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1842018C8C03; Mon, 2 Aug 2021 18:55:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9BDE74A66; Mon, 2 Aug 2021 18:55:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F0D1B180BAB2; Mon, 2 Aug 2021 18:55:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 172Ism8m006346 for ; Mon, 2 Aug 2021 14:54:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id A1E7A214700D; Mon, 2 Aug 2021 18:54:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A0142147012 for ; Mon, 2 Aug 2021 18:54:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C738989C7E1 for ; Mon, 2 Aug 2021 18:54:45 +0000 (UTC) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70090.outbound.protection.outlook.com [40.107.7.90]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-sZ6TMAncNmqocqEc8c5hyQ-1; Mon, 02 Aug 2021 14:54:41 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4278.eurprd08.prod.outlook.com (2603:10a6:20b:71::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Mon, 2 Aug 2021 18:54:37 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%8]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 18:54:37 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 18:54:35 +0000 X-MC-Unique: KGF95qNPMgqZNe8gTuDFJA-1 X-MC-Unique: sZ6TMAncNmqocqEc8c5hyQ-1 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH 2/8] block: add BlockParentClass class Date: Mon, 2 Aug 2021 21:54:10 +0300 Message-ID: <20210802185416.50877-3-vsementsov@virtuozzo.com> In-Reply-To: <20210802185416.50877-1-vsementsov@virtuozzo.com> References: <20210802185416.50877-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 989e2429-7e7c-44bc-027c-08d955e6fa03 X-MS-TrafficTypeDiagnostic: AM6PR08MB4278: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:216 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: 8ur9WUP6aYKwKDMteWePsHr3FowifmPOjuvbxmWyqze61kiWUoZoj1xf8FYvwWJ/jdIDiH7crRVJ6DBUFTmdhopk6BMfBDBWBsDMhzrXCWJzb4RlyRGZERJo8+YtMg1dZCV9ZBnxoyK2MmWelZpmSQ/9TZVDWjNe+zKICWDKA3CebINGyULa2ePs/UjdQinaOJFjZrbykL1CHsjOP40yuOMbShTyeAGI7EInMwwWwg34cA1M85nhWyYv8PjkQ98BTtF2xYOs+Ms+lkVKTDAP5W6cQsB2ap0Q0m9SiKOg9oXF8Drl6639wneu+ySAoYLewy7LXkxgZ59ocbSlCmqhV7JvCYBFbDy+AlMjgNmfeTKupBLK7OFrepUaoJkT51F+DQnUo3Ig9vO8ywLjAOXjFQjknit1N7b9LUzC1Yn/DNSrcdrXeEitHkO153vpQfIRlVcmTVHi5jzc7+XtLhDR6YNo/La3n3xUSZMMrFTILqVeXJ5c5fCFIRaXQFqiN1hTCWXWEHTARbXaKHAT7snP9zjKlsWUoJV61opYm72+cWgzAkIbRJo3hmZ5YO4h/oawMKTNpLIsydEucNXxv5DZca7aLlzw74FoKF2i5AQG67ThxO8OEelVSSCW1XqeUSdyHbqv7xRtaYtikX4hdoajkx5sU2ziV6wOk8La2I9fj0KAncbWsBAraRWsbSJVi0JKXA0hjkhy7FNZFcR4JHGl8Q== 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)(346002)(376002)(39840400004)(136003)(396003)(366004)(186003)(6916009)(52116002)(1076003)(83380400001)(8676002)(6512007)(38350700002)(38100700002)(2906002)(7416002)(6506007)(2616005)(478600001)(6666004)(36756003)(5660300002)(8936002)(956004)(4326008)(86362001)(26005)(316002)(6486002)(66946007)(66556008)(66476007); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?X4lsBvSvbklHDSNGwrJyyIg2w6PlJG/zubKlfQKsq4a1V5y0DDqhIvw0AxwQ?= =?us-ascii?Q?H0moPI1MyQ2j/J7fp2zMpjHDtBglRQHh/7BFamBy0T57OHElwJwmGNCuDTJG?= =?us-ascii?Q?CCCMtxBb/dXaY4ul8pXvbqL3L/SaQFyfgRGVmuj+WWRBSXPD2M0QfB/7dG8L?= =?us-ascii?Q?dVMRQxgnPn3N1dLEhRipH/P2X8JwUxHKx3GDSFMVqV7ZlWgwNlwOTc0sWV+X?= =?us-ascii?Q?LahKr89rMksnxQ7P7RzJFeJ5n9RGtvEDiMLEbk3MdClHCS89qBTFr4YSnPBx?= =?us-ascii?Q?8S6mDqTQ4s3CnI8A6fZ5vL38J5SzKWJAFBcXP+3vJK8/BKu35dZPcId1vCj/?= =?us-ascii?Q?OW8w5vt2Yo2GPEMDkOQb5WiSgRysFb8xnhYNzsa67WoQeHR0HuYou1bL9zgN?= =?us-ascii?Q?OleFWA/SjuP9aEdoke5dI6UUCwDfjjiZf6SsoiL/5MVwJcPksXv9/tCsRn/Y?= =?us-ascii?Q?Bimi2R1FmndNOzzxMeDv9natflAccDI/Fg1cQx4bWyXvQODA26MMz+o1HALi?= =?us-ascii?Q?x+M5unlMhL1ZWtAj4FWeHPJMNgDg633wEn5wZYNCib1CSXv+XO1R2KJCiOqZ?= =?us-ascii?Q?W6GJINAdFYuwguUSLbz+B/PspaZ99XVa5m/0ghjMAZ595kpydbkErg3KZjAQ?= =?us-ascii?Q?LEmTzoJSnqUZbLZceWwyFpPF7zzdxjev9RbzeeGgKWh53okn0bafiZ53a2u8?= =?us-ascii?Q?8ypgWOJSqXqvjL3dDNbRhl2iA4K2SFybKP8tMAZpikA6oaWCSFesHvAaWMoB?= =?us-ascii?Q?TDeNrEaGE7kkuKdOCb5QqubfKPz+2XsVPOvxITSGC7Mo/I0Li8cYKimm2mTj?= =?us-ascii?Q?LdrwJBxrKq6hfK3KmFRM+pH/4ADohf04gjnLsM1PrHl4grP2fRxb6G7/068S?= =?us-ascii?Q?h8lZ9AVAGUPasQqGvHDj4xL6TJ43YJ4fy0xipjzbPC7+W7lbITLtnhEsN8MQ?= =?us-ascii?Q?b1550Bm11kpPf7jKoMstBn9DWfPj7LvKu0sc+EyPguRl6CkZ7ruWCRI1oYNa?= =?us-ascii?Q?XIu9OhprP1pRaJvz8n7OKP2lx7uE8kPMU22R4wwbA0IZIhMHogNuKAtQISrY?= =?us-ascii?Q?if1AY0iQcu3ePZ7/KHJM/j7fPK7J1JdWGq8EPSjgMUpqV82J7OLQkYn2STCh?= =?us-ascii?Q?YAHGDt9ybRLu3N21anKIFcL1LIhFaxIxT3qnpnT89w+n5QX0KOD/RGXd7Ppz?= =?us-ascii?Q?eStu7vicLfc/969Y8ELh1VLD767p1OSugFIl/AtVvZ/q19hAWRHV4+vdk4qU?= =?us-ascii?Q?+o1Ef8PG3yZfQ3aWg8fYZpClxhCroZ92hVVVUlR6hixgDPXcHnJbY8r1MOhV?= =?us-ascii?Q?L4ewT++FwRfVErV/iCHbB9NR?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 989e2429-7e7c-44bc-027c-08d955e6fa03 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 18:54:37.6429 (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: g8y4JYKBpB5at5mX6XcO/WhhddPnappkcxSAftbuJ9srcRPnALXs/CqzH15X+1HQjnwPZR20zLNcPPCY63ru7yNSmn3Dm07P7DIzAjFpcwA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4278 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 172Ism8m006346 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, libvir-list@redhat.com, dim@virtuozzo.com, igor@virtuozzo.com, qemu-devel@nongnu.org, armbru@redhat.com, pkrempa@redhat.com, yur@virtuozzo.com, nshirokovskiy@virtuozzo.com, stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, mreitz@redhat.com, eblake@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1627930531945100002 Content-Type: text/plain; charset="utf-8" Add a class that will unify block parents for blockdev-replace functionality we are going to add. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block-parent.h | 32 +++++++++++++++++ block/block-parent.c | 66 ++++++++++++++++++++++++++++++++++++ block/meson.build | 1 + 3 files changed, 99 insertions(+) create mode 100644 include/block/block-parent.h create mode 100644 block/block-parent.c diff --git a/include/block/block-parent.h b/include/block/block-parent.h new file mode 100644 index 0000000000..bd9c9d91e6 --- /dev/null +++ b/include/block/block-parent.h @@ -0,0 +1,32 @@ +/* + * Block Parent class + * + * Copyright (c) 2021 Virtuozzo International GmbH. + * + * Authors: + * Vladimir Sementsov-Ogievskiy + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef BLOCK_PARENT_H +#define BLOCK_PARENT_H + +#include "block/block.h" + +typedef struct BlockParentClass { + const char *name; + + int (*find_child)(const char *parent_id, const char *child_name, + BlockDriverState *child_bs, BdrvChild **child, + Error **errp); + QTAILQ_ENTRY(BlockParentClass) next; +} BlockParentClass; + +void block_parent_class_register(BlockParentClass *cls); + +BdrvChild *block_find_child(const char *parent_id, const char *child_name, + BlockDriverState *child_bs, Error **errp); + +#endif /* BLOCK_PARENT_H */ diff --git a/block/block-parent.c b/block/block-parent.c new file mode 100644 index 0000000000..73b6026c42 --- /dev/null +++ b/block/block-parent.c @@ -0,0 +1,66 @@ +/* + * Block Parent class + * + * Copyright (c) 2021 Virtuozzo International GmbH. + * + * Authors: + * Vladimir Sementsov-Ogievskiy + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "block/block-parent.h" +#include "qapi/error.h" + +static QTAILQ_HEAD(, BlockParentClass) block_parent_classes =3D + QTAILQ_HEAD_INITIALIZER(block_parent_classes); + +void block_parent_class_register(BlockParentClass *cls) +{ + QTAILQ_INSERT_HEAD(&block_parent_classes, cls, next); +} + +BdrvChild *block_find_child(const char *parent_id, const char *child_name, + BlockDriverState *child_bs, Error **errp) +{ + BdrvChild *found_child =3D NULL; + BlockParentClass *found_cls =3D NULL, *cls; + + QTAILQ_FOREACH(cls, &block_parent_classes, next) { + int ret; + BdrvChild *c; + + /* + * Note that .find_child must fail if parent is found but doesn't = have + * corresponding child. + */ + ret =3D cls->find_child(parent_id, child_name, child_bs, &c, errp); + if (ret < 0) { + return NULL; + } + if (ret =3D=3D 0) { + continue; + } + + if (!found_child) { + found_cls =3D cls; + found_child =3D c; + continue; + } + + error_setg(errp, "{%s, %s} parent-child pair is ambiguous: it matc= h " + "both %s and %s", parent_id, child_name, found_cls->nam= e, + cls->name); + return NULL; + } + + if (!found_child) { + error_setg(errp, "{%s, %s} parent-child pair not found", parent_id, + child_name); + return NULL; + } + + return found_child; +} diff --git a/block/meson.build b/block/meson.build index 0450914c7a..5200e0ffce 100644 --- a/block/meson.build +++ b/block/meson.build @@ -10,6 +10,7 @@ block_ss.add(files( 'blkverify.c', 'block-backend.c', 'block-copy.c', + 'block-parent.c', 'commit.c', 'copy-on-read.c', 'preallocate.c', --=20 2.29.2 From nobody Wed May 8 05:30:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1627930541602953.9345287737984; Mon, 2 Aug 2021 11:55:41 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-wcyStWaOOTuvAsgrqo1aJQ-1; Mon, 02 Aug 2021 14:55:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4086118C8C0C; Mon, 2 Aug 2021 18:55:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1613B6A904; Mon, 2 Aug 2021 18:55:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D61194A7CB; Mon, 2 Aug 2021 18:55:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 172IsoFi006352 for ; Mon, 2 Aug 2021 14:54:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id E474AAEC9B; Mon, 2 Aug 2021 18:54:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC196A9A1C for ; Mon, 2 Aug 2021 18:54:46 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C629A89C7E2 for ; Mon, 2 Aug 2021 18:54:46 +0000 (UTC) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70090.outbound.protection.outlook.com [40.107.7.90]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-JKwV1lqGMUGlWQaLQ996cg-2; Mon, 02 Aug 2021 14:54:44 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4278.eurprd08.prod.outlook.com (2603:10a6:20b:71::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Mon, 2 Aug 2021 18:54:39 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%8]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 18:54:39 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 18:54:37 +0000 X-MC-Unique: wcyStWaOOTuvAsgrqo1aJQ-1 X-MC-Unique: JKwV1lqGMUGlWQaLQ996cg-2 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH 3/8] block: realize BlockParentClass for BlockDriverState Date: Mon, 2 Aug 2021 21:54:11 +0300 Message-ID: <20210802185416.50877-4-vsementsov@virtuozzo.com> In-Reply-To: <20210802185416.50877-1-vsementsov@virtuozzo.com> References: <20210802185416.50877-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e45cc2d5-c794-4b18-af52-08d955e6fb21 X-MS-TrafficTypeDiagnostic: AM6PR08MB4278: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:352 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: OmyPB8g+hKtwY9WQLyy/8rSv+F7/LnqSSEoLQ9B2zT9L8jFKKylIxRMExPbyE8XsJXmVoZAWgCsMNk+ilcGYmfXhfGVX1QLnemB3St248i7cCyjND5iTUZclpwGjQeofJ8uDRm0O8/WJQQtVr5NCkUDL+kmRfLb7Da6l+jr+KdvXWQmnB1oB2wASscr+Dk+SpxOfRP4fiIobLTRqYnUXQyjfM1kowjLJCj4qFCD0d+2yJ4qtTJgO+wWLHBo+djUSMcvIIYm/peXnsOwEPgdZGBPd6DMMFgS2QC7aP4vTkh+Y0D7HKd4bmlv6Q56Hu+1yvHJdoLo1wTXz6ld12+yyIjkJkswhDaWOLagYJOSgb3BAoeY4ses1eBLpDSREGOa4WO0MILscyqh2pIOCW5JYIykW2rIq4MYDRUni49vEUGqr8FqD64ogdFkrFtF4XWv/et8DJWwgJdiO3BViXDQD6ha3xhVFERfY4py4Hv+4kgH4XUTuSbx9bCmXcYaUOVGso0a9JIFAwxbuemAyk1jGFQphMAxahvPMf27GhLNsJSWnPSBcCCr7Nv/A9q6sqSQG9zttO2hTNJGrWD5+I5p2og3goR8TyRbZWBqqWcjEq/s27nvzdAotI23Go3RzZ0SSTX7PN1MEEYPzLjb6k6e3/x1j2FBVkuAm08Z6+Xc0tHIbtS/aBaG71l/3iEGu2eONYJEFS0RRyNjwmBrT6FvvYQ== 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)(346002)(376002)(39840400004)(136003)(396003)(366004)(186003)(6916009)(52116002)(1076003)(83380400001)(8676002)(6512007)(38350700002)(38100700002)(2906002)(7416002)(6506007)(2616005)(478600001)(6666004)(36756003)(5660300002)(8936002)(956004)(4326008)(86362001)(26005)(316002)(6486002)(66946007)(66556008)(66476007); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iIZqbLNbEcFcWpARwLAytnW+ElzI8nBhI8ijBvty2zeFhswpFpI8gN5cgAFW?= =?us-ascii?Q?ChnoWzXE7yB5kYoZjox4Hvo0+dxbUA9Xz5P+4jCquTqTb0hHDcwdcKC0yJkY?= =?us-ascii?Q?txQ16NzoCmxeLzTtApPEPk/qfci5iMxEaDeR/y8Fcvjh/KmGe8/CtEHyKtRq?= =?us-ascii?Q?HGFAkUlHLRqXwy0quvtJBh1xdwj0QwTK/80uXIcUR9cR4+wxLC/8eRW0fHrR?= =?us-ascii?Q?1VIKcRloZn5c8DQl24EMIwpYH9DM+FNcpdYaQ+mF9Iile+rC76k6oN8FC1GD?= =?us-ascii?Q?PMooZkicOvNnNDHwQaLE7mEMAI1CE/Kz2426ePcifemRvMma9MVbNXCMFJzC?= =?us-ascii?Q?nSoGFfNuxkPZUD7k1OvZCALet9rgcb0fZpxrQNSHUZhkXNYlqxIPDTKqks46?= =?us-ascii?Q?bLJ51vII/CLtYHQTqUkM53uygzLEYckP55oySRBozkVgx695eB98wc1RMNFS?= =?us-ascii?Q?CuQJEnQfsVJE0m9040ijvw2N9Rf6HjCjdKeXru/3QrtJ1lc+kAbM6DNY9WGv?= =?us-ascii?Q?zQjE0XK6ziYUmsJCuBmDVp6jAgmcvsiA+CsDrnOoWmCuKdQxos1LWD+haz8G?= =?us-ascii?Q?OH2iHmZDHySQr+/JvRxvOJ4JsDxDAZcg6+bhW5lgP2CwlVNspBkoVrehQ36L?= =?us-ascii?Q?WF3Pvlf1+ktZgfFu3hf7YWadlbwmOxsxm0h4Qbe8OfsstcBDf5LNk6Qb1LtO?= =?us-ascii?Q?/T3gpFA+MBfOuhtRKlcXP6EOAwCWshNIJt5+77qi1l22k8WPvjG2lXZh3tOe?= =?us-ascii?Q?xVJNPyRC5LhQu0ja3qsrzm47HlO1yNTQjPCvHykswoPgfx5x/oQNQJFB71AS?= =?us-ascii?Q?+oEbiYtFHkNpMan2wm8DbnSSG9JgYbQWhNFzdm5ZYSvQz94cpzFKrGfI+j/E?= =?us-ascii?Q?x5og8vkO7TYERs2oGlqitC9n13E8PzXB/ZcUCHOU3STtncqVQv/IWfIqMRC6?= =?us-ascii?Q?WcyScS9NFmRZDbyHz+Fnoiyrh0CtiBTHJ+f5Dxzsee1ALa3G2llMv6OtmQJ/?= =?us-ascii?Q?euDIOolAnNlI3PZhDUgekti2nUnUtbwlJiG4tSuWENuqOlbkvV32GTHEUt9c?= =?us-ascii?Q?piscaRq6hPUpJvdBBrYQQw7LEUsvrDl2kJz/KU2cGNA/Zb9WdMGJ31wNqiGR?= =?us-ascii?Q?VQ7ITlLhOkP50emcxfhYAIjvnkco80Dr4/VpHyAzfaCI0Zjmk1AH+6FF/Hol?= =?us-ascii?Q?4axhSAp4anPVOFJ1zO04lFwGliBZO61ccaROdAeRqgV64yusazbQgcC9Daz6?= =?us-ascii?Q?AMks7AnuPaeWFHz4nLGu4UEDUXx5f4M2LmSHGSWMtqmHBzExI3INAST1yWvG?= =?us-ascii?Q?bIlMvmFUWKqSKunF3foiTZ/T?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e45cc2d5-c794-4b18-af52-08d955e6fb21 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 18:54:39.5635 (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: JZHBhgQNyE6PZAeEv9K6/PnNT5Pg4SPQwU08bLsjAE9csTyWs4yBMbfs1bdnV9YCMFiztTXf6jCTG5ovmifeyjEXvc5efk1Hu5DN2jqihYk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4278 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 172IsoFi006352 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, libvir-list@redhat.com, dim@virtuozzo.com, igor@virtuozzo.com, qemu-devel@nongnu.org, armbru@redhat.com, pkrempa@redhat.com, yur@virtuozzo.com, nshirokovskiy@virtuozzo.com, stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, mreitz@redhat.com, eblake@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1627930542152100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/block.c b/block.c index e97ce0b1c8..449f933661 100644 --- a/block.c +++ b/block.c @@ -26,6 +26,7 @@ #include "qemu/osdep.h" #include "block/trace.h" #include "block/block_int.h" +#include "block/block-parent.h" #include "block/blockjob.h" #include "block/fuse.h" #include "block/nbd.h" @@ -7501,6 +7502,47 @@ int bdrv_make_empty(BdrvChild *c, Error **errp) return 0; } =20 +static int bdrv_find_child(const char *parent_id, const char *child_name, + BlockDriverState *child_bs, BdrvChild **child, + Error **errp) +{ + BdrvChild *c, *found =3D NULL; + BlockDriverState *bs; + + bs =3D bdrv_find_node(parent_id); + if (!bs) { + return 0; + } + + QLIST_FOREACH(c, &bs->children, next) { + if ((!child_name || strcmp(c->name, child_name) =3D=3D 0) && + (!child_bs || child_bs =3D=3D c->bs)) + { + if (found) { + error_setg(errp, "node '%s' has more than one matching chi= ld", + parent_id); + return -EINVAL; + } else { + found =3D c; + } + } + } + + if (!found) { + error_setg(errp, "node '%s' exists but it doesn't have matching ch= ild", + parent_id); + return -EINVAL; + } + + *child =3D found; + return 1; +} + +BlockParentClass block_parent_bdrv =3D { + .name =3D "block driver", + .find_child =3D bdrv_find_child, +}; + /* * Return the child that @bs acts as an overlay for, and from which data m= ay be * copied in COW or COR operations. Usually this is the backing file. @@ -7653,3 +7695,10 @@ BlockDriverState *bdrv_backing_chain_next(BlockDrive= rState *bs) { return bdrv_skip_filters(bdrv_cow_bs(bdrv_skip_filters(bs))); } + +static void block_c_init(void) +{ + block_parent_class_register(&block_parent_bdrv); +} + +block_init(block_c_init); --=20 2.29.2 From nobody Wed May 8 05:30:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=quarantine dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1627930792; cv=pass; d=zohomail.com; s=zohoarc; b=j5TN/bsevxxoB6VpxHwO4NyqQTLeL9dT/Ya0oYFsDUrVixXyS+leGOKi1XVjr5yLujVp8wstxg0Kyz3dngQ5TtrZRePIPQmwGAVUGIL3eH/ajz6du7UL1/BVgVM+N39WBkYfN/dY/XzcsODoelbgE/Or/ExYL/qN2KXIhz3zYmk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627930792; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bDHfmb2zGqdhCkB1byIMwN+CYve3TbKGtmmzqg2aFAo=; b=m/2nosDW9ZdQiLEVqd68nWjub6Xl6IW8GGweLmE5oQeRHRS83g3MrccmX14jRBZo6Vs/Yo4eYNX8pPVvszvcJWbjHxU8VHs23XJROKvLQD98p7XPmCPiqffgUYrqBSfLtfNqcpDqdSo3RvY4irqFH/SIdGJhf8HyC8HOq3EJpVc= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1627930792721330.0400339248905; Mon, 2 Aug 2021 11:59:52 -0700 (PDT) Received: from localhost ([::1]:34070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAdAF-0003i9-Gy for importer@patchew.org; Mon, 02 Aug 2021 14:59:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAd5U-0002sX-FQ; Mon, 02 Aug 2021 14:54:56 -0400 Received: from mail-he1eur04on0709.outbound.protection.outlook.com ([2a01:111:f400:fe0d::709]:64771 helo=EUR04-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAd5Q-0001rV-Rt; Mon, 02 Aug 2021 14:54:56 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4278.eurprd08.prod.outlook.com (2603:10a6:20b:71::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Mon, 2 Aug 2021 18:54:41 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%8]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 18:54:41 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 18:54:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UT0QX1hdEMUeg3m4jK3mPDan9F69rsTELzqvn6AV1eHV8Ih1cKF0KP8ce6sFKEHvzI/Cgh9W+jOd/7KUD6Z2CRu8eT8tRLQ17XsfloenCHpNnm/RYgkGTl3LOd1rmpnoi0wlESXW9CeaACnVF5DYXVlKL0R7xN383qGXsFWpdeaAXkBRcmtUNrWjMxkEffAk1Q3q674u+qYkMcVjk2kOkiW9pRod5JvLNCAX/npjUPfNoFyTKXkEhM+GyO9WxBDcExSorCbPwVbOg+SvyI5xvSACtevgwi2pebBiw+ZOzs7rjAt+JRBlEUxixcyW/iWwAJICZH8zwoxq40axFf1f2Q== 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=bDHfmb2zGqdhCkB1byIMwN+CYve3TbKGtmmzqg2aFAo=; b=TXwl8+/ns005+Vx7V63NxcfyvCFpUGGOc94FzGX1QJUCpZOGUpYhw6sgH80h6hdhBiGVvErvcYfpE4YkkNCFjDn0BGAD83XliIwGoCLPBUIZTbZPudendekapAUBoT12PHAs+5IgsreJSfQPyjdM505H9XS39yYR9ikLHLjIv2IrnLxNb3l9iNEjGkrn7tHfm/yPahBJAuVmlB4JGp9eVAq9ZAlPzTr2DMD1EwOfcYGUI/faDB3Mq3xSUosmJc+HXu92NJCMxHUywG2c0vi7gmT/FQfykuQ2XJiZaJ+uZOiLjuLZw0SqyienrLDW9b/x5jbldn6l47+Rjl2nj7YHvA== 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=bDHfmb2zGqdhCkB1byIMwN+CYve3TbKGtmmzqg2aFAo=; b=cQQ8GS8qgaw/DOOePiFiyE/yR2qJMNRyGAJ8nF9GLlR+gDfgYDKhSCMt1jWVCUB4QfHg3R4T0Qgt+YHCd1/d4FG2HPZUYmbXTLGDZOWT+deNAVOKp162qvvDzuKdLOGB8jBdjkp7meOqT6wO33mltDBMT2aHd+4Tow6N0XETvnU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, ehabkost@redhat.com, berrange@redhat.com, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, mreitz@redhat.com, kwolf@redhat.com, vsementsov@virtuozzo.com, den@openvz.org, nshirokovskiy@virtuozzo.com, yur@virtuozzo.com, dim@virtuozzo.com, igor@virtuozzo.com, pkrempa@redhat.com, libvir-list@redhat.com, stefanha@redhat.com Subject: [PATCH 4/8] block/export: realize BlockParentClass functionality Date: Mon, 2 Aug 2021 21:54:12 +0300 Message-Id: <20210802185416.50877-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210802185416.50877-1-vsementsov@virtuozzo.com> References: <20210802185416.50877-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ace51682-cdc4-44e8-d7b5-08d955e6fc4a X-MS-TrafficTypeDiagnostic: AM6PR08MB4278: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:40; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XAJ1+xrOyuG+SYoby431UHBeO/zHGidmOi2FpJ/xbcHnecNiL1mkbjZTEe+FJwtYdFbWBDiNIF3JvUuUeY+DsHYJHo+n/oYTArVmjqyiFLHC5r/THIN1Ht3DyNvN53+VRCaApGfXNDY4CBuyZP1G1kOg5arUhpfojWtQONqXP2lrF3/lWFCfSlrseOFWgaQhWWXOJqUNQ/1fM/4XLXqww6nfANp7/41zkk3RX3lAUyXm7hhDWcJ7TUC8Y4OHwyv2lBPkYMs9UJBJD70NrrRNxbgWYBf3B3YTq8VtKRMc/eKI1O8xPZFT7UGfOTsBIp6OJdGNpAMLhPM2TLzZAS+BdmkPpnixEZmG6echpRcZeigX7B/QcTEQSyCgZrHdzX1mzBorlrwR6X9X67pA93DWKBKNd0whgrIDhiTuO4qHPWQawuwbPeLQoV80Bt0D47GaHbhN2+FnEQ/xNiOHKSuafWkrYQ4mscSbJZCc7JxnChkESxLVRi+uQS21TCp6JwUliHIzOqEJwUZ3lXoXFglDmJqhT3k9L3DsaLHArOujZDS0OajLzYfb0VwjjDPqVPJzf4RUXwo5kDFHb+s7z5hkRxbFAulLK0uSRonxTO/cRo3ExbgPMJLdJajgAEH/pFXioMN7mOYXivJm8Ynzf1QCmp48kHnXcQ9n0Mv01nEsQoMgtvHKCO8YMlDpwPEH1bXJLnSteofj5pYtCfTd0BpRQA== 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)(346002)(376002)(39840400004)(136003)(396003)(366004)(186003)(6916009)(52116002)(1076003)(83380400001)(8676002)(6512007)(38350700002)(38100700002)(2906002)(7416002)(6506007)(2616005)(478600001)(6666004)(36756003)(5660300002)(8936002)(956004)(4326008)(86362001)(26005)(316002)(6486002)(66946007)(66556008)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sYqVj/JqzT7bByi8mZWpvbStEZJkUrRcbjHyoWupHqu5W4ha3kdFANGSZgG4?= =?us-ascii?Q?6m8yxVfPsBQ/ua8U0F8kqxZkxIrnl36mnAbLF80bXPf8isC4BW7fYReVOYnm?= =?us-ascii?Q?5Wv3kZZPl4Zt7rLEUD7dfWhUUVPoLJj1HUc27YV9Kn4jbFtZooFzWGRv4Ojp?= =?us-ascii?Q?RnMS0QrTf5sz5bFaOY5NyY1c965AjPoUFziQkNUs8Y0jskwp4ISR10Goj+t8?= =?us-ascii?Q?j8fiGr+hRJ7nxuAcwUTBVo30eBegs4/91OsTD01CSVeGZirJZOOpwzdCNLYr?= =?us-ascii?Q?6fGPwJu4l2tYmenvsIM0bPM5OSVntXONMKLqfCXhPLHr7KPiHGOckwgaxqUq?= =?us-ascii?Q?Glk1Cc1Om374N28A7duQmbnKbIVXci/k/c+D3bayNs4A4cqQtT+zGHciKKLj?= =?us-ascii?Q?F10z5KobjjfzJV2fZaENYO21YiwTQ/DSKT6UmniiwRwtKQWbgmE7sJZUmOcd?= =?us-ascii?Q?ykn6+o/regxe7RGUAhaBnlRd0y+EXTDesg+vnai1e+9Mn2U8TYaeG+q0Bd4x?= =?us-ascii?Q?6eNGcFSTkl6soqMbUJqo7RDK19DV8YZQR0hHrv3esYLADrbTngZE2T42tPdJ?= =?us-ascii?Q?QmgFalJPepp3InhDH79W2gxquP/R73xaNA4rGJxjYe+DrzO/SoDyDFyF4lCG?= =?us-ascii?Q?KGYM1yhLYy7vjkYpc0RkMbzCunMpiqitjAP2C9U0sW5VoQqp3lnTMdkIZMue?= =?us-ascii?Q?wo8P3Duu6KcN8muiaGQoSboCVJ4c3en5BBh0nIB9d+KAhqNYu6mCamP2IVRl?= =?us-ascii?Q?tlGqtLjMD1daoXLhFObeJOU66FC7aH+cIeYge0YLFbTgbqkXNISpjANI5yWT?= =?us-ascii?Q?mlYl8KtsiqExFvfON0nf36bIWKjYYhHld/xLVz3lWU+KhBq1tcWW/s2p2U8t?= =?us-ascii?Q?UDJd1Yj3IM4Y3D42arazQ6r6KXzaLN5UfHkRnqeMtdf6MUXmu71Ech6tSwrx?= =?us-ascii?Q?oHimCd+Vv5kQKhUriKdt8aJcPjswRg7Clwar3c42l7rz4oYkOlFqFn/9uEDK?= =?us-ascii?Q?N9yF9A6P4n60Zr9TbeXPVtpt7Ea3d1HDywoqmSHCOlD/6I5HM8Q2g4/MqZ9E?= =?us-ascii?Q?C35dujlW2yBGyc0a5xan3GSzwySd0BdyspBmjS2TwKRF/e+8AnpN0wOobLQk?= =?us-ascii?Q?00y+TXv9p5uabTlkkAtUdv+0yFLB5uAlTz63n685sekKT90yeQhF0ISZXcdS?= =?us-ascii?Q?CTToSl8mPXAAOopeUmCNyyX2XqUMSrCDYrLWz4Ufj82y+IFNcEc0dORnEwSr?= =?us-ascii?Q?CQOZFV95vOUy3oHFhN2MHLms4BEl5gGBvAA8QsDDgnfK0BSuc5eD+BDL6CfH?= =?us-ascii?Q?sH0/kV4wDzkxNr/MXFBH/hCf?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ace51682-cdc4-44e8-d7b5-08d955e6fc4a X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 18:54:41.5378 (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: IAHfQll46ootUb/4jQyIKTugo3XMZ8PhTkp8g11HpQmXtXv3SYlwzcGBxVUXJirH7j86x+W0gq6gBz6OZ4aXYksNRSJQsaGRCcbdBJX6QWU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4278 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a01:111:f400:fe0d::709; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-HE1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) X-ZM-MESSAGEID: 1627930793158100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/export/export.c | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/block/export/export.c b/block/export/export.c index 6d3b9964c8..39b45feafe 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" =20 #include "block/block.h" +#include "block/block-parent.h" #include "sysemu/block-backend.h" #include "sysemu/iothread.h" #include "block/export.h" @@ -362,3 +363,46 @@ BlockExportInfoList *qmp_query_block_exports(Error **e= rrp) =20 return head; } + +static int blk_exp_find_child(const char *parent_id, const char *child_nam= e, + BlockDriverState *child_bs, + BdrvChild **child, Error **errp) +{ + BlockExport *exp; + + exp =3D blk_exp_find(parent_id); + if (exp =3D=3D NULL) { + return 0; + } + + if (child_name && strcmp(child_name, "root")) { + error_setg(errp, "Block export may have only 'root' child"); + return -EINVAL; + } + + if (!exp->blk || !blk_root(exp->blk)) { + error_setg(errp, "Export '%s' does not have a block driver child", + parent_id); + return -EINVAL; + } + + if (child_bs && blk_bs(exp->blk) !=3D child_bs) { + error_setg(errp, "Export '%s' root child doesn't match", parent_id= ); + return -EINVAL; + } + + *child =3D blk_root(exp->blk); + return 1; +} + +BlockParentClass block_parent_export =3D { + .name =3D "block export", + .find_child =3D blk_exp_find_child, +}; + +static void export_init(void) +{ + block_parent_class_register(&block_parent_export); +} + +block_init(export_init); --=20 2.29.2 From nobody Wed May 8 05:30:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1627930530062545.9824086495031; Mon, 2 Aug 2021 11:55:30 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-379-RQMcjFxCP9ODp9iSJxUEYg-1; Mon, 02 Aug 2021 14:55:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DACA91006C88; Mon, 2 Aug 2021 18:55:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9120A101E663; Mon, 2 Aug 2021 18:55:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 51AB64BB7C; Mon, 2 Aug 2021 18:55:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 172Isph9006367 for ; Mon, 2 Aug 2021 14:54:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 355422147011; Mon, 2 Aug 2021 18:54:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 300D0214700E for ; Mon, 2 Aug 2021 18:54:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 149D396B061 for ; Mon, 2 Aug 2021 18:54:51 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2139.outbound.protection.outlook.com [40.107.21.139]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-575-C5runEhtMNKlnpWHhDmjQQ-1; Mon, 02 Aug 2021 14:54:47 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4405.eurprd08.prod.outlook.com (2603:10a6:20b:b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Mon, 2 Aug 2021 18:54:43 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%8]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 18:54:43 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 18:54:41 +0000 X-MC-Unique: RQMcjFxCP9ODp9iSJxUEYg-1 X-MC-Unique: C5runEhtMNKlnpWHhDmjQQ-1 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH 5/8] qdev: improve find_device_state() to distinguish simple not found case Date: Mon, 2 Aug 2021 21:54:13 +0300 Message-ID: <20210802185416.50877-6-vsementsov@virtuozzo.com> In-Reply-To: <20210802185416.50877-1-vsementsov@virtuozzo.com> References: <20210802185416.50877-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cdfaba5d-f219-466b-54ac-08d955e6fd7e X-MS-TrafficTypeDiagnostic: AM6PR08MB4405: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:108 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: WUDPXWY3SZEkylaRf5WywLpo3fLBL2SLdxk1K/ZnHhPsI6cudwMNVBBE/ZDq8jC78GZtY6ttW5JD5J44kCZOIhMlJ2O03WdI4ifxLeDmdW4QLSsS0XZ+L/+IofLfCwMyMvIPaGnAvYBjQbFJmX9QYsy4aglWTOGt+a/hh4HabVD7vuvabw3KbCRz1l/6vf4bMnYgJila51ySJWTtRufQCl0KsVQ8TaDY2aVsVF7K8x6UeWqT3+Lev9yF7Ui10tlvWNAXT6qYEvmMwAeTNgz9hKFtEZTYPCzJjeMj7oHvzqeC29bCqwqckl0BCvB1QUDXs9Yh55pJsZoxu3KBxfVQ6v63z6ElLbaOz9zo1utVJQHj2dPZr5329C6jYQiS4nnyrBtDid1U64k4wex+4tfUFyWwRxQP4epDq+6+iTuaragvWJItuw4mwIbx85btQle6ODUOc9UtpZjoYczyXkXzrnfMWzl0vSkCn8wVgffovcIgLMNhmJIoJIMHj271qcpMgmmZkGZyqzZ0WgmYkfF87XY4ioQku6nKaEL4oqG9ClUbYP5VFOgEc0EHyArNEMDj3IgzkGJmkTp9RZ8oKqd+wJ+M/rLJTNAa3PMM6pnVw2ipnnDuxDsj/NDJoa2s0sglsc22WObTw/3nWSij1fxYq7amC9oQzHyXszYhJ84NjTOrTSAyLfCh0BnK69b4HQNt02zOH0Y2n4aTevpZ+D7ehg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39840400004)(396003)(136003)(376002)(346002)(186003)(2906002)(316002)(5660300002)(26005)(6916009)(2616005)(956004)(38100700002)(7416002)(38350700002)(4326008)(36756003)(86362001)(6512007)(66476007)(66946007)(66556008)(8936002)(6486002)(478600001)(1076003)(6506007)(8676002)(83380400001)(6666004)(52116002); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ts3vMJhu2GZgK58TpZ4fqP1+ehEvOkHPgLbSGRm21Kd2L9o+5ouHbrGXRQpr?= =?us-ascii?Q?14mnyrEK9h783OemnZTQxb4ISX2DjtOf03wi+9V8IYdXEboqwQluk+zBQy4t?= =?us-ascii?Q?5i3KL86T6kJDHipJIlbLyV2oNUjj2m0Cst4yKXEgOcWAR2ICl140L+fBbmX1?= =?us-ascii?Q?6fZfbKBNLNkkDpgfX5Z7AAMEYWaN+ztYU9bHKRaxVRLaJY94asK31LVVuZkj?= =?us-ascii?Q?rBAVRDQWNS3S08ksiLoxQxAzfNBJ2QdQ2Ztf6Mf8B6HZuDqU3SpLbDLHwwr2?= =?us-ascii?Q?l0ETgG6dsY9IF/8rZWSgyPb/9kzgtJm/1RNM/aR33bWNzRg7KDDTgclYfr0j?= =?us-ascii?Q?cv4UBv/b2gHyG7pg4B5ZKtbd+sKxkfxBidr9fXpgx9pI20LjPinmJSZACMpJ?= =?us-ascii?Q?mbqu9EITy3JwivRuC6Gr8dYfNFvmsGEgnufEHxKnXmjfuDL0IVW6EeTqBv4c?= =?us-ascii?Q?X9A0zthjgDm2LZozBZxVuALs1sYvT398psZmu/zqLNNbppM+oI7WgNDJFd1+?= =?us-ascii?Q?qgaJE93vW+mL/e3ony+pGxRy0vD/o6x41gpBMG9YY1nIKYiAEMUnnLILGbS4?= =?us-ascii?Q?BDOUgbEl1c4cz3CgPwWlD3xs+6vtxj13YvkVIvyO5oyloZGmVCV+HtHevKoM?= =?us-ascii?Q?aGpkRYgXJveKw3kAOEtSTcL2aFJ39ABGO4XrNI21WmuCh9ys9iT+0LJztzlQ?= =?us-ascii?Q?l/T0JmhYr1pvyjktgEzCIi7HdBpxUknOLIYKryBnWXGagXv404tamTMWg/dC?= =?us-ascii?Q?sBJQEhlGlm/XSh2aD1WVCHQrsmnHOy7qDEEakXMbUJJ/P0S71zIdP8FE24G3?= =?us-ascii?Q?t7t2rYVRbLt2w3Ul6OXHv18SuW1aU00fxQc+f6qbnZ/yO3LuZTNWmcQDRTTj?= =?us-ascii?Q?RYk12i1XrNhKjCN76xAyS9KfPJEJ8j1yIJeXM9iQjKuAAGQGMkWrqnXbdJ16?= =?us-ascii?Q?mWcrhPTAlLPLKkOM7ik77FrBL6XPj93yb7D72lLcPwsogYwJiFxiS4y+LTUj?= =?us-ascii?Q?zsApirauQWlSUQVhBT7fJlYEiu0CBV9DExCHBOOl1y3e9gO5mEQFB+91zppr?= =?us-ascii?Q?w/b97eYPXK7w7uWaI/RTebojogsc1BqPaZ0XECpz+zmHkqdDxXik8zlmCJEC?= =?us-ascii?Q?V69uf/FCM5NbFn01OvGuV42iT6EfAd6DwFIGoJ/g0Yr8X/IebAlZgqOPn8tN?= =?us-ascii?Q?f+ebVlc7nBs2MBupw1JArpgwWJNxMVfAQTve0axFEcVcSr9oQiaHIFrwk0Zy?= =?us-ascii?Q?JjzLAMSYnTiYUoJtf1ElDZX+cbOUb9Q8dBG49/NpdyqqmntatZeclRudFiDw?= =?us-ascii?Q?xSTUl6LBLweKfZY8hnUCTQIC?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cdfaba5d-f219-466b-54ac-08d955e6fd7e X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 18:54:43.5381 (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: NDj34qlxU/JqQgRUSPmAH78CFcAbR35VFoamZ/SVJC93FBpS2Ssno0iA/jLofn7pnNK9XDQlLi7XMmNfrqqJgiEeWf9PXe98LbaqF5C1R5k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4405 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 172Isph9006367 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, libvir-list@redhat.com, dim@virtuozzo.com, igor@virtuozzo.com, qemu-devel@nongnu.org, armbru@redhat.com, pkrempa@redhat.com, yur@virtuozzo.com, nshirokovskiy@virtuozzo.com, stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, mreitz@redhat.com, eblake@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1627930531933100001 Content-Type: text/plain; charset="utf-8" We'll need this for realizing qdev_find_child() in the next commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- softmmu/qdev-monitor.c | 48 +++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 721dec2d82..0117989009 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -819,7 +819,12 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, = Error **errp) object_unref(OBJECT(dev)); } =20 -static DeviceState *find_device_state(const char *id, Error **errp) +/* + * Returns: 1 when found, @dev set + * 0 not found, @dev and @errp untouched + * <0 error, or id is ambiguous, @errp set + */ +static int find_device_state(const char *id, DeviceState **dev, Error **er= rp) { Object *obj; =20 @@ -835,17 +840,16 @@ static DeviceState *find_device_state(const char *id,= Error **errp) } =20 if (!obj) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, - "Device '%s' not found", id); - return NULL; + return 0; } =20 if (!object_dynamic_cast(obj, TYPE_DEVICE)) { error_setg(errp, "%s is not a hotpluggable device", id); - return NULL; + return -EINVAL; } =20 - return DEVICE(obj); + *dev =3D DEVICE(obj); + return 1; } =20 void qdev_unplug(DeviceState *dev, Error **errp) @@ -894,16 +898,25 @@ void qdev_unplug(DeviceState *dev, Error **errp) =20 void qmp_device_del(const char *id, Error **errp) { - DeviceState *dev =3D find_device_state(id, errp); - if (dev !=3D NULL) { - if (dev->pending_deleted_event) { - error_setg(errp, "Device %s is already in the " - "process of unplug", id); - return; + int ret; + DeviceState *dev; + + ret =3D find_device_state(id, &dev, errp); + if (ret <=3D 0) { + if (ret =3D=3D 0) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", id); } + return; + } =20 - qdev_unplug(dev, errp); + if (dev->pending_deleted_event) { + error_setg(errp, "Device %s is already in the " + "process of unplug", id); + return; } + + qdev_unplug(dev, errp); } =20 void hmp_device_add(Monitor *mon, const QDict *qdict) @@ -925,11 +938,16 @@ void hmp_device_del(Monitor *mon, const QDict *qdict) =20 BlockBackend *blk_by_qdev_id(const char *id, Error **errp) { + int ret; DeviceState *dev; BlockBackend *blk; =20 - dev =3D find_device_state(id, errp); - if (dev =3D=3D NULL) { + ret =3D find_device_state(id, &dev, errp); + if (ret <=3D 0) { + if (ret =3D=3D 0) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", id); + } return NULL; } =20 --=20 2.29.2 From nobody Wed May 8 05:30:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1627930544698292.9262504112444; Mon, 2 Aug 2021 11:55:44 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-121-TaxHTOjpNCqU1GuIDp0nlA-1; Mon, 02 Aug 2021 14:55:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 461BCC73A7; Mon, 2 Aug 2021 18:55:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 230AD5C1C2; Mon, 2 Aug 2021 18:55:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DCD6D180BABF; Mon, 2 Aug 2021 18:55:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 172IsurA006386 for ; Mon, 2 Aug 2021 14:54:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 18AFD200C0E0; Mon, 2 Aug 2021 18:54:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13BAD200C0C5 for ; Mon, 2 Aug 2021 18:54:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0CD38D138E for ; Mon, 2 Aug 2021 18:54:55 +0000 (UTC) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2139.outbound.protection.outlook.com [40.107.21.139]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-575-Yq-1ykD4NxOGrdgS12z2tA-2; Mon, 02 Aug 2021 14:54:49 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4405.eurprd08.prod.outlook.com (2603:10a6:20b:b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Mon, 2 Aug 2021 18:54:45 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%8]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 18:54:45 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 18:54:43 +0000 X-MC-Unique: TaxHTOjpNCqU1GuIDp0nlA-1 X-MC-Unique: Yq-1ykD4NxOGrdgS12z2tA-2 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH 6/8] qdev: realize BlockParentClass Date: Mon, 2 Aug 2021 21:54:14 +0300 Message-ID: <20210802185416.50877-7-vsementsov@virtuozzo.com> In-Reply-To: <20210802185416.50877-1-vsementsov@virtuozzo.com> References: <20210802185416.50877-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 87fa98a8-076b-4859-a4e3-08d955e6febf X-MS-TrafficTypeDiagnostic: AM6PR08MB4405: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: l3LN01duDr1wqYvzHu1S0cb9I4ExbftLxLAC6behCK9SwsUFUiAQol3LC0XsDzWH0R7L5uoRzb+s/eDFyyDK3PmNd6kGUfLTsIi5CO3xcmGlYQPKxRYK0KJEM/7HhDaDyjjwXJbCQgZMN6+JXdrh8TBinCkNCNEZfnt7cG9oJCCw5BYht0LJo5cTedzFsP1r4QjleEsvdvzJZsdsNmGl81yTp+dh9o6mbqAKyiRrxbHhex6Ip5SN5s3WO9x+eJzRJ5PqW9zyhdGh051oLy5ZwbkTBbV0dVaRV7PiNbWwOg0+DRpk3cvEk+kNqSRyM13ZN6O+q/f3oynfHTvwRfB/3EE+GzQR1LXBlp6GPg+bUvbdCPbzXwc5y6sscqvbWLyLXeFYFZFGqItN0s+sDNrLPXGCXH1IEUTs0ey7mexQiZNcstl5NI0lLD86GlK1iWEOK+ofcdSbquwP/4mpTNIE0qnrcH3P+QRKGR4MwvrKmAMGlwj9Yx0v0Xlzesenik+ZTxxVW5CXOWfzg4tfX7eItPWGpy2A03qQjWXYKyORT8epnABmSrTkCEoDLnQlP1azqJPuzCbHm2CHV/NV/pNeZO2yMbDlqLrpv80t6DyIvk0PTfI8g7+to2wWAItrnMEKb1spkz1GVHIUwo0T3qutvRCaEb1c8ZBU38q/9F+qkNVEbDQjr6NKlub8E3C6JLuopjDlF+5dwtpW0LF6FFgmKw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39840400004)(396003)(136003)(376002)(346002)(186003)(2906002)(316002)(5660300002)(26005)(6916009)(2616005)(956004)(38100700002)(7416002)(38350700002)(4326008)(36756003)(86362001)(6512007)(66476007)(66946007)(66556008)(8936002)(6486002)(478600001)(1076003)(6506007)(8676002)(83380400001)(6666004)(52116002); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?B7cjuttQYME3HuPbR3hjmvvEXb0Be4WSan+a+uKBRMQVYxUByvRgbKLHD6X3?= =?us-ascii?Q?ZEHa9fcvFOMypSK5mRyZkhXOky9s3PHxGrMO/DVrnUGOSjCUpeB5K0Z94HRf?= =?us-ascii?Q?XQVg/zlvrWsXrvwaDpsXaOpyT+mPHt8E8vDSKLiSMbrGrziT4q1iUMcIDkqP?= =?us-ascii?Q?jOhE/zE2Y4Vi44wTXaYRYMdlF2tWMXFHZT6C2eaMshadU8nUVF0espsOqYAc?= =?us-ascii?Q?2Bd8O1x7D86Y/uWLMshhrAXRVaSa+tMQ+jO4a03DBpYwZGCDLHAsp2KLoeOB?= =?us-ascii?Q?XJkoWQWgzwVeY/Xu+xvjSCKq6dI6WcplIkRHdEs5e5yawo1yMcrYTS0+xAAb?= =?us-ascii?Q?kE31sRqI230n2Gn/0lYTBqY38/Las01QuCmnTwsI0BP14/utxTvPa9wMDmFy?= =?us-ascii?Q?5+gZxZnG0Wlkn5VMQw1WWG5Fl711SLw2SI8Er+llGCt74GZNmddCPg5yK0qq?= =?us-ascii?Q?A6/afGJLBLIt7AKTkeLGEFFa8yVRy/4k/9we9BctO8ZQH8NkPBH03pwe1zk2?= =?us-ascii?Q?1bySYvb3Xbqh6bjrIjW6kfBVnwKE0VM4sXclAr6KVuubEann3EewSLTx/8Lm?= =?us-ascii?Q?v1w5UIDASEjG/gfSbvG9izEfOhJH5aB2yD4uMqPggkUdbrhTUYw4MOaHkBoY?= =?us-ascii?Q?Evt35CxkVxp7Lw3IYPSwUxUbsEacZY+JHu/cLHdlvyUggkpQRZi5L+ZW6h8X?= =?us-ascii?Q?DZhPryRCqdrCTp8qefGAynnxszpoKPYn3+jaVEbq+i6tcqRxL7PMFUYipG8F?= =?us-ascii?Q?U1uIjl2oHHxPvFnf3Rh4gkxgEIO76OThHKaEAvtRS5CAR+HljnDQGQ38YNhZ?= =?us-ascii?Q?UeeLre4QomVhUVVW2EwdxLlpTc7mEOlNy9ilNbJydSqPS5Clkfl13ogJITFC?= =?us-ascii?Q?6DPChtPLi/149+TFPDfxGN9BPNZWkWBVnd9N7X6bzL+BOAT8jEIqFopOEk7P?= =?us-ascii?Q?0v8cHsvufX7n1ArFqftYEe9/DT+xFQRJuNcEQjvaeAdWU64nmJRhZUYQdd6x?= =?us-ascii?Q?h4FC/TrwA7gQPr5Kt5ctwflgv9LaTDibJhfKQkfYscAI/MM6nNWobE17oVpW?= =?us-ascii?Q?nJU5UWnQFwIkIpqmgyLLWU3w0vDw+h3S2Ncyak2CqcHepwlHxRnpAr+tVsSN?= =?us-ascii?Q?qJ2aF1MDcHD/OYHS+aNbzfXEgIDRdKcyC3BUsjKCgxBcaTFvPIkMScscdFa7?= =?us-ascii?Q?ANW3vS+aOxoWAR4aBEe17OwFRCa9a5aH+6ds7BTiqsL/07I468yrTbJwqg1/?= =?us-ascii?Q?dFscGpSCS7OwvGt7ApEbVR0fxeuXjfJe47ci3hC3D8vHJeNoxCdxLwuYFrYs?= =?us-ascii?Q?7vmA4lFC7rzyO1E1JHKDJg5q?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87fa98a8-076b-4859-a4e3-08d955e6febf X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 18:54:45.5920 (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: XGRb8buyq0atvgmNbRudFTh64FsO2SS1y1buDpSfmt0c001Tn47gcnQuPLiOWi0GHl4PJpNm5LVR/auzxccwfULPE88TS4wU/by3sVUHBBY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4405 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 172IsurA006386 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, libvir-list@redhat.com, dim@virtuozzo.com, igor@virtuozzo.com, qemu-devel@nongnu.org, armbru@redhat.com, pkrempa@redhat.com, yur@virtuozzo.com, nshirokovskiy@virtuozzo.com, stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, mreitz@redhat.com, eblake@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1627930546250100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy --- softmmu/qdev-monitor.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 0117989009..2e149aa9b8 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "block/block-parent.h" #include "hw/sysbus.h" #include "monitor/hmp.h" #include "monitor/monitor.h" @@ -1023,3 +1024,44 @@ bool qmp_command_available(const QmpCommand *cmd, Er= ror **errp) } return true; } + +static int qdev_find_child(const char *parent_id, const char *child_name, + BlockDriverState *child_bs, + BdrvChild **child, Error **errp) +{ + int ret; + DeviceState *dev; + BlockBackend *blk; + + ret =3D find_device_state(parent_id, &dev, errp); + if (ret <=3D 0) { + return ret; + } + + blk =3D blk_by_dev(dev); + if (!blk || !blk_root(blk)) { + error_setg(errp, "Device '%s' does not have a block device backend= ", + parent_id); + return -EINVAL; + } + + if (child_bs && blk_bs(blk) !=3D child_bs) { + error_setg(errp, "Root child of device '%s' doesn't match", parent= _id); + return -EINVAL; + } + + *child =3D blk_root(blk); + return 1; +} + +BlockParentClass block_parent_qdev =3D { + .name =3D "qdev", + .find_child =3D qdev_find_child, +}; + +static void qdev_monitor_init(void) +{ + block_parent_class_register(&block_parent_qdev); +} + +block_init(qdev_monitor_init); --=20 2.29.2 From nobody Wed May 8 05:30:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1627930548748540.3967395035003; Mon, 2 Aug 2021 11:55:48 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-451-0uU2BqTxPI-s9tK6MQvbww-1; Mon, 02 Aug 2021 14:55:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7DEE118C8C06; Mon, 2 Aug 2021 18:55:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 506AA6A90E; Mon, 2 Aug 2021 18:55:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1458D180BAC5; Mon, 2 Aug 2021 18:55:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 172IsvCq006393 for ; Mon, 2 Aug 2021 14:54:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5AAAB2147012; Mon, 2 Aug 2021 18:54:57 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 54D7F200CD5E for ; Mon, 2 Aug 2021 18:54:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88FD718A01AE for ; Mon, 2 Aug 2021 18:54:54 +0000 (UTC) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70090.outbound.protection.outlook.com [40.107.7.90]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-K-FSvpKLMrScscqmhPKRJA-4; Mon, 02 Aug 2021 14:54:50 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4278.eurprd08.prod.outlook.com (2603:10a6:20b:71::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Mon, 2 Aug 2021 18:54:47 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%8]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 18:54:47 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 18:54:45 +0000 X-MC-Unique: 0uU2BqTxPI-s9tK6MQvbww-1 X-MC-Unique: K-FSvpKLMrScscqmhPKRJA-4 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH 7/8] block: improve bdrv_replace_node_noperm() Date: Mon, 2 Aug 2021 21:54:15 +0300 Message-ID: <20210802185416.50877-8-vsementsov@virtuozzo.com> In-Reply-To: <20210802185416.50877-1-vsementsov@virtuozzo.com> References: <20210802185416.50877-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fcf6093c-ae62-4eba-e077-08d955e6ffe2 X-MS-TrafficTypeDiagnostic: AM6PR08MB4278: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:374 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: oVUPEDup3EwQZHI84ocZGc5U8NeF6+HMsqAw/bbnJP7ibK/RQBPuLy0ncngu+bou1+vsilTXlIoqJkIfYtUgd9gB24s7swasAXNY5qrU2PjzPwFe/TJSbdxP5YSgp4XLToEanKo+2wqC2fRVvYo0QvsHlMGbr7vlz4jZu7hecUokV7Tqv2Hwy2+B72Ic3SlrxX/OJEyYeT/wou2+05CQgx0eslmMV1cNxOoXRZ8zQSJOTtYm3TQyz6r7OXaA5q7J7edGYtE4d0ACVzYIrNZMciR/mW0VVVryO+qKJsovNtiEhcJfHqItcbE5hW6Ah0jMhzvRIC/khoSpEY8ddOW6qoKVreoXuYbWyRwXpxiDBmqX2M+CtI/W1lqc4+QDeKMFadxYhmC9ouwLFKCmnAvvu+CIuyppuO3IcfLHfl/9kC16vrp0FMqBpuGVoqsetVnCQOe43T6o54jDMEsoldhVrfrIGIfRcS5+LP/Ge+bZpae38GqXLfU81f0Woq+NmHeYIZvNnNnd5WZ85RfbgumuSbkhYd+0oZgEBx38Yz07lP1GitOupDP30kIYpeKCE6AdXG3eu1eQ13GpcCulvHzgBZDQqpv7bZEwbaBs7pD1POOZ4EKOiAQJquAVWgpF0sYlE5t2INgleYTr2Sv/eOwS95C1TiFtS8aH/0F3WlX75H1N/5Q+5YZ1ZFWulBclE/4GWri3IpUNWtlQwllCe+yeJQ== 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)(346002)(376002)(39840400004)(136003)(396003)(366004)(186003)(6916009)(52116002)(1076003)(83380400001)(8676002)(6512007)(38350700002)(38100700002)(2906002)(7416002)(6506007)(2616005)(478600001)(6666004)(36756003)(5660300002)(8936002)(956004)(4326008)(86362001)(26005)(316002)(6486002)(66946007)(66556008)(66476007); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?W8qQqVpF7qL3+t3SJyI4xyOhbSk9RI/4KBaPGpFN6F2yNZB2t8MVzg1OeM5Q?= =?us-ascii?Q?PWUhoy63IP0QxfUbPtmTmVS0h1GTGq9t1yoBMXudVlmhpnCZCTTOcW2ATXrM?= =?us-ascii?Q?qmalesMiVWzzMEgLECEHmY70A0SUmdJ2OTXhOOA3xhjp0Ig/k32ehHTIt6UO?= =?us-ascii?Q?3lMLCLEhXMwwRCRgjWnRvraOXQ/yfpfJOmt74N8IkTQm08IJXZz9o8Wj9nPG?= =?us-ascii?Q?OrRDWvWS/5d159L9NqFR5MLyRYuVp//Yzy5G5rGsF/Lzf+bYhSTurUQfA/gm?= =?us-ascii?Q?iZozVXhIytG9QFFUbds7Dt+Uleqi0Q2oXsasktySE9v+AQI+gABt+PCIQuD2?= =?us-ascii?Q?m3vzPQ79IrXU0twnPoBe+eLDRDqrIL+xBhO5kKtGekvB7s53SKS5nrOBJ2ga?= =?us-ascii?Q?Cq6lif8/Qg8809sQTWEW8XIT5QNTkFm7F1kWj0RNW21R9hBb9oc97f4lGtFZ?= =?us-ascii?Q?ZL6w2u+HwCOAh/ctoON01c+I7gLouOfZuiGTo8GpInXtURGq+NvgQmUpaYQX?= =?us-ascii?Q?vtjvAv90bNOhrL4meVHNQbPoUtRukpgIMcJiSjQY9uK0GWSm071zWGnXYKj2?= =?us-ascii?Q?sEiz9f5+EWvIiqPrjs+3jCXbaRBouYfsGb95lJF8WH3ITKRYc4y0/oPS5irI?= =?us-ascii?Q?XRgEBXPDf+ktd06/Sp9944gwoRKgi0jAUW5ue3yRr2ouxAQYVcae5yQg8liD?= =?us-ascii?Q?RBPVzKOende7/C8RYsR99dimpeEezGj2RLDJHcKw7ajj5vt+owwlzIkapjPR?= =?us-ascii?Q?ty61nBL46ns8ynxzSYiQClAmrevg5x8ULg3B9C70PuEgLr3e8vrIWCJLQXHM?= =?us-ascii?Q?q/3DChsx7Bha+ljkFXjfCPdUW4upQhLIXvyD9PLDdlZ4+BunMxVD83vuDfYg?= =?us-ascii?Q?XN/dUgbn6cGgmQZDkhWwAT1VEByKxm4xMyU8qITNky6+6LQo3JPKEh1LnFXn?= =?us-ascii?Q?1ia3IIWfz9Z1dEpnMpVvhQZdIJKNbFM9mVoGFkucuhjybZ0Y6DyoidfBb7jE?= =?us-ascii?Q?X8tHu43ONcBJANKXi2OyIOzJjuEt7DcBTAHXKUTtpS4udIbedi/TgKNJxi9h?= =?us-ascii?Q?IXeNavty61jOGBOoldaWHHt7mG+00rUB/Qil4FVXmnS7JZT8uNa9ak+MoVqV?= =?us-ascii?Q?M6LuWcr3dGVipPYw6V9qeRnT5MOQPlF6gEEQZbCbzCcu38s+4N18qz27XS7f?= =?us-ascii?Q?/jXBPMBrYXEKFW8YORMTa9hk/oi7w/Z8BJxlOkAlwjB8wuQbtUQFkDUCWH6z?= =?us-ascii?Q?2jwMOaGav7gk6rfuA5T2KCzz7wj9PRBVlzlalDEvl/hR3WCfFtGzd5Tkg0Hz?= =?us-ascii?Q?YoTxqVkAeVcKGgKfzX2PwCks?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcf6093c-ae62-4eba-e077-08d955e6ffe2 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 18:54:47.5315 (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: JfFhrYQyqLGJO02YkeVQkM/qXlOOw8FH8lNXkSWkFlyOC99QrEWFgC6T7OFn33UGGtwKZarboX+2Krsu/WLmfj5DMGHmuR5Pg9Tbm+qoOR4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4278 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 172IsvCq006393 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, libvir-list@redhat.com, dim@virtuozzo.com, igor@virtuozzo.com, qemu-devel@nongnu.org, armbru@redhat.com, pkrempa@redhat.com, yur@virtuozzo.com, nshirokovskiy@virtuozzo.com, stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, mreitz@redhat.com, eblake@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1627930550633100001 Content-Type: text/plain; charset="utf-8" Add optional block edge name filter and new mode: "exactly one", which we are going to use soon. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 449f933661..ae8c8c4032 100644 --- a/block.c +++ b/block.c @@ -4894,13 +4894,22 @@ static void bdrv_remove_filter_or_cow_child(BlockDr= iverState *bs, =20 static int bdrv_replace_node_noperm(BlockDriverState *from, BlockDriverState *to, - bool auto_skip, Transaction *tran, + bool auto_skip, + const char *edge_name, + bool exactly_one, + Transaction *tran, Error **errp) { BdrvChild *c, *next; + bool found =3D false; + + assert(!(auto_skip && exactly_one)); =20 QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) { assert(c->bs =3D=3D from); + if (edge_name && strcmp(edge_name, c->name)) { + continue; + } if (!should_update_child(c, to)) { if (auto_skip) { continue; @@ -4914,9 +4923,19 @@ static int bdrv_replace_node_noperm(BlockDriverState= *from, c->name, from->node_name); return -EPERM; } + if (exactly_one && found) { + error_setg(errp, "More than one matching parents found"); + return -EINVAL; + } + found =3D true; bdrv_replace_child_tran(c, to, tran); } =20 + if (exactly_one && !found) { + error_setg(errp, "No one matching parents found"); + return -EINVAL; + } + return 0; } =20 @@ -4966,7 +4985,8 @@ static int bdrv_replace_node_common(BlockDriverState = *from, * permissions based on new graph. If we fail, we'll roll-back the * replacement. */ - ret =3D bdrv_replace_node_noperm(from, to, auto_skip, tran, errp); + ret =3D bdrv_replace_node_noperm(from, to, auto_skip, NULL, false, + tran, errp); if (ret < 0) { goto out; } @@ -5035,7 +5055,8 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriver= State *bs_top, goto out; } =20 - ret =3D bdrv_replace_node_noperm(bs_top, bs_new, true, tran, errp); + ret =3D bdrv_replace_node_noperm(bs_top, bs_new, true, NULL, false, + tran, errp); if (ret < 0) { goto out; } --=20 2.29.2 From nobody Wed May 8 05:30:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16279305522581015.2691275038022; Mon, 2 Aug 2021 11:55:52 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-78-Sq9nWVvvPUqOYhByQQqWog-1; Mon, 02 Aug 2021 14:55:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1ACB1006C98; Mon, 2 Aug 2021 18:55:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C832E17C0B; Mon, 2 Aug 2021 18:55:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 928034A70A; Mon, 2 Aug 2021 18:55:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 172It2Ac006424 for ; Mon, 2 Aug 2021 14:55:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 428C5114B2F1; Mon, 2 Aug 2021 18:55:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D092114B2EE for ; Mon, 2 Aug 2021 18:54:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A12CF800B28 for ; Mon, 2 Aug 2021 18:54:57 +0000 (UTC) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70090.outbound.protection.outlook.com [40.107.7.90]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-515-RpgQVRFEPG-MjXOkRzoIoQ-5; Mon, 02 Aug 2021 14:54:53 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4278.eurprd08.prod.outlook.com (2603:10a6:20b:71::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Mon, 2 Aug 2021 18:54:49 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::44b9:68ac:bdc7:e23c%8]) with mapi id 15.20.4373.026; Mon, 2 Aug 2021 18:54:49 +0000 Received: from localhost.localdomain (185.215.60.211) by HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Mon, 2 Aug 2021 18:54:47 +0000 X-MC-Unique: Sq9nWVvvPUqOYhByQQqWog-1 X-MC-Unique: RpgQVRFEPG-MjXOkRzoIoQ-5 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH 8/8] qapi: add blockdev-replace command Date: Mon, 2 Aug 2021 21:54:16 +0300 Message-ID: <20210802185416.50877-9-vsementsov@virtuozzo.com> In-Reply-To: <20210802185416.50877-1-vsementsov@virtuozzo.com> References: <20210802185416.50877-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0240.eurprd05.prod.outlook.com (2603:10a6:3:fb::16) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 744c51ee-23db-4818-ebc9-08d955e7010e X-MS-TrafficTypeDiagnostic: AM6PR08MB4278: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: liuBp3cPwGarTRKSf+7WxYnt0MUTuCbY/QFz2xtXrfRMblWRWbjmtEj0dlZwVRPhMps6Sa33gcR/ySaxX7SXbf08XHE9Ff8s7TqnBYpTVn4JuZjQDtmlTieSp/Tw5OK05Sjt9cXZxsoS040pD6D6sbdbDQ0oduhq2YibRLNF6nptKKAJ/XbbSiEYy3M1vVWryKooiEIIO52s7otlgk+5/s+4Cfs/ump2+dbVIpfQfrSxWddlO1t2iiojQH55ep2DHvWHeR7BfXYfN9bMWR2yR97dDGCXGg6tPHcm3EfbMk9jFW+H/B81vU9BtG37Y5+wVrMkj1LQ5AdpUIPrYAoIh6gPuWvlNTC0W6Z/1WhurUkgu+nrSPe0/RZUZV3vkAfGdSoil+SsnWFh+Vdkavvm/pVu7SHaFzi0CYGvlHr+jileaAPBgxm9Owbx92BvhSC/tf0E8o2T5B4aSl/0oPTf2sgDRCYplYr3JRzWnB/peC5GnqwAsi+9jaKm9U54MAyxDO3zKw96VZwQpiu4gCMvBHxMP/5sCArESIegieLnlWT/FT/1G0gOTuCH5JGTsZG6FTx7NTG3iku7seHYBwURdufmhfoqTjLVcidznHa+MElhdw/UX8UUidhWX1vidz0lE4RKnP15W8U+gae//P57Zjc/lswewW+/lp2Y+9X4cIqa9XOJEkIuyIpE1VK/ygkSwsDsejDB4Kr76Vowh43Pow== 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)(346002)(376002)(39840400004)(136003)(396003)(366004)(186003)(6916009)(52116002)(1076003)(83380400001)(8676002)(6512007)(38350700002)(38100700002)(2906002)(7416002)(6506007)(2616005)(478600001)(6666004)(36756003)(5660300002)(8936002)(956004)(4326008)(86362001)(26005)(316002)(6486002)(66946007)(66556008)(66476007); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?hQstUbTND79yJQIZCvORcxT2qptP8pWqdtshlzYFsUjerFVuVPNX7Rq3ssJH?= =?us-ascii?Q?IaiB1DhsYRQuY0t5bJUgGteeSNjyvKamPOOz06bUNtYPsXzeH88WVuvnVWr4?= =?us-ascii?Q?I3KmjUZ0/0rQQmcdfw2NfAKMXgmhdraGGbKhQzHb4TnZHjydFaci88dIdtSu?= =?us-ascii?Q?lXD0VngJBa+u24bs3OZoc2Z+BenbLaqQzjND5eErZwhhiSqvYIDPUDuT3md6?= =?us-ascii?Q?AIm6QmbOM4/6lBicwP4jgPxOBjbgtfc5EFYKBdC9kQpsZOl5+SPUt0NM83Ey?= =?us-ascii?Q?LHSgnXJY6/QjuIsJ0EiIJTuWXZ1lC1J7BN3L4tj/9PvJ3cWpn8y8X3LXVpO+?= =?us-ascii?Q?eH4G+j2KhGdqAGm05F7u26cyUk8hh/LXBwju+ZSX3CQ0OrurGWcgEDHxQf2T?= =?us-ascii?Q?K7DoHmmw27uMqhAPlwAFaIJervYZNLsd5NHOSBlJTke6ILk++tsehkTzPCv1?= =?us-ascii?Q?dcScSqTV+gVjgYaBXuBF7PMono5KfjrXdIjo0yTeMnW1MEOzY19WKkRLzAXP?= =?us-ascii?Q?XAxlImcdCuSoGU8tpsGMb4JZo9E0s3++OZHijuXneSA1D0rB5Zp/n0wdAbgv?= =?us-ascii?Q?jjsojBwT4lbbLNiD3Znu0+ZGEvjky/F9DM5oyQuInwvJkZZsmZDC1pfv2dDP?= =?us-ascii?Q?cW65J8dpZ0vLxJfZG9Fay+3ftk92lOqTHuw1WlFY48m980NPZqn5YREBfUCq?= =?us-ascii?Q?LRG3CkXngCLmr4B7Nn2zTg/FX8DYWmjKbmHRkEAlhAZSV4928gnLExk5PP0u?= =?us-ascii?Q?pb0ruSByv1yPG2sm5LXNBDSFPQESmNTTqMfcOiHONP836aptdqq8BP46KOnH?= =?us-ascii?Q?Ic/Gsfj7/cAIkYCYYGi5QNgyuKf7vd/BORbcw3wGkTgGhjrcG6iPRVCAdx4V?= =?us-ascii?Q?l1y7wYuwOJeebfs5fHw2kcRtGcH+EfUFk1Xiuq6iviomKYscH9tVKmsxojGp?= =?us-ascii?Q?tqU65s9ZF63KUKttq7v76VwtkQnFKRsaIzcRnE0R5sGC306loqHU4chDifiF?= =?us-ascii?Q?cNN9i5zv9r7iHgtpbekbVK7aZn8lI4zfXYnD/Uo7LB219spE6QzOnYM1ecT8?= =?us-ascii?Q?Yj6nshCbSLYLCdvCqsyFMcskMWmFMOtMDsey3QyGKEAhDIK/zUPnFTWO8FTT?= =?us-ascii?Q?/AKAqOtwOoDOg4410/O4gRCzRHSUvTwdNZMaiGljgs3Q5zvCK1DqHz/4J5+M?= =?us-ascii?Q?9pDBFWrGsHxviL4Oy3McjxRfQvuYM1ACO6M6I13E01a8USEKUt1GOnjnrFNX?= =?us-ascii?Q?l9tfj8d5c5JVoq+EtYeP+v4qs9DPrAPyP8JjoJrLRT3TuC9mSjShW/e7C9gM?= =?us-ascii?Q?7VxqWalCpJhdbarjKWp50TdQ?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 744c51ee-23db-4818-ebc9-08d955e7010e X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2021 18:54:49.4850 (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: Mhfll8Q729NFmwyxYFb8TErY1chtBJO6cbPLtp+LV/kucs0PgGH3Mpg2stTZ7yfRhXWn+XrTg51wy1cNvoh9UwCIoDkT++0Cm5hm5+P2KlQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4278 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 172It2Ac006424 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, ehabkost@redhat.com, libvir-list@redhat.com, dim@virtuozzo.com, igor@virtuozzo.com, qemu-devel@nongnu.org, armbru@redhat.com, pkrempa@redhat.com, yur@virtuozzo.com, nshirokovskiy@virtuozzo.com, stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, mreitz@redhat.com, eblake@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1627930552978100001 Content-Type: text/plain; charset="utf-8" Add command that can add and remove filters. Key points of functionality: What the command does is simply replace some BdrvChild.bs by some other nodes. The tricky thing is selecting there BdrvChild objects. To be able to select any kind of BdrvChild we use a generic parent_id, which may be a node-name, or qdev id or block export id. In future we may support block jobs. Any kind of ambiguity leads to error. If we have both device named device0 and block export named device0 and they both point to same BDS, user can't replace root child of one of these parents. So, to be able to do replacements, user should avoid duplicating names in different parent namespaces. So, command allows to replace any single child in the graph. On the other hand we want to realize a kind of bdrv_replace_node(), which works well when we want to replace all parents of some node. For this kind of task @parents-mode argument implemented. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 78 +++++++++++++++++++++++++++++++++++++++++ block.c | 82 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index 675d8265eb..8059b96341 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -5433,3 +5433,81 @@ { 'command': 'blockdev-snapshot-delete-internal-sync', 'data': { 'device': 'str', '*id': 'str', '*name': 'str'}, 'returns': 'SnapshotInfo' } + +## +# @BlockdevReplaceParentsMode: +# +# Alternative (to directly set @parent) way to chose parents in +# @blockdev-replace +# +# @exactly-one: Exactly one parent should match a condition, otherwise +# @blockdev-replace fails. +# +# @all: All matching parents are taken into account. If replacing lead +# to loops in block graph, @blockdev-replace fails. +# +# @auto: Same as @all, but automatically skip replacing parents if it +# leads to loops in block graph. +# +# Since: 6.2 +## +{ 'enum': 'BlockdevReplaceParentsMode', + 'data': ['exactly-one', 'all', 'auto'] } + +## +# @BlockdevReplace: +# +# Declaration of one replacement. +# +# @parent: id of parent. It may be qdev or block export or simple +# node-name. If id is ambiguous (for example node-name of +# some BDS equals to block export name), blockdev-replace +# fails. If not specified, blockdev-replace goes through +# @parents-mode scenario, see below. Note, that @parent and +# @parents-mode can't be specified simultaneously. +# If @parent is specified, only one edge is selected. If +# several edges match the condition, blockdev-replace fails. +# +# @edge: name of the child. If omitted, any child name matches. +# +# @child: node-name of the child. If omitted, any child matches. +# Must be present if @parent is not specified. +# +# @parents-mode: declares how to select edge (or edges) when @parent +# is omitted. Default is 'one'. +# +# Since: 6.2 +# +# Examples: +# +# 1. Change root node of some device. +# +# Note, that @edge name is omitted, as +# devices always has only one child. As well, no need in specifying +# old @child. +# +# -> { "parent": "device0", "new-child": "some-node-name" } +# +# 2. Insert copy-before-write filter. +# +# Assume, after blockdev-add we have block-node 'source', with several +# writing parents and one copy-before-write 'filter' parent. And we want +# to actually insert the filter. We do: +# +# -> { "child": "source", "parent-mode": "auto", "new-child": "filter" } +# +# All parents of source would be switched to 'filter' node, except for +# 'filter' node itself (otherwise, it will make a loop in block-graph). +## +{ 'struct': 'BlockdevReplace', + 'data': { '*parent': 'str', '*edge': 'str', '*child': 'str', + '*parents-mode': 'BlockdevReplaceParentsMode', + 'new-child': 'str' } } + +## +# @blockdev-replace: +# +# Do one or several replacements transactionally. +## +{ 'command': 'blockdev-replace', + 'data': { 'replacements': ['BlockdevReplace'] } } diff --git a/block.c b/block.c index ae8c8c4032..3bcb3152f1 100644 --- a/block.c +++ b/block.c @@ -41,6 +41,7 @@ #include "qapi/qmp/qnull.h" #include "qapi/qmp/qstring.h" #include "qapi/qobject-output-visitor.h" +#include "qapi/qapi-commands-block.h" #include "qapi/qapi-visit-block-core.h" #include "sysemu/block-backend.h" #include "qemu/notify.h" @@ -7717,6 +7718,87 @@ BlockDriverState *bdrv_backing_chain_next(BlockDrive= rState *bs) return bdrv_skip_filters(bdrv_cow_bs(bdrv_skip_filters(bs))); } =20 +void qmp_blockdev_replace(BlockdevReplaceList *list, Error **errp) +{ + int ret; + Transaction *tran =3D tran_new(); + g_autoptr(GHashTable) found =3D NULL; + g_autoptr(GSList) refresh_list =3D NULL; + g_autoptr(GSList) touched_list =3D NULL; + GSList *x; + + for ( ; list; list =3D list->next) { + BlockdevReplace *repl =3D list->value; + BlockDriverState *child_bs =3D NULL, *new_child_bs; + BlockdevReplaceParentsMode mode; + BdrvChild *child; + + if (repl->has_child) { + child_bs =3D bdrv_find_node(repl->child); + if (!child_bs) { + error_setg(errp, "Node '%s' not found", repl->child); + goto fail; + } + } + + new_child_bs =3D bdrv_find_node(repl->new_child); + if (!new_child_bs) { + error_setg(errp, "Node '%s' not found", repl->new_child); + goto fail; + } + + if (repl->has_parent) { + if (repl->has_parents_mode) { + error_setg(errp, "parent and parents-mode field must " + "not be set simultaneously."); + goto fail; + } + + child =3D block_find_child(repl->parent, repl->edge, child_bs,= errp); + if (!child) { + goto fail; + } + + touched_list =3D g_slist_prepend(touched_list, child->bs); + touched_list =3D g_slist_prepend(touched_list, new_child_bs); + bdrv_replace_child_tran(child, new_child_bs, tran); + continue; + } + + if (!repl->has_child) { + error_setg(errp, "At least one of parent and child fields " + "should be specified."); + goto fail; + } + + mode =3D repl->has_parents_mode ? repl->parents_mode : + BLOCKDEV_REPLACE_PARENTS_MODE_EXACTLY_ONE; + + touched_list =3D g_slist_prepend(touched_list, child_bs); + touched_list =3D g_slist_prepend(touched_list, new_child_bs); + ret =3D bdrv_replace_node_noperm(child_bs, new_child_bs, + mode =3D=3D BLOCKDEV_REPLACE_PARENTS_MODE_AUTO, + repl->edge, + mode =3D=3D BLOCKDEV_REPLACE_PARENTS_MODE_EXACTLY_ONE, + tran, errp); + if (ret < 0) { + goto fail; + } + } + + for (x =3D touched_list; x; x =3D x->next) { + refresh_list =3D bdrv_topological_dfs(refresh_list, found, x->data= ); + } + + ret =3D bdrv_list_refresh_perms(refresh_list, NULL, tran, errp); + + tran_finalize(tran, ret); + return; + +fail: + tran_abort(tran); +} + static void block_c_init(void) { block_parent_class_register(&block_parent_bdrv); --=20 2.29.2