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: 854758 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7968811wrq; Thu, 2 Jan 2025 13:19:56 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU1vvr7lbL3si8C+dd0c8/ZFF18AcUpGRmlIul1jjhlBWC842LHmx4get304eBRwZEnqfxpmA==@linaro.org X-Google-Smtp-Source: AGHT+IGu1PNQ8/3Xk72jmpEj88IIkAUiigEga+Lk1aYnmkAzC53GyrGE4RTpje7vPBc7NIBlzzGc X-Received: by 2002:a05:620a:4150:b0:7b6:c714:f65c with SMTP id af79cd13be357-7b9ba7a4f1dmr6923823585a.28.1735852795944; Thu, 02 Jan 2025 13:19:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735852795; cv=none; d=google.com; s=arc-20240605; b=ApzNkTI+4TJBQjmubfzWH8ue7Vqk3uDeXh29kqwwTiqoxEjgDJOj46/6e86OxKwHMs o+H1BkuOKL8DcohnlgS1Zqei67fxuSkfMf11hadqBCeHbtCX9WFMQR7auc6cAUERXkxk ZWmMsl0XIjUrR2m4vXnXS/2yLU1M1YjLHZ3ToeevbR+7wHY4Ummut9Qw8hIyRB1WBG4l a5VgpsV6PXQrNkgzMrItp3pb8+jdRnn/WtOX1gmP7mnFDveaiS2JV1E16cokBxTIxNrk v7PqWjdJjEgOhFIb/6O0LnxJp9BVRElOvkSVGohoR3zpjhfio8w0J4bKljdQaEibaPjs lqpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mOzPkO5TmCycPZ/aaTUQEr16ldzePeyfEU/CMbdVIug=; fh=Yr6y3Q7nw9Pkn2BMoDtN0XGcR8Ktn+gkbMNk1sAP+Hw=; b=kKK3tne7KzsbtT6kEWCdpGQg68/MpETP1uokS2bZAasS3P4cvVczq/MNGJNI6c7Gea jWTZRTAJO6sATeuHkc9i1NDrMPnYG5ujBnBAwInq/31wjGXBe1iZUDp4juSlQTT5PX2/ zcEgLgpbWg7MEKAAI+l+muRWyGlb6YxVVHs5MALrED+6hLkYPkDqbnYuvoAS55LhRDoP 3ZTPbFTYGTCW/m/H0b3Wd2mFrFw4Q93D9IeDmBCwcPZcR/xUBGldKgpy4rs/mgjmbcFG zKpUBxdK0loYZzeN5tcNLOIw+1AFHM2u/ejLXOQwHQt9VRnboClEZofJwUyNPt6wB/h5 3QcQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ahwe36KA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac2adb59si3743706285a.119.2025.01.02.13.19.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Jan 2025 13:19:55 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ahwe36KA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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;