From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139899; cv=none; d=zohomail.com; s=zohoarc; b=etKGCgLc51syG1lHxr2LTCoCKWcpFtqEiop2j/fWM+VSp7Z1zwfBQ+xF285UeDv8WHrshbcuJeIj8wZhL8+PBf8HbAwmJRJy+iOhLVOizblx5/U0U3c48WI/2iXxAMb0kheDlUYcYGR02xabsnw0VGVfzQbBbuCt2F2MuR85vhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139899; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=payjPLYurKI+5/EKzyakmMM06dc3GEHFTxopaOn1dX4=; b=kmfW0Sp6fB96E0uDz7pKS/5JZ7LxsG1CVlPOmKDQWawpaa3MT+iUVOiSW+wja9nUVjmR0DhmTQRyR97kcJdZ04kQSAwfaZdVeXv6WPbIV7QZ4sucquXPkWDnFv1qu6Cs+SGlyYfa7NLKOTsqrT7nQwB9zDBNbJSTbtzHplV4Mi4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139899336484.29239486228323; Wed, 20 Nov 2024 13:58:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshS-0008HS-HD; Wed, 20 Nov 2024 16:57:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshP-0008Cl-0U for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshM-0006Mz-19 for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:22 -0500 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-244-S0lWEthfPmOCvB4Ne_cZNQ-1; Wed, 20 Nov 2024 16:57:10 -0500 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-461011bd338so2674271cf.3 for ; Wed, 20 Nov 2024 13:57:10 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=payjPLYurKI+5/EKzyakmMM06dc3GEHFTxopaOn1dX4=; b=KCID8AoISrVxcJBLjeFUqmtEj/m31m5WWG73J58bLfZRgDEaildhG4cTBcVtFnaEBVw9FF 5CcsazBRYgFXO5MYaNtBiYTHtrGT5fNGnl+iDn18Nvs7hqXLuMSrbEYlb+mEp0szFtF7Vf fc4pk2UpESEvlHFZx30TgD80Sgn5xlk= X-MC-Unique: S0lWEthfPmOCvB4Ne_cZNQ-1 X-Mimecast-MFC-AGG-ID: S0lWEthfPmOCvB4Ne_cZNQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139829; x=1732744629; 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=payjPLYurKI+5/EKzyakmMM06dc3GEHFTxopaOn1dX4=; b=T9+IIBEwjOs18DaPop0IIu9Qccm4K8C9/Sl/odk/8XQvr07YB38OSLazf3g5l31ccb m31vI5r59jR8VwDRjHkJSym2C+u1i8K0SRN9z69Wxici1szqb813rGwVx4DDiiclvkRS /buSOSmpc4ZYByl+DbS0FNZyGUR5jXpI1blT90HhmwUM+CD8KRpcaJ3lDw07wcgL0PDa aUFc8uzYsuNUskU92Rx1zU3CDzyYIvIW02793ynbtPaMWw0uJjvzEijf7+8wMFPgzz7Y 6yN/H+ODYr6xtXNN8lcWSDO9KIrxBGOxbPkC+cQ9jQalRmicG/mjVmADZJnO4fZLORXy xT2w== X-Gm-Message-State: AOJu0YwSTl9CgZ0/Rj3/I9QOTVDTpMYz5kd9hf2nXsFbZ5GA5vk5y8Vb kMqZhSQrzaxg+aBOjFAgRV5DX8OnzkgUOo/PvhV37dSx3Vl7OtBPhz041jTSNp7iHCd1SMCoEEO iuI4RNhzXLb1kSJ0UhLw+yD7KEvVRv5hE3q7PAqQYtyZcm0+ggv68PP0igMsstEEtZ7k1dfW4MO GonWVRWQgHXkVVtv3lKFAYWWxB8NHG44iP2w== X-Received: by 2002:a05:622a:19a9:b0:460:9318:e4bb with SMTP id d75a77b69052e-464782a73f5mr50726211cf.9.1732139829412; Wed, 20 Nov 2024 13:57:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqYI4EbGa+pBwIBfzwW5MC23IJ6t+sM9r88rOhppSXbuA/5zJfuC7qcJOrRWZH7UTWZJDZqg== X-Received: by 2002:a05:622a:19a9:b0:460:9318:e4bb with SMTP id d75a77b69052e-464782a73f5mr50725931cf.9.1732139829066; Wed, 20 Nov 2024 13:57:09 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas Subject: [PATCH 01/12] qom: Add TYPE_CONTAINER macro Date: Wed, 20 Nov 2024 16:56:52 -0500 Message-ID: <20241120215703.3918445-2-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139899833116600 Content-Type: text/plain; charset="utf-8" Provide a macro for the container type across QEMU source tree, rather than hard code it every time. Signed-off-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/qom/object.h | 1 + hw/arm/stellaris.c | 2 +- qom/container.c | 4 ++-- qom/object.c | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 43c135984a..3ba370ce9b 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -26,6 +26,7 @@ typedef struct InterfaceClass InterfaceClass; typedef struct InterfaceInfo InterfaceInfo; =20 #define TYPE_OBJECT "object" +#define TYPE_CONTAINER "container" =20 typedef struct ObjectProperty ObjectProperty; =20 diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index 376746251e..6d518b9cde 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellaris.c @@ -1053,7 +1053,7 @@ static void stellaris_init(MachineState *ms, stellari= s_board_info *board) flash_size =3D (((board->dc0 & 0xffff) + 1) << 1) * 1024; sram_size =3D ((board->dc0 >> 18) + 1) * 1024; =20 - soc_container =3D object_new("container"); + soc_container =3D object_new(TYPE_CONTAINER); object_property_add_child(OBJECT(ms), "soc", soc_container); =20 /* Flash programming is done via the SCU, so pretend it is ROM. */ diff --git a/qom/container.c b/qom/container.c index 455e8410c6..cfec92a944 100644 --- a/qom/container.c +++ b/qom/container.c @@ -15,7 +15,7 @@ #include "qemu/module.h" =20 static const TypeInfo container_info =3D { - .name =3D "container", + .name =3D TYPE_CONTAINER, .parent =3D TYPE_OBJECT, }; =20 @@ -37,7 +37,7 @@ Object *container_get(Object *root, const char *path) for (i =3D 1; parts[i] !=3D NULL; i++, obj =3D child) { child =3D object_resolve_path_component(obj, parts[i]); if (!child) { - child =3D object_new("container"); + child =3D object_new(TYPE_CONTAINER); object_property_add_child(obj, parts[i], child); object_unref(child); } diff --git a/qom/object.c b/qom/object.c index 9edc06d391..214d6eb4c1 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1739,7 +1739,7 @@ Object *object_get_root(void) static Object *root; =20 if (!root) { - root =3D object_new("container"); + root =3D object_new(TYPE_CONTAINER); } =20 return root; @@ -1755,7 +1755,7 @@ Object *object_get_internal_root(void) static Object *internal_root; =20 if (!internal_root) { - internal_root =3D object_new("container"); + internal_root =3D object_new(TYPE_CONTAINER); } =20 return internal_root; --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139941; cv=none; d=zohomail.com; s=zohoarc; b=dF6+oshCYSU8+SnduPYP6FttIzaN5/i37Khb/Ax4ESX7cGspNFk0lsp4EriuWntbbBalT9+4Int5gqD0XjxUGsN4Q2vq6/XbeyUfol2YymAEMotrO7Ft09hk903WT0DjsvwR5U2ep5pfzgSlHKmtYLBxvHIRgWbk8uFhIM+AyQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139941; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DkBr4/YGRnjJuK64Ii4EqzW3873kCqGgygaLDsnSuN8=; b=LZnlBT78gfQEw3oGD60axlP4kWhf7B0e0fcK/ci1onlqeA+KMV1DrJdyzZRt0Mi2CYzGmiMCL+fMmnpU3wqlQN2SJmn5XogK0n4wGUwhEl7AKvddq0XMNHY3pZhhGlRf5UW6GNAuideedLk/bRADwDe6/cm9rPhS0CErKILQu/4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139941028410.25582355925326; Wed, 20 Nov 2024 13:59:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshS-0008JW-W8; Wed, 20 Nov 2024 16:57:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshQ-0008DK-6K for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshM-0006NB-0a for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:23 -0500 Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-315-9-aAGFOhMCWGCs0jJBBhZg-1; Wed, 20 Nov 2024 16:57:12 -0500 Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-5ee2aa2335eso259823eaf.1 for ; Wed, 20 Nov 2024 13:57:12 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DkBr4/YGRnjJuK64Ii4EqzW3873kCqGgygaLDsnSuN8=; b=ilErEUMwsK83t+U9kO1+g4nS7eNXK3Z1WjLj8Hlx8FfnkwHCQRu+LzB93/4qPY4K9NlRDS CWIWRkR6th/HPKieI4yTVu6fjV/Brt+a6a5S6DdCLAdGhNwn4FanGbSydSwN8zVwZMW68V 5R59/1u8UHojAKpk8CJTp031ic9TajU= X-MC-Unique: 9-aAGFOhMCWGCs0jJBBhZg-1 X-Mimecast-MFC-AGG-ID: 9-aAGFOhMCWGCs0jJBBhZg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139831; x=1732744631; 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=DkBr4/YGRnjJuK64Ii4EqzW3873kCqGgygaLDsnSuN8=; b=u7XtJCWkl1amvWvKZCMxguQp+Rvfu2dIHEFRtcT3qMPEiloo8pRUC2d2XKavkeZq9b KQ5OcitV2jsOUTWim9IUgkNbSaKrZ5GAhhVshgj2byfoo+EOdeZgnQHnVDiu7ZSA6MRT jDf8eD7e9hEXrqtSGuRvTae0xIM/rXYZ2GvWbaSTe5xz8XFRk0H4qWxYrkC2cQ22nsrM CVg/OojhPiVal4gPSqu46L8YHZQ8rYaK0qp5EbI0Y958rqm9Or9lN04qS8K6QlWQIX2u qhjfSd2ZXT8QYlvWSuujGnpSB9xsZ6OtHol/Ao4LijSryJuHlVQPUf36xgTuH9wNFb+J hwdQ== X-Gm-Message-State: AOJu0YyEl3g90ATn5H5T0hwKoI3XLoJsNSucpUq6JagMWmhwOGwW29+G Dxzl2evrJCaPrErJxa/+kLz/9RkzBPT9KCVwy63CLnOTyhWQx2he1lRuldL5zTe50EmMWp6+0xA 2WVGtTn03xhZWpAk9RulYCd4lNt7pfuoswL8CRWCv7D8NuJpbdp0282djkur9OVQ+WwUo1dWuUG U9JYFx+4YG8XmedLB1+jTR9YP6TczD7F9vlA== X-Received: by 2002:a05:6218:2882:b0:1b8:5e16:1a07 with SMTP id e5c5f4694b2df-1ca6649a9d7mr311131655d.12.1732139831635; Wed, 20 Nov 2024 13:57:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFL8RcWCANarTbMKguwXKmUyYUxfovP7K0iH2wS0BWp/YCbkB2tDPZE6j3kXW9Rgvycno6XMg== X-Received: by 2002:a05:6218:2882:b0:1b8:5e16:1a07 with SMTP id e5c5f4694b2df-1ca6649a9d7mr311129355d.12.1732139831330; Wed, 20 Nov 2024 13:57:11 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas Subject: [PATCH 02/12] qom: New container_create() Date: Wed, 20 Nov 2024 16:56:53 -0500 Message-ID: <20241120215703.3918445-3-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139941976116600 Content-Type: text/plain; charset="utf-8" To move towards explicit creations of containers, starting that by providing a helper for creating container objects. Signed-off-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 --- include/qom/object.h | 12 ++++++++++++ qom/container.c | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 3ba370ce9b..41ef53241e 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -2033,6 +2033,18 @@ int object_child_foreach_recursive(Object *obj, */ Object *container_get(Object *root, const char *path); =20 + +/** + * container_create: + * @root: root of the object to create the new container + * @name: name of the new container + * + * Create a container object under @root with @name. + * + * Returns: the newly created container object. + */ +Object *container_create(Object *root, const char *name); + /** * object_property_help: * @name: the name of the property diff --git a/qom/container.c b/qom/container.c index cfec92a944..da657754a4 100644 --- a/qom/container.c +++ b/qom/container.c @@ -24,6 +24,20 @@ static void container_register_types(void) type_register_static(&container_info); } =20 +Object *container_create(Object *obj, const char *name) +{ + Object *child =3D object_new(TYPE_CONTAINER); + + object_property_add_child(obj, name, child); + /* + * Simplify the caller by always drop the refcount directly here, as + * containers are normally never destroyed after created anyway. + */ + object_unref(child); + + return child; +} + Object *container_get(Object *root, const char *path) { Object *obj, *child; @@ -37,9 +51,7 @@ Object *container_get(Object *root, const char *path) for (i =3D 1; parts[i] !=3D NULL; i++, obj =3D child) { child =3D object_resolve_path_component(obj, parts[i]); if (!child) { - child =3D object_new(TYPE_CONTAINER); - object_property_add_child(obj, parts[i], child); - object_unref(child); + child =3D container_create(obj, parts[i]); } } =20 --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139938; cv=none; d=zohomail.com; s=zohoarc; b=cyNiqoLBN7EwYC/bv4BcdrGimL5caHBQLdVgXvvJHsYGyVODFkZXT2U8M28Wb2KB6sYShXngbqpTjacKQ91PVCiWt28r8TK4rAdeDrW6BqVL3he8PqCa/lnnl9mA+RH5HlfiYfRx9Ynxmm1YABq/m6d9/5oYcRmh1bOEEtQq3FQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139938; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ideNW5zodobmST7KFsD+Iz1+DW8emJAzcBwkBm7LdKo=; b=O7ChLIJuv9AM1jARPkG0EItvb3D8k/ILh3ypplk14v5bU6RBKOTKmCHNoL7c9ETpyGQo0q+VTwNzRMhAJtQYgM9r2HQJusLB1fp4MVOvhr38rmGQnmKtjl2nIDvtHI3M4CUFJFsbY+0tyaxnXd/QLu2ZM6SXZo7NzOPxVjmya5A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139938228203.28538053535829; Wed, 20 Nov 2024 13:58:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshS-0008Gu-9H; Wed, 20 Nov 2024 16:57:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshP-0008Cm-0M for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshM-0006Nd-14 for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:22 -0500 Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517--TogbWzqM0iacJhT8rYclg-1; Wed, 20 Nov 2024 16:57:14 -0500 Received: by mail-yb1-f197.google.com with SMTP id 3f1490d57ef6-e388f173db4so361185276.3 for ; Wed, 20 Nov 2024 13:57:14 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ideNW5zodobmST7KFsD+Iz1+DW8emJAzcBwkBm7LdKo=; b=N9lgJ4PW4JTJAyXLNl0Slbr/QBPg6GsNFgXSWKk0iXznhGnLZVEhxrJ/LHHXGnQnBmcczN g+CknB1QpTBIQyc961mgTyPsj+U0Qfk4kEaGaYMcD7V9YXeA+Yl5p5ScBf2lsXnQMIoopQ lvFlwvAeW+vFxJmK9LTQcgsVVsAiO8c= X-MC-Unique: -TogbWzqM0iacJhT8rYclg-1 X-Mimecast-MFC-AGG-ID: -TogbWzqM0iacJhT8rYclg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139833; x=1732744633; 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=ideNW5zodobmST7KFsD+Iz1+DW8emJAzcBwkBm7LdKo=; b=Il6zUfS9Kk+8AsBzFb7Bk/Vi8iI7OKHk6h9fsh7LYBk5U9IKxU2uXDabnCLzd2tbok 4/SuTsYwYKWEL9mhajyShM4y/XsZd/nBNZueklpgr8TnAU/RICsyUhyoPJVmqrcXMlxi GbHF6umPZJKXb1xj+Yj3uhZpgYsbylVZ64Uv3iXDyWtepz5UbOu7bXwjaU9XzC4UhhrY cA8/m8R12GtaChNFUT+7gKVvGeEGIqi2XhEwyrC4IBNYGaluRemEUgHNWOewQpDxm/7F c2cOC162sg1B6tpO6rVckVh5jeFkdDTn4sAD0RTBUvuLLhrOApV3QaVvZpe+MEbailir CLfw== X-Gm-Message-State: AOJu0Yzp+BDpv4V71ZRNZAKd5BYmMSNc5cxCMt8PQQrGbjSw+5hZAbpt 5Ca+RJtor9y3iJlcvd/1uYCnNeOw/F8bECdy6T6YSm1IeMBjkAPD91CW8GqfYCd6ySoQyNd8UJT YFtaAoCzIDlz1E3ttBsO9YZCPpdOFWR2gOI203I1dNyM7ILTpn0OjTV6KsiqtUJlxKkAZzQ4TXf RXS6ee2t2Oec8/05Zx8//IO2yGjKSz2cqHnQ== X-Received: by 2002:a05:6902:1009:b0:e2b:d75b:7630 with SMTP id 3f1490d57ef6-e38cb5e33a9mr3322690276.35.1732139833158; Wed, 20 Nov 2024 13:57:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1BItRPkLUdJUTgP6hk1zA1F/KXZsmd8BAS1Yqfkd0KQAqJ01UAGexIVkiAk9tFwacklJIaQ== X-Received: by 2002:a05:6902:1009:b0:e2b:d75b:7630 with SMTP id 3f1490d57ef6-e38cb5e33a9mr3322654276.35.1732139832680; Wed, 20 Nov 2024 13:57:12 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas Subject: [PATCH 03/12] tests: Fix test-qdev-global-props on anonymous qdev realize() Date: Wed, 20 Nov 2024 16:56:54 -0500 Message-ID: <20241120215703.3918445-4-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139940035116600 Content-Type: text/plain; charset="utf-8" test-qdev-global-props creates a few subprocesses and test things based on qdev realize(). One thing was overlooked since the start, that anonymous creations of qdev (then realize() the device) requires the machine object's presence, as all these devices need to be attached to QOM tree, by default to path "/machine/unattached". The test didn't crash simply because container_get() has an implicit semantic to silently create any missing container, hence what happened here is container_get() (when running these tests) will try to create containers at QOM path "/machine" on the fly. That's probably unexpected by the test, but worked like charm before. We're going to fix device_set_realized() soon, but before that make the test case prepared, by creating the machine object on its own. Signed-off-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/test-qdev-global-props.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unit/test-qdev-global-props.c b/tests/unit/test-qdev-glo= bal-props.c index c8862cac5f..b2a1598f8e 100644 --- a/tests/unit/test-qdev-global-props.c +++ b/tests/unit/test-qdev-global-props.c @@ -72,6 +72,25 @@ static const TypeInfo subclass_type =3D { .parent =3D TYPE_STATIC_PROPS, }; =20 +/* + * Initialize a fake machine, being prepared for future tests. + * + * All the tests later (even if to be run in subprocesses.. which will + * inherit the global states of the parent process) will try to create qdev + * and realize the device. + * + * Realization of such anonymous qdev (with no parent object) requires both + * the machine object and its "unattached" container to be at least presen= t. + */ +static void test_init_machine(void) +{ + /* This is a fake machine - it doesn't need to be a machine object */ + Object *machine =3D container_create(object_get_root(), "machine"); + + /* This container must exist for anonymous qdevs to realize() */ + container_create(machine, "unattached"); +} + /* Test simple static property setting to default value */ static void test_static_prop_subprocess(void) { @@ -295,6 +314,8 @@ int main(int argc, char **argv) type_register_static(&nohotplug_type); type_register_static(&nondevice_type); =20 + test_init_machine(); + g_test_add_func("/qdev/properties/static/default/subprocess", test_static_prop_subprocess); g_test_add_func("/qdev/properties/static/default", --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139929; cv=none; d=zohomail.com; s=zohoarc; b=OaQzlBRU92Kn5P16e/GNHemyC0cOyPH1mZd7q+qy2U/zLYYFYXbIVQlldVztW+miMycwQCwzA9XKhuTvQxKfHaLarI3Gg57SPlyJzEiUTpnVpDwJDgCWwfYyTqZA3tod/groTzf4TIDUcXtRnPDKj0PjIFH63+H4UzsSfj/ND48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139929; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pICttktoPXP0o0Y91pyX8XPxkopJ/YUp6Q3y8ZWPysw=; b=O0VrybBwLr1CHCWAjCMcmf9DsEbkegl10+rG2/rDv8aOtFF61ITKFoGTTHh2e0GnOyYIa3DdbheKaBKhPUidyjSETz/jy/gCMWjLQw2P6qdms9RDo/LMf6589Da4zPOKFQeW2LonK7hoPXV/CC7z1wVKJ8y5CwVM5RDRP8+I9Hw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139929303675.9113811611829; Wed, 20 Nov 2024 13:58:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshV-0008N6-TF; Wed, 20 Nov 2024 16:57:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshS-0008HG-CM for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshM-0006Nc-0y for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:24 -0500 Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-1IY-uPhtNOSdKosa8ao_-g-1; Wed, 20 Nov 2024 16:57:16 -0500 Received: by mail-yb1-f198.google.com with SMTP id 3f1490d57ef6-e3810bac8a7so381404276.0 for ; Wed, 20 Nov 2024 13:57:15 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139837; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pICttktoPXP0o0Y91pyX8XPxkopJ/YUp6Q3y8ZWPysw=; b=Yz5HZiZFsL94Nk0YkAX3/+KnCkMf+WpxMDpND2hREMLxf1QmtIqvQtFnU2tIpwV5dBawZX zZOYiamq/9p/KxIfVEbM7FID5+jm3E9BB9vB2rs6+BVcWlnVq6eoIcyJ/wbhFFrowGWrIE YIZHE2p4ezNAyDM0nh/nz+SVyQosfRA= X-MC-Unique: 1IY-uPhtNOSdKosa8ao_-g-1 X-Mimecast-MFC-AGG-ID: 1IY-uPhtNOSdKosa8ao_-g X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139835; x=1732744635; 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=pICttktoPXP0o0Y91pyX8XPxkopJ/YUp6Q3y8ZWPysw=; b=hAB1nmOCPuBCpXaE5K5f0ZnyccsadtHxg34fMTN0RZzUqZkkc9ChX2th3ZChPYFsFg YyTWw8mOi27tro3JMs33VK3jtbbhZsqX6UPZDp1HjiYEFfnt5lbh726nH5Z4B1MKGvVh /uF74OVlxfASDs9SiI8hyBpjAkWCmRg+K63sVzi0JkJ+K+EqtoVD1zwPkzWXZbe+589K yYQMCSl44O4daqvOsm5MSSi8BGvjYFPYGvcvyCZmiW3HInqw0BVg05FOr98q6suSi1ER L/EsuhPhOF607+nKZZ1nq9kEjl1Dk96rIkk1lJW7FJ3vi6MJX1J7KVhF6+ZDTJfpE83o 10gQ== X-Gm-Message-State: AOJu0YwevQqnp5L9cxGOtiSeyUiCjwxqPUAWaegOrxEQHuIlPGPWLzGM 3i5E5ImSLC9TmpKMnEnxlP8jZYEYQya2LIVBWDjemb0MW/DUKIGTUGWDoIWsUiWDig1kpDz3VBT lNV41UgC85AzTdiCkp244WA9USgElWuym3s3jiHRIQdfs1KvqFJDZT9HEl+LXhz/okqky8hS52S ffQL4McPNPtzyEYAsMHddJPA9LUg6v6AUZ7Q== X-Gm-Gg: ASbGncvOEeuCeebhbzqvAZY0tUxgKrqT4jbELIkoOLZBAX6knqOrAaYiGRnCk5FptbP CANWyddG5lkgb42/yLEivpGgwPdbGSzI9gfQFnHGQw0whWUqinIZUjDo9bhbLjenu78Et7OMBwV rUBQXzRPRZ3VO+z/NkZqQ6oGPjtDcKvH+Ov2lbF8ewexTPjNGiYWC69b33f1ivglRgcJr8G0y1i 8TuzCqkCBn2B9AqxoLrH3YMWDPdPXRIBAj4DQbAHmctFm1SVuEF8yd46Azf6u3DxBNrLFWA4/1h UUkvX+udKAZy5PINFCW8s4XT+g== X-Received: by 2002:a05:6902:2e0e:b0:e38:93af:4133 with SMTP id 3f1490d57ef6-e38cb6066e9mr3863420276.41.1732139834941; Wed, 20 Nov 2024 13:57:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUWF+4Xxud9q4OD9MX2uvolLtY/o7drR2XN10wxtEIDYuzVPDAw9ukLzatAzW5nqDVdIbuVw== X-Received: by 2002:a05:6902:2e0e:b0:e38:93af:4133 with SMTP id 3f1490d57ef6-e38cb6066e9mr3863392276.41.1732139834639; Wed, 20 Nov 2024 13:57:14 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas Subject: [PATCH 04/12] tests: Explicitly create containers in test_qom_partial_path() Date: Wed, 20 Nov 2024 16:56:55 -0500 Message-ID: <20241120215703.3918445-5-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139929833116600 Content-Type: text/plain; charset="utf-8" Drop one use of container_get(), instead switch to the explicit function to create a container. Signed-off-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/unit/check-qom-proplist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/check-qom-proplist.c b/tests/unit/check-qom-proplis= t.c index 79d4a8b89d..21b1e167ca 100644 --- a/tests/unit/check-qom-proplist.c +++ b/tests/unit/check-qom-proplist.c @@ -610,7 +610,7 @@ static void test_dummy_delchild(void) static void test_qom_partial_path(void) { Object *root =3D object_get_objects_root(); - Object *cont1 =3D container_get(root, "/cont1"); + Object *cont1 =3D container_create(root, "cont1"); Object *obj1 =3D object_new(TYPE_DUMMY); Object *obj2a =3D object_new(TYPE_DUMMY); Object *obj2b =3D object_new(TYPE_DUMMY); --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139897; cv=none; d=zohomail.com; s=zohoarc; b=G4OSLP9SLxCUYVig8QxVbEHAwyCnWA/iu7Gy18bAs0KbYIKScT+qp9w41RWWOV/lokXI246ZauP5aNSO+/SHkV3vHX//I8ldh1Z3l5oh3qEumej7jpx2gJ/Vmy/9Qa4xDNNO+zmzCHyO8sByFSzP5tbhn/AtrpzMOlVJgsCFhHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139897; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GdlWuAzVgLMPTb7jLHDxfnOi9pO2fiIoW8m2eDrLfQg=; b=Lm+tTSDC4zdwvUwtd81iNy86N23/ZfNW1Rf5Da3IAU9j3Cf7kMB1gaHfkL94vuD0zKEytCRa9jAr6g+ILmqAMus0TzpGk3AZ6Sr5K7ci/dxJjYnHseU8XfUmWliT/Qe9h1yNyhs3WqXEMI3pu2pnM9ZIdDQG/I9FO/dbAZOSfc0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139897807313.3299271511195; Wed, 20 Nov 2024 13:58:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshU-0008Ky-K7; Wed, 20 Nov 2024 16:57: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 1tDshS-0008HF-C4 for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshP-0006SY-Ba for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:25 -0500 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-32-MDcAJMaCMv2hjaOIBLbijg-1; Wed, 20 Nov 2024 16:57:19 -0500 Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-5eb742a18ebso204873eaf.3 for ; Wed, 20 Nov 2024 13:57:19 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GdlWuAzVgLMPTb7jLHDxfnOi9pO2fiIoW8m2eDrLfQg=; b=hOBbyi/+9xX5JCyTn8qRxrQUeUaobdWFZsyeulq2fyckHSWqipjAyZ2M6Keyb64klxiw1Y N4B0YcI13dnklzbJD/ei6iNSPSLs3RfhyXa8G8vxq2KG/+Yu0Yxh4iEikUyKQgLW670xah PnT96lBel1fFyiGoSD5c71dQZ0ws3RE= X-MC-Unique: MDcAJMaCMv2hjaOIBLbijg-1 X-Mimecast-MFC-AGG-ID: MDcAJMaCMv2hjaOIBLbijg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139837; x=1732744637; 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=GdlWuAzVgLMPTb7jLHDxfnOi9pO2fiIoW8m2eDrLfQg=; b=nzqSkL9kugiYmUnExfnqedt9ylyiyQqCqt5tZ5d9KRIgW9tND4aS2feQ4SEKJ9bdbP IoGiLABGiPonsw02nphay1rteHKQL0Y0Ts2XOIB12FxDfuG8RmDuZM8IoddY+qrvXXE+ nwS526Kk6woyl5bu41sKTPnoXS4OML9Y4x8Vx8+pvgj/g8seMaZ+NTdnqehiWlgd+jA8 vW5C7hemTmp51vKbP6dUfsdUUCoR4FiGUohjmp4cDgMqkdQiwsTiFiRQvakAZyg6tw5w Nif6mpGYI5t3St0pZAtAfg9cWyiNIPpFP1WE6p+ZlOhKaYsYj1/rpXlFjsauGiAkkycx Oy+Q== X-Gm-Message-State: AOJu0YyOPzd7o2CIdTeuPPWRx9rZimWEuxRUJeuWfBqAOSRjKHXj10KX LC9Y4sxMcxR1lYlkCzTnvVAlzZGJjg1eeF9/Qh4dBCrLu44rUePw2GkwQeXabjwmSZnjumeMEtb PbSUY4lLFdHqRNlEEPMTcThDd5CRmaz5lqF5eSsU27l4Ta6R7qB0qxTFghpUKEpqer6FwIrBI9a 5+cOa8KsakwFPpgsAJ4fbS5+8uAfK9X+CvYQ== X-Received: by 2002:a05:6359:2703:b0:1c3:8c84:e08c with SMTP id e5c5f4694b2df-1ca66495017mr344568655d.10.1732139837232; Wed, 20 Nov 2024 13:57:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZhlNlx3+iZq4ezAiFAE2b0r5JuUK83mBtbEHJy81HSXfFzaGsKsSK1jQ1j2lDNXCbJYSopw== X-Received: by 2002:a05:6359:2703:b0:1c3:8c84:e08c with SMTP id e5c5f4694b2df-1ca66495017mr344565555d.10.1732139836885; Wed, 20 Nov 2024 13:57:16 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 05/12] ui/console: Explicitly create "/backend" container Date: Wed, 20 Nov 2024 16:56:56 -0500 Message-ID: <20241120215703.3918445-6-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139899771116600 Follow the trend to explicitly create containers, do that for console.c on "/backend" container. Cc: Marc-Andr=C3=A9 Lureau Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- ui/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/console.c b/ui/console.c index 5165f17125..36f8c6debb 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1154,14 +1154,14 @@ DisplayState *init_displaystate(void) { gchar *name; QemuConsole *con; + Object *backend =3D container_create(object_get_root(), "backend"); =20 QTAILQ_FOREACH(con, &consoles, next) { /* Hook up into the qom tree here (not in object_new()), once * all QemuConsoles are created and the order / numbering * doesn't change any more */ name =3D g_strdup_printf("console[%d]", con->index); - object_property_add_child(container_get(object_get_root(), "/backe= nd"), - name, OBJECT(con)); + object_property_add_child(backend, name, OBJECT(con)); g_free(name); } =20 --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139951; cv=none; d=zohomail.com; s=zohoarc; b=d8VEwGtWPlBASrnEbtXnJI8d+P+2r9Z/eKPNpG3e34+z60VnG+6P946elhnkZ9zzbm4jrLomWqma6vmNxMcl55CEL3W8pPLpm1/cVWRq8wHCQNCV4pJRF6yot8ld0sTD6hkFEfy9tr3/yL04vZwBdSCW3DjRygP/vbqTkqxuEMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139951; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PREdB4/GA5F1WtJr+XErnL2nDAuMQINonyrD4P78cKQ=; b=mpN+6USedqkqb8+zsckHT8rkWlXkUZGaIYuVNiP/gdv4t3gCT2TFbIq8v7AYlqcM9RArpfoDluwriEulGcpQcskdWadHU75vk7mrldBu8ZMDERfUEVbFpzCmk92jXSvgczpgQkuA1V8IeBmixjdrNvzzf35wHLwI1/GR61X0Uj4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139951379629.1504071598886; Wed, 20 Nov 2024 13:59:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshW-0008Nl-2S; Wed, 20 Nov 2024 16:57:30 -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 1tDshS-0008HJ-Ca for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshO-0006QR-BV for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:25 -0500 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-386-6EN9IQXcM6egjXUy8UK7Zw-1; Wed, 20 Nov 2024 16:57:20 -0500 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-460c73093edso3031941cf.2 for ; Wed, 20 Nov 2024 13:57:20 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PREdB4/GA5F1WtJr+XErnL2nDAuMQINonyrD4P78cKQ=; b=fRz22foUYRNvPhtGVdBujBU9ofMI2h1kRY10VEs5mrkXcJQqktRI7+9u8KDEXxb6mnBsuR W/x59P6vHMzZARFNM9EAYfFV3T/gTkGa77xF55xth1B8AZE9/+ElhVqgizajC2o9ylRWTo 7/PogH+ztvcwYC+8FeAbZpMY5N/HyZY= X-MC-Unique: 6EN9IQXcM6egjXUy8UK7Zw-1 X-Mimecast-MFC-AGG-ID: 6EN9IQXcM6egjXUy8UK7Zw X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139839; x=1732744639; 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=PREdB4/GA5F1WtJr+XErnL2nDAuMQINonyrD4P78cKQ=; b=unysTrCwL5+Z3I69R9wP9PGUc8EnTb8irhn8Xbe0dfo13JJKfsIFDA2mZd5xcRP0nU I/zsPxKhF+XMS6y3PxvjmASqEBeShCjv9OCioFqdurBouuWjMR2RN227U26zBR6SIyFe iZaoq+CzUhf8sD6yonvuiRTNz2kfrRw60Ldd6367mgbjl8B/4vIHGjDG9sHVhxEWtiiL +C117OilCXbV2fXZFACu6oYILBaZfb8iTCDF+pu7KfHD5EYpzGhX5zMIYA+vKa7dCEw7 s8Ps2ngaWjfQHMgcwRywFRJO2zWsZemi3ZZ69jW5eFkURktE8PZX1MU+P/7ab2XgYCB5 0Rsw== X-Gm-Message-State: AOJu0YyiMQfim8EzCJcGlVHH3Lp2gXEDmw7lYoEiquIKiPhggHV7d/mQ qqU6XpoUKnqkR/uFV5YNCgd0if9FzFHwnOt1Rv1JYZmMPL6DOFiBv/97iG1tWPK+IGNu/W9WKI0 61qvKrqhRGV3KhPgktjYaM8H0z6ZvX3sVLe7RP7kfmoqsTG22s3Ed7tBmGhzY5fuiNaz/E0AZ3q kBxL7nJE0IX+1ayvPlhuswRB0xJbD6AoohAg== X-Received: by 2002:a05:622a:1bac:b0:460:edba:3696 with SMTP id d75a77b69052e-464786ad4e0mr46595241cf.29.1732139839276; Wed, 20 Nov 2024 13:57:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHVGHBdtQ/JmTIKWWrebmM1RCJOykDeHiCaIMIIXn6l1dAkdlCCtyvFple3xNRztYKMrd4FaQ== X-Received: by 2002:a05:622a:1bac:b0:460:edba:3696 with SMTP id d75a77b69052e-464786ad4e0mr46594901cf.29.1732139838917; Wed, 20 Nov 2024 13:57:18 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas , Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , qemu-ppc@nongnu.org Subject: [PATCH 06/12] hw/ppc: Explicitly create the drc container Date: Wed, 20 Nov 2024 16:56:57 -0500 Message-ID: <20241120215703.3918445-7-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139952104116600 Content-Type: text/plain; charset="utf-8" QEMU will start to not rely on implicit creations of containers soon. Make PPC drc devices follow by explicitly create the container whenever a drc device is realized, dropping container_get() calls. No functional change intended. Cc: Nicholas Piggin Cc: Daniel Henrique Barboza Cc: Harsh Prateek Bora Cc: qemu-ppc@nongnu.org Signed-off-by: Peter Xu --- hw/ppc/spapr_drc.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 1484e3209d..3d6ef26b38 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -27,7 +27,7 @@ #include "sysemu/reset.h" #include "trace.h" =20 -#define DRC_CONTAINER_PATH "/dr-connector" +#define DRC_CONTAINER_PATH "dr-connector" #define DRC_INDEX_TYPE_SHIFT 28 #define DRC_INDEX_ID_MASK ((1ULL << DRC_INDEX_TYPE_SHIFT) - 1) =20 @@ -514,6 +514,26 @@ static const VMStateDescription vmstate_spapr_drc =3D { } }; =20 +static GOnce drc_container_created =3D G_ONCE_INIT; + +static gpointer drc_container_create(gpointer unused G_GNUC_UNUSED) +{ + container_create(object_get_root(), DRC_CONTAINER_PATH); + return NULL; +} + +static Object *drc_container_get(void) +{ + return object_resolve_path_component( + object_get_root(), DRC_CONTAINER_PATH); +} + +/* TODO: create the container in an ppc init function */ +static void drc_container_create_once(void) +{ + g_once(&drc_container_created, drc_container_create, NULL); +} + static void drc_realize(DeviceState *d, Error **errp) { SpaprDrc *drc =3D SPAPR_DR_CONNECTOR(d); @@ -521,6 +541,9 @@ static void drc_realize(DeviceState *d, Error **errp) Object *root_container; const char *child_name; =20 + /* Whenever a DRC device is realized, create the container */ + drc_container_create_once(); + trace_spapr_drc_realize(spapr_drc_index(drc)); /* NOTE: we do this as part of realize/unrealize due to the fact * that the guest will communicate with the DRC via RTAS calls @@ -529,7 +552,7 @@ static void drc_realize(DeviceState *d, Error **errp) * inaccessible by the guest, since lookups rely on this path * existing in the composition tree */ - root_container =3D container_get(object_get_root(), DRC_CONTAINER_PATH= ); + root_container =3D drc_container_get(); child_name =3D object_get_canonical_path_component(OBJECT(drc)); trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name); object_property_add_alias(root_container, link_name, @@ -543,12 +566,10 @@ static void drc_unrealize(DeviceState *d) { SpaprDrc *drc =3D SPAPR_DR_CONNECTOR(d); g_autofree gchar *name =3D g_strdup_printf("%x", spapr_drc_index(drc)); - Object *root_container; =20 trace_spapr_drc_unrealize(spapr_drc_index(drc)); vmstate_unregister(VMSTATE_IF(drc), &vmstate_spapr_drc, drc); - root_container =3D container_get(object_get_root(), DRC_CONTAINER_PATH= ); - object_property_del(root_container, name); + object_property_del(drc_container_get(), name); } =20 SpaprDrc *spapr_dr_connector_new(Object *owner, const char *type, @@ -796,9 +817,8 @@ static const TypeInfo spapr_drc_pmem_info =3D { SpaprDrc *spapr_drc_by_index(uint32_t index) { Object *obj; - g_autofree gchar *name =3D g_strdup_printf("%s/%x", DRC_CONTAINER_PATH, - index); - obj =3D object_resolve_path(name, NULL); + g_autofree gchar *name =3D g_strdup_printf("%x", index); + obj =3D object_resolve_path_component(drc_container_get(), name); =20 return !obj ? NULL : SPAPR_DR_CONNECTOR(obj); } @@ -860,7 +880,7 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, = uint32_t drc_type_mask) /* aliases for all DRConnector objects will be rooted in QOM * composition tree at DRC_CONTAINER_PATH */ - root_container =3D container_get(object_get_root(), DRC_CONTAINER_PATH= ); + root_container =3D drc_container_get(); =20 object_property_iter_init(&iter, root_container); while ((prop =3D object_property_iter_next(&iter))) { @@ -953,7 +973,7 @@ void spapr_drc_reset_all(SpaprMachineState *spapr) ObjectProperty *prop; ObjectPropertyIterator iter; =20 - drc_container =3D container_get(object_get_root(), DRC_CONTAINER_PATH); + drc_container =3D drc_container_get(); restart: object_property_iter_init(&iter, drc_container); while ((prop =3D object_property_iter_next(&iter))) { --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139892; cv=none; d=zohomail.com; s=zohoarc; b=diPIeRw+1ihzWjns1mclMxnn2TTjM1u5ilWVwok5a8X4vC/6kZcWnFGjUHhzAkH5b/qjoQE/s5jWWaGK6Bf9WFJ3ojxSyUIc6kvTxX8jpSVshfdKOnqQcc5ejiVkO2rjjRKGqsvtH8dHj8L/GfeOSWmi534t5hGFlEV7O8Io+d8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139892; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2EHmLep7AvvNAIAY6Sg1hRRUPZ6LsfZnIsPCnbrbppo=; b=K1aM7vKTUIhS/0KMswZF3GswwyN4rnvGYS1c0QnF0j32gj8R+IE+0Y5wXX6wfEJpv19ISAoY+HQe3oq9I8oB7kCDN5SNDHWahc7Invwr4X5qL/+v8vV6xq1DqJR1K8KNR+Iyf41y6+6fFApWrg8hH5hyx8nDmSHOLuBUI4PToGU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139892716780.453420372928; Wed, 20 Nov 2024 13:58:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshW-0008PQ-H6; Wed, 20 Nov 2024 16:57:30 -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 1tDshS-0008HB-CG for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshQ-0006Sx-JK for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:25 -0500 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-491-igXLQSU2PE-GW8_ljdmJ7A-1; Wed, 20 Nov 2024 16:57:21 -0500 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4608a1a8d3eso3806091cf.1 for ; Wed, 20 Nov 2024 13:57:21 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2EHmLep7AvvNAIAY6Sg1hRRUPZ6LsfZnIsPCnbrbppo=; b=Nidy4+8Uc55iLPtVvyoczRRIcV3ht7H0HObWBmD45lQ5bAMJkbmmiLJDYhMghU1q3QQiLm AwGmQ4454L9lqF9ngDqtYCKneUnosc8TTsNyaM5QtVyY8uWAAxjTtxiN4EARicx3ySsY1G RHyCXbVtDvo8Qzg3YWU0wrqCEJTTDFM= X-MC-Unique: igXLQSU2PE-GW8_ljdmJ7A-1 X-Mimecast-MFC-AGG-ID: igXLQSU2PE-GW8_ljdmJ7A X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139841; x=1732744641; 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=2EHmLep7AvvNAIAY6Sg1hRRUPZ6LsfZnIsPCnbrbppo=; b=Pl1LjtKfC3F8C8th92t+OJkevE6CRMtH1Nl4vUfK3Z8ubPFtphxwOr6BbDwoLZ9dE6 iJKKXXjzS3nFb7GKuY1BOfWYmCKi5Y32vApucFwWsMi8jme9utdtSECePi7VbtT1pekO cFRXS+ZXtBdmudbLTp+x4Wx9w+tMxLPVyoFbItfV55Nk35Lrm3sAGpPUxTiaeLWB25x+ 7PhrfqMp++TQEYE/tpr2WfNYh4ClIopqEZGSrecb/B9jcRYQ1svvPSwiooxZ2s8bb4MB fTYOk2tD7uZLi+PVGkK9/KhjG1b+cUrsQM5ioMDMTBc7Y8spwKlHA4E8CgNwzaEOeRiL XGUg== X-Gm-Message-State: AOJu0YwJ5CB4ESdsFwrL9uYmefz+LbrC/GB3VJYuAvvk/HvrVIkrUvct 4RsF+71ivWLEyxWe8ShDFTBtw3Cb+gGCBRS0s2yxEhsKF9dy8PajShZDcI98vkiISMvi783x3JE ApB4y73ESd/zSyfAyq25gyzxzwB6Ex8mAD5ocRxYfWcFtYwZEiddOxr/rWyUB+P+7UwNUj0NrtI UDdo0sHypSqQRddbZic779MHEwyAayiTOBfA== X-Received: by 2002:a05:622a:90e:b0:460:a82a:39c9 with SMTP id d75a77b69052e-4652f4223b1mr18963541cf.10.1732139841039; Wed, 20 Nov 2024 13:57:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhTpJFYFPaqKrCGOnAQRP/66QSpuJXauYaNnVDsD42aETz7S6mjdkTaLvKyjx4avskcOkRBg== X-Received: by 2002:a05:622a:90e:b0:460:a82a:39c9 with SMTP id d75a77b69052e-4652f4223b1mr18963051cf.10.1732139840694; Wed, 20 Nov 2024 13:57:20 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas , Bharat Bhushan , qemu-ppc@nongnu.org Subject: [PATCH 07/12] ppc/e500: Avoid abuse of container_get() Date: Wed, 20 Nov 2024 16:56:58 -0500 Message-ID: <20241120215703.3918445-8-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139893945116600 Content-Type: text/plain; charset="utf-8" container_get() is going to become strict on not allowing to return a non-container. Switch the e500 user to use object_resolve_path_component() explicitly. Cc: Bharat Bhushan Cc: qemu-ppc@nongnu.org Signed-off-by: Peter Xu Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Daniel P. Berrang=C3=A9 --- hw/pci-host/ppce500.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c index b70631045a..65233b9e3f 100644 --- a/hw/pci-host/ppce500.c +++ b/hw/pci-host/ppce500.c @@ -418,8 +418,8 @@ static const VMStateDescription vmstate_ppce500_pci =3D= { static void e500_pcihost_bridge_realize(PCIDevice *d, Error **errp) { PPCE500PCIBridgeState *b =3D PPC_E500_PCI_BRIDGE(d); - PPCE500CCSRState *ccsr =3D CCSR(container_get(qdev_get_machine(), - "/e500-ccsr")); + PPCE500CCSRState *ccsr =3D CCSR( + object_resolve_path_component(qdev_get_machine(), "e500-ccsr")); =20 memory_region_init_alias(&b->bar0, OBJECT(ccsr), "e500-pci-bar0", &ccs= r->ccsr_space, 0, int128_get64(ccsr->ccsr_space.size)); --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139918; cv=none; d=zohomail.com; s=zohoarc; b=Ghr3neg9RH4/PrCnEZlxP6ZCgnWxTyxMXOGdF5imKsd1t4t+oU6gjf+W/uWY7sqLSU8akBctSIVuC8qLVFpyYEUGdrZ08aarESnbdoo16isJcDVrBICwsUPjM42Sf4kTgTGGxFvhDrmn5Q16aaIr/sp9dFsEGzAs0SlllhAQfAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139918; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RUD/75mbaWwn03RfqmIGYTLyWheX+4TPboJRY2WclVE=; b=iVubpBKZ6EXqmiDizUk43kbDD41o1wNENH0oUo9CS7kgwVfv7C2em3n6Ksk11/yNE5jine9hZJoxA+PtCTfVMU1a9h1siYVbQRsCU5Ff58Io+2uDAHRspznKRcpBcSlxUicYM+A08M//MBSz7xbL5mi9XC2aHHsCQnZE+kwTER0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139918708764.7388738834254; Wed, 20 Nov 2024 13:58:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshY-0008TI-VH; Wed, 20 Nov 2024 16:57: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 1tDshU-0008LO-Pp for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshS-0006TN-PE for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:28 -0500 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-Jo10uGCKMr-bUZlYDy-yHA-1; Wed, 20 Nov 2024 16:57:24 -0500 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-46360a97a99so3370731cf.1 for ; Wed, 20 Nov 2024 13:57:24 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RUD/75mbaWwn03RfqmIGYTLyWheX+4TPboJRY2WclVE=; b=fqCnA9ZDNeMxnFha1NVcPPGbyAykCyPYVscz0VmmcYkvTfHfzpuCdIKIygON91zEU9S4au C2f3OxdI/OVchqPz2332XxsmxWxy16rGYEIw4MXYE8Gt/SvN5ELva1yt8CkB5CZhKKPXIc cZk30vOPpESJpT7vcopvSZAT5ADEhAM= X-MC-Unique: Jo10uGCKMr-bUZlYDy-yHA-1 X-Mimecast-MFC-AGG-ID: Jo10uGCKMr-bUZlYDy-yHA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139843; x=1732744643; 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=RUD/75mbaWwn03RfqmIGYTLyWheX+4TPboJRY2WclVE=; b=P3RhouwtsWz+g9KL04TxDo1a7LK0kt6VKS4CLPz91pK6D3nWtQDBOPklgHaZz9TUZF lokhxmDekhJQQzrN3eqC6I87+lmDJ3AUiWLOyopeKfJGB2LqbYP96/npPy2lzvzvXm4E clwtFD3IoeaiZKYdSlBgOqvOuwjGhe7fBA3nHJ+GoZd5nsuT+hDMn182TCVeutnVlqhw TgW37iueQnW9vE0jSD+U9IIKfwKfcqcJziTIseLpi3p5/f8rZeHz+6L6m0NygK6bXGdA 20y0J7HLyMjKUdnSdIL/9qLzgGpWbgmiipFsXp9cQhC5oVSprpNgGtOoLCxS/bXPADrJ RIJA== X-Gm-Message-State: AOJu0YxiM26clSAeHxRIAwWngYgV09/Zu9k0fgNPu28x6oHRO4IyVWN7 2VT40fdDmSPHNCsoyuh99NhaUvYhvOJ7VFRHEZ0sIgqcKpPbe+TV6NEnTllpppDT6xIL2sp2QK8 nCtjNGh59ppZlKrXcujs8q6pLRXNW5UwkifIDcOG/EYZwaT5UGCeprBw+h6YXCYX7ESx/LZ23DX G2Zvo//CptA5rwvL8Nt3h0BfTUDoUJ8acDfQ== X-Gm-Gg: ASbGncuPgCHTaBq3qNiDI2QczpAA4I+955jBAVWrIPUZHliEx7upXOd6j39sDIRLYMD YOmrzmYK8Bz1hrGv2IQAuWYqQv+1JAZGt/R+j9tbS+tGbs5v4DAeCQW4r42E6SC/ykJs9/mRfst kVanSk+Hwn9etT1Ju0yMdnXfJjmaHBfLysnVcisIWNX+Uw5BZYclGg3kjFCJiBaRaagzADftcLL ItgoczzchRwyXWDMRYqrrsQN5ws49i2a23IYlbdYi/cZc9ipxi9XWDF2L2IDGuNRf+qHkngqjuT ChDVDnsR50w1auS4yxoshsbqbg== X-Received: by 2002:a05:622a:14d2:b0:458:5ed8:628 with SMTP id d75a77b69052e-464777e2232mr59002371cf.2.1732139843622; Wed, 20 Nov 2024 13:57:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IFrC2z4vGUqPgvRExvNJVpIY1AFRTKu3DMVYSLro3WVe+B1QpGlLkd0XbuTt8jH4ALDwOj7XA== X-Received: by 2002:a05:622a:14d2:b0:458:5ed8:628 with SMTP id d75a77b69052e-464777e2232mr59002081cf.2.1732139843259; Wed, 20 Nov 2024 13:57:23 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas Subject: [PATCH 08/12] qdev: Make qdev_get_machine() not use container_get() Date: Wed, 20 Nov 2024 16:56:59 -0500 Message-ID: <20241120215703.3918445-9-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139920211116600 Content-Type: text/plain; charset="utf-8" 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 --- hw/core/qdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 5f13111b77..c869c47a27 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -817,7 +817,13 @@ Object *qdev_get_machine(void) static Object *dev; =20 if (dev =3D=3D NULL) { - dev =3D container_get(object_get_root(), "/machine"); + /* + * NOTE: when the machine is not yet created, this helper will + * also keep the cached object untouched and return NULL. The next + * invoke of the helper will try to look for the machine again. + * It'll only cache the pointer when it's found the first time. + */ + dev =3D object_resolve_path_component(object_get_root(), "machine"= ); } =20 return dev; --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139952; cv=none; d=zohomail.com; s=zohoarc; b=mmr3BWyHhSNlHC2Szz4thegovyQmBOZWCCdwhhVDPr4DX2c6HIqpQxU2ov8eh2HXJoNOXa/0ckPp76jPlJ8YQWuVtR02OY96iAAfrjbum8VS/IYAmEsQf06zhMw1X2e9BjgoaQ3S73UoIMkdb3f++XpsUBWUXdmzDeOvVKvgNT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139952; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AlcX7vR9/mJZNCZh9j7iz8mHqKYU+1nKrqM52qsEyNA=; b=Fyu2OPjyEt2t2onfBonAODxHayuM48xl7mZAmHc+8fZXVPAEiBZucWeyIUZkUnERrQCzCesgSfljeKhpjmCDCYHgSNovGf1ptwmY1D8HZ1MaobvP57F+6z9Ipy/yiKTTKprMF1p3oM6OhIHg9V0gsDKwH2dQMGlQ3XE0jiZUclo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139952292283.1686246068481; Wed, 20 Nov 2024 13:59:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshb-0008UI-75; Wed, 20 Nov 2024 16:57:35 -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 1tDshX-0008R0-2Z for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshV-0006U3-Kp for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:30 -0500 Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-298-05MCBheKNgafiWWNFD1t6w-1; Wed, 20 Nov 2024 16:57:26 -0500 Received: by mail-yb1-f198.google.com with SMTP id 3f1490d57ef6-e30cf48435fso325702276.0 for ; Wed, 20 Nov 2024 13:57:26 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AlcX7vR9/mJZNCZh9j7iz8mHqKYU+1nKrqM52qsEyNA=; b=Pm/sLC3+6HTNnrUb0T1ePH+IfanHNBDwfUzfA8ZtVQPbtlytPQyaumkfqZdh/MdUmBCp3h x1jnYnTUZ8NBbel6w/VCwWKO5z96ruRI9UtyZFMnf/zNRPKrtQfzVaMib1QL4kLo79EXOC vvS2/VPK1ZnylNwdtC5/yHoCmO+JorU= X-MC-Unique: 05MCBheKNgafiWWNFD1t6w-1 X-Mimecast-MFC-AGG-ID: 05MCBheKNgafiWWNFD1t6w X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139845; x=1732744645; 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=AlcX7vR9/mJZNCZh9j7iz8mHqKYU+1nKrqM52qsEyNA=; b=Gom6Ot8n7p9MnbH03VE9fZ4fzr9xNfCxSN6ZZ+F6xyFGCeY19w9DKzR0kDXFGWonQm K8Zpg+ahLpGkFqrVqT51IheiWPG9+FjuqJFeY5ibmX7YlemzyD7S95CAU9UulM89AyYJ vEMATXUReBHkhtue0o5TtaaA7MPnBJmxUTVPnJoPkpVP1f9tM2keVnENnXkFFQWekK5R 7cGjsv6V/qutt2AGupC471fv6UTAeOR1waFoiXQeUl6mRwfcogYjgC4EgYushTtK+9OY W92wkjnZCmgMSbmlkbmj2SeHHFfmilbkqcnLpp5VrUK56V45jAQ0lWxzqF3x9l+7HA9s baNw== X-Gm-Message-State: AOJu0YwR+aeF89AYF47eDIst/dmUzG44CO5y49Cx7B9io+woaDihc7vV ohfhU6NEqABD6EKBudyTQkfX9S2nIH4pwngCaKad4XqbvVGoiOVxT1ScrwDYXWqBBfB9RPl3mYZ amSt3TyExSSgoOiVNrB+8J/RQgMfIFmkugQOLHtidzH1ucSH0dEcg18L7JBR0yenhcsqj9TQ1wV XVytnzW4B1foBqYog8AMMHa/nz7c1GOrsqQg== X-Received: by 2002:a05:6902:2510:b0:e38:7b08:867d with SMTP id 3f1490d57ef6-e38cb601d51mr3972711276.40.1732139845602; Wed, 20 Nov 2024 13:57:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtMOwvJ/qXdCVBrXtKWx6hrxtSYuXOITngPAjEwqna7/9eE1JlnYujaPCAN1dqxHkCTlZnWw== X-Received: by 2002:a05:6902:2510:b0:e38:7b08:867d with SMTP id 3f1490d57ef6-e38cb601d51mr3972663276.40.1732139844873; Wed, 20 Nov 2024 13:57:24 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas Subject: [PATCH 09/12] qdev: Add machine_get_container() Date: Wed, 20 Nov 2024 16:57:00 -0500 Message-ID: <20241120215703.3918445-10-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139954247116600 Content-Type: text/plain; charset="utf-8" Add a helper to fetch machine containers. Add some sanity check around. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/qdev-core.h | 10 ++++++++++ hw/core/qdev.c | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 5be9844412..38edfb1b54 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -996,6 +996,16 @@ const char *qdev_fw_name(DeviceState *dev); void qdev_assert_realized_properly(void); Object *qdev_get_machine(void); =20 +/** + * machine_get_container: + * @name: The name of container to lookup + * + * Get a container of the machine (QOM path "/machine/XXX"). + * + * 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 c869c47a27..6cb4fe4691 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -829,6 +829,23 @@ Object *qdev_get_machine(void) return dev; } =20 +Object *machine_get_container(const char *name) +{ + Object *container, *machine; + + /* + * NOTE: nobody should call this _before_ machine is created. If it + * happens, it's a programming error. + */ + machine =3D qdev_get_machine(); + assert(machine); + + container =3D 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 !=3D NULL); --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139898; cv=none; d=zohomail.com; s=zohoarc; b=GmL660YkZdo27fILsBtTSXX3xAVDTBEYKb2bQ9T59qpx2ik/eaRUXCheQQD9g3pdp5BxkzAi3BukN8wAIPzeMBwzjtxllf1aiMVeWD2AhK3EYDqMT3YTp2d6EoyZXaLmSsDU/mdr9ILoD7B/3zKzoFAVCPEt4TisW/DYz8J3MW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139898; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mpJER/wYd4T6D0J0YdjUL6DwWyjfFMtJPuGjw2kdAM8=; b=Bwk/imi0cwSkqvhxPSB+2UDauNNpXZCNj1SEWnXztsTOQO3J31m01ZdJQZrgCU1jw0ZvG5x9QUyJ4tsCNZGNfwR1bTMQSloIcDw+vcV4HBrYCWrH8K1ViiRSF8leb314/pQ1hleJbgn5MkkYlRWh64RKKPZ1hyqjDaor+0zPbAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139898599452.5908279946166; Wed, 20 Nov 2024 13:58:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshg-00005o-Jv; Wed, 20 Nov 2024 16:57:40 -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 1tDshX-0008S8-KE for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshW-0006U7-5E for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:31 -0500 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-43-NYDU3bSZPxConvnsTgXwKg-1; Wed, 20 Nov 2024 16:57:28 -0500 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4608d303ebeso2903581cf.0 for ; Wed, 20 Nov 2024 13:57:27 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mpJER/wYd4T6D0J0YdjUL6DwWyjfFMtJPuGjw2kdAM8=; b=ibTOfJXerwfMUrSzcm1Dy3YilehpKesAmz/+7R+prpMK3eT2LfG9Gg+x6GBEfLlf2U9FrV q2B/rfcL4U+GaQf1az40zhqtI+K9DXqlNKRMsRXY+VpqwxtK9kn51kwNNnYuJiuMReBuzj FHJ5RpRQ7ySFT7WStmdo10C5gXnv5qc= X-MC-Unique: NYDU3bSZPxConvnsTgXwKg-1 X-Mimecast-MFC-AGG-ID: NYDU3bSZPxConvnsTgXwKg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139847; x=1732744647; 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=mpJER/wYd4T6D0J0YdjUL6DwWyjfFMtJPuGjw2kdAM8=; b=l2F1Q3B0vToOzGmcqdJHUZS+ZZPEc+udYgtm8wesNbbba7opI+EABnl7RNv0W09eV7 jcaePaHy/hCubvqErrNsgvh5BOSr7uOXcxJ44E03T4zGd4/l9SoPbkzb6L8eUge5Wcbv ez9bPZKphLA0CxKI8EFDMx8qkZVxrH4AgYVZW00X3Ndx7ur70E1B8XK11IGKfd7/wyji RQHjyJuPV6vOnAIb6mr0riilatTP1MgGnUV1GHxD2om7POjp/PEshYxp665xjXE7C/Zb YQQzYRjmjICa26NdcBHjL8lnSZa2eXN6w4UzKvHksUXqDVHivGt0BKeVdG/okXdn2ruz fe2w== X-Gm-Message-State: AOJu0Yy/WFvXYo1jtMwTcvDKqzPYC4lpTYx1aagiMit7rXJnFWEegFNB IL3Q9ykZVFgc6xbbH2LT+0gPn/pZPdxe5xGgOfEeXE4hlh7M5eFqGLb4tkq+gTmQn4AVKtsx4xk vQGaYjlrKMQCZl1H6ADe+NfAwg3zuhGC+VU6RTOEMCJ+sBziREIX/WhKtGkRwHIZzsb5Xn+Mhbs wCt8G5j7SH4cXxwj91ezB6cnd4uqEjBWJq7w== X-Received: by 2002:a05:622a:1929:b0:461:22f1:dd17 with SMTP id d75a77b69052e-46479b3f8famr51132001cf.41.1732139847288; Wed, 20 Nov 2024 13:57:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEixnMe5QzRr4geZePKFKIi+MNm54MALeM743Sq2Y7/tNWRPgLBq0p7RifvgnSyJKoYDuraEA== X-Received: by 2002:a05:622a:1929:b0:461:22f1:dd17 with SMTP id d75a77b69052e-46479b3f8famr51131671cf.41.1732139846879; Wed, 20 Nov 2024 13:57:26 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas Subject: [PATCH 10/12] qom: Create system containers explicitly Date: Wed, 20 Nov 2024 16:57:01 -0500 Message-ID: <20241120215703.3918445-11-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139899807116600 Content-Type: text/plain; charset="utf-8" Always explicitly create QEMU system containers upfront. Root containers will be created when trying to fetch the root object the 1st time. Machine sub-containers will be created only until machine is being initialized. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/machine.c | 19 ++++++++++++++++--- qom/object.c | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index a35c4a8fae..a184dbf8f0 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1193,14 +1193,27 @@ static void machine_class_base_init(ObjectClass *oc= , void *data) } } =20 +const char *machine_containers[] =3D { + "unattached", + "peripheral", + "peripheral-anon" +}; + +static void qemu_create_machine_containers(Object *machine) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(machine_containers); i++) { + container_create(machine, machine_containers[i]); + } +} + static void machine_initfn(Object *obj) { MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); =20 - container_get(obj, "/peripheral"); - container_get(obj, "/peripheral-anon"); - + qemu_create_machine_containers(obj); ms->dump_guest_core =3D true; ms->mem_merge =3D (QEMU_MADV_MERGEABLE !=3D QEMU_MADV_INVALID); ms->enable_graphics =3D true; diff --git a/qom/object.c b/qom/object.c index 214d6eb4c1..810e6f2bd9 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1734,12 +1734,26 @@ const char *object_property_get_type(Object *obj, c= onst char *name, Error **errp return prop->type; } =20 +static Object *object_root_initialize(void) +{ + Object *root =3D object_new(TYPE_CONTAINER); + + /* + * Create all QEMU system containers. "machine" and its sub-containers + * are only created when machine initializes (qemu_create_machine()). + */ + container_create(root, "chardevs"); + container_create(root, "objects"); + + return root; +} + Object *object_get_root(void) { static Object *root; =20 if (!root) { - root =3D object_new(TYPE_CONTAINER); + root =3D object_root_initialize(); } =20 return root; --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139982; cv=none; d=zohomail.com; s=zohoarc; b=St1vS9Ts73eEdNoZajEoNS7GNfDvYxDoC5fg6hEo0K1nSUrTVHTw9bftSmcbjpjb/adz+mtFmndfvvYGHhxb2b8dWsHuykIybSe8E34ewxYnaDN3wAoGtuPeEWqy1Dq7JQMHIq3sFo2XT/mbp24Ecylr/55osRR66phW/uNv/oI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139982; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=u0jDqqudCxAu71oFUQRU0Kfl+jPW1gD7xhuPkzFbPVs=; b=OOeLMZEh3XNQ9JU1ZuzAh7yuevdSZcFPHO5A5g0g53JNJKPhq12qp0LOF6OI7V1lramRlIzXu01PMSew6NtYF141boQ9QKCJYqG1QdNBMoIaxZTDHy/ROUIkbJRyCrkG+ArBbthL53LoxyhBhubK41I86Kw6dH18vFZMH2wl2/M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139982842602.9153756610528; Wed, 20 Nov 2024 13:59:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshk-0000Dz-4X; Wed, 20 Nov 2024 16:57:44 -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 1tDshj-0000DL-1L for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshd-0006Uk-05 for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:42 -0500 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-428-5cv0xMfWMMiX2kJdCf1-Lw-1; Wed, 20 Nov 2024 16:57:30 -0500 Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-71a3da16d58so240519a34.3 for ; Wed, 20 Nov 2024 13:57:30 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u0jDqqudCxAu71oFUQRU0Kfl+jPW1gD7xhuPkzFbPVs=; b=Mmgh+ITom1MWPPsCG0nay3L/JhSkArd/KeSdMcXC3VGe9byf1wKTbQbDq5J4Akq9i36k9R eImp24DO/3wIzh+EP6n1idpYcLUnWytCs+VFs9SwgwwWQwrxZ9EigF9jEX825gL6V05IFz BKPmEqEZVjKOa1zFLsKgBUltBTDLstQ= X-MC-Unique: 5cv0xMfWMMiX2kJdCf1-Lw-1 X-Mimecast-MFC-AGG-ID: 5cv0xMfWMMiX2kJdCf1-Lw X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139849; x=1732744649; 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=u0jDqqudCxAu71oFUQRU0Kfl+jPW1gD7xhuPkzFbPVs=; b=RJpa1rvAs4yBr8+6N24z7rKLjRVMEtOQ4DopgnmTVkBSb7EiaL8aDWQ1eOQSUgswsJ Dy2fVwJZ2fhv8sZqfhA5K06tcL4ZSSY7DA4Xn1UJTwefFlSnFra1UcdsK/yFLURTY3Mq 0Rv4qsPCqGUoph6sTQz/01a2LIuHZHNCFHzLDqoKFVlg4+gflKpEGkRzLNlTp7ag1hc3 rkxM/2GSma2S0JKp8Y36OCzQQmN7ruHOjDxHYI+5oXTlmzdtlZZSOnaGeX0TKQXpoQ3F B8sFnan64raMKyiAp7LwQ3WxCMPyzag1zPKCbIuJCHKIt4EqeoO0db9qAtg/TVM70VPg P7mA== X-Gm-Message-State: AOJu0YzQ9dX9UGbwrYkGiXs9dd9B7UbXHgD+fUcWZJG3/X4XYVwosanz uwZzTdd5qD/I+YxoXEiHRb0ffYu0ZfJzhiCTUYGrsbdysQDKJwtdsAZEuVTi/ccOkVgfef8wira Jn7QQi9Uh4CpYGeJwgBfElOp4xZ0xLn3tyiYEUlEcEZqaEJpglpfP5Q9nEHWHEa6rsM13h0Qwki nmvyB4Esk7FGXHpqfCwzSNxvn5OD7kJ30r/g== X-Gm-Gg: ASbGncuP+0UREEI3doQdNDv+JcSdIPUG53f6G+tnyttAJwcdMq2PmcTpRFBZP5O9oGe DQX0Y8O7fw80ts0ZZ4j/w9BLraO+t/6qHl0eA8T3kc5vzJq/F2U4AhG3C6BFte+NYcfc+odjL4G k1Pdz8YDkRrtFf8855Vr/m1XB2Hoh8jhO45mhOKLugfWgk1/fZSY7ygcK697TsNL8EKEiGxhe1n lODAxs5Q/g7cIByAt4fyLuGrWAiXBrD6yu0VsUWDfYO/MT22L5yEzNm+LY0aNRVtq6yZ1mZ53F1 UvrJ9x500O+IVegaaSXndBwCKg== X-Received: by 2002:a05:6358:7aa:b0:1bc:58bc:ff14 with SMTP id e5c5f4694b2df-1ca664947femr337723255d.10.1732139849302; Wed, 20 Nov 2024 13:57:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEo9MBMpx+CJGTi9ic34jdBJyCvTF74aN8KAHGuB04iBGFPopNgBUzSPsjJBXNqKPvOe6W90w== X-Received: by 2002:a05:6358:7aa:b0:1bc:58bc:ff14 with SMTP id e5c5f4694b2df-1ca664947femr337721055d.10.1732139848923; Wed, 20 Nov 2024 13:57:28 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas Subject: [PATCH 11/12] qom: Add object_get_container() Date: Wed, 20 Nov 2024 16:57:02 -0500 Message-ID: <20241120215703.3918445-12-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139984282116600 Content-Type: text/plain; charset="utf-8" Add a helper to fetch a root container (under object_get_root()). Sanity check on the type of the object. Signed-off-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 41ef53241e..87b13f9681 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1524,6 +1524,16 @@ const char *object_property_get_type(Object *obj, co= nst char *name, */ Object *object_get_root(void); =20 +/** + * 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); + =20 /** * object_get_objects_root: diff --git a/qom/object.c b/qom/object.c index 810e6f2bd9..cf66803a6a 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1748,6 +1748,16 @@ static Object *object_root_initialize(void) return root; } =20 +Object *object_get_container(const char *name) +{ + Object *container; + + container =3D 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; --=20 2.45.0 From nobody Sat Nov 23 14:48:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732139916; cv=none; d=zohomail.com; s=zohoarc; b=mOmhQp10fj9WDyl0T6XNb80QseVZFJv5iHlkIPN9VV9j6bxmtNbdIXHcpc1+CuUO16aoSkG0b9V4UXZU3IzsScKQ+vz7LFGKFOKlIm8ryQcgoa2NLBQ+zAMNhgZSmQ7VBXl8hlrAF1MPkJ/77BbtzUZl7iqpQKLPjHrM1CtIqPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732139916; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FJcYtzNcS/KJmVCbZN7uP14mLneR75OL7jx8KA2RQuc=; b=APTGRl6o4t8A7ZqY+Ses1eWNrzDjlgEng8PvkjENsEBc9QwzAdYqGOlaHYMaXdKQXqghwPiUP6sAravGWHc32qRC2hGCiAOI8prQItp8NcNYMJHlD48ubeGTWXRUrK7npgplNOP2p5heYrYbA//vtai+C2eHhGcrYRodIEBOxfE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732139916002452.2257615600429; Wed, 20 Nov 2024 13:58:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDshk-0000E0-QA; Wed, 20 Nov 2024 16:57:44 -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 1tDshj-0000Dh-O0 for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDshh-0006Ut-2b for qemu-devel@nongnu.org; Wed, 20 Nov 2024 16:57:43 -0500 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-466-OMQAYkwyPQumgzANT7LCVA-1; Wed, 20 Nov 2024 16:57:32 -0500 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-460dd08f4d0so3144391cf.0 for ; Wed, 20 Nov 2024 13:57:32 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-464680d6826sm14632881cf.15.2024.11.20.13.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 13:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732139855; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FJcYtzNcS/KJmVCbZN7uP14mLneR75OL7jx8KA2RQuc=; b=AgLArsYXlQJgtFJfZ6HUUaHJJuJirBiF+45lp4jVf8M5b+0ighYB9XGjLbDB8jCSmf0ylD jZVg8wfRVohzNm8Ig73WjKSSfIpVWWg78wKMkVw3wQlDAOUYOMuEDMuZeAx1MSpTD2gB8q cgCn8ilQQ8JzpOefqoBVX6BWPdw3kCo= X-MC-Unique: OMQAYkwyPQumgzANT7LCVA-1 X-Mimecast-MFC-AGG-ID: OMQAYkwyPQumgzANT7LCVA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732139851; x=1732744651; 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=FJcYtzNcS/KJmVCbZN7uP14mLneR75OL7jx8KA2RQuc=; b=BxXHr1m1xdVvOotoMslcDhHXTq+a85sX5G4bPkpfeEcC+NURJs/VTh6Nulg55zmro/ vToiTvsasXOf6uGEl/iNb+rVIVfzOWxJzZqchT4lLKm7IZbnNE804S8wLW93FPL671aQ jCpkehsuZNRH4HD2Q9h0CTWZFzPdocSGiitF3CMHBn8tFpbwHIm+mbu5OZ3wNF0+0Jmi BE4WBFPmyOkdwFTiKtgx6OGJ0PaBuHy/wiW9YMUNt9vtTPPK+FrRiugst5dlcKT68aSJ D+OZh0jnLJOnZXEwXQl4Cx+FH17Oahop5X/HS1GRw/L0zlQ7Fd5qm/J1tPv0Og16PM28 fCMQ== X-Gm-Message-State: AOJu0Yxv/EE/WbRwxI5LBPQ48+8rf/w7ueP2hVV0lpACPNFG+wfkqWeb 1jO3RRfDCZ6K98VBrJEJqFlE5cSmR22akEocXt8Qbb3Sj5x08sV1zLnhE36E1BOQzrcWEd8jIyh 7G3d5f7IJiqk4MaGPl1paz3dbvhXAKvnLGBvlSRzt9RAAX3D/BMh/o///Xp1ujTemlSZI/46GDX 8H7gdZN7kKtlYj/HHB9zoZDXCME5ckn3X7Rw== X-Received: by 2002:ac8:5891:0:b0:461:2231:e01a with SMTP id d75a77b69052e-46479467757mr56904141cf.32.1732139851036; Wed, 20 Nov 2024 13:57:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLbiqfqs4MVgyaQoKxK2S34gY7K4DXnZFItvg3HSsgNUwY4U8b3y1iMzlFjHYGTD2Xk+jFzw== X-Received: by 2002:ac8:5891:0:b0:461:2231:e01a with SMTP id d75a77b69052e-46479467757mr56903841cf.32.1732139850712; Wed, 20 Nov 2024 13:57:30 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Juraj Marcin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paolo Bonzini , Fabiano Rosas Subject: [PATCH 12/12] qom: Drop container_get() Date: Wed, 20 Nov 2024 16:57:03 -0500 Message-ID: <20241120215703.3918445-13-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com> References: <20241120215703.3918445-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732139918132116600 Now we should be ready to always create containers upfront, meanwhile we have explicit helpers to fetch either: - Root containers (object_get_container()), or - Machine containers (machine_get_container()). Change all rest container_get() users to use the explicit & fast version of container lookup helpers, finally remove container_get(). Suggested-by: Daniel P. Berrang=C3=A9 Suggested-by: Markus Armbruster Signed-off-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 --- include/qom/object.h | 12 ------------ backends/cryptodev.c | 4 ++-- chardev/char.c | 2 +- hw/core/gpio.c | 3 +-- hw/core/qdev.c | 3 +-- hw/core/sysbus.c | 4 ++-- hw/i386/pc.c | 4 ++-- qom/container.c | 23 ----------------------- qom/object.c | 2 +- scsi/pr-manager.c | 4 ++-- system/ioport.c | 2 +- system/memory.c | 2 +- system/qdev-monitor.c | 6 +++--- system/vl.c | 3 +-- ui/dbus-chardev.c | 2 +- 15 files changed, 19 insertions(+), 57 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 87b13f9681..c6e7a7fc08 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -2031,18 +2031,6 @@ int object_child_foreach(Object *obj, int (*fn)(Obje= ct *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); - =20 /** * container_create: diff --git a/backends/cryptodev.c b/backends/cryptodev.c index d8bd2a1ae6..263de4913b 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 =3D NULL; - Object *objs =3D container_get(object_get_root(), "/objects"); + Object *objs =3D object_get_container("objects"); =20 object_child_foreach(objs, qmp_query_cryptodev_foreach, &list); =20 @@ -557,7 +557,7 @@ static void cryptodev_backend_stats_cb(StatsResultList = **result, switch (target) { case STATS_TARGET_CRYPTODEV: { - Object *objs =3D container_get(object_get_root(), "/objects"); + Object *objs =3D object_get_container("objects"); StatsArgs stats_args; stats_args.result.stats =3D result; stats_args.names =3D names; diff --git a/chardev/char.c b/chardev/char.c index a1722aa076..22fc5f7f76 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -48,7 +48,7 @@ =20 Object *get_chardevs_root(void) { - return container_get(object_get_root(), "/chardevs"); + return object_get_container("chardevs"); } =20 static void chr_be_event(Chardev *s, QEMUChrEvent event) diff --git a/hw/core/gpio.c b/hw/core/gpio.c index 80d07a6ec9..6e32a8eec6 100644 --- a/hw/core/gpio.c +++ b/hw/core/gpio.c @@ -121,8 +121,7 @@ void qdev_connect_gpio_out_named(DeviceState *dev, cons= t 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 6cb4fe4691..8051961fe5 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 =3D g_strdup_printf("device[%d]", unattached_count= ++); =20 - object_property_add_child(container_get(qdev_get_machine(), - "/unattached"), + object_property_add_child(machine_get_container("unattached"), name, obj); unattached_parent =3D true; g_free(name); diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index e64d99c8ed..9355849ff0 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -65,9 +65,9 @@ void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc *= func, void *opaque) }; =20 /* Loop through all sysbus devices that were spawned outside the machi= ne */ - container =3D container_get(qdev_get_machine(), "/peripheral"); + container =3D machine_get_container("peripheral"); find_sysbus_device(container, &find); - container =3D container_get(qdev_get_machine(), "/peripheral-anon"); + container =3D machine_get_container("peripheral-anon"); find_sysbus_device(container, &find); } =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 317aaca25a..b8ec2506e1 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -460,7 +460,7 @@ static int check_fdc(Object *obj, void *opaque) } =20 static const char * const fdc_container_path[] =3D { - "/unattached", "/peripheral", "/peripheral-anon" + "unattached", "peripheral", "peripheral-anon" }; =20 /* @@ -474,7 +474,7 @@ static ISADevice *pc_find_fdc0(void) CheckFdcState state =3D { 0 }; =20 for (i =3D 0; i < ARRAY_SIZE(fdc_container_path); i++) { - container =3D container_get(qdev_get_machine(), fdc_container_path= [i]); + container =3D machine_get_container(fdc_container_path[i]); object_child_foreach(container, check_fdc, &state); } =20 diff --git a/qom/container.c b/qom/container.c index da657754a4..5e36fb8773 100644 --- a/qom/container.c +++ b/qom/container.c @@ -38,27 +38,4 @@ Object *container_create(Object *obj, const char *name) return child; } =20 -Object *container_get(Object *root, const char *path) -{ - Object *obj, *child; - char **parts; - int i; - - parts =3D g_strsplit(path, "/", 0); - assert(parts !=3D NULL && parts[0] !=3D NULL && !parts[0][0]); - obj =3D root; - - for (i =3D 1; parts[i] !=3D NULL; i++, obj =3D child) { - child =3D object_resolve_path_component(obj, parts[i]); - if (!child) { - child =3D container_create(obj, parts[i]); - } - } - - g_strfreev(parts); - - return obj; -} - - type_init(container_register_types) diff --git a/qom/object.c b/qom/object.c index cf66803a6a..aeb04c483c 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1771,7 +1771,7 @@ Object *object_get_root(void) =20 Object *object_get_objects_root(void) { - return container_get(object_get_root(), "/objects"); + return object_get_container("objects"); } =20 Object *object_get_internal_root(void) diff --git a/scsi/pr-manager.c b/scsi/pr-manager.c index fb5fc29730..1977d99ce0 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" =20 -#define PR_MANAGER_PATH "/objects" +#define PR_MANAGER_PATH "objects" =20 typedef struct PRManagerData { PRManager *pr_mgr; @@ -135,7 +135,7 @@ PRManagerInfoList *qmp_query_pr_managers(Error **errp) { PRManagerInfoList *head =3D NULL; PRManagerInfoList **prev =3D &head; - Object *container =3D container_get(object_get_root(), PR_MANAGER_PATH= ); + Object *container =3D object_get_container(PR_MANAGER_PATH); =20 object_child_foreach(container, query_one_pr_manager, &prev); return head; diff --git a/system/ioport.c b/system/ioport.c index fd551d0375..55c2a75239 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 =3D container_get(qdev_get_machine(), "/unattached"); + owner =3D machine_get_container("unattached"); } else { owner =3D piolist->owner; } diff --git a/system/memory.c b/system/memory.c index 85f6834cb3..fba351b030 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1238,7 +1238,7 @@ static void memory_region_do_init(MemoryRegion *mr, char *name_array =3D g_strdup_printf("%s[*]", escaped_name); =20 if (!owner) { - owner =3D container_get(qdev_get_machine(), "/unattached"); + owner =3D machine_get_container("unattached"); } =20 object_property_add_child(owner, name_array, OBJECT(mr)); diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 4c09b38ffb..4d46af2c8d 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -348,7 +348,7 @@ static Object *qdev_get_peripheral(void) static Object *dev; =20 if (dev =3D=3D NULL) { - dev =3D container_get(qdev_get_machine(), "/peripheral"); + dev =3D machine_get_container("peripheral"); } =20 return dev; @@ -359,7 +359,7 @@ static Object *qdev_get_peripheral_anon(void) static Object *dev; =20 if (dev =3D=3D NULL) { - dev =3D container_get(qdev_get_machine(), "/peripheral-anon"); + dev =3D machine_get_container("peripheral-anon"); } =20 return dev; @@ -1085,7 +1085,7 @@ static GSList *qdev_build_hotpluggable_device_list(Ob= ject *peripheral) static void peripheral_device_del_completion(ReadLineState *rs, const char *str) { - Object *peripheral =3D container_get(qdev_get_machine(), "/peripheral"= ); + Object *peripheral =3D machine_get_container("peripheral"); GSList *list, *item; =20 list =3D qdev_build_hotpluggable_device_list(peripheral); diff --git a/system/vl.c b/system/vl.c index 3bb8f2db9a..822f7ff656 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2120,8 +2120,7 @@ static void qemu_create_machine(QDict *qdict) current_machine =3D MACHINE(object_new_with_class(OBJECT_CLASS(machine= _class))); object_property_add_child(object_get_root(), "machine", 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())); =20 if (machine_class->minimum_page_bits) { diff --git a/ui/dbus-chardev.c b/ui/dbus-chardev.c index 1d3a7122a1..bf061cbc93 100644 --- a/ui/dbus-chardev.c +++ b/ui/dbus-chardev.c @@ -106,7 +106,7 @@ dbus_chardev_init(DBusDisplay *dpy) dpy->notifier.notify =3D dbus_display_on_notify; dbus_display_notifier_add(&dpy->notifier); =20 - object_child_foreach(container_get(object_get_root(), "/chardevs"), + object_child_foreach(object_get_container("chardevs"), dbus_display_chardev_foreach, dpy); } =20 --=20 2.45.0