From nobody Sat Nov 23 17:53:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1732217095; cv=none; d=zohomail.com; s=zohoarc; b=P6uOKxtnHBrkHUuTW6UG7GiUSMo2H8Gn4UsQ/I27E7BGrrbNADiL6/gMkqCH6d3H1X5wb7Jb1tqNb8cPsygNzgbN+vTNckkiG4fvtViw/GJRBHQVWiASWLXnT4+yPF4TcsdJO3h+Pw2RJ3jET2VBIDt3i6JngQhNZWfmAK/9/68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732217095; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=arcBPmf8wzRlgW3nU1LndcjIfMFJuvboEpJ64NoZeIM=; b=V6N9MsDKCYA9mrV1qGRZ9Kv7n6sUpYAAIejt9e9sn8yZ/1wUhex6F3Uqkd+hbi26dLht+BwPqas5FFLsnuo8rMG17znTgAo8om7jPrvPPFDlnLbEWlwZegkYdQLH8AP1AzTk8Pfv7/g36K73n8XTrnejje4SAIb2VkiXAjUrtvI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732217095135831.0661687713704; Thu, 21 Nov 2024 11:24:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tECku-0006Mc-48; Thu, 21 Nov 2024 14:22:20 -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 1tECkn-0006KF-5N for qemu-devel@nongnu.org; Thu, 21 Nov 2024 14:22:13 -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 1tECkl-0002Vo-PS for qemu-devel@nongnu.org; Thu, 21 Nov 2024 14:22:12 -0500 Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-386-UE9zdm2jO9akU6Mfp3TYPg-1; Thu, 21 Nov 2024 14:22:09 -0500 Received: by mail-io1-f69.google.com with SMTP id ca18e2360f4ac-83abe8804a5so125091539f.2 for ; Thu, 21 Nov 2024 11:22: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 8926c6da1cb9f-4e1cfe345f0sm102939173.45.2024.11.21.11.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 11:22:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732216930; 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=arcBPmf8wzRlgW3nU1LndcjIfMFJuvboEpJ64NoZeIM=; b=CjV99JgjH0nZKoGC9bWmbAmSODVRyKEWkRav32eg5T1uVZoXXzNmXKWMeJBvKb1SdNEDmT F8kKow+i6oYyKR96AqGUgjI0DAFApwHkqiQ+91oXo6UQ+AcRYeeKOfjxFG9EX7bPqjGb3G FjMy51gXLfutWrtGlvyE/0LX5KpngUA= X-MC-Unique: UE9zdm2jO9akU6Mfp3TYPg-1 X-Mimecast-MFC-AGG-ID: UE9zdm2jO9akU6Mfp3TYPg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732216928; x=1732821728; 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=arcBPmf8wzRlgW3nU1LndcjIfMFJuvboEpJ64NoZeIM=; b=pkuYgoMmNCpTeXdL4/TII3UB6wxvaBoDNs6H5UHcCfNqhKrsWWHnaZqxTG0aE1ZOXt QPpbsz0Bgged+zoBYlclCdtWbV7xIdElArKVs/+BkRR2NOtptVEpXcx8mb2iGiBP17ZP tXDK3YEfseh151/WvkOq94a7zkUNbAoNHIDsOerild72gaBEbGoidqAY4o1W1y0Huf9W WWmSBuFjFD+3EGvost1M4Ok2mP9cOO6tjjU6SacDhrp2/IPTJcLfjTJZDzJ6I17kZtcA /moDRmzGC7TgdIYk23bc/tPLzJVVmNnEGBXh8zm+Y5u/zNMJG4Xs4laXZomLVJJpEYBK 4d7g== X-Gm-Message-State: AOJu0YyMfPRWWkxYAmDCspe9OzrqRVwV7gLfmgHiUeUr8WqVjyv6ja/S 0LhAM5CHDHLeIJb0EjRA8Tea21gv9N3+KqDnh4iBHt27r3RbI2kDNYy+Fhw23MAkydEJwtH4rt9 NzvWKQ+CJF9LGtLIH5/dnGWkppevunm37yVdzOWqM1MErU8stDT3uXg2flEsY8/yEDAdiE/7C/N aK+qYGT20vtCr561GP5Jmite4PQovyTHP9rw== X-Gm-Gg: ASbGnctkXO292ZHoEqBfKE91gp/Duvq2NGChwoGIWlh455+do+qKUdMrZ485jV97MeR wp3V3L3uVp1nVZXP6AmA4nDwk4HlFfelu7hcYxmgogjUao5HSLAoZnfwvDXXsJQyuk7XkAsNJvc fl5P2KIhvnoPCEbM3ypJXtcYUKJ8jOTvcEHRB4slh2HAbQiaE5k4ZSpUnSJtv1ZnX9o6OCsirjI kwug6d56U+X+QnSGU0/hRhyizfShzVJiGE6oFGvpiy5RHAYiX3/VuovhCefOj99IuUAz7VuNj6d hwy4LnyuQfwsi4LpM8SLgORwlQ== X-Received: by 2002:a05:6602:608b:b0:83a:9f64:6c75 with SMTP id ca18e2360f4ac-83ecdc515famr12124639f.3.1732216928079; Thu, 21 Nov 2024 11:22:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGm2roxzJg58laCb6r40bwkfzwJFUWdbEinhTY1AluIOOVeX80rme6EypEEPceq5GomYZ9SMw== X-Received: by 2002:a05:6602:608b:b0:83a:9f64:6c75 with SMTP id ca18e2360f4ac-83ecdc515famr12120239f.3.1732216927609; Thu, 21 Nov 2024 11:22:07 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Peter Maydell , Juraj Marcin , peterx@redhat.com, =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost Subject: [PATCH v2 02/13] qom: New object_property_add_new_container() Date: Thu, 21 Nov 2024 14:21:51 -0500 Message-ID: <20241121192202.4155849-3-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241121192202.4155849-1-peterx@redhat.com> References: <20241121192202.4155849-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1732217097346116600 Content-Type: text/plain; charset="utf-8" To move towards explicit creations of containers, starting that by providing a helper for creating container objects. Signed-off-by: Peter Xu Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/qom/object.h | 12 ++++++++++++ qom/container.c | 14 +++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 3ba370ce9b..597e961b8c 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -2033,6 +2033,18 @@ int object_child_foreach_recursive(Object *obj, */ Object *container_get(Object *root, const char *path); =20 +/** + * object_property_add_new_container: + * @obj: the parent object + * @name: the name of the parent object's property to add + * + * Add a newly created container object to a parent object. + * + * Returns: the newly created container object. Its reference count is 1, + * and the reference is owned by the parent object. + */ +Object *object_property_add_new_container(Object *obj, const char *name); + /** * object_property_help: * @name: the name of the property diff --git a/qom/container.c b/qom/container.c index cfec92a944..20ab74b0e8 100644 --- a/qom/container.c +++ b/qom/container.c @@ -24,6 +24,16 @@ static void container_register_types(void) type_register_static(&container_info); } =20 +Object *object_property_add_new_container(Object *obj, const char *name) +{ + Object *child =3D object_new(TYPE_CONTAINER); + + object_property_add_child(obj, name, child); + object_unref(child); + + return child; +} + Object *container_get(Object *root, const char *path) { Object *obj, *child; @@ -37,9 +47,7 @@ Object *container_get(Object *root, const char *path) for (i =3D 1; parts[i] !=3D NULL; i++, obj =3D child) { child =3D object_resolve_path_component(obj, parts[i]); if (!child) { - child =3D object_new(TYPE_CONTAINER); - object_property_add_child(obj, parts[i], child); - object_unref(child); + child =3D object_property_add_new_container(obj, parts[i]); } } =20 --=20 2.45.0