From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists1p.gnu.org (lists1p.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 258B9C4451B for ; Sat, 18 Jul 2026 21:45:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wlCqM-0007Nx-Cj; Sat, 18 Jul 2026 17:45:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wlCqD-0007BW-AM; Sat, 18 Jul 2026 17:45:01 -0400 Received: from pdx-out-001.esa.us-west-2.outbound.mail-perimeter.amazon.com ([44.245.243.92]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wlCqB-0002yF-Db; Sat, 18 Jul 2026 17:45:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1784411099; x=1815947099; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qVCl/LGYfL4UCle58yHXW8mCdP/ph3jgnSmOc1JYYvo=; b=ZhkIruUSOh3piSQKjvyBkYCv7yWqrr2JZRCA4RM3InDbNQnWf9i8rp9u +p3lVBRAWvgKSWxec4JUYIw3VxztDuIrlSgrhCAOX6mTTayC/zRpP27mJ CV/tzv1oh2QOxFSRiaC3T6uYVsCeZpn7TDpp5YkzonDG2sAS7hR2L0orl kpSkNjHD8VYSo0GTCkpb8kx6bCwEyUINeYUhuQUQJfyjiTspLvOcjTcYk DV7oeBkLWYLqVoy2VIFLAK0IcqwVUVhJqBnB/NLWw0qEEudemqdMSj4Gw QWxDMXetYQ2r8necpMc4+0YgOcPYDl8R/cVmMYeQ7ZKQk3gS3m51H9Pvp A==; X-CSE-ConnectionGUID: 7j7rb7PISgqsU1wtkjzSIw== X-CSE-MsgGUID: rJ+oC4gXQ96g7IvRC437ig== X-IronPort-AV: E=Sophos;i="6.25,171,1779148800"; d="scan'208";a="23422691" Received: from ip-10-5-6-203.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.6.203]) by internal-pdx-out-001.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2026 21:44:55 +0000 Received: from EX19MTAUWA002.ant.amazon.com [205.251.233.234:3753] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.11.151:2525] with esmtp (Farcaster) id 3a5ed661-dd78-4c44-992b-09c3c211baf5; Sat, 18 Jul 2026 21:44:55 +0000 (UTC) X-Farcaster-Flow-ID: 3a5ed661-dd78-4c44-992b-09c3c211baf5 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWA002.ant.amazon.com (10.250.64.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.43; Sat, 18 Jul 2026 21:44:55 +0000 Received: from ip-10-253-83-51.amazon.com (172.19.99.218) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.43; Sat, 18 Jul 2026 21:44:46 +0000 From: Alexander Graf To: CC: , , , , Song Gao <17746591750@163.com>, Aditya Gupta , Alexey Kardashevskiy , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Farhan Ali , Alistair Francis , "Alistair Francis" , Antony Pavlov , Markus Armbruster , Artyom Tarasenko , BALATON Zoltan , Felipe Balbi , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Christian Borntraeger , Brian Cain , Hendrik Brueckner , Chao Liu , "Huacai Chen" , =?UTF-8?q?Cl=C3=A9ment=20Chigot?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Helge Deller , Dorjoy Chowdhury , "Edgar E . Iglesias" , Alexandre Iooss , Eric Farman , Fabiano Rosas , Francisco Iglesias , "Gaurav Sharma" , Gautam Gala , "Harsh Prateek Bora" , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Jan Kiszka , Max Filippov , Joel Stanley , Jared Rossi , Tyrone Ting , Frederic Konrad , Laurent Vivier , "Manos Pitsidianakis" , Bibo Mao , Mark Cave-Ayland , Glenn Miles , Matthew Rosato , Michael Rolnik , "Michael S . Tsirkin" , Niek Linnenbank , Nicholas Piggin , Palmer Dabbelt , Halil Pasic , Paolo Bonzini , Peter Maydell , Peter Xu , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Pierrick Bouvier" , Richard Henderson , Sai Pavan Boddu , Samuel Tardieu , Bernhard Beschow , Stafford Horne , Sergio Lopez , "Subbaraya Sundeep" , Thomas Huth , "Ran Wang" , Hao Wu Subject: [RFC PATCH v2 029/137] hw/mem: Give onboard devices a QOM parent Date: Sat, 18 Jul 2026 21:35:04 +0000 Message-ID: <20260718213652.37673-30-graf@amazon.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20260718213652.37673-1-graf@amazon.com> References: <20260711223707.42139-1-graf@amazon.com> <20260718213652.37673-1-graf@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.19.99.218] X-ClientProxiedBy: EX19D035UWB002.ant.amazon.com (10.13.138.97) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Received-SPF: pass client-ip=44.245.243.92; envelope-from=prvs=65292d44c=graf@amazon.de; helo=pdx-out-001.esa.us-west-2.outbound.mail-perimeter.amazon.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@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-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Convert the *_orphan() device-creation calls in hw/mem to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name. The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions. Per-site rationale (reviewers: dispute the modeling here): hw/mem/sparse-mem.c:111 | qdev_new | parent (new arg) | "sparse-mem" | Public helper; thread Object *parent through. Only caller is generic_fuzz which passes qdev_get_machine() Link: https://lore.kernel.org/qemu-devel/87jyr3w9tc.fsf@pond.sub.org/ AI-used-for: code (refactoring) Signed-off-by: Alexander Graf --- hw/mem/sparse-mem.c | 6 +++--- include/hw/mem/sparse-mem.h | 2 +- tests/qtest/fuzz/generic_fuzz.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/mem/sparse-mem.c b/hw/mem/sparse-mem.c index 3310504578..fbf94eb8e7 100644 --- a/hw/mem/sparse-mem.c +++ b/hw/mem/sparse-mem.c @@ -104,14 +104,14 @@ static const Property sparse_mem_properties[] = { DEFINE_PROP_UINT64("maxsize", SparseMemState, maxsize, 10 * MiB), }; -MemoryRegion *sparse_mem_init(uint64_t addr, uint64_t length) +MemoryRegion *sparse_mem_init(Object *parent, uint64_t addr, uint64_t length) { DeviceState *dev; - dev = qdev_new_orphan(TYPE_SPARSE_MEM); + dev = qdev_new(parent, "sparse-mem", TYPE_SPARSE_MEM); qdev_prop_set_uint64(dev, "baseaddr", addr); qdev_prop_set_uint64(dev, "length", length); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map_overlap(SYS_BUS_DEVICE(dev), 0, addr, -10000); return &SPARSE_MEM(dev)->mmio; } diff --git a/include/hw/mem/sparse-mem.h b/include/hw/mem/sparse-mem.h index f9863b154b..79c30cf412 100644 --- a/include/hw/mem/sparse-mem.h +++ b/include/hw/mem/sparse-mem.h @@ -14,6 +14,6 @@ #define SPARSE_MEM_H #define TYPE_SPARSE_MEM "sparse-mem" -MemoryRegion *sparse_mem_init(uint64_t addr, uint64_t length); +MemoryRegion *sparse_mem_init(Object *parent, uint64_t addr, uint64_t length); #endif diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index e48f868775..99b38a7fd4 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -788,7 +788,7 @@ static void generic_pre_fuzz(QTestState *s) * Create a special device that we can use to back DMA buffers at very * high memory addresses */ - sparse_mem_mr = sparse_mem_init(0, UINT64_MAX); + sparse_mem_mr = sparse_mem_init(qdev_get_machine(), 0, UINT64_MAX); dma_regions = g_array_new(false, false, sizeof(address_range)); dma_patterns = g_array_new(false, false, sizeof(pattern)); -- 2.47.1