From nobody Sun Feb 8 22:06:30 2026 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+xvjSCKq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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