From patchwork Thu Jan 2 21:17:53 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: 13924956 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 6323EE77198 for ; Thu, 2 Jan 2025 21:19:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTSaG-00043c-Rr; Thu, 02 Jan 2025 16:18:24 -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 1tTSa4-00040f-Sw for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:17 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTSa1-0001Lb-0o for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:10 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-436326dcb1cso77460205e9.0 for ; Thu, 02 Jan 2025 13:18:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735852687; x=1736457487; 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=XroMYY0R/MiabM3vxlKI8plZjULUSdM7o1GYxaZu1lI=; b=yQQSuWpc9y/Cr2HdsP4qqCH2wd8qRMVC0Wle2L2kZL3rJoo+x9zzUhmDRcUCtW1s96 kZM70kKZ4cqbHAaR+qGxkmwXMcKGHeBGAs3NSh3vHk4UEER9N77hg0BHqYyRumI5Enb9 Dgq4igHsh/QJEok9mJNXyCQ6A2g/duEJkhxEvRn8gshuSgz3XL6Pfoi5Nu/q4KrqJJct uNw7dBQqY6NuqBbwmTmfasklfCGrjgKnHLF74tatLeCFfM9/Etg1IMiwc4m3RKYO2Sdb bpIrfCR8OypB5i35Z1YugiIKjyG6+qEESoaAQYD9MIMp4Tnlxe2DbDS0qVL3d1QW31fh CeDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735852687; x=1736457487; 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=XroMYY0R/MiabM3vxlKI8plZjULUSdM7o1GYxaZu1lI=; b=xOCWU4eKai/j3bEfL4JIymGf1cBWcMZizNHqpdHxWDSKKR9OdvERBVKSlrooigFkKM HnIbyP041Lx+dxZHNsIyqArDmxWfqr7U+5BbfRDcrZ7TanU5jzmuHkUChflHvTHwh8Rr ZdTc3ancaK7/7do7H5Ohfv+ffv4ARs23Gv9PSPcHJ7bLzORkZcZzUrgMZkXi/jy1/r9d WPdWEBDU2wuiFME29vk0UuQcmOLkxVyROZ0Wg/HBEpzZpYvVJJeIfb0ctbyeDKsbIdNy 0HyWo5jsnzSI3KYMqehcBE9HUk4PzPYTRjFTovviTYQgY+bbyCZ03FPUD0/4h1Uy9FDP mEgg== X-Gm-Message-State: AOJu0YwQ+a9PWIrfhzoiDgF5Q3uPpylPlxW0fPkt4NXS4W1k7GRuqXrm GCXRTZROObSWDPXet53Gsajzi3+w0PypIVYaSGj41N12e0mYLQrqJx26Qk2WqW85oNc1tRSDaEu 2hPOQkw== X-Gm-Gg: ASbGncuEfALacavKzxE6d62mNeJ4INNUsyJcQ+o0qfnN/3RAr1Qsx175erucvhWlYpN SW3VYQEGUdYO1+vDOugSbDOLXKq7GAw2DMuQQSiLZSYOeOe2P959W7Y/wgowVy4AGppiHdSeoWE vnpAkJ9C2+bc4+B6R8JI+CNMwFG9g1cYMjY5DctLkHPyZZVM4zkDKXkhIWwjbc29LSfvqF7x0qa B1Lru2+vLmdp36I+yDJhxYY7mCiHVR/iRUoZEuGIKYFqBVSsrBbYagEeXKPXqHgSmP6XVmgz0h1 IOihg3D4RbFItyRSuz5hJjC8B9V6x5o= X-Google-Smtp-Source: AGHT+IGifLsGTL7JCw1PUDyVQv1IqEOxdteLjKkX3xXmP8MqBs4a82XvG4UnVb/ArsvfHA1W6tKtJQ== X-Received: by 2002:a05:6000:471a:b0:38a:69a9:afb1 with SMTP id ffacd0b85a97d-38a69a9b17amr136101f8f.0.1735852687121; Thu, 02 Jan 2025 13:18:07 -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-38a1c8acabbsm38724383f8f.93.2025.01.02.13.18.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 13:18:06 -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 1/8] qdev: Implement qdev_create_fake_machine() for user emulation Date: Thu, 2 Jan 2025 22:17:53 +0100 Message-ID: <20250102211800.79235-2-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::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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 When a QDev instance is realized, qdev_get_machine() ends up called. In the next commit, qdev_get_machine() will require a "machine" container to be always present. To satisfy this QOM containers design, Implement qdev_create_fake_machine() which creates a fake "machine" container for user emulation. On system emulation, qemu_create_machine() is called from qemu_init(). For user emulation, since the TCG accelerator always calls tcg_init_machine(), we use it to hook our fake machine creation. Suggested-by: Peter Xu Signed-off-by: Philippe Mathieu-Daudé Acked-by: Peter Xu Reviewed-by: Richard Henderson --- include/hw/qdev-core.h | 10 ++++++++++ accel/tcg/tcg-all.c | 8 +++++++- hw/core/qdev-user.c | 21 +++++++++++++++++++++ hw/core/meson.build | 1 + 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 hw/core/qdev-user.c diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index e6ef80b7fd0..b83b1439968 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -1027,6 +1027,16 @@ const char *qdev_fw_name(DeviceState *dev); void qdev_assert_realized_properly(void); Object *qdev_get_machine(void); +/** + * qdev_create_fake_machine(): Create a fake machine container. + * + * .. note:: + * This function is a kludge for user emulation (USER_ONLY) + * because when thread (TYPE_CPU) are realized, qdev_realize() + * access a machine container. + */ +Object *qdev_create_fake_machine(void); + /** * qdev_get_human_name() - Return a human-readable name for a device * @dev: The device. Must be a valid and non-NULL pointer. diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c index c2565758876..95adaacee82 100644 --- a/accel/tcg/tcg-all.c +++ b/accel/tcg/tcg-all.c @@ -35,7 +35,9 @@ #include "qemu/atomic.h" #include "qapi/qapi-builtin-visit.h" #include "qemu/units.h" -#if !defined(CONFIG_USER_ONLY) +#if defined(CONFIG_USER_ONLY) +#include "hw/qdev-core.h" +#else #include "hw/boards.h" #endif #include "internal-common.h" @@ -124,6 +126,10 @@ static int tcg_init_machine(MachineState *ms) tcg_prologue_init(); #endif +#ifdef CONFIG_USER_ONLY + qdev_create_fake_machine(); +#endif + return 0; } diff --git a/hw/core/qdev-user.c b/hw/core/qdev-user.c new file mode 100644 index 00000000000..f816340db5a --- /dev/null +++ b/hw/core/qdev-user.c @@ -0,0 +1,21 @@ +/* + * QDev helpers specific to user emulation. + * + * Copyright 2025 Linaro, Ltd. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "qemu/osdep.h" +#include "qom/object.h" +#include "hw/qdev-core.h" + +Object *qdev_create_fake_machine(void) +{ + Object *fake_machine_obj; + + fake_machine_obj = object_property_add_new_container(object_get_root(), + "machine"); + object_property_add_new_container(fake_machine_obj, "unattached"); + + return fake_machine_obj; +} diff --git a/hw/core/meson.build b/hw/core/meson.build index ce9dfa3f4bf..65a1698ed1f 100644 --- a/hw/core/meson.build +++ b/hw/core/meson.build @@ -46,3 +46,4 @@ system_ss.add(files( 'vm-change-state-handler.c', 'clock-vmstate.c', )) +user_ss.add(files('qdev-user.c')) From patchwork Thu Jan 2 21:17:54 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: 13924960 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 813CAE77188 for ; Thu, 2 Jan 2025 21:19:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTSaI-00044X-6d; Thu, 02 Jan 2025 16:18:26 -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 1tTSa8-00040l-Ql for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:17 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTSa7-0001N1-9i for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:16 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-385de9f789cso8786960f8f.2 for ; Thu, 02 Jan 2025 13:18:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735852693; x=1736457493; 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=yFrtobX5dEs1+8eScAKkWEL068+5vqZlHD9HfY3Xigw=; b=qoFfRBOkUgjTk2l94gRw+R9DQ4aeyL16PZOxfIvJojzj+oq0Bc2KuwkN37aEbmE5dj O6GcLKp/OaB5roXIiSGQHGXopvv9l67M4XKgSyidAQR4lnL/vbPZ8RX7p7QRMhILYN9W XiBGq5HgoDhuD/CF3lKzrvWtYe9hVcqRgDb6gVYltxcItogBr1eEmHsKgOmmqIbv1PVJ QtiV6KrvEQuX71CQYBfcRT0RijjchdqthKdBw4NOoNQoejTSK1rxVrXXUoo1jbCBeu8K VAkmMw8OLtx8LMgjSRyHZnSeYvrdjA49ubqAQBdbyaRo944EZEqTqGk6LysepvcbWKtg TpRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735852693; x=1736457493; 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=yFrtobX5dEs1+8eScAKkWEL068+5vqZlHD9HfY3Xigw=; b=YuF39WHRvO8yRBs4K2t5tpmuMaH8V+7veROzFFfUnqoS8TOt7fLHdFKz6/CChD9LdZ 66B4as3JD136px6tyIaYTYwFgdHbghzDL9rrFnK7OHexNocSOU0gY2ZZTMTcB2kG7N2S efEr7Qhk6+xDr/Rlx+C7H27N8UvgejezJV7J99B8fp4wIANqRmaQDZcz0cUu4L6OrTrK 0zZD01Uy31QtRd2kGdkf5ySAx+AAmD8D8tRfMOUjYx/z8ibJUroPTHFJbLdu2Dq9S0T9 50ZAnakZ/Zg+Mq2syJXaGIahfBejaYaPJnLfA0pEff5+gq98rnH55d8yn1sPc19hHy4E PakA== X-Gm-Message-State: AOJu0YzpkD/W0624dseD21+l07gRnytjon0VEEJmEYBfFdV93xhgkKD7 xDee1Rb6cwqRoXDMCemF3/BaW2QvT0dIMzGDZE7Io5WlDo7s5TPSHogP73LoTB3894lFTV8vJys JinkBDA== X-Gm-Gg: ASbGnctg24/2weYEiinQ9K77x4UuDHAq47P2XfXcXvL4VV5qpoJxVhKiwhsEtA/GRZy 6oSDKrQ2t9cc78bJyDOoZMIOefJ8ixG7tVHrkhcwAthocyOsdSw4s3qT7eL+TXIbTIp3Us6WfUS 364K0L0VRaBi2N92stUVwvT22k/AnxZXszdvBK57e4D36DA6j+gX9+E4idP8mDDC/ZOzmPzwjgB RGpeco1J2fFiC/ixHzRiOi3Dm3EK5gI3wE78xXzc5Bymz4Yosu317u+2jrUPZzRnlyh1Mwv1VWr st+yWhqvo/sBEF+S9A3jMr3/wvIib6U= X-Google-Smtp-Source: AGHT+IGIXzLfZOWf7dhlRagncF8WRe4eO/6+e7WA7/thdiVR/TtjQ4FQR31nYplFbHHUuoWo9cTIHA== X-Received: by 2002:a05:6000:4012:b0:385:f7d9:99f5 with SMTP id ffacd0b85a97d-38a224087b8mr37943617f8f.51.1735852692938; Thu, 02 Jan 2025 13:18:12 -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-38a1c89e4ebsm39336728f8f.85.2025.01.02.13.18.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 13:18:12 -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 2/8] qdev: Make qdev_get_machine() not use container_get() Date: Thu, 2 Jan 2025 22:17:54 +0100 Message-ID: <20250102211800.79235-3-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::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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 Currently, qdev_get_machine() has a slight misuse on container_get(), as the helper says "get a container" but in reality the goal is to get the machine object. It is still a "container" but not strictly. Note that it _may_ get a container (at "/machine") in our current unit test of test-qdev-global-props.c before all these changes, but it's probably unexpected and worked by accident. Switch to an explicit object_resolve_path_component(), with a side benefit that qdev_get_machine() can happen a lot, and we don't need to split the string ("/machine") every time. This also paves way for making the helper container_get() never try to return a non-container at all. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20241121192202.4155849-9-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/core/qdev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 57c1d9df3a7..bc5b60212a7 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -818,7 +818,12 @@ Object *qdev_get_machine(void) static Object *dev; if (dev == NULL) { - dev = container_get(object_get_root(), "/machine"); + dev = object_resolve_path_component(object_get_root(), "machine"); + /* + * Any call to this function before machine is created is treated + * as a programming error as of now. + */ + assert(dev); } return dev; From patchwork Thu Jan 2 21:17:55 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: 13924955 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 2DEFCE77188 for ; Thu, 2 Jan 2025 21:19:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTSaJ-00044c-4V; Thu, 02 Jan 2025 16:18:27 -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 1tTSaE-00041t-1z for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:24 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTSaC-0001OQ-G0 for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:21 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4368a293339so79819405e9.3 for ; Thu, 02 Jan 2025 13:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735852698; x=1736457498; 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=424nUjnt0mSbCqT2Iy8fBR2D+25DbV9xd+ohVsIuqlU=; b=JUIiF/u3H/ziU1vcqi3gbUpIbiyRQ25D8v9fgvkGWb1QTSWOBVHSvvo9wVej+Jsu9K 6C1cwUNdsUuMltpwbvqi64jJZnr4tDL1gRKZgfYV69EaaeuorK9wKt7hbTphY0Qzwgs3 BXOilkUX7TB7XqlJ8Lhz1/l4IHX8qbHfntcRbOxSnWLxMYbAbNka0hRNuBdwSZWKCMDF RG4Gigq6kYlR1wqWjKcxwnK7KCXpjToVZng6dyS8jF45vXAvG/ZoBk8LysNgvXK5aRky tz3yEKQrZ/hci64ywPQAOC1O/2Bd0hh+qPcheKcJPHI+PZsECp4TNdeGuEDRL5xPsiLo 0QfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735852698; x=1736457498; 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=424nUjnt0mSbCqT2Iy8fBR2D+25DbV9xd+ohVsIuqlU=; b=b0/eLUYb51Z3HracUjalir2U3qlCDEN0lY8s+VFIzNO7KWcgp6/6J7XhP4rvaBM7XO xrYY1MlU43Y3/iVuiFiQEZoqe1YsLMJWlMvnAM33ufzuubN5Qnt8XsaEboDPuDvWNk7W jE/Xh5VZSJOCFB7PHtYH1G3AxXluVyitOnQfnMQnO3Mnvy88lrqK7ySCoXjz2z0MqDoz WikyEwrfcEphbQItvYStK3Fl2R28j8GwwoLkegr3KaexiX/nw910m3thAs4+4RizDvYK hEFbfy8sd2vTvMkrYk1BuLfVJ02b8XPtMAEbKJrDrCPUWWzmwF352OK3ovj0QRBBlTsM oSmw== X-Gm-Message-State: AOJu0Yzr0Yioomjkk+Bnh+4wyb5r+zMIr3zh6U9Bq+2cwzeQlaRBU+bO wUsn6yDNzfsvolAizU4kDOHVldQdC9HWgFjMaUGZ2jhp/cxVrXJuff+SJkPiN1bpviAghghrT9B +qTCh6Q== X-Gm-Gg: ASbGnct42nuBAvQvYyxFwcSjTtY6dhMmZJUrhAakxBQeMj+XR1MagzdlgCR4s4GMIvT seuTd5IEsE410xVeMmbjxIkBJ3slbT1Ywd9VpjsX0Kb8G6YykE7gYfpq6pClNw5OKFEdbBxXTfl WMdLZI5cp65579CC6VR6ssSYLoZvGKyFWH1hHCfvTFWI2Z8itOWxjIFVcx7IYi4DdBPOiuLxHgZ jPf15z65PoW6TDUiIsNVvXcrZ+lr78soTwPFuz0wIjeM4aRwGEocnwy0zvmON4Tzv+xOnGaCbg6 UCB7oX6E1r0YG3zFw1cSgJpoujKCF7Y= X-Google-Smtp-Source: AGHT+IGfozx6MUYu1gUMV/CUhu3LI1INkamt5mCUXdSqXJmJvsY6cOxsqASOCiMuu5ImKU/ES+5/Rg== X-Received: by 2002:a05:600c:693:b0:434:f586:753c with SMTP id 5b1f17b1804b1-4366a0cf7f2mr341455805e9.7.1735852698527; Thu, 02 Jan 2025 13:18:18 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366128a62asm459186485e9.44.2025.01.02.13.18.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 13:18:17 -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 3/8] qdev: Add machine_get_container() Date: Thu, 2 Jan 2025 22:17:55 +0100 Message-ID: <20250102211800.79235-4-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::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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 machine containers. Add some sanity check around. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Peter Xu Message-ID: <20241121192202.4155849-10-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/qdev-core.h | 10 ++++++++++ hw/core/qdev.c | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index b83b1439968..2434065bad2 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -1037,6 +1037,16 @@ Object *qdev_get_machine(void); */ Object *qdev_create_fake_machine(void); +/** + * machine_get_container: + * @name: The name of container to lookup + * + * Get a container of the machine (QOM path "/machine/NAME"). + * + * Returns: the machine container object. + */ +Object *machine_get_container(const char *name); + /** * qdev_get_human_name() - Return a human-readable name for a device * @dev: The device. Must be a valid and non-NULL pointer. diff --git a/hw/core/qdev.c b/hw/core/qdev.c index bc5b60212a7..9973e029ffa 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -829,6 +829,17 @@ Object *qdev_get_machine(void) return dev; } +Object *machine_get_container(const char *name) +{ + Object *container, *machine; + + machine = qdev_get_machine(); + container = object_resolve_path_component(machine, name); + assert(object_dynamic_cast(container, TYPE_CONTAINER)); + + return container; +} + char *qdev_get_human_name(DeviceState *dev) { g_assert(dev != NULL); From patchwork Thu Jan 2 21:17:56 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: 13924961 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 F2A09E77197 for ; Thu, 2 Jan 2025 21:19:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTSaL-00045c-KT; Thu, 02 Jan 2025 16:18:29 -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 1tTSaK-000459-4J for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:28 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTSaI-0001PX-8g for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:27 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-436326dcb1cso77461515e9.0 for ; Thu, 02 Jan 2025 13:18:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735852704; x=1736457504; 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=bIbguNzGlLeMSVI5iz/yTsatznjZcvdQ/dAtnbN8W3c=; b=KIWFU74kUx1auKAcj/h6v6VX/DhOumxduc+oBqgMqngumvijiytEr8L2ZL30Niq35+ 7bMRCsZQbgQa1pifoLZBjY4ZOSI5Tr+s3y8gg2xZUlw8wari7lO85ioHUjrpOkW8+LxB BUTIXPY5jmCHAe/3amYhz+5ZPMi9lYc1Y9O8DpZLTZGEaSCtfuSV9+nTnrqI97Pon5Xm E9E+SRwzqvqSWbZmt4j61sMkHSXl2x7k/UGVeS+9PjQhN2XGo1hfFEUIR8NGiVOP3ZWc Y0s+5U4RFMX1XAXlEiOIJPeq8f0f6zvTNsaVrkTz90FYYVSgFjH8OE5Ni7ns8dH+AOoc +t3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735852704; x=1736457504; 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=bIbguNzGlLeMSVI5iz/yTsatznjZcvdQ/dAtnbN8W3c=; b=UJ92PMLFxtvRkBOx1bp22e3p9vWzVpazpjbRZBPHK1Qy9qO2u+vIn3Ohz89p4yCiy9 2TDghHkfyaWC1QwzCnOCfvuwvuqwWzT041mqkpoEEbuaQ/c4RvyBimGRNA3VCkc+kDuC iHHiuLoECjYW3CHCRvxQfA2ea3wKiuGKznyA2X65+OHdk2r87DlgsSo7WkZzPW2sWKMp yG5mIrxbatdqV9RcVa3UAm6V00i+/niBx9+WLKuCDJrQpv+JcVNPyYX6sm8ul9SAOJ/c YMAHIct/qhD8KA/mLHZWsrCSl926p7jFgv1ZIJaCtajAzU0rjWEj22CeYjVfStAQU0zl 7yoA== X-Gm-Message-State: AOJu0YxKNRqvcM7HKCRv8A9MS4EWkJHfV1AKG7ULf7lBiB3oxj77Ucu5 bJGKPS8Q5TOjse2XZCehJOzxfg+Yc6o1GqBAdgul5K5PrtU3GiZWQ3KTkqhgJa9ODPD84MP5UVl e35YfAQ== X-Gm-Gg: ASbGncuH3gVYXy6yGgvMQTwrNBj8rJRMnodjLjddOQe6RJF59o9ryzwZh2gfeAv5azb uVpAatIRYomPWSIXpW1DTK++qQQaYABhUDg5mQmA2lsXjXYludxKK5dUeNrHOlXUxkqwkXfkzli eXoGw1n6NZS3tgfg8QfvsMVSO4wint5vOjh4glr0WHoCTFLCjxmYugCD+nsyBi5HpH8A2L6r+vH O4ZtKPv6shCaJsKValZzgmW1Hi8Y3sCW+N+wS9EW01viIl5dy2o3sI6dvKcrJVzFwjLXjl/DgWi Dws3ONTTv343mKDjCSLw0/nwkQd03zg= X-Google-Smtp-Source: AGHT+IFdU+AKQGMhxuE/mm/2/UPcTBOoY/qUZrm5EoNC5Agaz5NHMksitRvlIexe0sgQS0AuRIFBBg== X-Received: by 2002:a05:600c:1f85:b0:434:f2f4:4c07 with SMTP id 5b1f17b1804b1-436686464d9mr437207185e9.15.1735852704363; Thu, 02 Jan 2025 13:18:24 -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-38a1c89e528sm39511607f8f.83.2025.01.02.13.18.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 13:18:23 -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 4/8] qdev: Use machine_get_container() Date: Thu, 2 Jan 2025 22:17:56 +0100 Message-ID: <20250102211800.79235-5-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::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 Use machine_get_container() whenever applicable across the tree. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20241121192202.4155849-11-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/core/gpio.c | 3 +-- hw/core/qdev.c | 3 +-- hw/core/sysbus.c | 4 ++-- hw/i386/pc.c | 4 ++-- system/ioport.c | 2 +- system/memory.c | 2 +- system/qdev-monitor.c | 6 +++--- system/vl.c | 3 +-- 8 files changed, 12 insertions(+), 15 deletions(-) diff --git a/hw/core/gpio.c b/hw/core/gpio.c index 80d07a6ec99..6e32a8eec61 100644 --- a/hw/core/gpio.c +++ b/hw/core/gpio.c @@ -121,8 +121,7 @@ void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n, name ? name : "unnamed-gpio-out", n); if (input_pin && !OBJECT(input_pin)->parent) { /* We need a name for object_property_set_link to work */ - object_property_add_child(container_get(qdev_get_machine(), - "/unattached"), + object_property_add_child(machine_get_container("unattached"), "non-qdev-gpio[*]", OBJECT(input_pin)); } object_property_set_link(OBJECT(dev), propname, diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 9973e029ffa..cfdb7beca24 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -476,8 +476,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp) if (!obj->parent) { gchar *name = g_strdup_printf("device[%d]", unattached_count++); - object_property_add_child(container_get(qdev_get_machine(), - "/unattached"), + object_property_add_child(machine_get_container("unattached"), name, obj); unattached_parent = true; g_free(name); diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index e64d99c8edf..9355849ff0a 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -65,9 +65,9 @@ void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc *func, void *opaque) }; /* Loop through all sysbus devices that were spawned outside the machine */ - container = container_get(qdev_get_machine(), "/peripheral"); + container = machine_get_container("peripheral"); find_sysbus_device(container, &find); - container = container_get(qdev_get_machine(), "/peripheral-anon"); + container = machine_get_container("peripheral-anon"); find_sysbus_device(container, &find); } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 71118765884..9334b033f65 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -463,7 +463,7 @@ static int check_fdc(Object *obj, void *opaque) } static const char * const fdc_container_path[] = { - "/unattached", "/peripheral", "/peripheral-anon" + "unattached", "peripheral", "peripheral-anon" }; /* @@ -477,7 +477,7 @@ static ISADevice *pc_find_fdc0(void) CheckFdcState state = { 0 }; for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) { - container = container_get(qdev_get_machine(), fdc_container_path[i]); + container = machine_get_container(fdc_container_path[i]); object_child_foreach(container, check_fdc, &state); } diff --git a/system/ioport.c b/system/ioport.c index fd551d0375e..55c2a752396 100644 --- a/system/ioport.c +++ b/system/ioport.c @@ -258,7 +258,7 @@ static void portio_list_add_1(PortioList *piolist, object_ref(&mrpio->mr); object_unparent(OBJECT(&mrpio->mr)); if (!piolist->owner) { - owner = container_get(qdev_get_machine(), "/unattached"); + owner = machine_get_container("unattached"); } else { owner = piolist->owner; } diff --git a/system/memory.c b/system/memory.c index 78e17e0efa8..b17b5538ffa 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1238,7 +1238,7 @@ static void memory_region_do_init(MemoryRegion *mr, char *name_array = g_strdup_printf("%s[*]", escaped_name); if (!owner) { - owner = container_get(qdev_get_machine(), "/unattached"); + owner = machine_get_container("unattached"); } object_property_add_child(owner, name_array, OBJECT(mr)); diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index c844f538025..7f4a1f5083b 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -348,7 +348,7 @@ static Object *qdev_get_peripheral(void) static Object *dev; if (dev == NULL) { - dev = container_get(qdev_get_machine(), "/peripheral"); + dev = machine_get_container("peripheral"); } return dev; @@ -359,7 +359,7 @@ static Object *qdev_get_peripheral_anon(void) static Object *dev; if (dev == NULL) { - dev = container_get(qdev_get_machine(), "/peripheral-anon"); + dev = machine_get_container("peripheral-anon"); } return dev; @@ -1098,7 +1098,7 @@ static GSList *qdev_build_hotpluggable_device_list(Object *peripheral) static void peripheral_device_del_completion(ReadLineState *rs, const char *str) { - Object *peripheral = container_get(qdev_get_machine(), "/peripheral"); + Object *peripheral = machine_get_container("peripheral"); GSList *list, *item; list = qdev_build_hotpluggable_device_list(peripheral); diff --git a/system/vl.c b/system/vl.c index 0843b7ab49b..20e0eaf95ac 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2137,8 +2137,7 @@ static void qemu_create_machine(QDict *qdict) object_property_add_child(object_get_root(), "machine", OBJECT(current_machine)); qemu_create_machine_containers(OBJECT(current_machine)); - object_property_add_child(container_get(OBJECT(current_machine), - "/unattached"), + object_property_add_child(machine_get_container("unattached"), "sysbus", OBJECT(sysbus_get_default())); if (machine_class->minimum_page_bits) { 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; From patchwork Thu Jan 2 21:17:58 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: 13924963 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 13658E77188 for ; Thu, 2 Jan 2025 21:20:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTSaV-00047Q-Ji; Thu, 02 Jan 2025 16:18:39 -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 1tTSaU-00047A-D2 for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:38 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTSaR-0001QG-Q8 for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:38 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43621d27adeso81275625e9.2 for ; Thu, 02 Jan 2025 13:18:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735852714; x=1736457514; 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=4ko8bxyqNd4qTqbyGca0rSHQuh29/RSksetMq0xif/o=; b=bs6r9XfI9CPAGKRy6+ILYPYHxbmEEC3UgiIem5zOC6jM76HybTZKvihTc4BQwE0Gm1 C/ILfZ7V35eXIuB07AfSP69uKjpojMNPsO1t2LXX/WsqFyml8NhvhH1b3ceVE6pDCWu/ MqvV+8aImpp7PYjCWvkSLQzmtxMeKUSqWcHu7LfNq8/yMRAtfWm/opyqJ6zfmHkfrSTT j58qwJaE3pQqylmyvMHLF+/PDXa9SaOwcrNBOYX2+82oFVuC2Sv4benBnBuUoJc13Cov Kg9Q99X6dEUfIhJFzWanYvFzOh058Oyw7lV9iF0IYeeqbiU2LeWeBSIw7ZkXccp/Oi+X inpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735852714; x=1736457514; 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=4ko8bxyqNd4qTqbyGca0rSHQuh29/RSksetMq0xif/o=; b=cXyWS1OBY5MusQnohn+YJrOtWJmB5oA3yKmtP3e4y/jp/MJjeksyjJri54rKl0PqSt SmRZfsT3W0uHvyO6Mn911yGrtWZeVN0N0eMxVNgpBGW2TtzTE2x02PJJxOz3WfAAx70A BQ28tHWqpYNOFtoX6XFVVmuTHq1Z3l60ZY4Nqcyh+O3O+PJUZ4P9KrVre4xL3HINH/tq oEz5Jb+J8ZAtUZNQPT2tb2W4A/YpbtPv8lY8ICEl6YZoUxaZPO8Znp0PaWHUj7SiLGdb VVHSxfN7ftrnQ+ypXxJcuO+ogSyHCptSH8/cSoYu8is5VDqNmfXgiovEHvEP1vspewwv e62Q== X-Gm-Message-State: AOJu0Yz10ehBcI5ebKX9qfdSCfGVJXqHlHgSbN41856WyYHohpszJaq0 v646hv1na9mUWO2xUx44QoURY6Ftf/Q4fRe9zwIdylqBaoTstPJCr3ODDZU1vP1Jczu6XvPJhJz C+022xQ== X-Gm-Gg: ASbGnctJN32FHT9gbfPst4WpO7tyeZZZxI11cFykdOglxxcHVFJPA3gZAcIbUp86RZA 4MmvCXN745cPPwUZsBPuhXwFdPg9U2Dn62uhh3AYYTWhRNRsK+EiC5Bg8udcEIlsfAroiLzwooX CQ19fX6uTH7/LnVOA7BN+C6LhpO/2gISG4dkClV/n2t+WwXG/CZXGs0n3csVQYdGRUEcdIdX6KI 6fqb/3DuXHL6nxWix5sHM8VczQXtUHw1UEvBD7QSYBrB8caGYe3xoaD7b55naYasvO35fkROJEw CvT6EfnB1qzQsNqLtvJdxKwp+bNq1rM= X-Google-Smtp-Source: AGHT+IHeKD+EqwcEplzZNb4Fx7FdqR28a2/UvMfDlfXCtQwz9iMGcCqmZMXsgJk/chSJt/DlBh8IeQ== X-Received: by 2002:a05:600c:350c:b0:434:fdaf:af2d with SMTP id 5b1f17b1804b1-43668b7850emr412736405e9.30.1735852714118; Thu, 02 Jan 2025 13:18:34 -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-38a1c8acabbsm38725112f8f.93.2025.01.02.13.18.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 13:18:33 -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 6/8] qom: Use object_get_container() Date: Thu, 2 Jan 2025 22:17:58 +0100 Message-ID: <20250102211800.79235-7-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::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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 Use object_get_container() whenever applicable across the tree. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20241121192202.4155849-13-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- backends/cryptodev.c | 4 ++-- chardev/char.c | 2 +- qom/object.c | 2 +- scsi/pr-manager.c | 4 ++-- ui/console.c | 2 +- ui/dbus-chardev.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backends/cryptodev.c b/backends/cryptodev.c index 1157a149d02..1187b08dacf 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -97,7 +97,7 @@ static int qmp_query_cryptodev_foreach(Object *obj, void *data) QCryptodevInfoList *qmp_query_cryptodev(Error **errp) { QCryptodevInfoList *list = NULL; - Object *objs = container_get(object_get_root(), "/objects"); + Object *objs = object_get_container("objects"); object_child_foreach(objs, qmp_query_cryptodev_foreach, &list); @@ -557,7 +557,7 @@ static void cryptodev_backend_stats_cb(StatsResultList **result, switch (target) { case STATS_TARGET_CRYPTODEV: { - Object *objs = container_get(object_get_root(), "/objects"); + Object *objs = object_get_container("objects"); StatsArgs stats_args; stats_args.result.stats = result; stats_args.names = names; diff --git a/chardev/char.c b/chardev/char.c index 44ff116fcda..7705da5ad02 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -48,7 +48,7 @@ Object *get_chardevs_root(void) { - return container_get(object_get_root(), "/chardevs"); + return object_get_container("chardevs"); } static void chr_be_event(Chardev *s, QEMUChrEvent event) diff --git a/qom/object.c b/qom/object.c index 81c06906d30..58897a79a76 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1774,7 +1774,7 @@ Object *object_get_root(void) Object *object_get_objects_root(void) { - return container_get(object_get_root(), "/objects"); + return object_get_container("objects"); } Object *object_get_internal_root(void) diff --git a/scsi/pr-manager.c b/scsi/pr-manager.c index fb5fc297309..1977d99ce0d 100644 --- a/scsi/pr-manager.c +++ b/scsi/pr-manager.c @@ -21,7 +21,7 @@ #include "qemu/module.h" #include "qapi/qapi-commands-block.h" -#define PR_MANAGER_PATH "/objects" +#define PR_MANAGER_PATH "objects" typedef struct PRManagerData { PRManager *pr_mgr; @@ -135,7 +135,7 @@ PRManagerInfoList *qmp_query_pr_managers(Error **errp) { PRManagerInfoList *head = NULL; PRManagerInfoList **prev = &head; - Object *container = container_get(object_get_root(), PR_MANAGER_PATH); + Object *container = object_get_container(PR_MANAGER_PATH); object_child_foreach(container, query_one_pr_manager, &prev); return head; diff --git a/ui/console.c b/ui/console.c index 5165f171257..914ed2cc76b 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1160,7 +1160,7 @@ DisplayState *init_displaystate(void) * all QemuConsoles are created and the order / numbering * doesn't change any more */ name = g_strdup_printf("console[%d]", con->index); - object_property_add_child(container_get(object_get_root(), "/backend"), + object_property_add_child(object_get_container("backend"), name, OBJECT(con)); g_free(name); } diff --git a/ui/dbus-chardev.c b/ui/dbus-chardev.c index 1d3a7122a11..bf061cbc930 100644 --- a/ui/dbus-chardev.c +++ b/ui/dbus-chardev.c @@ -106,7 +106,7 @@ dbus_chardev_init(DBusDisplay *dpy) dpy->notifier.notify = dbus_display_on_notify; dbus_display_notifier_add(&dpy->notifier); - object_child_foreach(container_get(object_get_root(), "/chardevs"), + object_child_foreach(object_get_container("chardevs"), dbus_display_chardev_foreach, dpy); } From patchwork Thu Jan 2 21:17:59 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: 13924959 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 06314E77188 for ; Thu, 2 Jan 2025 21:19:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTSab-00049f-5N; Thu, 02 Jan 2025 16:18:45 -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 1tTSaZ-00048S-RF for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:43 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTSaY-0001Qe-AA for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:43 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-386329da1d9so5377158f8f.1 for ; Thu, 02 Jan 2025 13:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735852720; x=1736457520; 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=X072cNLxlYU70g0aPAnHdJmyEbpQKTIAoLkN1KVyvsY=; b=VdD5b2MTwqOzkcwx3Sf8KbVcivw3vPR8i2H9JzrTz0JwevpNdKlTfPMqk3FAJIAVqD lC9IjU4KXtAG8i/cp9QBgPrYcc40LziBsKi2fOV0IJ9kjOzlhBFtyoyv+aXWxj4+BzB6 YpqMTe2a6HnI/7KWpQZvSVMVx49E5rpNncavJmsBeT1/pG5BRl8gU3hTBqByFAFIAZtk VYABK1nU1mgHihHsKivbUsX841Taf7OlkZAM2kCFSbDDO4sA+QRrkip65iGyhrvBZOZA CAlzCOQSJiwWxZJRQGxrnNTXu+nsfPvlQCaf3+wMwL0q+LSdUzAvpGF5AP+91zkx4b6P acuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735852720; x=1736457520; 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=X072cNLxlYU70g0aPAnHdJmyEbpQKTIAoLkN1KVyvsY=; b=mAqL3nqQbhVaC8NnT4c1hgjjjGsrgsD/vsgz/D/Yta7TuSSBO9pjgLNSE2TC3jouYJ nNYQVMc59Ujjj4Got577XfodtzYGzEEti8CH699AYXCjBm/KNjkLsmJ/8YbGK+zL8L8K 488b1ahfEoEwWW0nx/CW+C5mkgTMnXQ0HCcZBl2TPG6rKpwGOXOkczGtPlTn4sLpuKGW AF5fUo4NBQKkzh/r0UawF5pyFIYbK+mo+4fBRzXmWHlLxCvaxMy8bAM8h1rrnEIW+/69 mLpCA8GE7lEr9P0A0Oonh/UttQLnqlgmmVOMEbBJRbJzzaNSjtu2By7vjSFeruPFKL1j uduQ== X-Gm-Message-State: AOJu0Yxly4H5sxc3dMuJZ/VS709ZJ6twc7KH43hoCfD5y6NGMZ2pQSFL HvlXTedNtgmyDF4pHRIL8woskM0y3jan19U7hNNbFyfUXAcO8Q4QqF4/FtHJDVJXu/GcNjqwWze C22F4kQ== X-Gm-Gg: ASbGncvgaf92OPC26U/Xygsd7OcwEY1wRvz8he8Om9KQPVz/iTukjloegKC1t+Lqmgs 3bMtItAMKd5GoyvtVyVm9uN9OA9QK4hQV0MYXkbn6gNquObWyzmuguojp1LxRChF6yDf0ye8iLo rfHglItdLbOTAimMdce9wsTYzhSUBJqeCVAVpB/s8mXH9oCWkPCDTeiZyx+4WzTne4KLNI0hffj MRjFsRwCgfNHUf5gt76zz5ZOaGi6gl8ARk9KF08VKgQZeTNV+Mco35pg0SqC6uICc2arFQQwR2s o4qVrvDf44uqgQh4bnLgfM+FwQF3Beo= X-Google-Smtp-Source: AGHT+IFktdjjUzUBETKV9PyuXkCREZ3c3g+nxlKsHbj9nwq6FsyN1dPaFpF5Gb7QuNkcttZGCo6slg== X-Received: by 2002:a05:6000:2a7:b0:385:ef2f:9282 with SMTP id ffacd0b85a97d-38a221f321dmr44804791f8f.5.1735852720584; Thu, 02 Jan 2025 13:18:40 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43661219a7csm460601325e9.24.2025.01.02.13.18.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 13:18:40 -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 7/8] qom: Remove container_get() Date: Thu, 2 Jan 2025 22:17:59 +0100 Message-ID: <20250102211800.79235-8-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::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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 Now there's no user of container_get(), remove it. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20241121192202.4155849-14-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/qom/object.h | 11 ----------- qom/container.c | 23 ----------------------- 2 files changed, 34 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index bcf9910b42c..77935572894 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -2017,17 +2017,6 @@ int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), int object_child_foreach_recursive(Object *obj, int (*fn)(Object *child, void *opaque), void *opaque); -/** - * container_get: - * @root: root of the #path, e.g., object_get_root() - * @path: path to the container - * - * Return a container object whose path is @path. Create more containers - * along the path if necessary. - * - * Returns: the container object. - */ -Object *container_get(Object *root, const char *path); /** * object_property_add_new_container: diff --git a/qom/container.c b/qom/container.c index 20ab74b0e8d..38a27ec1edd 100644 --- a/qom/container.c +++ b/qom/container.c @@ -34,27 +34,4 @@ Object *object_property_add_new_container(Object *obj, const char *name) return child; } -Object *container_get(Object *root, const char *path) -{ - Object *obj, *child; - char **parts; - int i; - - parts = g_strsplit(path, "/", 0); - assert(parts != NULL && parts[0] != NULL && !parts[0][0]); - obj = root; - - for (i = 1; parts[i] != NULL; i++, obj = child) { - child = object_resolve_path_component(obj, parts[i]); - if (!child) { - child = object_property_add_new_container(obj, parts[i]); - } - } - - g_strfreev(parts); - - return obj; -} - - type_init(container_register_types) From patchwork Thu Jan 2 21:18:00 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: 13924957 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 D5A87E77199 for ; Thu, 2 Jan 2025 21:19:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTSaf-0004Nn-VK; Thu, 02 Jan 2025 16:18:49 -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 1tTSae-0004Js-Im for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:48 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTSad-0001R6-3E for qemu-devel@nongnu.org; Thu, 02 Jan 2025 16:18:48 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-38a34e8410bso3695298f8f.2 for ; Thu, 02 Jan 2025 13:18:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735852725; x=1736457525; 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=kDI3lCD1sPhDvWQCISzoMNySRhiCGgE2MRu1ybe3Kgc=; b=yA6ZT4lsDGCgd3t/lXcg8mo6FbFDr3qXU3I39hihpc/gLHEzqKljFIzvqsa76o5ivi Uvv/dlTq8IQS7QJ22nCLbCi/8PMHASEtol0mVwRujiQ4a8jAqO/S8A93+cyohegMaFLE lqDjcQGhMsMDYTcF6XpgcSyq1/vlwELPbcdq5lf9+jM6m0dz4mRlyL5CnGgtmTeEv6Ao 0fGHTFsP1vIP3bWsVCDOOU0pLN4qIqqttS2wuIqzaN4pvkudhiBYmlry1BnKMLcnIRHW aCy5XKv3LrEyeIzv82dY4e+flpv11djTH2Qf5KMl0kupy+IQ3R4vLcw1YJpz/NuPgVyt fAdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735852725; x=1736457525; 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=kDI3lCD1sPhDvWQCISzoMNySRhiCGgE2MRu1ybe3Kgc=; b=w7EEcZCOrkZl/cMGURCm3k1hL7NsDx3C0L9bKUUC/hVb4OcIWhivM1Hu7xhPwPOIks 0+Pk56jTTmvn8gEjoWzZetxuCr1nV7rBM54Z4RsTPJJqcOHX4cOv+QP3b1G5StAaY61F LdqdPJNppGZ9Dn8V4XlBe1RQD+KVdfysjgltKRMiGwk08aZEsMpUCh+hCJUAD3nP3gYT PjztqXJGc7Zzzm+DarZUcM8bCCDVxnAVxBCWZJmZjnDLsb+GnyNykxhMLmXFpIwBpKjW sgZLNbQPhNGtMojwOwvQrTR9be6EiJn4qTwxaPayC2YkO7oHnaHeFOiF3CohHZseyg46 vQBQ== X-Gm-Message-State: AOJu0YxcgQXXtp89zk0oPpSVQvXWPSEsyaB98/JuenF26Gpp+vSIx8By XvthR6FmLAqSHDUGOoVD1zwuPGv8KFJxiuIwh5CM4SknQNUk80StlBlzRsxF7hvzQXS4rEtn7SU D5AS0Qw== X-Gm-Gg: ASbGncvPIfPreaUEhGBhL/zl2lu3NzNpYTIH/5u1pG0S5XQkOhjkCNDgGhORBS10bZy Nh/VS5XPqlYWbLaAZgHXD+Hh9x2hC8d9MSQ8I3RUbp0MMqz/V9FwnEguaBSijy2SOMiDdbamEO0 ZDBvW7AFrOWbxQow9WrsHwr5fHd+4JNvxl07NA2zmTCZZ/x7e5WVUQZI+31Mbvq4Dvd+6CRkcWk 7hSwGKmFZTxv5Hu0q56RcTdLm2NOyFa+tWA4GcGbp/JW6P0NjHEdpHuXAFyC4e0sRxH0XSxTQMR uI2ZILoSdClrQ8ak/OL1/0G9uWQfUQo= X-Google-Smtp-Source: AGHT+IGVqfWMXOa8PWWxT7VDpGVEh5nDlTlhMEJ4cZk/eo5r036XGZvq+eeNOm7o+8KIKJx/sDlFzQ== X-Received: by 2002:a05:6000:3cd:b0:386:1cd3:8a03 with SMTP id ffacd0b85a97d-38a222009camr33679904f8f.32.1735852725465; Thu, 02 Jan 2025 13:18:45 -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-38a1c89e140sm39906532f8f.79.2025.01.02.13.18.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Jan 2025 13:18:45 -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 8/8] system: Inline machine_containers[] in qemu_create_machine_containers() Date: Thu, 2 Jan 2025 22:18:00 +0100 Message-ID: <20250102211800.79235-9-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::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Only qemu_create_machine_containers() uses the machine_containers[] array, restrict the scope to this single user. Signed-off-by: Philippe Mathieu-Daudé Acked-by: Peter Xu Reviewed-by: Richard Henderson --- system/vl.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/system/vl.c b/system/vl.c index 20e0eaf95ac..0768f93f9f1 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2113,18 +2113,16 @@ static void parse_memory_options(void) loc_pop(&loc); } -static const char *const machine_containers[] = { - "unattached", - "peripheral", - "peripheral-anon" -}; - static void qemu_create_machine_containers(Object *machine) { - int i; + static const char *const containers[] = { + "unattached", + "peripheral", + "peripheral-anon", + }; - for (i = 0; i < ARRAY_SIZE(machine_containers); i++) { - object_property_add_new_container(machine, machine_containers[i]); + for (unsigned i = 0; i < ARRAY_SIZE(containers); i++) { + object_property_add_new_container(machine, containers[i]); } }