From patchwork Wed Nov 20 21:56:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C7E1D743E7 for ; Wed, 20 Nov 2024 21:58:19 +0000 (UTC) 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 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= 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 X-MC-Unique: S0lWEthfPmOCvB4Ne_cZNQ-1 X-Mimecast-MFC-AGG-ID: S0lWEthfPmOCvB4Ne_cZNQ Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-461011bd338so2674271cf.3 for ; Wed, 20 Nov 2024 13:57:10 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- 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; #define TYPE_OBJECT "object" +#define TYPE_CONTAINER "container" typedef struct ObjectProperty ObjectProperty; 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, stellaris_board_info *board) flash_size = (((board->dc0 & 0xffff) + 1) << 1) * 1024; sram_size = ((board->dc0 >> 18) + 1) * 1024; - soc_container = object_new("container"); + soc_container = object_new(TYPE_CONTAINER); object_property_add_child(OBJECT(ms), "soc", soc_container); /* 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" static const TypeInfo container_info = { - .name = "container", + .name = TYPE_CONTAINER, .parent = TYPE_OBJECT, }; @@ -37,7 +37,7 @@ Object *container_get(Object *root, const char *path) for (i = 1; parts[i] != NULL; i++, obj = child) { child = object_resolve_path_component(obj, parts[i]); if (!child) { - child = object_new("container"); + child = 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; if (!root) { - root = object_new("container"); + root = object_new(TYPE_CONTAINER); } return root; @@ -1755,7 +1755,7 @@ Object *object_get_internal_root(void) static Object *internal_root; if (!internal_root) { - internal_root = object_new("container"); + internal_root = object_new(TYPE_CONTAINER); } return internal_root; From patchwork Wed Nov 20 21:56:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E70BBD743E5 for ; Wed, 20 Nov 2024 21:59:00 +0000 (UTC) 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 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= 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 X-MC-Unique: 9-aAGFOhMCWGCs0jJBBhZg-1 X-Mimecast-MFC-AGG-ID: 9-aAGFOhMCWGCs0jJBBhZg Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-5ee2aa2335eso259823eaf.1 for ; Wed, 20 Nov 2024 13:57:12 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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); + +/** + * 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); } +Object *container_create(Object *obj, const char *name) +{ + Object *child = 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 = 1; parts[i] != NULL; i++, obj = child) { child = object_resolve_path_component(obj, parts[i]); if (!child) { - child = object_new(TYPE_CONTAINER); - object_property_add_child(obj, parts[i], child); - object_unref(child); + child = container_create(obj, parts[i]); } } From patchwork Wed Nov 20 21:56:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E03A4D743E5 for ; Wed, 20 Nov 2024 21:58:57 +0000 (UTC) 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 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= 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 X-MC-Unique: -TogbWzqM0iacJhT8rYclg-1 X-Mimecast-MFC-AGG-ID: -TogbWzqM0iacJhT8rYclg Received: by mail-yb1-f197.google.com with SMTP id 3f1490d57ef6-e388f173db4so361185276.3 for ; Wed, 20 Nov 2024 13:57:14 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- 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-global-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 = { .parent = TYPE_STATIC_PROPS, }; +/* + * 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 present. + */ +static void test_init_machine(void) +{ + /* This is a fake machine - it doesn't need to be a machine object */ + Object *machine = 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); + test_init_machine(); + g_test_add_func("/qdev/properties/static/default/subprocess", test_static_prop_subprocess); g_test_add_func("/qdev/properties/static/default", From patchwork Wed Nov 20 21:56:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DE7BD743E5 for ; Wed, 20 Nov 2024 21:58:49 +0000 (UTC) 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 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= 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 X-MC-Unique: 1IY-uPhtNOSdKosa8ao_-g-1 X-Mimecast-MFC-AGG-ID: 1IY-uPhtNOSdKosa8ao_-g Received: by mail-yb1-f198.google.com with SMTP id 3f1490d57ef6-e3810bac8a7so381404276.0 for ; Wed, 20 Nov 2024 13:57:15 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Drop one use of container_get(), instead switch to the explicit function to create a container. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- 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-proplist.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 = object_get_objects_root(); - Object *cont1 = container_get(root, "/cont1"); + Object *cont1 = container_create(root, "cont1"); Object *obj1 = object_new(TYPE_DUMMY); Object *obj2a = object_new(TYPE_DUMMY); Object *obj2b = object_new(TYPE_DUMMY); From patchwork Wed Nov 20 21:56:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90E36D743E6 for ; Wed, 20 Nov 2024 21:58:17 +0000 (UTC) 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 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= 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 X-MC-Unique: MDcAJMaCMv2hjaOIBLbijg-1 X-Mimecast-MFC-AGG-ID: MDcAJMaCMv2hjaOIBLbijg Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-5eb742a18ebso204873eaf.3 for ; Wed, 20 Nov 2024 13:57:19 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Paolo Bonzini , Fabiano Rosas , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Follow the trend to explicitly create containers, do that for console.c on "/backend" container. Cc: Marc-André Lureau Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé --- 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 = container_create(object_get_root(), "backend"); 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 = g_strdup_printf("console[%d]", con->index); - object_property_add_child(container_get(object_get_root(), "/backend"), - name, OBJECT(con)); + object_property_add_child(backend, name, OBJECT(con)); g_free(name); } From patchwork Wed Nov 20 21:56:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1513DD743E5 for ; Wed, 20 Nov 2024 21:59:11 +0000 (UTC) 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 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= 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 X-MC-Unique: 6EN9IQXcM6egjXUy8UK7Zw-1 X-Mimecast-MFC-AGG-ID: 6EN9IQXcM6egjXUy8UK7Zw Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-460c73093edso3031941cf.2 for ; Wed, 20 Nov 2024 13:57:20 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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" -#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) @@ -514,6 +514,26 @@ static const VMStateDescription vmstate_spapr_drc = { } }; +static GOnce drc_container_created = 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 = SPAPR_DR_CONNECTOR(d); @@ -521,6 +541,9 @@ static void drc_realize(DeviceState *d, Error **errp) Object *root_container; const char *child_name; + /* 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 = container_get(object_get_root(), DRC_CONTAINER_PATH); + root_container = drc_container_get(); child_name = 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 = SPAPR_DR_CONNECTOR(d); g_autofree gchar *name = g_strdup_printf("%x", spapr_drc_index(drc)); - Object *root_container; trace_spapr_drc_unrealize(spapr_drc_index(drc)); vmstate_unregister(VMSTATE_IF(drc), &vmstate_spapr_drc, drc); - root_container = container_get(object_get_root(), DRC_CONTAINER_PATH); - object_property_del(root_container, name); + object_property_del(drc_container_get(), name); } SpaprDrc *spapr_dr_connector_new(Object *owner, const char *type, @@ -796,9 +817,8 @@ static const TypeInfo spapr_drc_pmem_info = { SpaprDrc *spapr_drc_by_index(uint32_t index) { Object *obj; - g_autofree gchar *name = g_strdup_printf("%s/%x", DRC_CONTAINER_PATH, - index); - obj = object_resolve_path(name, NULL); + g_autofree gchar *name = g_strdup_printf("%x", index); + obj = object_resolve_path_component(drc_container_get(), name); 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 = container_get(object_get_root(), DRC_CONTAINER_PATH); + root_container = drc_container_get(); object_property_iter_init(&iter, root_container); while ((prop = object_property_iter_next(&iter))) { @@ -953,7 +973,7 @@ void spapr_drc_reset_all(SpaprMachineState *spapr) ObjectProperty *prop; ObjectPropertyIterator iter; - drc_container = container_get(object_get_root(), DRC_CONTAINER_PATH); + drc_container = drc_container_get(); restart: object_property_iter_init(&iter, drc_container); while ((prop = object_property_iter_next(&iter))) { From patchwork Wed Nov 20 21:56:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A329ED743E6 for ; Wed, 20 Nov 2024 21:58:12 +0000 (UTC) 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 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= 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 X-MC-Unique: igXLQSU2PE-GW8_ljdmJ7A-1 X-Mimecast-MFC-AGG-ID: igXLQSU2PE-GW8_ljdmJ7A Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4608a1a8d3eso3806091cf.1 for ; Wed, 20 Nov 2024 13:57:21 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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édric Le Goater Reviewed-by: Daniel P. Berrangé --- 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 = { static void e500_pcihost_bridge_realize(PCIDevice *d, Error **errp) { PPCE500PCIBridgeState *b = PPC_E500_PCI_BRIDGE(d); - PPCE500CCSRState *ccsr = CCSR(container_get(qdev_get_machine(), - "/e500-ccsr")); + PPCE500CCSRState *ccsr = CCSR( + object_resolve_path_component(qdev_get_machine(), "e500-ccsr")); memory_region_init_alias(&b->bar0, OBJECT(ccsr), "e500-pci-bar0", &ccsr->ccsr_space, 0, int128_get64(ccsr->ccsr_space.size)); From patchwork Wed Nov 20 21:56:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 953D3D743E6 for ; Wed, 20 Nov 2024 21:58:38 +0000 (UTC) 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 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= 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 X-MC-Unique: Jo10uGCKMr-bUZlYDy-yHA-1 X-Mimecast-MFC-AGG-ID: Jo10uGCKMr-bUZlYDy-yHA Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-46360a97a99so3370731cf.1 for ; Wed, 20 Nov 2024 13:57:24 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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; if (dev == NULL) { - dev = 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 = object_resolve_path_component(object_get_root(), "machine"); } return dev; From patchwork Wed Nov 20 21:57:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B97EFD743E6 for ; Wed, 20 Nov 2024 21:59:11 +0000 (UTC) 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 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= 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 X-MC-Unique: 05MCBheKNgafiWWNFD1t6w-1 X-Mimecast-MFC-AGG-ID: 05MCBheKNgafiWWNFD1t6w Received: by mail-yb1-f198.google.com with SMTP id 3f1490d57ef6-e30cf48435fso325702276.0 for ; Wed, 20 Nov 2024 13:57:26 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add a helper to fetch machine containers. Add some sanity check around. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé --- 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); +/** + * 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; } +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 = qdev_get_machine(); + assert(machine); + + container = object_resolve_path_component(machine, name); + assert(object_dynamic_cast(container, TYPE_CONTAINER)); + + return container; +} + char *qdev_get_human_name(DeviceState *dev) { g_assert(dev != NULL); From patchwork Wed Nov 20 21:57:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51BB4D743E5 for ; Wed, 20 Nov 2024 21:58:18 +0000 (UTC) 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 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= 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 X-MC-Unique: NYDU3bSZPxConvnsTgXwKg-1 X-Mimecast-MFC-AGG-ID: NYDU3bSZPxConvnsTgXwKg Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4608d303ebeso2903581cf.0 for ; Wed, 20 Nov 2024 13:57:27 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é --- 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) } } +const char *machine_containers[] = { + "unattached", + "peripheral", + "peripheral-anon" +}; + +static void qemu_create_machine_containers(Object *machine) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(machine_containers); i++) { + container_create(machine, machine_containers[i]); + } +} + static void machine_initfn(Object *obj) { MachineState *ms = MACHINE(obj); MachineClass *mc = MACHINE_GET_CLASS(obj); - container_get(obj, "/peripheral"); - container_get(obj, "/peripheral-anon"); - + qemu_create_machine_containers(obj); ms->dump_guest_core = true; ms->mem_merge = (QEMU_MADV_MERGEABLE != QEMU_MADV_INVALID); ms->enable_graphics = 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, const char *name, Error **errp return prop->type; } +static Object *object_root_initialize(void) +{ + Object *root = 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; if (!root) { - root = object_new(TYPE_CONTAINER); + root = object_root_initialize(); } return root; From patchwork Wed Nov 20 21:57:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A4562D743E6 for ; Wed, 20 Nov 2024 21:59:42 +0000 (UTC) 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 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= 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 X-MC-Unique: 5cv0xMfWMMiX2kJdCf1-Lw-1 X-Mimecast-MFC-AGG-ID: 5cv0xMfWMMiX2kJdCf1-Lw Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-71a3da16d58so240519a34.3 for ; Wed, 20 Nov 2024 13:57:30 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé --- 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, const char *name, */ Object *object_get_root(void); +/** + * object_get_container: + * @name: the name of container to lookup + * + * Lookup a root level container. + * + * Returns: the container with @name. + */ +Object *object_get_container(const char *name); + /** * object_get_objects_root: diff --git a/qom/object.c b/qom/object.c index 810e6f2bd9..cf66803a6a 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1748,6 +1748,16 @@ static Object *object_root_initialize(void) return root; } +Object *object_get_container(const char *name) +{ + Object *container; + + container = object_resolve_path_component(object_get_root(), name); + assert(object_dynamic_cast(container, TYPE_CONTAINER)); + + return container; +} + Object *object_get_root(void) { static Object *root; From patchwork Wed Nov 20 21:57:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13881470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8B35D743E5 for ; Wed, 20 Nov 2024 21:58:35 +0000 (UTC) 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 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= 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 X-MC-Unique: OMQAYkwyPQumgzANT7LCVA-1 X-Mimecast-MFC-AGG-ID: OMQAYkwyPQumgzANT7LCVA Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-460dd08f4d0so3144391cf.0 for ; Wed, 20 Nov 2024 13:57:32 -0800 (PST) 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) 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) From: Peter Xu To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Peter Maydell , Markus Armbruster , peterx@redhat.com, =?utf-8?q?Daniel_?= =?utf-8?q?P_=2E_Berrang=C3=A9?= , Juraj Marcin , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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é Suggested-by: Markus Armbruster Signed-off-by: Peter Xu Reviewed-by: Daniel P. Berrangé --- 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)(Object *child, void *opaque), int object_child_foreach_recursive(Object *obj, int (*fn)(Object *child, void *opaque), void *opaque); -/** - * container_get: - * @root: root of the #path, e.g., object_get_root() - * @path: path to the container - * - * Return a container object whose path is @path. Create more containers - * along the path if necessary. - * - * Returns: the container object. - */ -Object *container_get(Object *root, const char *path); - /** * 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 = NULL; - Object *objs = container_get(object_get_root(), "/objects"); + Object *objs = object_get_container("objects"); object_child_foreach(objs, qmp_query_cryptodev_foreach, &list); @@ -557,7 +557,7 @@ static void cryptodev_backend_stats_cb(StatsResultList **result, switch (target) { case STATS_TARGET_CRYPTODEV: { - Object *objs = container_get(object_get_root(), "/objects"); + Object *objs = object_get_container("objects"); StatsArgs stats_args; stats_args.result.stats = result; stats_args.names = names; diff --git a/chardev/char.c b/chardev/char.c index a1722aa076..22fc5f7f76 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -48,7 +48,7 @@ Object *get_chardevs_root(void) { - return container_get(object_get_root(), "/chardevs"); + return object_get_container("chardevs"); } static void chr_be_event(Chardev *s, QEMUChrEvent event) diff --git a/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, const char *name, int n, name ? name : "unnamed-gpio-out", n); if (input_pin && !OBJECT(input_pin)->parent) { /* We need a name for object_property_set_link to work */ - object_property_add_child(container_get(qdev_get_machine(), - "/unattached"), + object_property_add_child(machine_get_container("unattached"), "non-qdev-gpio[*]", OBJECT(input_pin)); } object_property_set_link(OBJECT(dev), propname, diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 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 = g_strdup_printf("device[%d]", unattached_count++); - object_property_add_child(container_get(qdev_get_machine(), - "/unattached"), + object_property_add_child(machine_get_container("unattached"), name, obj); unattached_parent = true; g_free(name); diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 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) }; /* Loop through all sysbus devices that were spawned outside the machine */ - container = container_get(qdev_get_machine(), "/peripheral"); + container = machine_get_container("peripheral"); find_sysbus_device(container, &find); - container = container_get(qdev_get_machine(), "/peripheral-anon"); + container = machine_get_container("peripheral-anon"); find_sysbus_device(container, &find); } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 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) } static const char * const fdc_container_path[] = { - "/unattached", "/peripheral", "/peripheral-anon" + "unattached", "peripheral", "peripheral-anon" }; /* @@ -474,7 +474,7 @@ static ISADevice *pc_find_fdc0(void) CheckFdcState state = { 0 }; for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) { - container = container_get(qdev_get_machine(), fdc_container_path[i]); + container = machine_get_container(fdc_container_path[i]); object_child_foreach(container, check_fdc, &state); } diff --git a/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; } -Object *container_get(Object *root, const char *path) -{ - Object *obj, *child; - char **parts; - int i; - - parts = g_strsplit(path, "/", 0); - assert(parts != NULL && parts[0] != NULL && !parts[0][0]); - obj = root; - - for (i = 1; parts[i] != NULL; i++, obj = child) { - child = object_resolve_path_component(obj, parts[i]); - if (!child) { - child = 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) Object *object_get_objects_root(void) { - return container_get(object_get_root(), "/objects"); + return object_get_container("objects"); } Object *object_get_internal_root(void) diff --git a/scsi/pr-manager.c b/scsi/pr-manager.c index 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" -#define PR_MANAGER_PATH "/objects" +#define PR_MANAGER_PATH "objects" typedef struct PRManagerData { PRManager *pr_mgr; @@ -135,7 +135,7 @@ PRManagerInfoList *qmp_query_pr_managers(Error **errp) { PRManagerInfoList *head = NULL; PRManagerInfoList **prev = &head; - Object *container = container_get(object_get_root(), PR_MANAGER_PATH); + Object *container = object_get_container(PR_MANAGER_PATH); object_child_foreach(container, query_one_pr_manager, &prev); return head; diff --git a/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 = container_get(qdev_get_machine(), "/unattached"); + owner = machine_get_container("unattached"); } else { owner = piolist->owner; } diff --git a/system/memory.c b/system/memory.c index 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 = g_strdup_printf("%s[*]", escaped_name); if (!owner) { - owner = container_get(qdev_get_machine(), "/unattached"); + owner = machine_get_container("unattached"); } object_property_add_child(owner, name_array, OBJECT(mr)); diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 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; if (dev == NULL) { - dev = container_get(qdev_get_machine(), "/peripheral"); + dev = machine_get_container("peripheral"); } return dev; @@ -359,7 +359,7 @@ static Object *qdev_get_peripheral_anon(void) static Object *dev; if (dev == NULL) { - dev = container_get(qdev_get_machine(), "/peripheral-anon"); + dev = machine_get_container("peripheral-anon"); } return dev; @@ -1085,7 +1085,7 @@ static GSList *qdev_build_hotpluggable_device_list(Object *peripheral) static void peripheral_device_del_completion(ReadLineState *rs, const char *str) { - Object *peripheral = container_get(qdev_get_machine(), "/peripheral"); + Object *peripheral = machine_get_container("peripheral"); GSList *list, *item; list = qdev_build_hotpluggable_device_list(peripheral); diff --git a/system/vl.c b/system/vl.c index 3bb8f2db9a..822f7ff656 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2120,8 +2120,7 @@ static void qemu_create_machine(QDict *qdict) current_machine = 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())); 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 = dbus_display_on_notify; dbus_display_notifier_add(&dpy->notifier); - object_child_foreach(container_get(object_get_root(), "/chardevs"), + object_child_foreach(object_get_container("chardevs"), dbus_display_chardev_foreach, dpy); }