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 848CBC4451C for ; Tue, 21 Jul 2026 20:16:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wmGsH-0004yw-SU; Tue, 21 Jul 2026 16:15:33 -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 1wmGsC-0004si-Cs for qemu-arm@nongnu.org; Tue, 21 Jul 2026 16:15:29 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wmGs9-0003Do-Jq for qemu-arm@nongnu.org; Tue, 21 Jul 2026 16:15:28 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66LH2hXo2418329 for ; Tue, 21 Jul 2026 20:15:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= We5DuZ6V6TnuJjY9VdsMK+w/90vNGZmBBsZZPL1T8KY=; b=nXHEoM8dqsmgZg2h Ma3bpw3so/u715lsp97yHbZWIWjMXjPbOmY933kVUsN0f+FqP5duv0U2tyIuJUdj nEMqCcRJz7ozCemeE42pWBkMDHhxt2icX9M9QA3Lr8NJrdiCqZFtjRZDQBYYfGlD gaYNzknAF9tjxxmkBuKp9exZpSPrItxrPDPExNYcTGa3nPMPH2dfdpVQYU6BvQvS +RiotY8Gs4wig57aKtnSC7LJWT0uCQ6j9dNHmcPGIBYcug+gC/+A1Nfh5aIu/qno 86D1sWM3LnYdEAJm16ZjtzwonCrVxS6uIXNN9j2wLBUKw0Fnyk0AhIl93EjA2ylQ fCjLyg== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fj9bsa0kd-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 21 Jul 2026 20:15:23 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-51bec738909so137753091cf.1 for ; Tue, 21 Jul 2026 13:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784664922; x=1785269722; darn=nongnu.org; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=We5DuZ6V6TnuJjY9VdsMK+w/90vNGZmBBsZZPL1T8KY=; b=XZ0mXjUgLOwtLV4JQoZiiAoMpzsNZXapvJEwm1yVKiwRSu+u171dF9r8uWFbdCaxwz qYRsaGKeacYgM/763OH8BVs9bat5iWVJDMobDxDsLZjJXBM3qPAbPYtcqRx6xnrSlpA4 aL1LMA81DTYeqyGBP1h2HHJOsOubuXJ8c2xu9jFkhlD8azpDy2WOUCE8uYkcPfHvWl/r GzPX4x7RtB22E9zmu+AhC6uyA5mcDAw9FFeXPysxSy8gL6BRL6JRyVIkhQUQdK5l26Fw uOH9C6+16Hj2KSbt3pQJ+ibKMCX0qAeU2I2zkJ1WipuTvYtf38lOgFtpHIDvlVMn/rfS 25kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784664922; x=1785269722; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=We5DuZ6V6TnuJjY9VdsMK+w/90vNGZmBBsZZPL1T8KY=; b=esndZIAaAhSLHAs+RTX3sAp1UMNiiGl//AhsgQzvuayEbxv1n09Sm6iK37FjhSMBQj POxau5xH2lmotcODzQIdJ6jaXSnBIT7fUfcvSVVs/MYKSoNlYMChHVS7A8UvnPSCAKaU KvAzZyopt4vvFjPfDuKkU6iUEMYlTjGMelOvp2+35uxOBf+xifedqIKJJL3YdANF7TKB q53wuzGq3oMH/8Yot0eC1/Ch1BrOdsJaInNHlq15DqlZBzKfO/hMFCTu28EzDI2dqEZF hbCaCJvOWfDF+uVZ3UOUMWUeic+wJypzK1zHVmKHs/ihIGq1LH+fs4dNSNnOvwNVhB61 c/Mg== X-Forwarded-Encrypted: i=1; AHgh+Rrr9PhL5EC0kLECA10FVD19HsbKgYdQJnX0S1qGCCAQ8mIjamVtlYviVDg7NvZTjGxwSSxHU15G6w==@nongnu.org X-Gm-Message-State: AOJu0Yxeq0+WJ/IjKO8B96lBAQipxZhgaocul/3njEfCAVslBIgPgh+c UV8jyY5fmvFVmIGa+Bh2FANT3E8UT5meAQM/NXDxvbhh4KebDiVyY2khaTduGjWYJKijoMuihh6 r2dynQBzD5mTXTJy7TtSm8/xcATmaOl2Wq/CslVJBEUcAaKiauPXnLgs= X-Gm-Gg: AfdE7cm2c+ypdl3GCrSk4vdZ8chFlebvFcgcp6UN3MhWzKZSXjdz+VwuWke1cuC+3iC zRHETT/HJk7/JHmCpPeu/RtdECePOuDeIjMBahqfhBfKFw+6sNPBtgb3Unzw4ChyKE6tjmDPxx/ 0CVJEEGEU80V3pHlNmkAXPyAhScSgetTvLPeL3cpfHNeGIT0LcL5CAbROeSUhhfJEyMBu9Nqu2W /mrbpUwHiS5rnFMkTnUNxUeqC65XVSjgeBHB/D6QxIdimq/x77kNF71enxxia5rDZE5jZacbAyl AiJjoUSI6fc3Kdw3OELp9ocXTxQXSUL3lPxcOkTbqTazuguQpim8aQMhSjUtHE+QJ+NuM1PVYGE fZ5phMqP/YepUDJOe5Inq8oBTiB4flwGLs+3Mi8jDiy1hTKMpJrI= X-Received: by 2002:a05:622a:4106:b0:51b:efe9:27c0 with SMTP id d75a77b69052e-5213ed6fef6mr173135491cf.71.1784664921793; Tue, 21 Jul 2026 13:15:21 -0700 (PDT) X-Received: by 2002:a05:622a:4106:b0:51b:efe9:27c0 with SMTP id d75a77b69052e-5213ed6fef6mr173135151cf.71.1784664921354; Tue, 21 Jul 2026 13:15:21 -0700 (PDT) Received: from [192.168.69.212] (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63e51986sm47076475f8f.11.2026.07.21.13.15.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jul 2026 13:15:20 -0700 (PDT) Message-ID: Date: Tue, 21 Jul 2026 22:15:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH for-11.2 v3 14/15] hw/qdev: Parent device before setting parent bus Content-Language: en-US To: Akihiko Odaki , qemu-devel@nongnu.org Cc: BALATON Zoltan , Paolo Bonzini , =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , "Maciej S. Szmigiero" , "Michael S. Tsirkin" , David Hildenbrand , Igor Mammedov , FangSheng Huang , Alistair Francis , "Edgar E. Iglesias" , Peter Maydell , qemu-arm@nongnu.org, Nicholas Piggin , Aditya Gupta , Glenn Miles , Harsh Prateek Bora , qemu-ppc@nongnu.org, Alex Williamson , =?UTF-8?Q?C=C3=A9dric_Le_Goater?= , Zhao Liu , Hendrik Brueckner , Richard Henderson , Ilya Leoshkevich , Cornelia Huck , Eric Farman , Matthew Rosato , qemu-s390x@nongnu.org, Luc Michel , Fam Zheng , Eric Blake , Markus Armbruster References: <20260721-qdev-v3-0-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp> <20260721-qdev-v3-14-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp> From: =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= In-Reply-To: <20260721-qdev-v3-14-d2e226fa002e@rsg.ci.i.u-tokyo.ac.jp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: Hkgeln05jBLWY1WzrB3a4JJ0YW5Ji7ga X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzIxMDIxMCBTYWx0ZWRfX6zUbxuHL0Ltl A+n1EmD4zD/9xAfX+V+q71ccdhKwBD4lUPYrjQQgfuXMy8hfC4X8bKYBNCKFGiP5IpclQPWIhNW kuDsr8eGT5IpM1ctkmhO4APT223W+KO/zcR9oLq7MdUvtpqfzjWgutQYTmvnGHjUZIv9tX8lLA1 Az3q9jHdcaqHQEBH1R44/TB6epSt8auA4AMSheKKjx08wBMIaJJFuvE+YrQMPLAGsseAW3BAKgC AeK12DhW3t91rbyti0whlEcpHGmVIyzYwSvUGoBcooMkQirOIQG/ygeZWThQd1gBP2FQCEljRh/ yUMHrrx/tQIujPy7GPt9KzFxAhqy83BaL4oJSfE2OZQXyxvpzn1A5v081SBpiwRwi1h0dDLIH8M /Ny1JujfU6JcU6NkPWcu6oVWjOERr0yIfj6xbb+gnL4/oEGlWlMNmgrOZbVQZt21TUeza0oTol0 NO46f/XTfiZJ0vGKPBw== X-Proofpoint-GUID: Hkgeln05jBLWY1WzrB3a4JJ0YW5Ji7ga X-Proofpoint-Spam-Info: AW1haW4tMjYwNzIxMDIxMCBTYWx0ZWRfX/DAfytcE8/MQ JDziCB6lhhX1IK6N/+U8Pdtv6IuzGznX5OFb69+dR12/xK2PKuFZsRwVKUpk9oyIVB8eQNvydzn 2RN+0euorLMzCH48Qm+3UG6YDsOpsZ0= X-Authority-Analysis: v=2.4 cv=QK1YgALL c=1 sm=1 tr=0 ts=6a5fd35b cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=4s3hRJSeHn4rkQlkrse1kQ==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=M51BFTxLslgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=fgZSBK4kzu8o4Ek6pjwA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=uxP6HrT_eTzRwkO_Te1X:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-21_03,2026-07-21_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 phishscore=0 impostorscore=0 bulkscore=0 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607210210 Received-SPF: pass client-ip=205.220.168.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 On 21/7/26 10:17, Akihiko Odaki wrote: > Commit 9940b2cfbc05 ("qdev: New qdev_new(), qdev_realize(), etc.") says > "device state 'no QOM parent, but plugged into bus' is dangerous". In > such a case, unrealizing the bus will hang in bus_unparent(): > > while ((kid = QTAILQ_FIRST(&bus->children)) != NULL) { > DeviceState *dev = kid->child; > object_unparent(OBJECT(dev)); > } > > object_unparent() does nothing when its argument has no QOM parent, > and the loop spins forever. > > However, that commit did not completely eliminate such a situation. > When the device is not parented, device_set_realized() lets > /machine/unattached parent it, but it happens after setting parent bus. > Therefore, any failure between the two operations can leave the device > in a dangerous state. > > qdev_realize() at least asserts that the device is not already realized > and prevents one realization failure pattern, but it is not > comprehensive. Besides, it will trip with a command line like the > following: > > qemu-system-x86_64 -M none -nodefaults -nographic \ > -device ipmi-bmc-sim,realized=on > > Eliminate the dangerous state by ensuring that the device is parented > before calling qdev_set_parent_bus(). Also, stop asserting that the > device is not already realized in qdev_realize(); it is broken and > no longer serves any purpose. > > Fixes: 9940b2cfbc05 ("qdev: New qdev_new(), qdev_realize(), etc.") > Signed-off-by: Akihiko Odaki > --- > hw/core/qdev.c | 51 ++++++++++++++++++++++++++++---------------------- > tests/unit/test-qdev.c | 13 +++++++++++++ > 2 files changed, 42 insertions(+), 22 deletions(-) Reviewed-by: Philippe Mathieu-Daudé