From patchwork Thu Jan 2 21:17:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13924962 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2387AE77197 for ; Thu, 2 Jan 2025 21:19:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTSaP-00046I-NP; Thu, 02 Jan 2025 16:18:33 -0500 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 1tTSaO-000468-J7 for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:32 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTSaN-0001Ps-2f for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:32 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4363dc916ceso74664755e9.0 for ; Thu, 02 Jan 2025 13:18:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735852709; x=1736457509; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mOzPkO5TmCycPZ/aaTUQEr16ldzePeyfEU/CMbdVIug=; b=ahwe36KA0yJzj2Dt20snb7WiEbUJ82jontu72fTUmbPdxhT1pRKr16iD/6J0XJsBkC juEWs0LXkk0nWdzOXqRGcFZeOVSOVzspeKjwZpNctd50ecSsQjnzWtssCm2h1H3vfYIt aQ/zsfJAd/Ehs9Q6SacLc0UMVeZk/FLLHFPpb+sLpQ+Sgu/lIdVWYEBSYP6KJgE7n09m BEjXiLqX+aKV8AN947FOCwhwF+uulU3830sSuPyE/5R0vJ+ZRXMXVQWUXhqx9gKske1m AqI3nd4NtsMHHRnbH/vVl5543YDkDkntbBmOkypvezjN/L1YzVmdStn1PgpLk4FtOnoC buwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735852709; x=1736457509; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mOzPkO5TmCycPZ/aaTUQEr16ldzePeyfEU/CMbdVIug=; b=lJt5yPuT0MWTzT0cfUaWBGsBfcOMsJs7C+Iy3sDb+eohdfzyxFrKGLpv8Q4PmgT6DX r1q711KGIuznRwuT4WGzjbwR/KhfGvtC0xF6wkA1DlfydtZaZvj3Bg8lT3lzpQ3Sbg+3 Gi05P0ZnLKuXxiGWQwvBW6Ip1oYjB+2TvxQ+34+Eevk9p9TzKZ0ePFqDltMe5l5KRwUO dpq+iEEU/rxRNQHI/rFUYHL9GHtFdtBeVsqndfyj5CONpXJbGGLxZGsVzuaC98DleqHQ Ga+k5sNKzMorn/P+ftBVRrr5x9muNk6zATqD6Rdmuv1YTiUOoahjAXUJtSGI0ibKRlRI DO5Q== X-Gm-Message-State: AOJu0YwuuaKiEQAzxKgnTKEhXCpskyXpKO8+LtA1WypeJZ/0354+EMfS m/hF1IseqyA5bf+XdvRMNrqQ+sQxLnH9dmNGa8VSiQgI223O/sERJtUVojKQjEZMYPAchCHfym+ AJZEHVQ== X-Gm-Gg: ASbGncumR1obrYfLqnga6ZUgas6vcRVdk/nRMEHxM2NJtEN3DTgvWarfcLsm3df7nwN i/hlJsRQ/sRP0uCZk334xmhILsTElrY2fwQuTvu5rP7D1ubktTOZMYau1gq1TZwlpn/vKecuZ3r nuvd0sxtG8kUTkI2jzs/nLKl+mY0iQCSI4ipfE1x2qmCxiTrZkCKmuCiM2Vm+EYoSJVNoWBB/kM i6kC/yn0+dpxj8oh/xd0GwSBJjRwT+gy+jE3LOVOZMz+3kCuYRoYFKDC2L7AHyVr3oJJYuqBrjp cpQF73WwFMT/fTG/bZ/baIIfhYzTQ9M= X-Google-Smtp-Source: AGHT+IFU3Ak1Tex0YDo2PB7ja9Wd9PA1j+50jH6zY14zk2XZnqdul0bDSoDkpr5Jw/reI/O4XHF1Ig== X-Received: by 2002:a05:6000:381:b0:38a:69aa:31f5 with SMTP id ffacd0b85a97d-38a69aa338bmr100361f8f.3.1735852709348; Thu, 02 Jan 2025 13:18:29 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8a6ca5sm39940132f8f.86.2025.01.02.13.18.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 13:18:28 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , "Michael S. Tsirkin" , Richard Henderson , Paolo Bonzini , David Hildenbrand , Zhenwei Pi , Marcel Apfelbaum , "Gonglei (Arei)" , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Peter Xu , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Fam Zheng , Eduardo Habkost Subject: [PATCH v4 5/8] qom: Add object_get_container() Date: Thu, 2 Jan 2025 22:17:57 +0100 Message-ID: <20250102211800.79235-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250102211800.79235-1-philmd@linaro.org> References: <20250102211800.79235-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Peter Xu Add a helper to fetch a root container (under object_get_root()). Sanity check on the type of the object. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé Signed-off-by: Peter Xu Message-ID: <20241121192202.4155849-12-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/qom/object.h | 10 ++++++++++ qom/object.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index 95d6e064d9b..bcf9910b42c 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1510,6 +1510,16 @@ const char *object_property_get_type(Object *obj, const char *name, */ Object *object_get_root(void); +/** + * object_get_container: + * @name: the name of container to lookup + * + * Lookup a root level container. + * + * Returns: the container with @name. + */ +Object *object_get_container(const char *name); + /** * object_get_objects_root: diff --git a/qom/object.c b/qom/object.c index b4c52d055d9..81c06906d30 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1751,6 +1751,16 @@ static Object *object_root_initialize(void) return root; } +Object *object_get_container(const char *name) +{ + Object *container; + + container = object_resolve_path_component(object_get_root(), name); + assert(object_dynamic_cast(container, TYPE_CONTAINER)); + + return container; +} + Object *object_get_root(void) { static Object *root;