From patchwork Thu Jan 9 17:19:38 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: 13933018 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 C010DE77197 for ; Thu, 9 Jan 2025 17:20:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwCQ-0002Ep-A3; Thu, 09 Jan 2025 12:20:02 -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 1tVwCN-0002EO-Hf for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:19:59 -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 1tVwCL-0000ab-Mg for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:19:59 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-43623f0c574so9707295e9.2 for ; Thu, 09 Jan 2025 09:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443195; x=1737047995; 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=/Q9jLlzxL8Ky1CJr0jutwQaeChtyLfFwACEyWiRFh40=; b=irH9t4Co6pOxpFCOCF/IhakaPR1LEoAdPcdxmwaq/K/ucONvE2PLblkDO0Qj0cVN6q vkaVw5y/GLJWx34Tnl0gq1Syk8WSoyu3drxFxWsxpodAfddt5WbBNSZ+ng+yoZVpNOiI 7eRNOKMzjUa6CSbjPMOy+O2yHKauOIUlqrorzlSXjk0jrVG+6XUtnSXtULqKa6Qergew IbUEEjnBSI+/sEmv8KdnbQaGhRdrlnBMlpJmdRKJLm7+QRi3R02ccR0+C8zNHgbU00ht dSM3RlvQiFJnE6XzUVBAXTF6hPEVHzYE1vodYJreKvgGovN7NfiuNTZIGISHhXqTS1ZZ n4iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443195; x=1737047995; 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=/Q9jLlzxL8Ky1CJr0jutwQaeChtyLfFwACEyWiRFh40=; b=qUI5EYpV5Ltc51rgMIJEeXd1M7aMP5nJFLZFowYB4FZVcF54jgk1zNMjqLWIKHYUfy 7JNOJVABKIU+1v/euCa9gXtZwKU9+MOQwZEsCpqJjGMrUFTyGmF1wwfUR/I49+qmwRLz mnkbBS5ttin+UGXmVr2m/Zp2idLoe2I4jScsIlLuClJ0FEMAt16XYsJ6yNQhTCET/i9H dFB3sJr86af2cDugyIpoAt1ldABC/ohVeGrfA8gv4uB+naijWzT6iyr7hEJGoG4PiJsA ZwTo96zTto578E06zT32K7AYjZ9vid6ghOaZ2jODwrxC/t6TLOisLPcdEknoj0JR9k1k +AyQ== X-Gm-Message-State: AOJu0YxBpgmeyDBPgFrEbnlo75I7WCOwwAaQe4oIiYDQvUpSWEF0G/rk 5ipEWtUwTDJAgcs6LGmZ+e9ZA8lm9GbNUPk0WJoYrea0az1OzzxJ0p33NjMYVYZT4b7ovBf94kK /hbU= X-Gm-Gg: ASbGncsdwsJIvfAkcJpANnHVy93SghIGY8JOewIvTuDnSrjIqgxZwQmnRgBYtkyUOW/ Xmp/S1sLUqfyXesruyRocfBaX2nBiIApyu6Lhw6morGFiOrDHz85+9Bzow05g56I5NezcF+9HVE KLXADgZCvk1TTnSxfq6PmGr3rHPsOePlBHkKdhs+QYt09QeAfIjtZZ/WGfMknINS1rpK4ZILers jw+OPxrfXPQ76uvPxKAFK6JdydoSOB8Htm+KUs3GIggjIrHcuF8tQWBeBk2LW8vwFtSbYWLlkzw GzaewqrnSYlZgyiG8A6N+Z8Gqx0qBZD8ci2R X-Google-Smtp-Source: AGHT+IFIhoeE0zWkqWg5VfuT8yphcMYFOvW9uduyHsvWaejxfY1gFpAWaTMQTsVTUzkR21X8pUkzEA== X-Received: by 2002:a05:600c:3505:b0:434:a7b6:10e9 with SMTP id 5b1f17b1804b1-436e26a9045mr74163005e9.17.1736443195346; Thu, 09 Jan 2025 09:19:55 -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-436e9e37d74sm26954385e9.29.2025.01.09.09.19.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:19:54 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 01/11] hw/pci: Use -1 as the default value for rombar Date: Thu, 9 Jan 2025 18:19:38 +0100 Message-ID: <20250109171948.31092-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-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=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 From: Akihiko Odaki vfio_pci_size_rom() distinguishes whether rombar is explicitly set to 1 by checking dev->opts, bypassing the QOM property infrastructure. Use -1 as the default value for rombar to tell if the user explicitly set it to 1. The property is also converted from unsigned to signed. -1 is signed so it is safe to give it a new meaning. The values in [2 ^ 31, 2 ^ 32) become invalid, but nobody should have typed these values by chance. Suggested-by: Markus Armbruster Signed-off-by: Akihiko Odaki Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250104-reuse-v18-13-c349eafd8673@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 2 +- hw/vfio/pci.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 8eaf0d58bb3..16ea7f4c19b 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -148,7 +148,7 @@ struct PCIDevice { uint32_t romsize; bool has_rom; MemoryRegion rom; - uint32_t rom_bar; + int32_t rom_bar; /* INTx routing notifier */ PCIINTxRoutingNotifier intx_routing_notifier; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index b6c630c3236..78907527f2e 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -85,7 +85,7 @@ static const Property pci_props[] = { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX), - DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), + DEFINE_PROP_INT32("rombar", PCIDevice, rom_bar, -1), DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present, QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false), DEFINE_PROP_BIT("x-pcie-lnksta-dllla", PCIDevice, cap_present, diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 17080b9dc0b..ab17a98ee5b 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1012,7 +1012,6 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) { uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK); off_t offset = vdev->config_offset + PCI_ROM_ADDRESS; - DeviceState *dev = DEVICE(vdev); char *name; int fd = vdev->vbasedev.fd; @@ -1046,12 +1045,12 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) } if (vfio_opt_rom_in_denylist(vdev)) { - if (dev->opts && qdict_haskey(dev->opts, "rombar")) { + if (vdev->pdev.rom_bar > 0) { warn_report("Device at %s is known to cause system instability" " issues during option rom execution", vdev->vbasedev.name); error_printf("Proceeding anyway since user specified" - " non zero value for rombar\n"); + " positive value for rombar\n"); } else { warn_report("Rom loading for device at %s has been disabled" " due to system instability issues", From patchwork Thu Jan 9 17:19:39 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: 13933016 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 2CA61E77197 for ; Thu, 9 Jan 2025 17:20:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwCU-0002Ib-VK; Thu, 09 Jan 2025 12:20:06 -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 1tVwCT-0002HS-FQ for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:05 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVwCR-0000bk-Dn for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:04 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-38a8b35e168so791731f8f.1 for ; Thu, 09 Jan 2025 09:20:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443201; x=1737048001; 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=vk41Fdbmt4kvm6C2wIMyLOfMKTEmUCUG4l8SIJbTN28=; b=GF4TXF0yhS0GCLBjE+DDN3JgAAALPqQF+hdmuDOlNNbSw1wlT+q7LGoBuYTeTS0Yr7 OPVyMO8KM4yVm9BdyOLTlBzEZun8Dxu84DeQTh8Dn2KRIGBICpBKf7VpImkl1Tks/ka/ t2MKz5avUvrXrhjCEIRIfg188uT8Yr72JLw+52s0sHjq/K7DwiWA3tQzbNYoeSawp/bb nhiX+vOqK1+XA1PWnbvuJb7hcoxRcrwPuWsCgBa2epStZsQlvmRwUrPyLB3xSLe5GAjj 5Ahp5nj3Hnf++b7jLO/Lfr7GkpyD/94+06qCtVfzva4TApMRzJ6qqmzIVaz5/9HgQL96 McEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443201; x=1737048001; 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=vk41Fdbmt4kvm6C2wIMyLOfMKTEmUCUG4l8SIJbTN28=; b=qL7ObRLV+ayDnjXrD9JojDJC/ZKNeLBrxPbCBWU5mNaQc2yGaduxGQcYwaWiTAtmZx wmBAtmgEPucapHrUb0pu5rUaGbSIm/R8wJrh/M668XgNlc0dgB9GONbcesmiJaPI2vLQ l9Mr5cL/JW8U/HaxcrpKO8NXcQhy099vn1mbFthbemfNSc4mI7XHvD5zeSay4w4liHIO NQjj6L31Yy6xXw1vvqQ3JyG769jLDIWePmsXREWIgx3hMF+pvcnNrOJkqwtKFimZpFNe eMn6VzD6V4TfRG/AHmJ5054r3Vq/+6JEl9jghz76H0IfxPyOx3kBzhFTfdlfpOLkq1z3 m8SA== X-Gm-Message-State: AOJu0YxvpCoA4BOkTKMorPpH8m5BonaqX4lEMqHaJjVMRLddFlncO8l2 PvzB8rLxYUO+P3Ff2GMnkS+8omAaXUSmQwtfFeWe96EWKWd/lzFeAKNIl7nQCph5iMXvNtEgk96 HgsM= X-Gm-Gg: ASbGncv7cyDFW6/KK1mUVIYEJTxi40pMyDCIvSd81IhsnplIoIiY0aJKUsiehI85obM yumZDIydXix3c7hoNaM6j3+cg4JuxVoAACyyWO0Nq+2UdLN3qVeBA4mtl2m39Wi7TFveRH+0JPr K0eiwGZlBdj7xQ0bfypX+uQFDZzzFuwTLAtBqcGXDfV42JkIoxhy+J/gJtcNbuhl6efmiGf5CKz VjT/C5C9ROx+oH00UpxmxkWpoDtzkdfumSZMseCoq+JrcG1WJ0sG0VPVG4406QkN2JkCiZjyy1h KH4yyZU4ZJu8TJJ57297DJy+K/Fq8RSAYc+S X-Google-Smtp-Source: AGHT+IHAuzPivzlPebHg8AsqBSkDnohRC0UqTfTP5nzc3x3Lt8jf/Xmqp8L3y/oJw8hvTdNivN0syA== X-Received: by 2002:a05:6000:2a9:b0:38a:88bc:aea6 with SMTP id ffacd0b85a97d-38a8b0b816dmr3668256f8f.6.1736443200760; Thu, 09 Jan 2025 09:20:00 -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-38a8e4b81a4sm2372032f8f.68.2025.01.09.09.19.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:19:59 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Markus Armbruster Subject: [PULL 02/11] qdev: Remove opts member Date: Thu, 9 Jan 2025 18:19:39 +0100 Message-ID: <20250109171948.31092-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.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 From: Akihiko Odaki It is no longer used. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster Message-ID: <20250104-reuse-v18-14-c349eafd8673@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- include/hw/qdev-core.h | 4 ---- hw/core/qdev.c | 1 - system/qdev-monitor.c | 12 +++++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index e6ef80b7fd0..c4d3dc39064 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -248,10 +248,6 @@ struct DeviceState { * @pending_deleted_expires_ms: optional timeout for deletion events */ int64_t pending_deleted_expires_ms; - /** - * @opts: QDict of options for the device - */ - QDict *opts; /** * @hotplugged: was device added after PHASE_MACHINE_READY? */ diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 57c1d9df3a7..09c4489e3c4 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -691,7 +691,6 @@ static void device_finalize(Object *obj) dev->canonical_path = NULL; } - qobject_unref(dev->opts); g_free(dev->id); } diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index c844f538025..6a38b567876 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -631,6 +631,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, char *id; DeviceState *dev = NULL; BusState *bus = NULL; + QDict *properties; driver = qdict_get_try_str(opts, "driver"); if (!driver) { @@ -712,13 +713,14 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, } /* set properties */ - dev->opts = qdict_clone_shallow(opts); - qdict_del(dev->opts, "driver"); - qdict_del(dev->opts, "bus"); - qdict_del(dev->opts, "id"); + properties = qdict_clone_shallow(opts); + qdict_del(properties, "driver"); + qdict_del(properties, "bus"); + qdict_del(properties, "id"); - object_set_properties_from_keyval(&dev->parent_obj, dev->opts, from_json, + object_set_properties_from_keyval(&dev->parent_obj, properties, from_json, errp); + qobject_unref(properties); if (*errp) { goto err_del_dev; } From patchwork Thu Jan 9 17:19:40 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: 13933017 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 D1FA5E77199 for ; Thu, 9 Jan 2025 17:20:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwCb-0002MQ-Dr; Thu, 09 Jan 2025 12:20:13 -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 1tVwCZ-0002LF-5p for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:11 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVwCW-0000e6-Oj for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:10 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-38a8b17d7a7so656598f8f.2 for ; Thu, 09 Jan 2025 09:20:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443206; x=1737048006; 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=USByRXNnIcm1zr75pvlA/VQ1iSROrZwNJ1I9XsVsaz8=; b=BdJlwGWFoODLVfIRsUpCEsdwJG8DWP5ZCcVQhEconPBJEB5FTWJ2V0nSo7n9CU49u/ jrAj4EWDmoF4HgJlCCjVDOn5DKLFc6cWlJjOoi1GlgdQTrUzn65lPmA+IHefmBpLsRrq cy30zDmqPsj+mGDwf3v0JsecigpO45W+a4x92E92kS+qQxjtNwaGuczlWd7MrDZz9amP /n7hO0U7+VeadGM7LC7tH7lMYFuEihtUabdhsTDhP6uBjXX94yLJOKn1HcpOzWFrsVDh YqW69WuYw4hqHo8MTOVXwKHKX7vu8Rr0URZrfbPegnIrckU+iD7Ngk/zjAEpYYiZDuW8 V3Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443206; x=1737048006; 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=USByRXNnIcm1zr75pvlA/VQ1iSROrZwNJ1I9XsVsaz8=; b=xCcadH1boEaV0DMa9De6zppKpuSvw04N5x2JLgWT19JYVKmPqW/FKKnkV8dAgJKQbh duKn8bFp9b+nQ6nDqcIsJ7c6ldgjnug5c9iw3+8L9iXEuxUHCU2ppOdF7jXhJQYDM/dW dkPexwomH+/09V1JqStmQH31KoOa9t0R7NhR+8m5p0q278M+GMjP8k8xjmq7Ob2PkC28 pkQPQ+k7aamj20boo8xTeCt5wLsBz/0OgTL8ik8cogP2kCi3p6kYnLGOVi7gZ4PhLdmD /4mcwGQPJIr8aeYh2UJ8oCZ6ctWUrmjYCUfctrvFM+ZswucyaY9kty07S11o47weJT89 /B1Q== X-Gm-Message-State: AOJu0YwkXWHiCCWsRY/F5nIiaexgs5K3XTagmGKeiaK+/ht7Xxcex03d TB5mF3Id1N/Z6AFI6ahLkTLpzX2c1p+1JksXMwM7QCA+WSs8Fqu4zSEd8IOVfMGGlbeZv/Gd/nU V9pI= X-Gm-Gg: ASbGncvAzZ+vQFqJf563wKbTWl6g0cSv6va30gJ93p+OGfPpNcXVzpir7/P96980aOm Zl+y2sU08v7jHliHZ4SdsvOSxr/M3DSmDkgxURquH2Sl2uBy7We+smo2FQePSA+rnPB6Yu6Vqtb 8Zu5lU4UAmFy/FSBGd0e8Vlr69QXkGsqXLmLE5TAonbC6Vo3hxWSPFUva/DzRuIcZujrmV0s9hn b36yYu6sJKqG9gZiS1CIjJK1LrAszVmsjYBy5Qt56gC/1pwEsYwHrqhNWukMlEVPrnKTqA8kOQY TncOcWEg+C5Cjwjy8Qy0NzWpVjKR5C9+cnNa X-Google-Smtp-Source: AGHT+IF+v9r7ePdpxEeqC3PjtWfvZ/u00EgEEc1Xd8cESZ71xEWTIk8RRfI4BJeteX4idN2TmMn8yQ== X-Received: by 2002:adf:c08d:0:b0:38a:87cc:fb2c with SMTP id ffacd0b85a97d-38a87ccfc17mr4578783f8f.18.1736443205706; Thu, 09 Jan 2025 09:20:05 -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-38a9407fd62sm509369f8f.92.2025.01.09.09.20.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:20:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , Richard Henderson Subject: [PULL 03/11] qdev: Implement qdev_create_fake_machine() for user emulation Date: Thu, 9 Jan 2025 18:19:40 +0100 Message-ID: <20250109171948.31092-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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 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 Message-Id: <20250102211800.79235-2-philmd@linaro.org> --- include/hw/qdev-core.h | 10 ++++++++++ accel/tcg/tcg-all.c | 8 +++++++- hw/core/qdev-user.c | 19 +++++++++++++++++++ hw/core/meson.build | 1 + 4 files changed, 37 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 c4d3dc39064..50cbbf81211 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -1023,6 +1023,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. + */ +void 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..3d421d8f4e5 --- /dev/null +++ b/hw/core/qdev-user.c @@ -0,0 +1,19 @@ +/* + * 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" + +void 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"); +} 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 9 17:19:41 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: 13933022 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 A651BE77197 for ; Thu, 9 Jan 2025 17:21:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwCf-0002Oo-5w; Thu, 09 Jan 2025 12:20:17 -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 1tVwCd-0002Mh-SR for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:16 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVwCb-0000ef-Mo for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:15 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361b0ec57aso12581535e9.0 for ; Thu, 09 Jan 2025 09:20:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443211; x=1737048011; 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=qz3bj6rw803M1uR6VsFauScvvIZVsKyPf1NJH8U1zkU=; b=sXVDktixxqNr4foVZKXSnJCiBqZ4xHs81ZNJvYCqr3QcWEJG/BZwHJxT48h/yDUaF1 5gAtyy7PYx0xw2GnjG4S4QEOInAJxAuB+lUEcG8Xi2hpqHu0+i2fqh6wUqsN8qEzlRoR 3WdLnA8mXYP1H6F65OiwTT6PvtUOQIgwFzNWS7vjmJ0Kk3aakH6i2ijvJFeK+GyNI3vg SkFJteVbQ3HFM6oiUmrhGfHH2KqY/1gGYdPz8UuJCDoJZc6WRmrhDXy4Mq+dj3ugikgd kI2/Ddq9R+BDy+WmNTCbu/ibqNIoHIs5RdwsVcwM/oqMlTdKmwUNXLA6qYf4v0pAl5CG qm1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443211; x=1737048011; 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=qz3bj6rw803M1uR6VsFauScvvIZVsKyPf1NJH8U1zkU=; b=ON/3qop5xPEuytB4UOsYLiApTL9e+CtvDxamokYbnqvM7bDMaFhXfC0PPnqSyIOLFw OQS1mnbmFLuwtja7s6dL0Nf7sEZFS5VjfIV5m1u5vptaa9ahWC9WtBCnp7rQyGU8Qu0y 3HqQf77HBKAeMen2TlRng3iX5IxodQU0CzrZzdffr/zAnpizSypibBpYLBtRPDhnTg/G v/w0nkkjWRf0lQ0K1MJu1ZdQPkIKB3Xfh6rhulKkicsnUgxKS+1Rveym17Lby+FPMIz8 ZeWUBPj17SdsprYUf4nAD64pdK5EqmRQR4bIkiJUc4OJjHPlddKHAQWpM2n/Rsnh1R5J TxYw== X-Gm-Message-State: AOJu0Yw9EWE+yPPgz6Mfcvlo1ZE8gMBMJCza68aKNSKTGPOgiB7nhIF/ h7qYgixnyiykrmCYZawHGiyWAS4edq3lpooBAjCoRzFEjY/Julu9HimER9v0WA6VHv38zvWCwGA RHAA= X-Gm-Gg: ASbGnctjHQfVNnnOu5KyqAWbwsBOCXLJJmjBSLbI4BwG2TXbk0s7pD+uLmFvXjHNePU KLo7TGFuvTe07g+cUldMFQr8jJjYaRXqrGMJ4vPnxW1+TyEmjM18EtyYlZwLdKNVd1PQKL14B9I bxplmpdc0J3YGLLtD6+bnrb0na8dP9oyEvT+qJMdxIErHQGojlFiaZqYOZJd14AGqqOgZmY8LfS j9qXyIAWKDCemiRPzNY/KdzeFSKagGkzRgvoCSkAxNhrioauaB/a2dR0u6P+Gbt/rMpdRsnCUGk A8ddS7Z57+t0w2ZeBr/FMiUiMtZny8daRAQI X-Google-Smtp-Source: AGHT+IEXJMYOV1taRVFlCVKzS97GhTEvb0dXWNf7+KUvG8AX4EJQtCcmLDtCNJ1S0re1fipnieSg9w== X-Received: by 2002:a05:600c:3b02:b0:435:1a2:2633 with SMTP id 5b1f17b1804b1-436e26cf8a5mr32814435e9.15.1736443210960; Thu, 09 Jan 2025 09:20:10 -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-38a8e37e375sm2295146f8f.22.2025.01.09.09.20.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:20:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 04/11] qdev: Make qdev_get_machine() not use container_get() Date: Thu, 9 Jan 2025 18:19:41 +0100 Message-ID: <20250109171948.31092-5-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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 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 09c4489e3c4..48bc9a7b9c7 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -817,7 +817,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 9 17:19:42 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: 13933019 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 A76FFE77197 for ; Thu, 9 Jan 2025 17:20:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwCj-0002Qa-Lt; Thu, 09 Jan 2025 12:20:21 -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 1tVwCi-0002QB-0Z for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:20 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVwCg-0000f9-BI for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:19 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-43635796b48so8101515e9.0 for ; Thu, 09 Jan 2025 09:20:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443216; x=1737048016; 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=UYVoLWc90TjSnXBWQnMWyZY22lK6Lc4zmHvaduQQgBs=; b=mWME27ASY++JmgXplutd9EMHhCPY/i/hwiqP6shlsbl8LbMCS1QrkBn4m7cHbXNszn s5x0rTv/ucoHlZqFEcO0bhPdToPcAm2YgcqzhbiFPRIbg3UHqxr+WGmgB1raAQcO9j83 QNP7zNa2O6ozVtSLpRlUMg2/GaKW6mkaJEnuMzAGP15qaRrq76qYh3tdGPf3MYqhV0HO SDH1senFfCPRzL1kZ3SS+J3QLEEv7FihTO58S54/l97R/AQDLzRInaY+1DGhKmV0rVyA n09QPe44nu6MM9xzII++DwujwNqZ6SH/AhdDp6IxlgrIbf59I++bJa7+kP5x8jnTs/bT P2oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443216; x=1737048016; 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=UYVoLWc90TjSnXBWQnMWyZY22lK6Lc4zmHvaduQQgBs=; b=TqMWwrNA+tgmEX9VBVWho6ljZUu78zdlXGchU4T0EEad3VyTc2h9bwdJ9ZJ+fjm5Sd lj1hSh5FLvznJ4cyjbVwxP3vBsfhyDYsnC736jIVEQqsVI9GW8iuE3pSrwuYUgoGEn3s x/fGXAp8qCQ8mjSsy8NtW/PU6SGMfcr+WYqZKgPoFMZRFnwT+W4VKW+6TnMcaqh8lTKR mWcmFbhTfLE0lrq7RZLtXfIQ9avpYy4aBGdssZo/jwflKpbfby9xOJm3RWpSDS+BGNlL 8hb+dQhUacSZp+W+RUrnO79z6fIizhw11qEPNLtM90LcCmf4ulNL2la+ZpSqxjvpxbx7 ZtqQ== X-Gm-Message-State: AOJu0YzQe2Q3mTiwem5jVpgPZ+8RxKgdjp4R7HPuIYdxGal+HYwOJ4zm AVTll7B5kPmZQa1OuA1yeNG1uveUTYmaW/AkJPzIxm8E4VQRB5QDvzuv8Fj7NQnhU50AZ1LJBSl 4ueI= X-Gm-Gg: ASbGncseAMh4Kps/IIZYScI5da5krQC4SGf7byxRjCKu0fMVFacfoSoKhgxUDzgSkni MVAlkLjT1badd4NGCGJSkbNk82rAwaXI4yfFvueXVAtDCEt70SeW5QUvrAIHx557/8AGY2kT7jp p+JEVgLr4iicbPZcHThNKTaV0qd/OamwTP8Vkrru9NZxL70Cxo/ij0h4yJ715Aa3iOtpkvUdSC4 g1bALC/Uy95OTCRtTlb+e/S3fT832V7z7CMER04S/W3ZBew8rnF+eTUwPmCLTLFerfPt3cEiHwK m7pDL00Cx1OmrkrBE/BQmQWvir5kDFQh1bnr X-Google-Smtp-Source: AGHT+IGdgqoXPnGF2lcK+LAQfU3ZdfrA1Ka0Kkrj/L+eQjTDCQPl9L/bg5MPbz0F0/mQyfX9hEaJxA== X-Received: by 2002:a05:600c:1c9b:b0:434:ffb2:f9cf with SMTP id 5b1f17b1804b1-436e9d80fc4mr29197855e9.14.1736443215826; Thu, 09 Jan 2025 09:20:15 -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-436e2e89fc3sm62157365e9.30.2025.01.09.09.20.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:20:14 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 05/11] qdev: Add machine_get_container() Date: Thu, 9 Jan 2025 18:19:42 +0100 Message-ID: <20250109171948.31092-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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 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 50cbbf81211..89575e74e27 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -1033,6 +1033,16 @@ Object *qdev_get_machine(void); */ void 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 48bc9a7b9c7..9abc4e8322f 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -828,6 +828,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 9 17:19:43 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: 13933020 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 82F3FE77199 for ; Thu, 9 Jan 2025 17:20:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwCq-0002e2-5U; Thu, 09 Jan 2025 12:20:28 -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 1tVwCn-0002aB-Tw for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:26 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVwCl-0000qz-Sy for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:25 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4361e89b6daso9691785e9.3 for ; Thu, 09 Jan 2025 09:20:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443221; x=1737048021; 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=EUzVGKeluHJTwIU2Bj0/kdJ+NUb+Ue/QhX3Ykfr1q8Q=; b=ObO1+5a3632bwJPaPsV/KFWDbt8YCS/4gZgYwcFtIKEaQaYlo/KSjr7zqBPbg9yCTv 7o8yBEB44nf2mCN8LMjkaOeEkinqiDOJuGmbCYEmjSTWJQivnOcrmaWL2DFxW9dYE7Yg /C+hTkVal8ZbrvYZncj8Hwkf69kg9qcnsyBSZbbK7rPpPBXVpIqP4fu0igHXC12QBY4k zkzWqL5tpaAZDpHFKHSdcje2N78BHlUc1RVXYysYFWAwxIcEwNhmzcHfVNhOuWdsLuXI K1YrQni7Bk5SQ0sH5Ce5wkKhzYQSMuI4pqc5OG1L9CDbeRrwcm8kZRh4aPNLkU3iqKm7 Njlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443221; x=1737048021; 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=EUzVGKeluHJTwIU2Bj0/kdJ+NUb+Ue/QhX3Ykfr1q8Q=; b=NL6FgoPib4KxZvvYQjk8imuS6YHyxxgejbFmSjHdXBDKoIlm5NQ3E8PorOl1pskBsq +K+ew30eTdKAEdZBFA90qUUCXwCZY1YIDqFCYQnk56xyTpIuOJUbNhN76RKfqIhs9dpJ +cuDf7DqV0GQNfUbsIlcuvrNmbYdboljhSQ10xR0J3WATu+5Br6+wtj6Sr+hcw7qIMxm cI09aAh4UMWHLH8bthBDWkKpm91+l7Xmag+QHFTdfD268JcRyYHF9UhlxDlV2Odxt6oA V7fRkou3QTifKUp9RcCFxUIf94Cjif64AmAvWvIi0mgM41bHwx54GI4JLlxLu7hungsp dKNg== X-Gm-Message-State: AOJu0YzrUpm+X8bZGyrLP8gau67464aUYilrehfZPTlIrZ4RmWUSVEQL IDLbq+ktBXQeaVwrA9FYT5wxRTXzmj6bA6D+8rLWeZg/XJZz6AoxBp4GmE/7miy/yTDO09Zdvb9 L1R0= X-Gm-Gg: ASbGncsSGf4JKf4c7+4abE9a9UmN/IUz7ON9KFlXIaY4nk5PvF9XPy6q35LJAOEInhD 2pLsXXC+TW0mUaJE/ycvc/UbA+uwvMX1opvUZKZeCOMTUp6JxVJz2sW7e0ovHp2dRT17v5Z1ICa IGqAPz5NJqwAbeoH47b3Bq8t6olc0JaAV4gYxwzyk4C5RPbcXoRiHw5qSclA6X3nccmKKGsXHsN j3oNpIGX6S45HVHVx8qhsdXENrxJMa8HviU8DUbpo55HgyhJF/q6lDu4yW2sd3o9dleXnT8m5r0 AyyBRmc/XP7MnuzI4xaShKK4Myd9qoza3+9b X-Google-Smtp-Source: AGHT+IGq17mk+DRbE/b7puYLM34oZnYM6v8TQ1zLKxxYmh+xXfaQreWcYNM48rSqtLiMLFue9EbP2g== X-Received: by 2002:a05:600c:a08b:b0:431:5863:4240 with SMTP id 5b1f17b1804b1-436e26dda73mr60242025e9.24.1736443221145; Thu, 09 Jan 2025 09:20:21 -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-38a8e4c1b2asm2272284f8f.89.2025.01.09.09.20.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:20:19 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 06/11] qdev: Use machine_get_container() Date: Thu, 9 Jan 2025 18:19:43 +0100 Message-ID: <20250109171948.31092-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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 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 9abc4e8322f..82bbdcb654e 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 6a38b567876..23043b1e0d5 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; @@ -1100,7 +1100,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 3c5bd36d7d7..ed1623b26b9 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 9 17:19:44 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: 13933021 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 8FDE8E77199 for ; Thu, 9 Jan 2025 17:21:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwCv-0002s7-QC; Thu, 09 Jan 2025 12:20: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 1tVwCu-0002mI-2K for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:32 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVwCs-0000sH-E4 for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:31 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-385e3621518so683526f8f.1 for ; Thu, 09 Jan 2025 09:20:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443228; x=1737048028; 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=SAkpQ1iPeEc9FavMfrE5ZMAHDuM/hnnhJGDNmUL3hkk=; b=DPm4mPvaWVWDkwyQq4930Pw9asVYNlEi4obki63Z9hxpbnmfqvBgzfITufqDG2JUBP U6b6kaEiB1xrWqMTItg7kxEpAwvAC17H//yvOu7nt/lQmXrYBGKPtagLVexeiGoG1UaM LmsWNsTJpJvjc7vBvMzFmLlerFBIuIN0PlMD7zp7k/YEOXKynhM+J+UKkagHlwL/S2Or f+L+p2vAzbdn8GPmqorrM5pkVJ0JDtlNqF5kGKH3P73UUOgY25jbXs7AcOHI9JpJtBV9 qcW86ve5Nr/yL/zQpc+kvfp+VBL95IooDDtpHNQDnbdV07aajr4VV7bcv05MrR385zY5 leog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443228; x=1737048028; 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=SAkpQ1iPeEc9FavMfrE5ZMAHDuM/hnnhJGDNmUL3hkk=; b=e4Fi17x6X2ZybgK51ol//R9hxoR8cWohjMTYgHy9da2fstL07esxLMEo9RTd3rm8Hi w/5DQQW8m0ss2yKJg5gj6yDXlyGr7/NHoBnGnr0L1y9XCHEsQT3oNxZgMj06lXCoTt/0 W43JlruRA1OUrGwmd3OyYbw0LwGaGGuvPvTSS6muV4E4WxJqhYh0CEL8uIm1A+smoJUv EbXD2ToNp56TKtpG/ndTGjrHNHhZIRdwhgcEi36sJLp+XIx7DI+pz2iVN9DHMrJfUdCP PQ6AdHmSTeNiIFWwpvz+XuZ1SHfVi3yhcJ/oDR04reFtmaIp6zxa5wcdbjrHFPRlnKcc A+9w== X-Gm-Message-State: AOJu0Yxi+erCgTLpGHvBWfGyzHCiGn0FJ8z07Ws/pcc8hUF9KGvv6ygy j1jJ/aNwgcfFP1g0k9sgK9mnrDFKBzmVeHCesLKZ+qeW5VT2QOD9xrTIu9it+log7JiIMQTR1u5 g5YM= X-Gm-Gg: ASbGncu+vpoefmJWJOK5n9ybNi7iKoxdHSHs5Hfs8zXmJAv82uy2VzfueluIxay51M/ t8A8UYztk4oAYA4OR7EokkLmvUHmrnx3wGbvJA+hnOhdj85UhvavL5uLZ0wy39wyQnp9o8TnhBl NtCPNdyO/CCQOQ76gWZX4lzSoyYONzm7ClNFnz3t6pgNI9K7wmshT+rNDLSUCQnyjAfdo8ggv9t 0DCmILr6YEQHvcQTvaFBy/iTIpixmwwIovCW9s/kUTKm0ACM5wfFlQ81SqaBHWt1n8vToOFps0F cwwNhXNNtQYofvxdAztFNmzgAMctoGKtbq++ X-Google-Smtp-Source: AGHT+IGSuJk4lWB6tPRViHuFddmQsMG/6P2N4ccDhknJxFNY9hsZP3XnLPI1XgMQ8M82WoicmJ0TQw== X-Received: by 2002:a05:6000:1446:b0:385:fc97:9c76 with SMTP id ffacd0b85a97d-38a872f7fd9mr7017156f8f.3.1736443227979; Thu, 09 Jan 2025 09:20:27 -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-38a8e38c596sm2348386f8f.51.2025.01.09.09.20.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:20:25 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Dani?= =?utf-8?q?el_P=2E_Berrang=C3=A9?= , Richard Henderson Subject: [PULL 07/11] qom: Add object_get_container() Date: Thu, 9 Jan 2025 18:19:44 +0100 Message-ID: <20250109171948.31092-8-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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 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 9 17:19:45 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: 13933025 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 B8115E7719A for ; Thu, 9 Jan 2025 17:21:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwD4-0003EJ-TU; Thu, 09 Jan 2025 12:20:43 -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 1tVwD0-00030o-BH for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:38 -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 1tVwCy-0000tc-7u for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:38 -0500 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-385deda28b3so754842f8f.0 for ; Thu, 09 Jan 2025 09:20:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443233; x=1737048033; 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=Fu8Vu673xpGHSEU3TsRnxhPoaDJwCSLcIbc+aa/VbVk=; b=vNTCrC03I1kA1P9lv4IKGfTW1cwJX+dqx6QGvOK7RoWWHk1JL393sBrGuL17NTOzv7 C9vyHzNRKzH/m/s/+5/UfFoNo8IkL6oLVCJAmZfot9jCXB/z5O1x2a078Q6WR0ZkCPVm IvSUGBeMWZ1d6e4gcP7uLJ6wipbMLU2aH0x1iDf3P1RtAqjNdt1VPleK+kEVAkBKbDiq PKxB5Sm2k5DqtsyxR6tRcRVaSzDHaRvdrbYgKzYwvo6616v1p5AkM9DCvmooO47mnTg4 teF4Q/XYf5bwNCGw4gQ0jWNz3/Vg7EOMh0QTl/No/JijpmvvcLZ3/eIVv8ZWXN9V8+WQ C47A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443233; x=1737048033; 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=Fu8Vu673xpGHSEU3TsRnxhPoaDJwCSLcIbc+aa/VbVk=; b=UFGo2o++NflStOL+hA8BK8Zh10O7mnNG+LkJ2DS7+ypps+EkHEm+hmRQsQWy683mPi Ov5k6L03/7EML/2zVARBPXd2tnsBXyQ0cpS6b0iqG+QDm99Jn82PR2GRAjpW7135cW7A X2/yYqcnhXvyr+fIr10IRjP8LuBpWv8HhzBSWfrHe1/nCzEv0dvQiMmG5u+K/bHveJqZ YnDwodpo4jbIc3HhMxbeOBKYSXhPQJ8PcBZmqnpaG6SLxE7ry5n5Inf/DnvbogmsC77p jTQpgyjmacmxrK+fw+6taLlb6SxF/seIftj0AGRGaRLThytfPRMuas9eEcRqdPyAJ3Bs kOCg== X-Gm-Message-State: AOJu0YyMXfK6RDQZXgJVtsop319/Uy5tzEsPtQv0AR8uSbIumZu+ML8l L3rueVodKEzQt2esX4JmPAxsGHJamnsaEb9Oy2JhEIQDhPF43KEIz8JgWD2mUve4IpgpEJtb+M1 Whi8= X-Gm-Gg: ASbGncuECFNdUTGOgYTpTKK5aZFncA7fKX0BgdIYL0CD0SyeBx+R4u/aADzVxhQrmqK fMWSM0SNvTYDb3p1MckZCaEl1E4WcyBlKMZvy092ZKkLzIWA+RWomnbX+ziARZUjOg9LS9y667z TySd+/LsQWzlDD55EIOBfmyuj8AlI6qqMjZz5/jhDjLpg+B3dIEGDY0UL3riHLc0qLl3gpJzR1+ ObsXNezMYuiRk1lMiNQbFa5f7ay/A1ZU/NLZevssQlVHMJD0WUaF1LAfSNBuVKM5TDkfV7JeLOP EkshjKQOhRMNTaaCU2e1ofuPVgyfdU6bLOr5 X-Google-Smtp-Source: AGHT+IEGiXaB6FW/vO/gf2GWnn+Xd33BmrnC8hTxuJzXhqEDZikw+wRi/x0ZoPZF9rebXbAxYlxJLA== X-Received: by 2002:a05:6000:184e:b0:385:f64e:f163 with SMTP id ffacd0b85a97d-38a87312f41mr6302388f8f.32.1736443233646; Thu, 09 Jan 2025 09:20:33 -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-436e2ddd013sm62334295e9.24.2025.01.09.09.20.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:20:31 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 08/11] qom: Use object_get_container() Date: Thu, 9 Jan 2025 18:19:45 +0100 Message-ID: <20250109171948.31092-9-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-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 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 9 17:19:46 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: 13933023 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 90185E77197 for ; Thu, 9 Jan 2025 17:21:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwD8-0003fg-7Q; Thu, 09 Jan 2025 12:20:46 -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 1tVwD6-0003Rt-4n for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:44 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVwD4-0000uQ-Bw for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:43 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-43626213fffso14877165e9.1 for ; Thu, 09 Jan 2025 09:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443240; x=1737048040; 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=CEHoOzKyVxEglpmxh6lJRCjvFkinjqf0bKzuyMt1kmA=; b=suOkAL8qdGUFwbkWItOVdvYESw6+/SWaDC8myny/fARJ3z9ycBtJ2kj9Ig9mgtIP42 Hn2ANHVt87uYBRUcGkZfCr4wLvgQXQ2dpocMP3mTAjq+aCFh1je6mfdn00fJnMYwyaAY VtNMq+AKK5B7smPQlHFCCU3Pj5KUNhKMqY2uomBm5LnMNB8VFKCphOHmiSA+GFrOvmKw v+YeJ5qi+1HMkiB7nY4tC1YVpwHLQoUFRLQjty+wNqzT8TW4K3KYsyQqn7sA2H81qKy9 Y67cuYGE+IWTLSAaVN+USu1LLoXj7mmiC/NQUKncs0ROWoF8nxnOopUYz07yz3a38alc n0Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443240; x=1737048040; 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=CEHoOzKyVxEglpmxh6lJRCjvFkinjqf0bKzuyMt1kmA=; b=k7mcmQ9aonfDCC2nTiou9ExqmPJrESne2yTMDGs9PSAoZFeJBiX8/J2sUrwQuxeSn3 nvAAyJxQ0QgJ+WGCM49+Ix/0c5l/w4uytEHYwdywMCfNbDZwWVSrVy6mSY+Tg6QOaoAc oecD9TfArKa/redUCSnX/IL2EWVmEykLa9cZyA4l6Am6SRmr6S41F4mkCr/I8iXKvCqr JMMYHDwJpScb8PI73z5Xvr89ndcP0wpGEYtLVPXAJY82ieH0kwGk7yFkyjXnvltP7Uky btMnoUtKG/CPmM9nymKJWFWQjreuZ4lcdzwcklw946HSepqrQKkJItqn9zFj9FqrKWfd o8sw== X-Gm-Message-State: AOJu0YzHzzvfralct4gJyrtBQEKgW5xJHhKoA+/iCaHlhoSE/nlZCo9h 51pITqhojPf+5Ns2rcZQsdf0AeLDO6ThFXca0/Es2vHQcMefEPAyIq1MjXAJfO/5Z2F0n3hY1LB SA7w= X-Gm-Gg: ASbGncu8vhaQ3YTcrwhpXJDvjvU8z79/SvACeWQoPu+wQJioJnEVp3Z9UvwrOkoBy3k 2r1xRCwlDIXp8GnBxhM1RpxKZLJR3/61NuTuNmW+hBDNPYiHPbiPBJ71Ta65SY2Kg3zwStNm5fW b98xjDNbzMHw2RY3nql2PH0pNEF6Rzv2CqYhyH/JBnoMaSQmBaSfgm8BEyCJD3gSQjUUw3Ui/gD BDpGdGyVgWZKXs/BCNHieha0mGb7EjdZfnhxe06xlHgTejXVtB+LmiFN84uw0YNoK+T5B69p2u/ gntzGiK+cvpm8M1d2S1wszcINuEtVXFAlCQr X-Google-Smtp-Source: AGHT+IEdDuYK6BPxWIjxcr4VZNIr5nl2I+Uhsa5UgRt7sCnz4aIdIjbtQDZb99ZB2RrqIIARZ8rmMQ== X-Received: by 2002:a05:6000:1fa5:b0:38a:88ac:ee69 with SMTP id ffacd0b85a97d-38a8b0d5bb4mr3396738f8f.13.1736443239590; Thu, 09 Jan 2025 09:20:39 -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-38a8e4c1ce5sm2357604f8f.94.2025.01.09.09.20.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:20:37 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 09/11] qom: Remove container_get() Date: Thu, 9 Jan 2025 18:19:46 +0100 Message-ID: <20250109171948.31092-10-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 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 9 17:19:47 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: 13933026 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 EAF12E77197 for ; Thu, 9 Jan 2025 17:21:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwDD-0004Ml-FW; Thu, 09 Jan 2025 12:20:51 -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 1tVwDB-0004CU-L1 for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:49 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVwD9-0000vY-PP for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:49 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-436326dcb1cso9434545e9.0 for ; Thu, 09 Jan 2025 09:20:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443244; x=1737048044; 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=bEpqXVU8Ur/P9HPMuqzJk8wNNbtEkgm3VtINnkR/R0k=; b=SGgYfRvcDJz5NA85QIeegH2NGC9g0gQCpWSHQIOOc9HxyH+lLAB5QUtt6+NlvY0N41 NSn2hvB8mHUcguDoOTBv1KJE09C5s6YM9xIOQZLYH51brxcheWf1HBsKUUisZnbkQP8q 7p2LWn5PNaI1ORzeZkDyXSbOOFAiyDK5Pmzo0+Nk6esaP0vc5FX4JPT0EGosLkxnOMQa TjghTekRYGr8paMLMC10yao6rND12vzdvmacexHNeO26OIDBF6twapZFyv7VZXA3s7MH cr1ERlW4WZzX1aCpxhtOB8AD/lMtmaWVWFMKTgcLe1hf7xRT2p/OXwX1OHTabw+LybNJ QaXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443244; x=1737048044; 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=bEpqXVU8Ur/P9HPMuqzJk8wNNbtEkgm3VtINnkR/R0k=; b=a0/qfn+jOW4lakdpEqJw2YAhhCFmQvSL8XWW2iARbjzq2cTgcAS1tYtDf2bVyMZmsP hDfyYTs/1bTeF7h9FdmLXczLTpR7x3+FFrpiSVuYz/hBdaHypq8M2V4WUho7azio7jmK iU8YWEMJZUchBYvcCtw85FYv1mGF4BQQynjJnCFpRfo7fDgRudUGZncIRc2OD+a9tgnp 9bos3vjybMdPQwst6oLBTvquCzz3QlD39DvVD2zUiCs68tPZ3YOjugPzcpp+Moz+owS2 ZGLC3TkKswprYqvLoBBg0JPtL63LKzkiD9vKw3rrbO+2kfP1qmZGQcUINRCr7IKD/U6x 3m9Q== X-Gm-Message-State: AOJu0Yyv9Xq7Y4Me2Km/1c94mugL+VHQ2ZwPhkZk+TCbVYLNqnlMJBDc iH6fxsYk9r9t95imQw1u+333w7XEU+z2MH73mRqK0t2tdoFAG81PVJi/TWOv/BHworL9PxYKLoq XOpI= X-Gm-Gg: ASbGncuBXP5DOHUihpsSac6Nq9Ih/2GxPqpv/Oi/M1NIXFftw7XJrpkhgxGvaJUJ64w OL7jGgcbIz7OaPe+TvjXFp/d87NJQxVgUb4A3R0hlnd7HC/p80fbSIjRUcVf2qxlaqkEcOIRiNo bLyvcjZrdJXIvbrgU8nSQ0Gs/ANzvXxmLzn0aP93xh4dUqG35LPlj4ngSAu4Qcqki5Qu+5Chd7s j7qFedp1HCyFS6Eyyj63fcZbwprKO1EfzwHspuO1W/ADPSnmjmDVZq7P8vfxxmzUgrCpp0ExHqh aHsMCBTsyxGSYgwGkgvtZliVticzb97d/C7D X-Google-Smtp-Source: AGHT+IHmmF2A+MA1ZCXsxdRGrsjDmUIhOzjDNv1N4dKcFmAOW946Kdq0v7C/tRY3Q6IHyRgJ95tm3g== X-Received: by 2002:a05:600c:310c:b0:434:f8a0:9dc5 with SMTP id 5b1f17b1804b1-436e26a8c21mr73170825e9.13.1736443244508; Thu, 09 Jan 2025 09:20:44 -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-436e9d8fb99sm27331315e9.3.2025.01.09.09.20.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:20:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 10/11] qom: remove unused InterfaceInfo::concrete_class field Date: Thu, 9 Jan 2025 18:19:47 +0100 Message-ID: <20250109171948.31092-11-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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 From: Paolo Bonzini The "concrete_class" field of InterfaceClass is only ever written, and as far as I can tell is not particularly useful when debugging either; remove it. Signed-off-by: Paolo Bonzini Reviewed-by: Peter Maydell Message-ID: <20250107111308.21886-1-pbonzini@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- include/qom/object.h | 5 ++++- qom/object.c | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 77935572894..9192265db76 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -573,12 +573,15 @@ struct InterfaceInfo { * * The class for all interfaces. Subclasses of this class should only add * virtual methods. + * + * Note that most of the fields of ObjectClass are unused (all except + * "type", in fact). They are only present in InterfaceClass to allow + * @object_class_dynamic_cast to work with both regular classes and interfaces. */ struct InterfaceClass { ObjectClass parent_class; /* private: */ - ObjectClass *concrete_class; Type interface_type; }; diff --git a/qom/object.c b/qom/object.c index 58897a79a76..ec447f14a78 100644 --- a/qom/object.c +++ b/qom/object.c @@ -314,7 +314,6 @@ static void type_initialize_interface(TypeImpl *ti, TypeImpl *interface_type, g_free((char *)info.name); new_iface = (InterfaceClass *)iface_impl->class; - new_iface->concrete_class = ti->class; new_iface->interface_type = interface_type; ti->class->interfaces = g_slist_append(ti->class->interfaces, new_iface); From patchwork Thu Jan 9 17:19:48 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: 13933024 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 90664E77197 for ; Thu, 9 Jan 2025 17:21:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwDK-0004w6-A2; Thu, 09 Jan 2025 12:20:58 -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 1tVwDI-0004ja-D8 for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:56 -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 1tVwDG-0000xI-Tf for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:20:56 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-385e3621518so683872f8f.1 for ; Thu, 09 Jan 2025 09:20:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443252; x=1737048052; 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=zevfD/0XJNMcMENJjO9t+oO6TupDgy91bB9ym/P30U4=; b=ZTf98iy477k8jzEFvBXLN3MV+UnBq2QenqI/CCgHgjB9oet/iT9Y0kh84dGSg7ttK6 KNVh+JOm/D1SH2dETglvET+JNWwKIqj0Rh8G+zMSfTF5FqF+oO1aQoon2p99tuJtM8rj bSlcA5ixU4/LkYehxQdS7HVxJ1XfBpw+QraQHKtWV2FCQiAB04GGPmNLqjb7kWDDhEyY Cj4okrCBuWNLq9ycNPJKW2ZeOKnAT0NsQWwF2TKC6EEz5xnZpyZSozjMy+2IyH+MM5zg Bj5HV/qfUrz4M/Woav/UE/npGUd4FeQEGmbzzjkF8YAX5ZxV9RrWhKMdp4B7Y1zfblY9 iTlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443252; x=1737048052; 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=zevfD/0XJNMcMENJjO9t+oO6TupDgy91bB9ym/P30U4=; b=VviUvd3cAb19KIohllYPw6w+e8LboCuXxe7Ur4Zw5QKiJSwa0Yl9XefIQn1c6cGVB/ JvPrzKPxQcK7nt2/jWvsvX8FNPj3/6JbINY2BYF856NCmyUdzpcaPG+36lvZ8wzgjC6/ Xpki23B4nkXbZz0AM0Dcq9AYvG87THwwmEKpDf8/nXvQ1iXTNAFCSMh9HvmLmEZPDXeE 5ETbKpGwhn0R+bO7aaz7IADvMBiN6LLPpuvjdk5KODdSmoxO/X362p3y48CJ38y0D7P0 Ti6vRhFwaUlUhs3zyvIhZ++SG4NJIdnUYZhWzO7XvClLuaQsFW0dImd+NGypkFB087xJ eqDg== X-Gm-Message-State: AOJu0Yxd9RwgMX5GFVfMyhP91pQWIaRpUUeCX4c2NjDlH6nXchns0Sms 3l9Cmo9tYddB8c8CTZARlJtTUDLLS3H64P5X621FKEWCqjkY2OT8tF4QFZbtmZsSqLs719fEwiu I83E= X-Gm-Gg: ASbGncs5c/1VzULRXC2PlR+Y820FihuYDR8uVKvSDvHGD3uXf/hKz83p+m+8Ng8Bsa0 B1wx5lSmvfvEIpUaBssgHjilYuGA+PZ95VAVqvVCLAeIdrGKLggLyGOJcPlGFNuofSH8Q7C8BVa 9zBknwQBW2D2SVj0ii0ovo4tl3Qg0a0JHA11vuF1Bzz4J2TnW/E/qLH40VmsW4M4ijH51PVB0tz H8NUTC9iTyWvotvuOHzEI4twqCcArSEjfPhB4pYSHK+ViYIx3Jp+v0apd77/HE5ypryUqYOjWGq AprjPav0Fzq6A4oK7qzU65DuRVy44TuF1l5M X-Google-Smtp-Source: AGHT+IGOwgjY57/fBV6z4udumMChiJWSjeOvUVwTxZtl6edZ9ywQ1NPOzWvNDxvzb9O0XOV1ag4eNg== X-Received: by 2002:adf:a2c4:0:b0:385:faec:d94d with SMTP id ffacd0b85a97d-38a87355754mr6052475f8f.51.1736443252512; Thu, 09 Jan 2025 09:20:52 -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-38a8e4c1ce5sm2357948f8f.94.2025.01.09.09.20.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:20:48 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Xu , Richard Henderson Subject: [PULL 11/11] system: Inline machine_containers[] in qemu_create_machine_containers() Date: Thu, 9 Jan 2025 18:19:48 +0100 Message-ID: <20250109171948.31092-12-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-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=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 Message-Id: <20250102211800.79235-9-philmd@linaro.org> --- system/vl.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/system/vl.c b/system/vl.c index ed1623b26b9..be029c52ef8 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]); } }