From patchwork Fri Dec 20 16:14:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 852410 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp2145506wrq; Fri, 20 Dec 2024 08:19:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVj4j6bX7ba4RttivWQ7UZFz/r92jXr0yqjJMBFrIpG1vd9Z++TRVsJWXZUJj+spYqcsqAKPQ==@linaro.org X-Google-Smtp-Source: AGHT+IFBvdTeAd2JzShS1mBAT4g96ege9Ctt4yb34Jh2EBf/07vNyym7HJ1qwR5LcapkTN79w/iF X-Received: by 2002:a05:6214:407:b0:6d8:7a52:5d5 with SMTP id 6a1803df08f44-6dd235aa9d2mr58658906d6.6.1734711554767; Fri, 20 Dec 2024 08:19:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734711554; cv=none; d=google.com; s=arc-20240605; b=b45JEqsnBUq2fatfsptHQjXbUG3m5XSGWPeMj883ihkmnFF3qOtvsWKIn0vn7R9Nrn B4MaW8qhaz1zlipZCBcV3VV2hqulro9XAGByudJ2/htKCE/9/1qlVqgifVo9b8LE/POf Ofx42bAgc03DTzBx6/l6KWWPUfpeZ+u1T3OeI8ntZei2+YHuBeRq7RN1Dz2UCrwHNOfM bAjgxtfriFIImAOfwtxXEBzklHb2W/4B9pJWhb3JfHPL9VXc/TgwzJ0ZzqMV1Cs+AyGa u9MGni6DmjNDry81WGQuoYMzNl8iCxs5WydMz5kCyE83mCUe/iz6qrweCa+/NYgMuEvc LY8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YaupKmRaiQE1rQ0k1M3YCIRubFuxasmL5+OyAuZAyCQ=; fh=7PHrIgFS+I90+SvPRZVZCfGcQW3A6kvXzFKxbVJJZBs=; b=Lpk7SfVj+ln1oK7UVTMZcmDdzVV33w+RtnkNeTfTfw8qcEqyjeBl+VkOrdl8UtHo/0 2GPIgMeS8HDPCCDWyIt6otht6pCI7KzIj7jB9I/U9kkwqYUG3Nu4htfGgUeTg8imh8DS jA88jnC3LzR5x+dMsyNZRKKsmyc3YxkCkyGXjvon++y42C1v9V4rFUjbkCDBbs1OGHHc YYTzYYDOf/NybDn7vu/qF5PS0ksHDc/RXwGCjiy7T9hD8pgn9ukJSnm3Py+BVmqv4IaG D+fUFG5zPcyroAFIHd8jg2f8AcIKfnb3FQB4wpG11HPrtbLvNZp/Wssg+yAgfNdLIO/P DXDw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g1b0a9Lq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6dd18136bfdsi48297276d6.135.2024.12.20.08.19.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Dec 2024 08:19:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g1b0a9Lq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOffo-0005y7-J7; Fri, 20 Dec 2024 11:16: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 1tOffk-0005qs-Kp for qemu-devel@nongnu.org; Fri, 20 Dec 2024 11:16:16 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOffh-0006ga-BF for qemu-devel@nongnu.org; Fri, 20 Dec 2024 11:16:15 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361d5dcf5bso22623705e9.3 for ; Fri, 20 Dec 2024 08:16:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734711371; x=1735316171; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YaupKmRaiQE1rQ0k1M3YCIRubFuxasmL5+OyAuZAyCQ=; b=g1b0a9LqnPoufcmEXzmugZ9A2Hhiqgu9rv51cg5YIFvRsomTWGX1U/GEFsOFCLUkHT xmIm3jG4IAaF/zxwr/qAt1IiUpI20EmhPKpy5FpSm8zFOeOFJ3gjWq1KIJhlCraSrvlD b8V7zrs92Sozh+D581mTMuBsF7cmBoHyGSU8rluleKOL5G/3JqG71odI9ALzxruogDj5 XlEn5zxZ9QuEDtORjil5TA4R3qPmZODRJ/WH2E39kkIgIvqouPbmZR3baVta1AvJ3q2n KIZuJl5Dmj5D6ZOfgyehecDM0S/U4sqP4zTMWkRS9acHeWWKnIyvfubPa5LiiWaouElD STWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734711371; x=1735316171; 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=YaupKmRaiQE1rQ0k1M3YCIRubFuxasmL5+OyAuZAyCQ=; b=kC0Rw1Q18MRdgxrBvIQ93/jpCHbZSB/VwjPWTDV5wED1h71KgrCojTCTm0sndeZK6g 9X1ifFTZWH6lCmzlhx0yUkCd5wjDFhzz2HSfkpab5k5GqQ1W+QWOTp1BIIU9C+8EpIvc UAEbL9bpOh7w+2IdDN0FIbNwHPy1YTuhMyxoDbDX63tYZYB/i/BLbH/zutxhlVvapOde LlyQv8rGYhHJ71YabbHecn2oQ1ENZi6PgItI/u1ipQKv/Z1evU/rc/FoDVnvC/Limn9N nC68HQbeOAaospxoza1qi4E4jRj/eE2lxxP/Rdr9J9juH/mC+Q1ZRjVp0wVmCm1wnOVf S3tw== X-Gm-Message-State: AOJu0YwqxQULVExxBooq+NNUvqrrF0MfaweiGFcr0w4kBUbjUh3fAOXQ qcUo890O7BXDDj3+3r3fW0w0/7G4ItSq3+zZPj075Z5RNsB1y+YgUvApDWJRT056SktzJt9Faef 3 X-Gm-Gg: ASbGncuAME5eP71vMSbK3A8ah+pnZsWfjvLbN1pClrD26xxs4P0+IsRVIpH1vXMz4Ya AveYKLBejg5NYRcvS6m4GvggQs5UMK748R9CmczHWER+9GTGQX27l2MC4Gj+B+xB0nZHHNAeyAE h3ffVNm7eESbdFUlrLIyHO+WYLMMz+dp5N8PH0uHKg+Iwf2fuG+D+wmYmWdWfFWGOPHVfvQGjOI R1/YaKPW+oWoqsoq+HMao8vp1dsa3QVOXcImOuXQOs7HZrbIA4F+f6YCsa7/HdPCzpyyrFa8AI= X-Received: by 2002:a05:6000:4a11:b0:385:dedb:a148 with SMTP id ffacd0b85a97d-38a223f5c90mr3454151f8f.46.1734711371349; Fri, 20 Dec 2024 08:16:11 -0800 (PST) Received: from localhost.localdomain ([78.196.4.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8add5asm4318399f8f.107.2024.12.20.08.16.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Dec 2024 08:16:10 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Xu , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 04/59] qom: New object_property_add_new_container() Date: Fri, 20 Dec 2024 17:14:55 +0100 Message-ID: <20241220161551.89317-5-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241220161551.89317-1-philmd@linaro.org> References: <20241220161551.89317-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Xu 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é Message-ID: <20241121192202.4155849-3-peterx@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- 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 de02e16817c..95d6e064d9b 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -2019,6 +2019,18 @@ int object_child_foreach_recursive(Object *obj, */ Object *container_get(Object *root, const char *path); +/** + * 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 cfec92a9447..20ab74b0e8d 100644 --- a/qom/container.c +++ b/qom/container.c @@ -24,6 +24,16 @@ static void container_register_types(void) type_register_static(&container_info); } +Object *object_property_add_new_container(Object *obj, const char *name) +{ + Object *child = 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 = 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 = object_property_add_new_container(obj, parts[i]); } }