From nobody Fri May 10 06:52:36 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1682077375; cv=none; d=zohomail.com; s=zohoarc; b=MYiWBCsgwcqt2TOCeUG1giSpX3yBHr0Mp11XgnoAj/Dp61XpwFbddhGSbMJ8UC5PEXs6JoyTN3Bsu5ZFUq4I3+wfvWCupRhqvlwgtnZEH84opYD9AqQWtcVgHqS27wPMD+ew3sse5kUwx3dFRWn9/vFcwhy4naUVjN0yubCpFrs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682077375; h=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=uExpcHS3pyN1A8WHNwF+hN2FTrzHFlqJ7ocINzFRLQE=; b=eIGUA4fe10qZagEk45WMScHCOGZ/WlRxN068THYHBjxq+Ib0owZai/KvTIw4NOYd1OKSin3Dy7Y025vWbJltRhDtCZDW/tZYpkXx2Q7v+mCB11ZB/BNqsI7YeLOp/GpXienHY0i3n8hRteouaZofoM/ODunJUcmR82R6A4DWPMk= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682077375097677.1761465161242; Fri, 21 Apr 2023 04:42:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppp9I-0007AM-NM; Fri, 21 Apr 2023 07:41:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8u-0006mI-15; Fri, 21 Apr 2023 07:41:33 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8p-0001Ez-Dh; Fri, 21 Apr 2023 07:41:31 -0400 Received: from mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7f29:0:640:9a2b:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id CA4245FDFA; Fri, 21 Apr 2023 14:41:17 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:b081:8816::1:4]) by mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 3fdrVT1OnCg0-4Csn2bst; Fri, 21 Apr 2023 14:41:17 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682077277; bh=uExpcHS3pyN1A8WHNwF+hN2FTrzHFlqJ7ocINzFRLQE=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=0Lql7kCacE6iX1Rj7sPlQwi2g3xT847vHXWj6ImNb71CwPMW8tfx94A9MZ8k6O5fw gZZYY4BwsAsVyI++NePtc7BGr9UswOLpWClc1t3SUanmMWBG+4EQeD3TZGQTI1qAAK n7IaPerD/UXyyOi5MiruBu0Mhusl5teTUEuUmzjc= Authentication-Results: mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, alexander.ivanov@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH v7 1/7] block-backend: blk_root(): drop const specifier on return type Date: Fri, 21 Apr 2023 14:40:56 +0300 Message-Id: <20230421114102.884457-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421114102.884457-1-vsementsov@yandex-team.ru> References: <20230421114102.884457-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1682077376933100003 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 --- block/block-backend.c | 2 +- include/sysemu/block-backend-global-state.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 55efc735b4..9a28d0de1f 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2685,7 +2685,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) { GLOBAL_STATE_CODE(); return blk->root; diff --git a/include/sysemu/block-backend-global-state.h b/include/sysemu/b= lock-backend-global-state.h index 2b6d27db7c..5db83ed8cb 100644 --- a/include/sysemu/block-backend-global-state.h +++ b/include/sysemu/block-backend-global-state.h @@ -122,7 +122,7 @@ void blk_set_force_allow_inactivate(BlockBackend *blk); bool blk_register_buf(BlockBackend *blk, void *host, size_t size, Error **= errp); void blk_unregister_buf(BlockBackend *blk, void *host, size_t size); =20 -const BdrvChild *blk_root(BlockBackend *blk); +BdrvChild *blk_root(BlockBackend *blk); =20 int blk_make_empty(BlockBackend *blk, Error **errp); =20 --=20 2.34.1 From nobody Fri May 10 06:52:36 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1682077313; cv=none; d=zohomail.com; s=zohoarc; b=m8evsfXFe9mqe6IBxnaNMrK7GXrjfc4UlpNicB35uYzN9x4WR1jRTnYTcHekNVCJV7V70CctQUSRmmORrTO892TPCeZbd1sCjJkaS6l7bnq+QqMHU7mj4zQP+TXjQzABZvF1oACHqf2iHKhOQgZh8awpVAAWJQNc6Nl0L4rOGok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682077313; h=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=8GuVf94sF+b7IEH4fpDM5Aac9QA7jzmqplg6osgw9lU=; b=mDnZqQ8Uwgsjn8GD0a1u2Y0xTg4MublGr0Yxm86IZQh2wFQX4XbflFdXQJV8unfXTT5AjpEMwKV7DZ0sEZbIIZIdFJKsuieZxtqZTe1WoM5wOarLUhpdUie8YDYOR/Qv0YQ9mMSa5jGQvKSdKmCuwg6cYR5q0XT/ZbuL7Bb577A= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682077313957150.04322570887098; Fri, 21 Apr 2023 04:41:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppp93-0006vb-4G; Fri, 21 Apr 2023 07:41:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8t-0006jw-0i; Fri, 21 Apr 2023 07:41:31 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8p-0001F4-FX; Fri, 21 Apr 2023 07:41:30 -0400 Received: from mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7f29:0:640:9a2b:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id A1E526194E; Fri, 21 Apr 2023 14:41:18 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:b081:8816::1:4]) by mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 3fdrVT1OnCg0-p3fY7sn2; Fri, 21 Apr 2023 14:41:17 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682077277; bh=8GuVf94sF+b7IEH4fpDM5Aac9QA7jzmqplg6osgw9lU=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=Wmr0ejAuYVB6fF/PbWODeRxakSDMEpOyV6EUP1Mc7wPZAvJaihGKxPgby9cCfT9Pg 5ETGqeiGPVo8khH+ba85BQKXuTbthnAyLNlFWS994ZLnlc++cY/dwXxCirxAl6wAvz QaD5lzhOLFlGOwjQrFCEmhx6luOQrhTLTaVPNw4g= Authentication-Results: mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, alexander.ivanov@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH v7 2/7] block/export: add blk_by_export_id() Date: Fri, 21 Apr 2023 14:40:57 +0300 Message-Id: <20230421114102.884457-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421114102.884457-1-vsementsov@yandex-team.ru> References: <20230421114102.884457-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1682077314671100003 Content-Type: text/plain; charset="utf-8" We need it for further blockdev-replace functionality. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/export/export.c | 18 ++++++++++++++++++ include/sysemu/block-backend-global-state.h | 1 + 2 files changed, 19 insertions(+) diff --git a/block/export/export.c b/block/export/export.c index 28a91c9c42..016943860c 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -368,3 +368,21 @@ BlockExportInfoList *qmp_query_block_exports(Error **e= rrp) =20 return head; } + +BlockBackend *blk_by_export_id(const char *id, Error **errp) +{ + BlockExport *exp; + + exp =3D blk_exp_find(id); + if (exp =3D=3D NULL) { + error_setg(errp, "Export '%s' not found", id); + return NULL; + } + + if (!exp->blk) { + error_setg(errp, "Export '%s' is empty", id); + return NULL; + } + + return exp->blk; +} diff --git a/include/sysemu/block-backend-global-state.h b/include/sysemu/b= lock-backend-global-state.h index 5db83ed8cb..b9dc81c34d 100644 --- a/include/sysemu/block-backend-global-state.h +++ b/include/sysemu/block-backend-global-state.h @@ -71,6 +71,7 @@ void blk_detach_dev(BlockBackend *blk, DeviceState *dev); DeviceState *blk_get_attached_dev(BlockBackend *blk); BlockBackend *blk_by_dev(void *dev); BlockBackend *blk_by_qdev_id(const char *id, Error **errp); +BlockBackend *blk_by_export_id(const char *id, Error **errp); void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaq= ue); =20 void blk_activate(BlockBackend *blk, Error **errp); --=20 2.34.1 From nobody Fri May 10 06:52:36 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1682077305; cv=none; d=zohomail.com; s=zohoarc; b=OtS8sHYTQa4fcEgLvGJH1RA//uQnBokZipl9v9pxADmymvyJ500FarKDbVGyr0lHYFvgKMc03S+FWf+Qjm5xzTMinpCqgYaQ3/NALABeJTrEAjTeMu03gz2E+HAGd1dDEdwxPmRL/4XnBexd06shqOKaEB+4wYDC9c2iqaWIMh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682077305; h=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=BZSFW4d7itr58ixETZgsDpAM1CwhQD8/BSwlpj19vGc=; b=Ph4EgzRpqNXjG1UV0TV+LWSNg4NmmokocwmdCWd6h8vBKb/g8yzazijfILdcUbxwbRGahMJGhwZ7maENMkzm56AhHy4n/tF5Q28M5lKR9Lq05C2Q0mtSsP8kQgrHYJ69DsMUNg8G1jTR8o1OLzuVm3JkRA4hTXLtvdKcgjrVXLo= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682077304645857.1958248518224; Fri, 21 Apr 2023 04:41:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppp8y-0006pf-Bt; Fri, 21 Apr 2023 07:41:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8t-0006jx-0z; Fri, 21 Apr 2023 07:41:31 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8p-0001FF-Fu; Fri, 21 Apr 2023 07:41:30 -0400 Received: from mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7f29:0:640:9a2b:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 8B31161968; Fri, 21 Apr 2023 14:41:19 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:b081:8816::1:4]) by mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 3fdrVT1OnCg0-QHk5X2C9; Fri, 21 Apr 2023 14:41:18 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682077278; bh=BZSFW4d7itr58ixETZgsDpAM1CwhQD8/BSwlpj19vGc=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=BdiOV3PburGvlRcAKl/sje69iVmQL2cVrfNjT/V+LqcN2TDgzdweNeQkeWdBnn62m hcQT62jhOEJYvHCr6JpRlC7ta3mANgOP4R8aEoM1Huz6bVYsfZcqmkipCNf+FuTqIN dYfanEJSw1f9W1vU/pQdAdmyKO6dOLXHlAJdlihE= Authentication-Results: mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, alexander.ivanov@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH v7 3/7] block: make bdrv_find_child() function public Date: Fri, 21 Apr 2023 14:40:58 +0300 Message-Id: <20230421114102.884457-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421114102.884457-1-vsementsov@yandex-team.ru> References: <20230421114102.884457-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1682077307495100001 Content-Type: text/plain; charset="utf-8" To be reused soon for blockdev-replace functionality. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 13 +++++++++++++ blockdev.c | 14 -------------- include/block/block_int-io.h | 1 + 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index d79a52ca74..e2cc686074 100644 --- a/block.c +++ b/block.c @@ -8027,6 +8027,19 @@ int bdrv_make_empty(BdrvChild *c, Error **errp) return 0; } =20 +BdrvChild *bdrv_find_child(BlockDriverState *parent_bs, const char *child_= name) +{ + BdrvChild *child; + + QLIST_FOREACH(child, &parent_bs->children, next) { + if (strcmp(child->name, child_name) =3D=3D 0) { + return child; + } + } + + return NULL; +} + /* * 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. diff --git a/blockdev.c b/blockdev.c index d7b5c18f0a..461657edda 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3617,20 +3617,6 @@ out: aio_context_release(aio_context); } =20 -static BdrvChild *bdrv_find_child(BlockDriverState *parent_bs, - const char *child_name) -{ - BdrvChild *child; - - QLIST_FOREACH(child, &parent_bs->children, next) { - if (strcmp(child->name, child_name) =3D=3D 0) { - return child; - } - } - - return NULL; -} - void qmp_x_blockdev_change(const char *parent, const char *child, const char *node, Error **errp) { diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index eb0da7232e..aecf7f0929 100644 --- a/include/block/block_int-io.h +++ b/include/block/block_int-io.h @@ -130,6 +130,7 @@ bdrv_co_refresh_total_sectors(BlockDriverState *bs, int= 64_t hint); int co_wrapper_mixed_bdrv_rdlock bdrv_refresh_total_sectors(BlockDriverState *bs, int64_t hint); =20 +BdrvChild *bdrv_find_child(BlockDriverState *parent_bs, const char *child_= name); BdrvChild *bdrv_cow_child(BlockDriverState *bs); BdrvChild *bdrv_filter_child(BlockDriverState *bs); BdrvChild *bdrv_filter_or_cow_child(BlockDriverState *bs); --=20 2.34.1 From nobody Fri May 10 06:52:36 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1682077334; cv=none; d=zohomail.com; s=zohoarc; b=bLIAOsD8wWZqiDI9FhEFcccwPvVV2E/0JSbM+nRUPZai1qzrbsaLgApKDkA2hNoIzv1kWniWiYbCa9J4wyu6Vs1bjRlJkYBpA88hwl6fXS6+oBatT7q6fYGSe7BOkCdjCduxbWW6uFJ/dEzOdHTBaScgL9DRBbpvzLoyN+Xi3UY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682077334; h=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=mv0a/KtDpEVCcW103rC/FA47XqWalxiRzqFUPptmZLI=; b=dy2P/skwxaHjkxFyg8df4DfshmgCOYLLD3WkYzYIz8N0CvIkyJSKgPHOBmC86PSR5QOoqT1NyUzlIG+Acu802G1yOcS0l6/Qw0A+zG5KBN1C6vJ3VH7nV68v9Pj+ltkhRrUy83IotmIdJptrKY1zsgKjZOSApXsnIk9LaHmq2JY= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16820773340051018.8694751766247; Fri, 21 Apr 2023 04:42:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppp93-0006vs-Km; Fri, 21 Apr 2023 07:41:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8w-0006no-3M; Fri, 21 Apr 2023 07:41:34 -0400 Received: from forwardcorp1c.mail.yandex.net ([2a02:6b8:c03:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8s-0001H0-P8; Fri, 21 Apr 2023 07:41:33 -0400 Received: from mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7f29:0:640:9a2b:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 9CEE360025; Fri, 21 Apr 2023 14:41:20 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:b081:8816::1:4]) by mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 3fdrVT1OnCg0-qR1uosON; Fri, 21 Apr 2023 14:41:19 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682077279; bh=mv0a/KtDpEVCcW103rC/FA47XqWalxiRzqFUPptmZLI=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=DzBUsnJemrK7xCEh3EeUxWD05n4Hxfs7g+vo9TtpTAUu/eMUXcitBB51dCerMoaQ5 wUHU6rKvtTnAXM4PDYEhSNFfjFWyjGhviN+UXeOJ8Ztw0DYx51vlUtYRY7H+mIe2Ta 4oTUxBRxS7hED7FJNo6Ecl2fofwm0wyh3gTh26Is= Authentication-Results: mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, alexander.ivanov@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH v7 4/7] qapi: add x-blockdev-replace command Date: Fri, 21 Apr 2023 14:40:59 +0300 Message-Id: <20230421114102.884457-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421114102.884457-1-vsementsov@yandex-team.ru> References: <20230421114102.884457-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c03:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1682077335134100001 Content-Type: text/plain; charset="utf-8" Add a command that can replace bs in following BdrvChild structures: - qdev blk root child - block-export blk root child - any child of BlockDriverState selected by child-name Signed-off-by: Vladimir Sementsov-Ogievskiy --- blockdev.c | 56 ++++++++++++++++++++++++++++++++++++++ qapi/block-core.json | 62 ++++++++++++++++++++++++++++++++++++++++++ stubs/blk-by-qdev-id.c | 9 ++++++ stubs/meson.build | 1 + 4 files changed, 128 insertions(+) create mode 100644 stubs/blk-by-qdev-id.c diff --git a/blockdev.c b/blockdev.c index 461657edda..75d6283ef3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2193,6 +2193,62 @@ static void abort_commit(BlkActionState *common) g_assert_not_reached(); /* this action never succeeds */ } =20 +void qmp_x_blockdev_replace(BlockdevReplace *repl, Error **errp) +{ + BdrvChild *child =3D NULL; + BlockDriverState *new_child_bs; + + if (repl->parent_type =3D=3D BLOCK_PARENT_TYPE_DRIVER) { + BlockDriverState *parent_bs; + + parent_bs =3D bdrv_find_node(repl->u.driver.node_name); + if (!parent_bs) { + error_setg(errp, "Block driver node with node-name '%s' not " + "found", repl->u.driver.node_name); + return; + } + + child =3D bdrv_find_child(parent_bs, repl->u.driver.child); + if (!child) { + error_setg(errp, "Block driver node '%s' doesn't have child " + "named '%s'", repl->u.driver.node_name, + repl->u.driver.child); + return; + } + } else { + /* Other types are similar, they work through blk */ + BlockBackend *blk; + bool is_qdev =3D repl->parent_type =3D=3D BLOCK_PARENT_TYPE_QDEV; + const char *id =3D + is_qdev ? repl->u.qdev.qdev_id : repl->u.export.export_id; + + assert(is_qdev || repl->parent_type =3D=3D BLOCK_PARENT_TYPE_EXPOR= T); + + blk =3D is_qdev ? blk_by_qdev_id(id, errp) : blk_by_export_id(id, = errp); + if (!blk) { + return; + } + + child =3D blk_root(blk); + if (!child) { + error_setg(errp, "%s '%s' is empty, nothing to replace", + is_qdev ? "Device" : "Export", id); + return; + } + } + + assert(child); + assert(child->bs); + + new_child_bs =3D bdrv_find_node(repl->new_child); + if (!new_child_bs) { + error_setg(errp, "Node '%s' not found", repl->new_child); + return; + } + + bdrv_replace_child_bs(child, new_child_bs, errp); +} + static const BlkActionOps actions[] =3D { [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT] =3D { .instance_size =3D sizeof(ExternalSnapshotState), diff --git a/qapi/block-core.json b/qapi/block-core.json index c05ad0c07e..c03ec01b53 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -5858,3 +5858,65 @@ ## { 'struct': 'DummyBlockCoreForceArrays', 'data': { 'unused-block-graph-info': ['BlockGraphInfo'] } } + +## +# @BlockParentType: +# +# Since 8.1 +## +{ 'enum': 'BlockParentType', + 'data': ['qdev', 'driver', 'export'] } + +## +# @BdrvChildRefQdev: +# +# Since 8.1 +## +{ 'struct': 'BdrvChildRefQdev', + 'data': { 'qdev-id': 'str' } } + +## +# @BdrvChildRefExport: +# +# Since 8.1 +## +{ 'struct': 'BdrvChildRefExport', + 'data': { 'export-id': 'str' } } + +## +# @BdrvChildRefDriver: +# +# Since 8.1 +## +{ 'struct': 'BdrvChildRefDriver', + 'data': { 'node-name': 'str', 'child': 'str' } } + +## +# @BlockdevReplace: +# +# Since 8.1 +## +{ 'union': 'BlockdevReplace', + 'base': { + 'parent-type': 'BlockParentType', + 'new-child': 'str' + }, + 'discriminator': 'parent-type', + 'data': { + 'qdev': 'BdrvChildRefQdev', + 'export': 'BdrvChildRefExport', + 'driver': 'BdrvChildRefDriver' + } } + +## +# @x-blockdev-replace: +# +# Replace a block-node associated with device (selected by +# @qdev-id) or with block-export (selected by @export-id) or +# any child of block-node (selected by @node-name and @child) +# with @new-child block-node. +# +# Since 8.1 +## +{ 'command': 'x-blockdev-replace', 'boxed': true, + 'data': 'BlockdevReplace' } diff --git a/stubs/blk-by-qdev-id.c b/stubs/blk-by-qdev-id.c new file mode 100644 index 0000000000..0e751ce4f7 --- /dev/null +++ b/stubs/blk-by-qdev-id.c @@ -0,0 +1,9 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "sysemu/block-backend.h" + +BlockBackend *blk_by_qdev_id(const char *id, Error **errp) +{ + error_setg(errp, "blk '%s' not found", id); + return NULL; +} diff --git a/stubs/meson.build b/stubs/meson.build index b2b5956d97..026866aea7 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -1,6 +1,7 @@ stub_ss.add(files('bdrv-next-monitor-owned.c')) stub_ss.add(files('blk-commit-all.c')) stub_ss.add(files('blk-exp-close-all.c')) +stub_ss.add(files('blk-by-qdev-id.c')) stub_ss.add(files('blockdev-close-all-bdrv-states.c')) stub_ss.add(files('change-state-handler.c')) stub_ss.add(files('cmos.c')) --=20 2.34.1 From nobody Fri May 10 06:52:36 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1682077377; cv=none; d=zohomail.com; s=zohoarc; b=VKpRsG1SDTgNE8RoHveDP6Wq7buyj2KTIKAJhYry2BoyuXtl1pHVyHlLG+nJ5QQ2YQ6ZBpnLq5gzME2RybdtMH++xNPe/SZvS127kYv1uGiPVDY/r8+/glTj7z9jzzgTtW9EgEjKalcND0Fs20MnkKPGgLQklkEiaIun3k7bLKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682077377; h=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=HSwcko5Yr12QyhDkXUDISzlG14pQobTOcx+hJ03+k8I=; b=Ho2cQpmv7qisGS1FhJVfzb1sl9HIDO1u/T2aqgZa14Ap7Po5Sa0qioShR4t9ibyKszYc4kJnS6ZDRYklleegdo8PmyTg7mlC6P6CyA0zkGM7Pr2NZxh9ifbUbJuMmRdc0ohPDUVVRzlv0n4NyHeAamIm7vfwjxXgM69l5HZB3ao= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682077377401462.2973302947114; Fri, 21 Apr 2023 04:42:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppp9J-0007DE-D2; Fri, 21 Apr 2023 07:41:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8u-0006mg-Dv; Fri, 21 Apr 2023 07:41:33 -0400 Received: from forwardcorp1c.mail.yandex.net ([2a02:6b8:c03:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8s-0001HA-O4; Fri, 21 Apr 2023 07:41:32 -0400 Received: from mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7f29:0:640:9a2b:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 739BF6006A; Fri, 21 Apr 2023 14:41:21 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:b081:8816::1:4]) by mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 3fdrVT1OnCg0-cpc7VIso; Fri, 21 Apr 2023 14:41:20 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682077280; bh=HSwcko5Yr12QyhDkXUDISzlG14pQobTOcx+hJ03+k8I=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=FOWRWLYUHc5H5LoU304IwylegmAuEcACQEWPOHwB56tb/PfrY0SEfPu/sapbjZti1 QrHC7ZIJ2O+f1YIIHs55pxVI7cvk20jKYMv7O5trvGgjE9JIfWcU7Nza0ZsSYFAFnP 3Sv6V/YDogjHYLEXCuXv0ec152P4txxIRY//5064= Authentication-Results: mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, alexander.ivanov@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH v7 5/7] block: bdrv_get_xdbg_block_graph(): report export ids Date: Fri, 21 Apr 2023 14:41:00 +0300 Message-Id: <20230421114102.884457-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421114102.884457-1-vsementsov@yandex-team.ru> References: <20230421114102.884457-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:c03:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1682077378965100007 Content-Type: text/plain; charset="utf-8" Currently for block exports we report empty blk names. That's not good. Let's try to find corresponding block export and report its id. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 4 ++++ block/export/export.c | 13 +++++++++++++ include/block/export.h | 1 + stubs/blk-exp-find-by-blk.c | 9 +++++++++ stubs/meson.build | 1 + 5 files changed, 28 insertions(+) create mode 100644 stubs/blk-exp-find-by-blk.c diff --git a/block.c b/block.c index e2cc686074..6c8c98ee60 100644 --- a/block.c +++ b/block.c @@ -6140,7 +6140,11 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **er= rp) for (blk =3D blk_all_next(NULL); blk; blk =3D blk_all_next(blk)) { char *allocated_name =3D NULL; const char *name =3D blk_name(blk); + BlockExport *exp =3D blk_exp_find_by_blk(blk); =20 + if (!*name && exp) { + name =3D exp->id; + } if (!*name) { name =3D allocated_name =3D blk_get_attached_dev_id(blk); } diff --git a/block/export/export.c b/block/export/export.c index 016943860c..1659bee9da 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -60,6 +60,19 @@ BlockExport *blk_exp_find(const char *id) return NULL; } =20 +BlockExport *blk_exp_find_by_blk(BlockBackend *blk) +{ + BlockExport *exp; + + QLIST_FOREACH(exp, &block_exports, next) { + if (exp->blk =3D=3D blk) { + return exp; + } + } + + return NULL; +} + static const BlockExportDriver *blk_exp_find_driver(BlockExportType type) { int i; diff --git a/include/block/export.h b/include/block/export.h index 7feb02e10d..172c180819 100644 --- a/include/block/export.h +++ b/include/block/export.h @@ -80,6 +80,7 @@ struct BlockExport { =20 BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp); BlockExport *blk_exp_find(const char *id); +BlockExport *blk_exp_find_by_blk(BlockBackend *blk); void blk_exp_ref(BlockExport *exp); void blk_exp_unref(BlockExport *exp); void blk_exp_request_shutdown(BlockExport *exp); diff --git a/stubs/blk-exp-find-by-blk.c b/stubs/blk-exp-find-by-blk.c new file mode 100644 index 0000000000..2fc1da953b --- /dev/null +++ b/stubs/blk-exp-find-by-blk.c @@ -0,0 +1,9 @@ +#include "qemu/osdep.h" +#include "sysemu/block-backend.h" +#include "block/export.h" + +BlockExport *blk_exp_find_by_blk(BlockBackend *blk) +{ + return NULL; +} + diff --git a/stubs/meson.build b/stubs/meson.build index 026866aea7..7247ae04b6 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -2,6 +2,7 @@ stub_ss.add(files('bdrv-next-monitor-owned.c')) stub_ss.add(files('blk-commit-all.c')) stub_ss.add(files('blk-exp-close-all.c')) stub_ss.add(files('blk-by-qdev-id.c')) +stub_ss.add(files('blk-exp-find-by-blk.c')) stub_ss.add(files('blockdev-close-all-bdrv-states.c')) stub_ss.add(files('change-state-handler.c')) stub_ss.add(files('cmos.c')) --=20 2.34.1 From nobody Fri May 10 06:52:36 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1682077314; cv=none; d=zohomail.com; s=zohoarc; b=I0y3KrGBU8m4PnJqcdeK/Ujmd1lmfOxK/gclS84XNvvWc4EQBU7f7DgutPQevLuGmnpcZJjgj6wRsNxkCzx+Cju2ITeVLVOWhqHVfEqB9YLa3CWA8nRtwhZVablWssnaMvC7nSYnoWcYndTxVXCsTjYOJcYJ6NFsDl1k5qk8gSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682077314; h=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=fDyWzxUnkejgaTPlhVdraFKY1+bzlYe8s7QSj4Rp7wo=; b=Yz6yotvxc8Bh002LgkmsEXAlKwW+Vx1OGyjIRmBSz7gOGwQVeGHPDCP5h7sX5mkNnhGfmpkA+EshebGmf3Td+wpMVmmQAlpfY3F8GP3AeCLMpsLTaZu2ZVJL0BCGz0zvpG3BaT8iUBfM726ocSbLxwlEHqTSHdJZGd9E9bm+TAM= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682077314250758.2323695040199; Fri, 21 Apr 2023 04:41:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppp95-0006xn-07; Fri, 21 Apr 2023 07:41:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8u-0006mf-Cd; Fri, 21 Apr 2023 07:41:33 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8s-0001HL-OX; Fri, 21 Apr 2023 07:41:32 -0400 Received: from mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7f29:0:640:9a2b:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 4516E61965; Fri, 21 Apr 2023 14:41:22 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:b081:8816::1:4]) by mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 3fdrVT1OnCg0-Puvb34Bs; Fri, 21 Apr 2023 14:41:21 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682077281; bh=fDyWzxUnkejgaTPlhVdraFKY1+bzlYe8s7QSj4Rp7wo=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=d76fKiSVYfFd9MjKycjjChY2kFkoe9iQLjnuA9y7e2nWVITKkRDk9l9GJ7ISCZWZ7 Bk669Zl0BtzVTgoN3F49EDJ4v8L+NL4rWNWmRgICfTmkPxt8IL02+Ihi1rbQPo1OP6 jag1Mr0ixRCPkSB2ie4aTZv2rhxszExGhKWLdapQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, alexander.ivanov@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH v7 6/7] iotests.py: introduce VM.assert_edges_list() method Date: Fri, 21 Apr 2023 14:41:01 +0300 Message-Id: <20230421114102.884457-7-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421114102.884457-1-vsementsov@yandex-team.ru> References: <20230421114102.884457-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1682077314657100001 Content-Type: text/plain; charset="utf-8" Add an alternative method to check block graph, to be used in further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 3e82c634cf..3ff172e409 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1092,6 +1092,23 @@ def check_bitmap_status(self, node_name, bitmap_name= , fields): =20 return fields.items() <=3D ret.items() =20 + def get_block_graph(self): + """ + Returns block graph in form of edges list, where each edge is a tu= ple: + (parent_node_name, child_name, child_node_name) + """ + graph =3D self.qmp('x-debug-query-block-graph')['return'] + + nodes =3D {n['id']: n['name'] for n in graph['nodes']} + # Check that all names are unique: + assert len(set(nodes.values())) =3D=3D len(nodes) + + return [(nodes[e['parent']], e['name'], nodes[e['child']]) + for e in graph['edges']] + + def assert_edges_list(self, edges): + assert sorted(edges) =3D=3D sorted(self.get_block_graph()) + def assert_block_path(self, root, path, expected_node, graph=3DNone): """ Check whether the node under the given path in the block graph --=20 2.34.1 From nobody Fri May 10 06:52:36 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; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1682077376; cv=none; d=zohomail.com; s=zohoarc; b=lxqy9REMyfhjhKNOG1yeqhF+bQEKpdFDHlhUDNzS6u/d7vBtUQHixnLEcBwcehBqKeES9o+vY/NImQE8Mciek1ELWH8irimHw6an3oxAbRtQMHqWHFwhUAy6YC7EZULjmrq+WAtBNvCqimGWQ1qnhyfDNTinvYNdpqEDsPVtFL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682077376; h=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=7CuWW+DlLTMZJ+rGQSrSRcYmm+nLxXD8266GtCjJvrs=; b=Qx3LHe2+C4enDhVXo0ZYerOoiOtTfAWdl5ej30CP/aP95DPTn1GY57UZsEuIpwbrJZ4uQiNx0GjUf/mlKs8+0j/dF74WoFthCUn+X2DzgAWvdEVGZPvVz+jk+8R8s4n/PcCHtoYSCKzxT20c19nQE1sJ1HtOkpCyuBiiAEmpcGQ= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682077376815875.0233822526948; Fri, 21 Apr 2023 04:42:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppp9D-00072B-3w; Fri, 21 Apr 2023 07:41:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8w-0006ny-4k; Fri, 21 Apr 2023 07:41:34 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppp8t-0001Hk-5o; Fri, 21 Apr 2023 07:41:33 -0400 Received: from mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7f29:0:640:9a2b:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 6520E5F332; Fri, 21 Apr 2023 14:41:23 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:b081:8816::1:4]) by mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 3fdrVT1OnCg0-mIcitxme; Fri, 21 Apr 2023 14:41:22 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682077282; bh=7CuWW+DlLTMZJ+rGQSrSRcYmm+nLxXD8266GtCjJvrs=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=nGB2hTHxrCsBc/mAWyOiF8GYdNhw4wdEkbYCCGXy/aLaFxtKyYcbhJJ+7vmHf8iim OkJkXDzOQtwaugsX4p9HOWpDz2s863XztdE0Oni23MAwCp5zjDpLIQb4uIYm84uhLr A3aXweLtu8pukFaCuj9ucoRjd2qQbrv/PKaU5dbs= Authentication-Results: mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, den@openvz.org, alexander.ivanov@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH v7 7/7] iotests: add filter-insertion Date: Fri, 21 Apr 2023 14:41:02 +0300 Message-Id: <20230421114102.884457-8-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230421114102.884457-1-vsementsov@yandex-team.ru> References: <20230421114102.884457-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1682077379367100011 Content-Type: text/plain; charset="utf-8" Demonstrate new blockdev-replace API for filter insertion and removal. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/filter-insertion | 257 ++++++++++++++++++ tests/qemu-iotests/tests/filter-insertion.out | 5 + 2 files changed, 262 insertions(+) create mode 100755 tests/qemu-iotests/tests/filter-insertion create mode 100644 tests/qemu-iotests/tests/filter-insertion.out diff --git a/tests/qemu-iotests/tests/filter-insertion b/tests/qemu-iotests= /tests/filter-insertion new file mode 100755 index 0000000000..11c0ea0447 --- /dev/null +++ b/tests/qemu-iotests/tests/filter-insertion @@ -0,0 +1,257 @@ +#!/usr/bin/env python3 +# +# Tests for inserting and removing filters in a block graph. +# +# Copyright (c) 2022 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import os + +import iotests +from iotests import qemu_img_create, try_remove + + +disk =3D os.path.join(iotests.test_dir, 'disk') +sock =3D os.path.join(iotests.sock_dir, 'sock') +size =3D 1024 * 1024 + + +class TestFilterInsertion(iotests.QMPTestCase): + def setUp(self): + qemu_img_create('-f', iotests.imgfmt, disk, str(size)) + + self.vm =3D iotests.VM() + self.vm.launch() + + result =3D self.vm.qmp('blockdev-add', { + 'node-name': 'disk0', + 'driver': 'qcow2', + 'file': { + 'node-name': 'file0', + 'driver': 'file', + 'filename': disk + } + }) + self.assert_qmp(result, 'return', {}) + + def tearDown(self): + self.vm.shutdown() + os.remove(disk) + try_remove(sock) + + def test_simple_insertion(self): + vm =3D self.vm + + result =3D vm.qmp('blockdev-add', { + 'node-name': 'filter', + 'driver': 'preallocate', + 'file': 'file0' + }) + self.assert_qmp(result, 'return', {}) + + result =3D vm.qmp('x-blockdev-replace', { + 'parent-type': 'driver', + 'node-name': 'disk0', + 'child': 'file', + 'new-child': 'filter' + }) + self.assert_qmp(result, 'return', {}) + + # Filter inserted: + # disk0 -file-> filter -file-> file0 + vm.assert_edges_list([ + ('disk0', 'file', 'filter'), + ('filter', 'file', 'file0') + ]) + + result =3D vm.qmp('x-blockdev-replace', { + 'parent-type': 'driver', + 'node-name': 'disk0', + 'child': 'file', + 'new-child': 'file0' + }) + self.assert_qmp(result, 'return', {}) + + # Filter replaced, but still exists: + # dik0 -file-> file0 <-file- filter + vm.assert_edges_list([ + ('disk0', 'file', 'file0'), + ('filter', 'file', 'file0') + ]) + + result =3D vm.qmp('blockdev-del', node_name=3D'filter') + self.assert_qmp(result, 'return', {}) + + # Filter removed + # dik0 -file-> file0 + vm.assert_edges_list([ + ('disk0', 'file', 'file0') + ]) + + def test_insert_under_qdev(self): + vm =3D self.vm + + result =3D vm.qmp('device_add', driver=3D'virtio-scsi') + self.assert_qmp(result, 'return', {}) + result =3D vm.qmp('device_add', id=3D'sda', driver=3D'scsi-hd', + drive=3D'disk0') + self.assert_qmp(result, 'return', {}) + + result =3D vm.qmp('blockdev-add', { + 'node-name': 'filter', + 'driver': 'compress', + 'file': 'disk0' + }) + self.assert_qmp(result, 'return', {}) + + result =3D vm.qmp('x-blockdev-replace', { + 'parent-type': 'qdev', + 'qdev-id': 'sda', + 'new-child': 'filter' + }) + self.assert_qmp(result, 'return', {}) + + # Filter inserted: + # sda -root-> filter -file-> disk0 -file-> file0 + vm.assert_edges_list([ + # parent_node_name, child_name, child_node_name + ('sda', 'root', 'filter'), + ('filter', 'file', 'disk0'), + ('disk0', 'file', 'file0'), + ]) + + result =3D vm.qmp('x-blockdev-replace', { + 'parent-type': 'qdev', + 'qdev-id': 'sda', + 'new-child': 'disk0' + }) + self.assert_qmp(result, 'return', {}) + result =3D vm.qmp('blockdev-del', node_name=3D'filter') + self.assert_qmp(result, 'return', {}) + + # Filter removed: + # sda -root-> disk0 -file-> file0 + vm.assert_edges_list([ + # parent_node_name, child_name, child_node_name + ('sda', 'root', 'disk0'), + ('disk0', 'file', 'file0'), + ]) + + def test_insert_under_nbd_export(self): + vm =3D self.vm + + result =3D vm.qmp('nbd-server-start', + addr=3D{'type': 'unix', 'data': {'path': soc= k}}) + self.assert_qmp(result, 'return', {}) + result =3D vm.qmp('block-export-add', id=3D'exp1', type=3D'nbd', + node_name=3D'disk0', name=3D'exp1') + self.assert_qmp(result, 'return', {}) + result =3D vm.qmp('block-export-add', id=3D'exp2', type=3D'nbd', + node_name=3D'disk0', name=3D'exp2') + self.assert_qmp(result, 'return', {}) + result =3D vm.qmp('object-add', qom_type=3D'throttle-group', + id=3D'tg', limits=3D{'iops-read': 1}) + self.assert_qmp(result, 'return', {}) + + result =3D vm.qmp('blockdev-add', { + 'node-name': 'filter', + 'driver': 'throttle', + 'throttle-group': 'tg', + 'file': 'disk0' + }) + self.assert_qmp(result, 'return', {}) + + result =3D vm.qmp('x-blockdev-replace', { + 'parent-type': 'export', + 'export-id': 'exp1', + 'new-child': 'filter' + }) + self.assert_qmp(result, 'return', {}) + + # Only exp1 is throttled, exp2 is not: + # exp1 -root-> filter + # | + # |file + # v + # exp2 -file-> disk0 -file> file0 + vm.assert_edges_list([ + # parent_node_name, child_name, child_node_name + ('exp1', 'root', 'filter'), + ('filter', 'file', 'disk0'), + ('disk0', 'file', 'file0'), + ('exp2', 'root', 'disk0') + ]) + + result =3D vm.qmp('x-blockdev-replace', { + 'parent-type': 'export', + 'export-id': 'exp2', + 'new-child': 'filter' + }) + self.assert_qmp(result, 'return', {}) + + # Both throttled: + # exp1 -root-> filter <-file- exp2 + # | + # |file + # v + # disk0 -file> file0 + vm.assert_edges_list([ + # parent_node_name, child_name, child_node_name + ('exp1', 'root', 'filter'), + ('filter', 'file', 'disk0'), + ('disk0', 'file', 'file0'), + ('exp2', 'root', 'filter') + ]) + + # Check, that filter is in use and can't be removed + result =3D vm.qmp('blockdev-del', node_name=3D'filter') + self.assert_qmp(result, 'error/desc', 'Node filter is in use') + + result =3D vm.qmp('x-blockdev-replace', { + 'parent-type': 'export', + 'export-id': 'exp1', + 'new-child': 'disk0' + }) + self.assert_qmp(result, 'return', {}) + + result =3D vm.qmp('x-blockdev-replace', { + 'parent-type': 'export', + 'export-id': 'exp2', + 'new-child': 'disk0' + }) + self.assert_qmp(result, 'return', {}) + result =3D vm.qmp('blockdev-del', node_name=3D'filter') + self.assert_qmp(result, 'return', {}) + + # Filter removed: + # exp1 -root-> disk0 <-file- exp2 + # | + # |file + # v + # file0 + vm.assert_edges_list([ + # parent_node_name, child_name, child_node_name + ('exp1', 'root', 'disk0'), + ('disk0', 'file', 'file0'), + ('exp2', 'root', 'disk0') + ]) + + +if __name__ =3D=3D '__main__': + iotests.main( + supported_fmts=3D['qcow2'], + supported_protocols=3D['file'] + ) diff --git a/tests/qemu-iotests/tests/filter-insertion.out b/tests/qemu-iot= ests/tests/filter-insertion.out new file mode 100644 index 0000000000..8d7e996700 --- /dev/null +++ b/tests/qemu-iotests/tests/filter-insertion.out @@ -0,0 +1,5 @@ +... +---------------------------------------------------------------------- +Ran 3 tests + +OK --=20 2.34.1