From nobody Mon May 25 20:31:51 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778508970; cv=none; d=zohomail.com; s=zohoarc; b=e8bxRBmOoW63/Lhial9i+lWGOmwcR0kIEI80lkRscWBs87PhHjgl2QfynH7YEwOJnqK0ztve0/JDkc1SuwY1cNVQNHufSjkTalGUhzA0iUpolSfUl/i/f3uAGSlBXJ2m/ZSbge7CXuKYb3cd4r1lSyq86a6ELXBVJ6bt4dzQ4uU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778508970; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yssNP4Qju6M+L9O9i/N+1SAZ/OA+QE9LNFEMu8/6mU4=; b=V191qw7HSy5Dlmuzbnafbu9/gPiuicdYceEp2FqJg5WiuMEWcbVtJHit9e24ncVnljfOunl2mcPZOOMpEI+J+fLBp2uUn2iHyRUksLJaer4Dpjr1v2wHlS6tfOkiGz9icn3+TSGa+1ut9N+YkTzGV4h5fd3TSRwDpjLFgMjszEY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778508970616535.259461843787; Mon, 11 May 2026 07:16:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMRP7-00034P-2H; Mon, 11 May 2026 10:14:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMRP4-00030N-Gb for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:38 -0400 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 1wMROz-000119-CX for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:36 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-99-ok7fVZJJOjCHekQeVf0xgg-1; Mon, 11 May 2026 10:14:28 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 71AA41800612; Mon, 11 May 2026 14:14:27 +0000 (UTC) Received: from berrange.com (unknown [10.44.50.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7144319560A2; Mon, 11 May 2026 14:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778508872; 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=yssNP4Qju6M+L9O9i/N+1SAZ/OA+QE9LNFEMu8/6mU4=; b=TsdD5tslYryj9Z8Nurps/ZOke/l59c3pC9cXCSx05QQtJffqiB5oxmCz+jBrywyNfEejnZ 1cdOdIl6sA0zvM3fhjVmOTtOL8WRl8qPgFQCY8CPUdG8MmwEeZmSQDk+dhuPiLP8pxeAyg yHg7iwfOJjhIQXMnZ2Rp3mUyp7OukfQ= X-MC-Unique: ok7fVZJJOjCHekQeVf0xgg-1 X-Mimecast-MFC-AGG-ID: ok7fVZJJOjCHekQeVf0xgg_1778508867 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 01/10] qom: add trace events for object/property lifecycle Date: Mon, 11 May 2026 15:14:11 +0100 Message-ID: <20260511141420.229023-2-berrange@redhat.com> In-Reply-To: <20260511141420.229023-1-berrange@redhat.com> References: <20260511141420.229023-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1778508974161154100 This adds tracing around object allocation & finalization, the addition & deletion of properties, and the addition & deletion of children. Signed-off-by: Daniel P. Berrang=C3=A9 --- qom/object.c | 34 +++++++++++++++++++++++++++------- qom/trace-events | 12 ++++++++++-- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/qom/object.c b/qom/object.c index f981e27044..9c391071fb 100644 --- a/qom/object.c +++ b/qom/object.c @@ -603,6 +603,8 @@ static void object_property_del_all(Object *obj) object_property_iter_init(&iter, obj); while ((prop =3D object_property_iter_next(&iter)) !=3D NULL) { if (g_hash_table_add(done, prop)) { + trace_object_property_del(obj, obj->class->type->name, + prop->name, prop->opaque); if (prop->release) { prop->release(obj, prop->name, prop->opaque); released =3D true; @@ -621,10 +623,14 @@ static void object_property_del_child(Object *obj, Ob= ject *child) GHashTableIter iter; gpointer key, value; =20 + trace_object_property_del_child(obj, obj->class->type->name, + child, child->class->type->name); g_hash_table_iter_init(&iter, obj->properties); while (g_hash_table_iter_next(&iter, &key, &value)) { prop =3D value; if (object_property_is_child(prop) && prop->opaque =3D=3D child) { + trace_object_property_del(obj, obj->class->type->name, + prop->name, prop->opaque); if (prop->release) { prop->release(obj, prop->name, prop->opaque); prop->release =3D NULL; @@ -664,7 +670,7 @@ static void object_finalize(void *data) { Object *obj =3D data; TypeImpl *ti =3D obj->class->type; - + trace_object_finalize(obj, obj->class->type->name); object_property_del_all(obj); object_deinit(obj, ti); =20 @@ -714,6 +720,7 @@ static Object *object_new_with_type(Type type) object_initialize_with_type(obj, size, type); obj->free =3D obj_free; =20 + trace_object_new(obj, obj->class->type->name); return obj; } =20 @@ -844,8 +851,9 @@ Object *object_dynamic_cast(Object *obj, const char *ty= pename) Object *object_dynamic_cast_assert(Object *obj, const char *typename, const char *file, int line, const char = *func) { - trace_object_dynamic_cast_assert(obj ? obj->class->type->name : "(null= )", - typename, file, line, func); + trace_object_dynamic_cast_assert( + obj, obj ? obj->class->type->name : "(null)", + typename, file, line, func); =20 #ifdef CONFIG_QOM_CAST_DEBUG int i; @@ -935,8 +943,9 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectCla= ss *class, { ObjectClass *ret; =20 - trace_object_class_dynamic_cast_assert(class ? class->type->name : "(n= ull)", - typename, file, line, func); + trace_object_class_dynamic_cast_assert( + class ? class->type->name : "(null)", + typename, file, line, func); =20 #ifdef CONFIG_QOM_CAST_DEBUG int i; @@ -1220,6 +1229,8 @@ object_property_try_add(Object *obj, const char *name= , const char *type, prop->release =3D release; prop->opaque =3D opaque; =20 + trace_object_property_add(obj, obj->class->type->name, + prop->name, prop->opaque); g_hash_table_insert(obj->properties, prop->name, prop); return prop; } @@ -1258,6 +1269,8 @@ object_class_property_add(ObjectClass *klass, prop->release =3D release; prop->opaque =3D opaque; =20 + trace_object_class_property_add(klass->type->name, prop->name, + prop->opaque); g_hash_table_insert(klass->properties, prop->name, prop); =20 return prop; @@ -1346,6 +1359,8 @@ void object_property_del(Object *obj, const char *nam= e) { ObjectProperty *prop =3D g_hash_table_lookup(obj->properties, name); =20 + trace_object_property_del(obj, obj->class->type->name, prop->name, + prop->opaque); if (prop->release) { prop->release(obj, name, prop->opaque); } @@ -1634,8 +1649,11 @@ int object_property_get_enum(Object *obj, const char= *name, bool object_property_parse(Object *obj, const char *name, const char *string, Error **errp) { - Visitor *v =3D string_input_visitor_new(string); - bool ok =3D object_property_set(obj, name, v, errp); + Visitor *v; + bool ok; + trace_object_property_parse(obj, obj->class->type->name, name, string); + v =3D string_input_visitor_new(string); + ok =3D object_property_set(obj, name, v, errp); =20 visit_free(v); return ok; @@ -1766,6 +1784,8 @@ object_property_try_add_child(Object *obj, const char= *name, g_autofree char *type =3D NULL; ObjectProperty *op; =20 + trace_object_property_add_child(obj, obj->class->type->name, name, + child, child->class->type->name); assert(!child->parent); =20 type =3D g_strdup_printf("child<%s>", object_get_typename(child)); diff --git a/qom/trace-events b/qom/trace-events index b2e9f4a712..44c63e72af 100644 --- a/qom/trace-events +++ b/qom/trace-events @@ -1,5 +1,13 @@ # See docs/devel/tracing.rst for syntax documentation. =20 # object.c -object_dynamic_cast_assert(const char *type, const char *target, const cha= r *file, int line, const char *func) "%s->%s (%s:%d:%s)" -object_class_dynamic_cast_assert(const char *type, const char *target, con= st char *file, int line, const char *func) "%s->%s (%s:%d:%s)" +object_dynamic_cast_assert(void *obj, const char *type, const char *target= , const char *file, int line, const char *func) "obj=3D%p type=3D%s->%s (%s= :%d:%s)" +object_finalize(void *obj, const char *type) "obj=3D%p type=3D%s" +object_new(void *obj, const char *type) "obj=3D%p type=3D%s" +object_property_add(void *obj, const char *type, const char *name, void *v= alue) "obj=3D%p type=3D%s name=3D%s value=3D%p" +object_property_add_child(void *obj, const char *type, const char *name, v= oid *child, const char *childtype) "obj=3D%p type=3D%s name=3D%s child=3D%p= child-type=3D%s" +object_property_del(void *obj, const char *type, const char *name, void *v= alue) "obj=3D%p type=3D%s name=3D%s value=3D%p" +object_property_del_child(void *obj, const char *type, void *child, const = char *childtype) "obj=3D%p type=3D%s child=3D%p child-type=3D%s" +object_property_parse(void *obj, const char *type, const char *name, const= char *value) "obj=3D%p type=3D%s prop=3D%s value=3D%s" +object_class_dynamic_cast_assert(const char *type, const char *target, con= st char *file, int line, const char *func) "type=3D%s->%s (%s:%d:%s)" +object_class_property_add(const char *type, const char *name, void *value)= "type=3D%s name=3D%s value=3D%p" --=20 2.54.0 From nobody Mon May 25 20:31:51 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778508913; cv=none; d=zohomail.com; s=zohoarc; b=Iglpx9C+OXD2PzIAEQi3W1TaqDWDKdfvV8/FWRRHE+yPDDZX/LDEYTsawFbQcTAXUQMk+wQ6VywYKAeBRhQzA0Vm2LOJQEmJzUMXylZkVJypetHg7XZdCRXPvhqEXDhYTrhMvZjdaR7DNzNlJAkxwB7HAqEFNuB9owi9Bq4eAfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778508913; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NzGJyCwDRRicw9ZbRTGDUXJ9F2vnDG4yuoCyoa5p0GE=; b=ECvy4TYWHqLkdipGXWJS51nNNLxY4xmsjIhy/ZW2ueZnHTqcdhLJQSIC/BVbOOsIG1OI1TF5hHRQrV5SAbLiRQUsKE9SfHOVck/AJQg9eyF5janmug/p1pxnnDsQXRqcjhpHTtcFJAUMEwKYiCmFWVdgrN/c+dWioZY9+ZanAng= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778508913776779.650960076798; Mon, 11 May 2026 07:15:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMRP9-00036m-1H; Mon, 11 May 2026 10:14:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMRP5-00031Z-OF for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:39 -0400 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 1wMRP3-00011o-IZ for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:39 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-673-U8uG-es3PIar2nJjqCqvWQ-1; Mon, 11 May 2026 10:14:31 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D9EAC195608B; Mon, 11 May 2026 14:14:29 +0000 (UTC) Received: from berrange.com (unknown [10.44.50.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E953019560A2; Mon, 11 May 2026 14:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778508875; 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=NzGJyCwDRRicw9ZbRTGDUXJ9F2vnDG4yuoCyoa5p0GE=; b=RRDJ1Fte05JS4rUXv2oRk28Pxeor59zCxZf7gZ17nMHAzXBQr94VDXFSF/4ODhmRp5xD4S RxQOMvno0AKJdCq0LamQFLC2iurpw2EUDLi/4VokJICa57PlT4+Qk/gp0JrI4MBJYiGkZZ S4bRliCiMcQG2s+6Y4CY8/dh/IMJW20= X-MC-Unique: U8uG-es3PIar2nJjqCqvWQ-1 X-Mimecast-MFC-AGG-ID: U8uG-es3PIar2nJjqCqvWQ_1778508870 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 02/10] qom: validate ID format when creating objects Date: Mon, 11 May 2026 15:14:12 +0100 Message-ID: <20260511141420.229023-3-berrange@redhat.com> In-Reply-To: <20260511141420.229023-1-berrange@redhat.com> References: <20260511141420.229023-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1778508915160158501 The object_new_with_props/propv methods failed to validate the ID string format, thus diverging from user_creatable_add_type. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Daniel P. Berrang=C3=A9 --- qom/object.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qom/object.c b/qom/object.c index 9c391071fb..62d2f0486a 100644 --- a/qom/object.c +++ b/qom/object.c @@ -24,6 +24,8 @@ #include "qapi/forward-visitor.h" #include "qapi/qapi-builtin-visit.h" #include "qobject/qjson.h" +#include "qemu/id.h" +#include "qapi/qmp/qerror.h" #include "trace.h" =20 /* TODO: replace QObject with a simpler visitor to avoid a dependency @@ -764,6 +766,13 @@ Object *object_new_with_propv(const char *typename, ObjectClass *klass; UserCreatable *uc; =20 + if (id !=3D NULL && !id_wellformed(id)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id", "an identifie= r"); + error_append_hint(errp, "Identifiers consist of letters, digits, " + "'-', '.', '_', starting with a letter.\n"); + return NULL; + } + klass =3D object_class_by_name(typename); if (!klass) { error_setg(errp, "invalid object type: %s", typename); --=20 2.54.0 From nobody Mon May 25 20:31:51 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778508907; cv=none; d=zohomail.com; s=zohoarc; b=nXLOrOB/3yNLL1sm39pBixczXXMAPWL3Hr1oJ5ruUvfvgLGN0yaVv3mR//GFMq85xlLZ3C3t21QWyligJtr/di8Rpzp+lMRUtRdrbPEa9g6L4vGkYmXaesab+C0ooWzjAoS+JrroadSwX5+SYTgodFDovGAUSc63N/0g1NOMd5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778508907; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MESaAZFWAyS94hDcX5eywJKSiXbN7+TMtz9pwhn/ftI=; b=iraBD3GIbNmHnNwLA84vhJEbNnqm7a4+X1UvYsVNXQWrUUIludnInGRakC9z9kQnTEmBNs+0EXVc35V0HSeZP0qIlYKegrmB59KuS40HRbnDzEnCJLUp7qVi4MuM6phMU1VcACVr7epZu65fs12H9a+vCMbKJ8VFAqzDDJY9K+Y= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778508907272865.4158764220632; Mon, 11 May 2026 07:15:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMRPB-00037f-P1; Mon, 11 May 2026 10:14:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMRP5-00031y-TC for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:39 -0400 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 1wMRP3-00011u-RV for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:39 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-ESH97vdFMTmHYMHzlg9vAg-1; Mon, 11 May 2026 10:14:34 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4342319560BC; Mon, 11 May 2026 14:14:33 +0000 (UTC) Received: from berrange.com (unknown [10.44.50.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B2CCA19560A2; Mon, 11 May 2026 14:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778508875; 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=MESaAZFWAyS94hDcX5eywJKSiXbN7+TMtz9pwhn/ftI=; b=E3JtIiJAV4cboI8TuH4PGlHTrlfN1kFQezccOKHb/AVSBoYnzcBAaP7hmNpu9WI20DcDGm bjzULCUwhOi4qibgfb05JGLa5jzqu6R1nEn4V+BDoCPUlWRQqb+sTsfAV20QbbpfZUEgE4 mcWNFr5ORgZTiDCO8rCEu5Xc/yQf1BI= X-MC-Unique: ESH97vdFMTmHYMHzlg9vAg-1 X-Mimecast-MFC-AGG-ID: ESH97vdFMTmHYMHzlg9vAg_1778508873 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 03/10] qom: make errp last param in methods taking va_list Date: Mon, 11 May 2026 15:14:13 +0100 Message-ID: <20260511141420.229023-4-berrange@redhat.com> In-Reply-To: <20260511141420.229023-1-berrange@redhat.com> References: <20260511141420.229023-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1778508908923154100 object_new_with_props can't put 'errp' last due to the use of variadic arguments. That constraint does not apply to the use of va_list with object_new_with_propv, so follow normal practice with 'errp' placement. The same rationale applies to object_set_propv. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qom/object.h | 10 +++++----- qom/object.c | 20 ++++++++++---------- tests/unit/check-qom-proplist.c | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 510885218b..c7d80914fb 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -689,16 +689,16 @@ Object *object_new_with_props(const char *typename, * @typename: The name of the type of the object to instantiate. * @parent: the parent object * @id: The unique ID of the object - * @errp: pointer to error object * @vargs: list of property names and values + * @errp: pointer to error object * * See object_new_with_props() for documentation. */ Object *object_new_with_propv(const char *typename, Object *parent, const char *id, - Error **errp, - va_list vargs); + va_list vargs, + Error **errp); =20 /** * object_set_props: @@ -739,14 +739,14 @@ bool object_set_props(Object *obj, Error **errp, ...)= G_GNUC_NULL_TERMINATED; /** * object_set_propv: * @obj: the object instance to set properties on - * @errp: pointer to error object * @vargs: list of property names and values + * @errp: pointer to error object * * See object_set_props() for documentation. * * Returns: %true on success, %false on error. */ -bool object_set_propv(Object *obj, Error **errp, va_list vargs); +bool object_set_propv(Object *obj, va_list vargs, Error **errp); =20 /** * object_initialize: diff --git a/qom/object.c b/qom/object.c index 62d2f0486a..608c9c0ac7 100644 --- a/qom/object.c +++ b/qom/object.c @@ -550,7 +550,7 @@ bool object_initialize_child_with_propsv(Object *parent= obj, object_initialize(childobj, size, type); obj =3D OBJECT(childobj); =20 - if (!object_set_propv(obj, errp, vargs)) { + if (!object_set_propv(obj, vargs, errp)) { goto out; } =20 @@ -749,7 +749,7 @@ Object *object_new_with_props(const char *typename, Object *obj; =20 va_start(vargs, errp); - obj =3D object_new_with_propv(typename, parent, id, errp, vargs); + obj =3D object_new_with_propv(typename, parent, id, vargs, errp); va_end(vargs); =20 return obj; @@ -759,8 +759,8 @@ Object *object_new_with_props(const char *typename, Object *object_new_with_propv(const char *typename, Object *parent, const char *id, - Error **errp, - va_list vargs) + va_list vargs, + Error **errp) { Object *obj; ObjectClass *klass; @@ -785,7 +785,7 @@ Object *object_new_with_propv(const char *typename, } obj =3D object_new_with_type(klass->type); =20 - if (!object_set_propv(obj, errp, vargs)) { + if (!object_set_propv(obj, vargs, errp)) { goto error; } =20 @@ -813,14 +813,14 @@ Object *object_new_with_propv(const char *typename, =20 =20 bool object_set_props(Object *obj, - Error **errp, - ...) + Error **errp, + ...) { va_list vargs; bool ret; =20 va_start(vargs, errp); - ret =3D object_set_propv(obj, errp, vargs); + ret =3D object_set_propv(obj, vargs, errp); va_end(vargs); =20 return ret; @@ -828,8 +828,8 @@ bool object_set_props(Object *obj, =20 =20 bool object_set_propv(Object *obj, - Error **errp, - va_list vargs) + va_list vargs, + Error **errp) { const char *propname; =20 diff --git a/tests/unit/check-qom-proplist.c b/tests/unit/check-qom-proplis= t.c index ee3c6fb32b..7f31735459 100644 --- a/tests/unit/check-qom-proplist.c +++ b/tests/unit/check-qom-proplist.c @@ -373,8 +373,8 @@ static Object *new_helper(Error **errp, obj =3D object_new_with_propv(TYPE_DUMMY, parent, "dummy0", - errp, - vargs); + vargs, + errp); va_end(vargs); return obj; } --=20 2.54.0 From nobody Mon May 25 20:31:51 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778508907; cv=none; d=zohomail.com; s=zohoarc; b=W4jvC9V4Jjf+XVnBZeZ5w0YeKd3xqYjH4G0b0QvlBnyCD4VzG+uKkKVbHpD3d1DxcQrV4OhxkWeXOOwM8LVHbYtc613exDCEBoqmFnCokbi61Qn7SmDBYTFNHHnGOkp2hzLVRLR0O9P/SFb7PIzt3UhqyarNLVAluKfhj8iJaBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778508907; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8Qw95Rr2nhMPOvK9li1D/zcB3kAu9EHrXRsUOSiefiQ=; b=NksRqnsabbKbxNp/hyPKihaosPPoHmYXmTrKXLPHoU5euw+HFa3FbG+fHN4ze3rW1bfPiFVQUDf+dhBV5y1isn+Rmoaf1uf4bJ/1J9a56l5alHrxMAxPf5/4ogeBl6Zxyqx4v/a3EIAGgQW9Jaae3PqOL96O6RN63Qu1Qu/6Hec= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778508907388931.7430531293921; Mon, 11 May 2026 07:15:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMRPB-00037g-Nj; Mon, 11 May 2026 10:14:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMRP7-00034w-6B for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:41 -0400 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 1wMRP5-00012F-4D for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:40 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-2wNPMLsgNlW4MLNNoNDM4Q-1; Mon, 11 May 2026 10:14:36 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EB15A18002E3; Mon, 11 May 2026 14:14:35 +0000 (UTC) Received: from berrange.com (unknown [10.44.50.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D1E6519560A2; Mon, 11 May 2026 14:14:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778508878; 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=8Qw95Rr2nhMPOvK9li1D/zcB3kAu9EHrXRsUOSiefiQ=; b=SAf1EqjvhDacIOL3Qc2k3lgl2gFB8K11TNsH0Zu4Jl4myyG4JSC8ifl1ZeQ+ALhpwFy+Ye z3LRihfs8XPEhWAyhQm4mzclBWsSIAEE2xhkhT+jxpQpiWlirez6vX+GkHdGJ1659BULRb 2BB4YYOrGmcC0a8zTOmbci3Gy+bEuww= X-MC-Unique: 2wNPMLsgNlW4MLNNoNDM4Q-1 X-Mimecast-MFC-AGG-ID: 2wNPMLsgNlW4MLNNoNDM4Q_1778508876 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 04/10] qom: shorten name of object_set_properties_from_keyval Date: Mon, 11 May 2026 15:14:14 +0100 Message-ID: <20260511141420.229023-5-berrange@redhat.com> In-Reply-To: <20260511141420.229023-1-berrange@redhat.com> References: <20260511141420.229023-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1778508908936154101 This matches the convention established by the object_set_props and object_set_propv methods. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qom/object.h | 6 +++--- qom/object_interfaces.c | 12 ++++++------ system/qdev-monitor.c | 4 ++-- system/vl.c | 7 ++++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index c7d80914fb..d841c338a2 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -915,7 +915,7 @@ type_init(do_qemu_init_ ## type_array) bool type_print_class_properties(const char *type); =20 /** - * object_set_properties_from_keyval: + * object_set_props_from_keyval: * @obj: a QOM object * @qdict: a dictionary with the properties to be set * @from_json: true if leaf values of @qdict are typed, false if they @@ -925,8 +925,8 @@ bool type_print_class_properties(const char *type); * For each key in the dictionary, parse the value string if needed, * then set the corresponding property in @obj. */ -void object_set_properties_from_keyval(Object *obj, const QDict *qdict, - bool from_json, Error **errp); +void object_set_props_from_keyval(Object *obj, const QDict *qdict, + bool from_json, Error **errp); =20 /** * object_class_dynamic_cast_assert: diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 415cbee8c5..4377d65b76 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -44,8 +44,8 @@ bool user_creatable_can_be_deleted(UserCreatable *uc) } } =20 -static void object_set_properties_from_qdict(Object *obj, const QDict *qdi= ct, - Visitor *v, Error **errp) +static void object_set_props_from_qdict(Object *obj, const QDict *qdict, + Visitor *v, Error **errp) { const QDictEntry *e; =20 @@ -62,8 +62,8 @@ out: visit_end_struct(v, NULL); } =20 -void object_set_properties_from_keyval(Object *obj, const QDict *qdict, - bool from_json, Error **errp) +void object_set_props_from_keyval(Object *obj, const QDict *qdict, + bool from_json, Error **errp) { Visitor *v; if (from_json) { @@ -71,7 +71,7 @@ void object_set_properties_from_keyval(Object *obj, const= QDict *qdict, } else { v =3D qobject_input_visitor_new_keyval(QOBJECT(qdict)); } - object_set_properties_from_qdict(obj, qdict, v, errp); + object_set_props_from_qdict(obj, qdict, v, errp); visit_free(v); } =20 @@ -110,7 +110,7 @@ Object *user_creatable_add_type(const char *type, const= char *id, =20 assert(qdict); obj =3D object_new_with_class(klass); - object_set_properties_from_qdict(obj, qdict, v, &local_err); + object_set_props_from_qdict(obj, qdict, v, &local_err); if (local_err) { goto out; } diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index e5b55e3004..dfc95a08c1 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -730,8 +730,8 @@ DeviceState *qdev_device_add_from_qdict(const QDict *op= ts, qdict_del(properties, "bus"); qdict_del(properties, "id"); =20 - object_set_properties_from_keyval(&dev->parent_obj, properties, from_j= son, - errp); + object_set_props_from_keyval(&dev->parent_obj, properties, from_json, + errp); qobject_unref(properties); if (*errp) { goto err_del_dev; diff --git a/system/vl.c b/system/vl.c index d2f4044e5d..288819c409 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2009,7 +2009,8 @@ static bool object_create_early(const char *type) =20 static void qemu_apply_machine_options(QDict *qdict) { - object_set_properties_from_keyval(OBJECT(current_machine), qdict, fals= e, &error_fatal); + object_set_props_from_keyval(OBJECT(current_machine), qdict, + false, &error_fatal); =20 if (semihosting_enabled(false) && !semihosting_get_argc()) { /* fall back to the -kernel/-append */ @@ -2224,8 +2225,8 @@ static void qemu_create_machine(QDict *qdict) keyval_parse(machine_class->default_machine_opts, NULL, NULL, &error_abort); qemu_apply_legacy_machine_options(default_opts); - object_set_properties_from_keyval(OBJECT(current_machine), default= _opts, - false, &error_abort); + object_set_props_from_keyval(OBJECT(current_machine), default_opts, + false, &error_abort); qobject_unref(default_opts); } } --=20 2.54.0 From nobody Mon May 25 20:31:51 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778509021; cv=none; d=zohomail.com; s=zohoarc; b=NKHWEt0HCxqm7nL8eAZTJR5OSUnTCtpE7EqNMPZ/U58PEdiyy4wPRh+Ixlnb7lI/tOZQ1k1atmAZ40cAVl/Jm8El/For/P4y15To2+SVej5NxyoX62V/G3LF5rjnFOu4o7hoYGb5Ifx1+V4jvM9Cgb2LPRdncqQl4aD1Tc89CLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778509021; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sfxBSukgXDZPtvTVXw5hj6A2Y0LAcOg2hsFIj+FphcY=; b=DvJdeXVB1y4rA2kMNiqWY+WmlmW68RjpeDy96AQZndHBG85SN9AJH0E2HD2lf+sAWbZoA7y32tKhuVj3ozUTk2UmM+HiTvNmMiXlevrnWaXcPLipvNQDD0dQpHppqdGLjUIOeU/vsyidR5tnL4OtJtxpVjfB5nrZYs3fis4je/4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778509021800520.2219876823902; Mon, 11 May 2026 07:17:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMRPL-0003Ak-6M; Mon, 11 May 2026 10:14:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMRPC-00038c-4Z for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:46 -0400 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 1wMRPA-00013l-Ii for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:45 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-88-H60B9n8PPaqijytTwuW0_w-1; Mon, 11 May 2026 10:14:39 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 71A3319560AA; Mon, 11 May 2026 14:14:38 +0000 (UTC) Received: from berrange.com (unknown [10.44.50.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 80E2219560A2; Mon, 11 May 2026 14:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778508884; 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=sfxBSukgXDZPtvTVXw5hj6A2Y0LAcOg2hsFIj+FphcY=; b=YM3g7RnpNd7Fw32CBG4yzM9ec6aQTmP7/joKYi1kC0Z2SycNzNUUv2vtDvGM7KvkLknJba vSSkWVKfhZGmdi2A7O8AiHwuZEGauOvwwhm7XlxPDYHPHj6ba8YQ3NOgSV42T7VtiPI/c0 kbAR+D2UDwIZ7ILUAYPbFWSlFOz5+qE= X-MC-Unique: H60B9n8PPaqijytTwuW0_w-1 X-Mimecast-MFC-AGG-ID: H60B9n8PPaqijytTwuW0_w_1778508878 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 05/10] qom: have object_set_props_keyval return bool Date: Mon, 11 May 2026 15:14:15 +0100 Message-ID: <20260511141420.229023-6-berrange@redhat.com> In-Reply-To: <20260511141420.229023-1-berrange@redhat.com> References: <20260511141420.229023-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1778509023604154100 This matches the convention established by the object_set_props and object_set_propv methods. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qom/object.h | 4 +++- qom/object_interfaces.c | 13 +++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index d841c338a2..20a04cc4a9 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -924,8 +924,10 @@ bool type_print_class_properties(const char *type); * * For each key in the dictionary, parse the value string if needed, * then set the corresponding property in @obj. + * + * Returns: %true on success, %false on error. */ -void object_set_props_from_keyval(Object *obj, const QDict *qdict, +bool object_set_props_from_keyval(Object *obj, const QDict *qdict, bool from_json, Error **errp); =20 /** diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 4377d65b76..50736b80c8 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -44,13 +44,14 @@ bool user_creatable_can_be_deleted(UserCreatable *uc) } } =20 -static void object_set_props_from_qdict(Object *obj, const QDict *qdict, +static bool object_set_props_from_qdict(Object *obj, const QDict *qdict, Visitor *v, Error **errp) { + ERRP_GUARD(); const QDictEntry *e; =20 if (!visit_start_struct(v, NULL, NULL, 0, errp)) { - return; + return false; } for (e =3D qdict_first(qdict); e; e =3D qdict_next(qdict, e)) { if (!object_property_set(obj, e->key, v, errp)) { @@ -60,19 +61,23 @@ static void object_set_props_from_qdict(Object *obj, co= nst QDict *qdict, visit_check_struct(v, errp); out: visit_end_struct(v, NULL); + + return *errp =3D=3D NULL; } =20 -void object_set_props_from_keyval(Object *obj, const QDict *qdict, +bool object_set_props_from_keyval(Object *obj, const QDict *qdict, bool from_json, Error **errp) { + bool ret; Visitor *v; if (from_json) { v =3D qobject_input_visitor_new(QOBJECT(qdict)); } else { v =3D qobject_input_visitor_new_keyval(QOBJECT(qdict)); } - object_set_props_from_qdict(obj, qdict, v, errp); + ret =3D object_set_props_from_qdict(obj, qdict, v, errp); visit_free(v); + return ret; } =20 Object *user_creatable_add_type(const char *type, const char *id, --=20 2.54.0 From nobody Mon May 25 20:31:51 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778508970; cv=none; d=zohomail.com; s=zohoarc; b=Dl+ELTr4WOiyhCFo95DMfus3XJmzNl6+q4s2uhuQJn0cSLqJ5Yr33wJ9+BFImeD9tjmCkDqNdzI701RnoQzRR52jriE1wjdGzC+uD81Dk76g6tbE0k8kzJ30ZZIEVIi+T0xR6LXaeTwes65VQPvHEZ/lZcDgzU0PsO0PrJZvp78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778508970; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W3N69S2HP6DOOioem4NT1ph8aNy2Ra92PkRUQ7BLnR8=; b=JFTWsQatqTEQctMjygqoP4S8t6Rg3BJl/he/i+FNvzHsK1/wooUquFOjrTBehRWW0r9Ud/jO2eR7a9TzztA7yoACSfSDI66o/XFlXKV4DMhT57x3LzH9lDg61VutRZdwFfo44fx4CC05HgfAlaP8QLuOAjHt8kXKSTDyP1+BuTM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778508970530831.9465241095407; Mon, 11 May 2026 07:16:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMRPR-0003CV-Qu; Mon, 11 May 2026 10:15:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMRPJ-00039z-1n for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:53 -0400 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 1wMRPG-00014i-Lc for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:52 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-86-p7_fkksoOlO_NxVTY29hGA-1; Mon, 11 May 2026 10:14:42 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 25C3418002EA; Mon, 11 May 2026 14:14:41 +0000 (UTC) Received: from berrange.com (unknown [10.44.50.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1442E19560A2; Mon, 11 May 2026 14:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778508888; 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=W3N69S2HP6DOOioem4NT1ph8aNy2Ra92PkRUQ7BLnR8=; b=Pg88oHAp/OPc9RT3fHh2z5FfHbWUdKnp5QSYs870YemCoE+KC/nD/j4edUb+rMUQ4/evia UJOQJti4Xs5NuvqLN1yNv2MbZU7EkyP/pzDdHOZb27Zz015N+Ou8235yid1kZzK3jY1fwh seIAiTcNkS0BrryOTMEZQt7Taj5tlgQ= X-MC-Unique: p7_fkksoOlO_NxVTY29hGA-1 X-Mimecast-MFC-AGG-ID: p7_fkksoOlO_NxVTY29hGA_1778508881 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 06/10] qom: move object_set_prop_keyval into object.c Date: Mon, 11 May 2026 15:14:16 +0100 Message-ID: <20260511141420.229023-7-berrange@redhat.com> In-Reply-To: <20260511141420.229023-1-berrange@redhat.com> References: <20260511141420.229023-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1778508972094158500 This matches the location of the object_set_props and object_set_propv methods, since this method is not inherently tied to the user creatable interface. As part of this, object_set_props_from_qdict is also exposed as a public API since it is still called from object_interfaces.c. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qom/object.h | 47 +++++++++++++++++++++++++++-------------- qom/object.c | 36 +++++++++++++++++++++++++++++++ qom/object_interfaces.c | 36 ------------------------------- 3 files changed, 67 insertions(+), 52 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 20a04cc4a9..1b2b2702fc 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -748,6 +748,37 @@ bool object_set_props(Object *obj, Error **errp, ...) = G_GNUC_NULL_TERMINATED; */ bool object_set_propv(Object *obj, va_list vargs, Error **errp); =20 +/** + * object_set_props_from_qdict: + * @obj: a QOM object + * @qdict: a dictionary with the properties to be set + * @v: a visitor to iterate over @dict + * @errp: pointer to error object + * + * For each key in the dictionary, set the corresponding + * property in @obj. + * + * Returns: %true on success, %false on error. + */ +bool object_set_props_from_qdict(Object *obj, const QDict *qdict, + Visitor *v, Error **errp); + +/** + * object_set_props_from_keyval: + * @obj: a QOM object + * @qdict: a dictionary with the properties to be set + * @from_json: true if leaf values of @qdict are typed, false if they + * are strings + * @errp: pointer to error object + * + * For each key in the dictionary, parse the value string if needed, + * then set the corresponding property in @obj. + * + * Returns: %true on success, %false on error. + */ +bool object_set_props_from_keyval(Object *obj, const QDict *qdict, + bool from_json, Error **errp); + /** * object_initialize: * @obj: A pointer to the memory to be used for the object. @@ -914,22 +945,6 @@ type_init(do_qemu_init_ ## type_array) */ bool type_print_class_properties(const char *type); =20 -/** - * object_set_props_from_keyval: - * @obj: a QOM object - * @qdict: a dictionary with the properties to be set - * @from_json: true if leaf values of @qdict are typed, false if they - * are strings - * @errp: pointer to error object - * - * For each key in the dictionary, parse the value string if needed, - * then set the corresponding property in @obj. - * - * Returns: %true on success, %false on error. - */ -bool object_set_props_from_keyval(Object *obj, const QDict *qdict, - bool from_json, Error **errp); - /** * object_class_dynamic_cast_assert: * @klass: The #ObjectClass to attempt to cast. diff --git a/qom/object.c b/qom/object.c index 608c9c0ac7..d8083dc318 100644 --- a/qom/object.c +++ b/qom/object.c @@ -23,6 +23,7 @@ #include "qapi/qobject-input-visitor.h" #include "qapi/forward-visitor.h" #include "qapi/qapi-builtin-visit.h" +#include "qobject/qdict.h" #include "qobject/qjson.h" #include "qemu/id.h" #include "qapi/qmp/qerror.h" @@ -847,6 +848,41 @@ bool object_set_propv(Object *obj, return true; } =20 +bool object_set_props_from_qdict(Object *obj, const QDict *qdict, + Visitor *v, Error **errp) +{ + ERRP_GUARD(); + const QDictEntry *e; + + if (!visit_start_struct(v, NULL, NULL, 0, errp)) { + return false; + } + for (e =3D qdict_first(qdict); e; e =3D qdict_next(qdict, e)) { + if (!object_property_set(obj, e->key, v, errp)) { + goto out; + } + } + visit_check_struct(v, errp); +out: + visit_end_struct(v, NULL); + + return *errp =3D=3D NULL; +} + +bool object_set_props_from_keyval(Object *obj, const QDict *qdict, + bool from_json, Error **errp) +{ + bool ret; + Visitor *v; + if (from_json) { + v =3D qobject_input_visitor_new(QOBJECT(qdict)); + } else { + v =3D qobject_input_visitor_new_keyval(QOBJECT(qdict)); + } + ret =3D object_set_props_from_qdict(obj, qdict, v, errp); + visit_free(v); + return ret; +} =20 Object *object_dynamic_cast(Object *obj, const char *typename) { diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 50736b80c8..e0a3cd8d0f 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -44,42 +44,6 @@ bool user_creatable_can_be_deleted(UserCreatable *uc) } } =20 -static bool object_set_props_from_qdict(Object *obj, const QDict *qdict, - Visitor *v, Error **errp) -{ - ERRP_GUARD(); - const QDictEntry *e; - - if (!visit_start_struct(v, NULL, NULL, 0, errp)) { - return false; - } - for (e =3D qdict_first(qdict); e; e =3D qdict_next(qdict, e)) { - if (!object_property_set(obj, e->key, v, errp)) { - goto out; - } - } - visit_check_struct(v, errp); -out: - visit_end_struct(v, NULL); - - return *errp =3D=3D NULL; -} - -bool object_set_props_from_keyval(Object *obj, const QDict *qdict, - bool from_json, Error **errp) -{ - bool ret; - Visitor *v; - if (from_json) { - v =3D qobject_input_visitor_new(QOBJECT(qdict)); - } else { - v =3D qobject_input_visitor_new_keyval(QOBJECT(qdict)); - } - ret =3D object_set_props_from_qdict(obj, qdict, v, errp); - visit_free(v); - return ret; -} - Object *user_creatable_add_type(const char *type, const char *id, const QDict *qdict, Visitor *v, Error **errp) --=20 2.54.0 From nobody Mon May 25 20:31:51 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778508947; cv=none; d=zohomail.com; s=zohoarc; b=oFHN3CcZ/t+8INS6ieqIK5DhOHNhUCmIUfbUQ3Sg9T3NqBnGeQvfnwZXT//mJM+1RuxespdhU12nJNIhb6mPPn/UpNIootwhhsgx6L+YaWrp9Cov6TLZLJTDaGcGqUfuaGakVmrJ0gzcQ1gWGEqrYYcy7+3jEilf40ENk5WVkUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778508947; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rzc8AWkwb0qd8O3CFJYB0nXakC3oVlw15sch7W5AUqs=; b=ench1TOr6B1+i60Z/H4znAZCY6YWejuir4z5qXyN3GIgAOoBbvQkPyppUrFFF2XzByyl6xtr+XphoZ3xIgyzHR5PAGGZ2e+QNngkXWnbQAOhiahjicDLihLFH5t3tTcaauCy0Fru4QEz2M/ZabKzYctVACeZCIFgytB9T+BMj8E= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778508947824614.4619144822038; Mon, 11 May 2026 07:15:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMRPQ-0003CA-Tw; Mon, 11 May 2026 10:15:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMRPJ-00039y-0i for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:53 -0400 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 1wMRPG-00014c-LG for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:52 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-5c38U5jjO6GczjIAldvUEw-1; Mon, 11 May 2026 10:14:44 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B5CDC180035D; Mon, 11 May 2026 14:14:43 +0000 (UTC) Received: from berrange.com (unknown [10.44.50.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B5F4319560A6; Mon, 11 May 2026 14:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778508887; 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=rzc8AWkwb0qd8O3CFJYB0nXakC3oVlw15sch7W5AUqs=; b=OndltLJfOaGAM3SZGQBTLjCEOAXg5OH0nGEvXju2wml9EvkHNvCwuyS7A5++vlWpqnTwXG HIQDU1knB2qvKO2DiSvgc4bBYcMZaEFDiZVbbrHEDw0t+q2uXtWKxRWUO3ZQHHZ3Hef7Ed +hLaS24PeW83Luz8cWNxgMbyqX37Qkw= X-MC-Unique: 5c38U5jjO6GczjIAldvUEw-1 X-Mimecast-MFC-AGG-ID: 5c38U5jjO6GczjIAldvUEw_1778508883 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 07/10] qom: add object_new_with_props_from_qdict Date: Mon, 11 May 2026 15:14:17 +0100 Message-ID: <20260511141420.229023-8-berrange@redhat.com> In-Reply-To: <20260511141420.229023-1-berrange@redhat.com> References: <20260511141420.229023-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1778508949681158500 This will be used to replace user_creatable_add_type with an impl that shares most code with object_new_with_props, and is not tied to the user creatable interface. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qom/object.h | 19 +++++++++++ qom/object.c | 75 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 6 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 1b2b2702fc..f33d512b19 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -700,6 +700,25 @@ Object *object_new_with_propv(const char *typename, va_list vargs, Error **errp); =20 +/** + * object_new_with_props_from_qdict: + * @typename: The name of the type of the object to instantiate. + * @parent: the parent object + * @id: The unique ID of the object + * @props: dictionary of property names and values + * @v: visitor to iterate over @props + * @errp: pointer to error object + * + * A variant of object_new_with_props() which accepts the + * properties in a QDict. + */ +Object *object_new_with_props_from_qdict(const char *typename, + Object *parent, + const char *id, + const QDict *props, + Visitor *v, + Error **errp); + /** * object_set_props: * @obj: the object instance to set properties on diff --git a/qom/object.c b/qom/object.c index d8083dc318..0c13e5ee1c 100644 --- a/qom/object.c +++ b/qom/object.c @@ -757,11 +757,14 @@ Object *object_new_with_props(const char *typename, } =20 =20 -Object *object_new_with_propv(const char *typename, - Object *parent, - const char *id, - va_list vargs, - Error **errp) +static Object * +object_new_with_props_helper(const char *typename, + Object *parent, + const char *id, + void *props, + bool (set_props)(Object *obj, void *props, + Error **errp), + Error **errp) { Object *obj; ObjectClass *klass; @@ -786,7 +789,7 @@ Object *object_new_with_propv(const char *typename, } obj =3D object_new_with_type(klass->type); =20 - if (!object_set_propv(obj, vargs, errp)) { + if (!set_props(obj, props, errp)) { goto error; } =20 @@ -812,6 +815,66 @@ Object *object_new_with_propv(const char *typename, return NULL; } =20 +struct ObjectNewVargsData { + va_list vargs; +}; + +static bool object_new_with_propv_setter(Object *obj, + void *props, + Error **errp) +{ + struct ObjectNewVargsData *data =3D props; + return object_set_propv(obj, data->vargs, errp); +} + +Object *object_new_with_propv(const char *typename, + Object *parent, + const char *id, + va_list vargs, + Error **errp) +{ + Object *obj; + struct ObjectNewVargsData data; + + va_copy(data.vargs, vargs); + obj =3D object_new_with_props_helper(typename, + parent, + id, + &data, + object_new_with_propv_setter, + errp); + va_end(data.vargs); + return obj; +} + +struct ObjectNewQDictData { + const QDict *props; + Visitor *v; +}; + +static bool object_new_with_qdict_setter(Object *obj, + void *props, + Error **errp) +{ + struct ObjectNewQDictData *data =3D props; + return object_set_props_from_qdict(obj, data->props, data->v, errp); +} + +Object *object_new_with_props_from_qdict(const char *typename, + Object *parent, + const char *id, + const QDict *props, + Visitor *v, + Error **errp) +{ + struct ObjectNewQDictData data =3D { props, v }; + return object_new_with_props_helper(typename, + parent, + id, + &data, + object_new_with_qdict_setter, + errp); +} =20 bool object_set_props(Object *obj, Error **errp, --=20 2.54.0 From nobody Mon May 25 20:31:51 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778508971; cv=none; d=zohomail.com; s=zohoarc; b=JXiOZ13bPZr6T1m6sEjynVn/ipfG/UaBiSvTH4VSjAdXki5U4g5Wow3/KwEgIbyGTeqdgpwOtca1SMCqtVR3x+IYqICvgUniHWqBWkofK3D0cnza/xkiRoucnCt1HRmiMdps86MzNMTWyA648B8lKveZAZoucvn+BT4f2bJaW+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778508971; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=44ghoS8733tFYVEDqyM31T5lHaYLoS2R9vzjn7CXkkA=; b=NmDT8t72uQNWUhZITDqSmWHRYoIqOoBGAe80qcW6/nEhIWX89hWicaUiKHvQy29kAEyY3OpoSxhjCzyNNyO34XL6gnToaqdlIqz6dYg62I7ySJChmCZ7Lua+alZBbriQt+4O26k+HvsGZezDOS+2WGG1oy9+UmklRgf0lqlj+qE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778508971282192.7861561941295; Mon, 11 May 2026 07:16:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMRPS-0003Cd-HR; Mon, 11 May 2026 10:15:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMRPK-0003Au-VL for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:55 -0400 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 1wMRPH-00014x-6U for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:54 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-75SlXnxEM7uKcugvGQac8w-1; Mon, 11 May 2026 10:14:47 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 309A01954200; Mon, 11 May 2026 14:14:46 +0000 (UTC) Received: from berrange.com (unknown [10.44.50.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4A55B19560A2; Mon, 11 May 2026 14:14:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778508890; 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=44ghoS8733tFYVEDqyM31T5lHaYLoS2R9vzjn7CXkkA=; b=Oh/iUSHxSLXF/hp2fKWrhV6OfdBhS1h882H+jW1eFXEi3vFlbKQVBradbcggGau+5piH5G 2ZgsIvfRmIz4U1yR7o6a2Hp1PinLO80hiyLRTDv0OVwIvmWzv/RsBjAn4lMe6axTaosa77 +aM2qWINQNSFCnewJcfaBK04pKmdsyM= X-MC-Unique: 75SlXnxEM7uKcugvGQac8w-1 X-Mimecast-MFC-AGG-ID: 75SlXnxEM7uKcugvGQac8w_1778508886 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 08/10] qom: fix ability to create objects without a parent Date: Mon, 11 May 2026 15:14:18 +0100 Message-ID: <20260511141420.229023-9-berrange@redhat.com> In-Reply-To: <20260511141420.229023-1-berrange@redhat.com> References: <20260511141420.229023-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1778508972412158500 object_new_with_propv allowed id/parent to be optional, in which case the caller was expected to own the returned object. Unfortunately a trailing object_unref() meant that the returned object was already freed. It is confusing to have a single method with two different ownership scenarios for the returned object. Make id/parent mandatory in object_new_with_propv once more, and add a new object_new_with_propv_parentless that does not accept id/parent at all and lets the caller own the returned reference. The helper method has abstracted the way properties are represented and setk in order to facilitate the subsequent commit. Unit tests are added to address the root cause that allowed the bug to slip through in commit 6134d752. Fixes: 6134d7522e570a30d7f0d1e092ee37351c5183ed Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qom/object.h | 47 ++++++++++++++++++ qom/object.c | 74 +++++++++++++++++++++++---- tests/unit/check-qom-proplist.c | 88 ++++++++++++++++++++++++++++----- 3 files changed, 187 insertions(+), 22 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index f33d512b19..4c2313a57b 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -719,6 +719,53 @@ Object *object_new_with_props_from_qdict(const char *t= ypename, Visitor *v, Error **errp); =20 +/** + * object_new_with_props_parentless: + * @typename: The name of the type of the object to instantiate. + * @errp: pointer to error object + * @...: list of property names and values + * + * Behaviour as object_new_with_props(), except the object + * will not be added to any parent and thus the caller will + * own the returned instance. The caller must call + * object_unref when it is no longer required. + */ +Object *object_new_with_props_parentless(const char *typename, + Error **errp, + ...) G_GNUC_NULL_TERMINATED; + +/** + * object_new_with_propv_parentless: + * @typename: The name of the type of the object to instantiate. + * @vargs: list of property names and values + * @errp: pointer to error object + * + * Behaviour as object_new_with_propv(), except the object + * will not be added to any parent and thus the caller will + * own the returned instance. The caller must call + * object_unref when it is no longer required. + */ +Object *object_new_with_propv_parentless(const char *typename, + va_list vargs, + Error **errp); + +/** + * object_new_with_props_from_qdict_parentless: + * @typename: The name of the type of the object to instantiate. + * @props: dictionary of property names and values + * @v: visitor to iterate over @props + * @errp: pointer to error object + * + * Behaviour as object_new_with_props_from_qdict(), except the + * object will not be added to any parent and thus the caller + * will own the returned instance. The caller must call + * object_unref when it is no longer required. + */ +Object *object_new_with_props_from_qdict_parentless(const char *typename, + const QDict *props, + Visitor *v, + Error **errp); + /** * object_set_props: * @obj: the object instance to set properties on diff --git a/qom/object.c b/qom/object.c index 0c13e5ee1c..e4a0179468 100644 --- a/qom/object.c +++ b/qom/object.c @@ -749,6 +749,8 @@ Object *object_new_with_props(const char *typename, va_list vargs; Object *obj; =20 + assert(parent !=3D NULL); + assert(id !=3D NULL); va_start(vargs, errp); obj =3D object_new_with_propv(typename, parent, id, vargs, errp); va_end(vargs); @@ -766,10 +768,14 @@ object_new_with_props_helper(const char *typename, Error **errp), Error **errp) { + ERRP_GUARD(); Object *obj; ObjectClass *klass; UserCreatable *uc; =20 + assert((id !=3D NULL && parent !=3D NULL) || + (id =3D=3D NULL && parent =3D=3D NULL)); + if (id !=3D NULL && !id_wellformed(id)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id", "an identifie= r"); error_append_hint(errp, "Identifiers consist of letters, digits, " @@ -794,7 +800,10 @@ object_new_with_props_helper(const char *typename, } =20 if (id !=3D NULL) { - object_property_add_child(parent, id, obj); + object_property_try_add_child(parent, id, obj, errp); + if (*errp) { + goto error; + } } =20 uc =3D (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE); @@ -807,7 +816,6 @@ object_new_with_props_helper(const char *typename, } } =20 - object_unref(obj); return obj; =20 error: @@ -835,7 +843,8 @@ Object *object_new_with_propv(const char *typename, { Object *obj; struct ObjectNewVargsData data; - + assert(parent !=3D NULL); + assert(id !=3D NULL); va_copy(data.vargs, vargs); obj =3D object_new_with_props_helper(typename, parent, @@ -844,6 +853,9 @@ Object *object_new_with_propv(const char *typename, object_new_with_propv_setter, errp); va_end(data.vargs); + if (obj) { + object_unref(obj); + } return obj; } =20 @@ -868,12 +880,56 @@ Object *object_new_with_props_from_qdict(const char *= typename, Error **errp) { struct ObjectNewQDictData data =3D { props, v }; - return object_new_with_props_helper(typename, - parent, - id, - &data, - object_new_with_qdict_setter, - errp); + Object *obj; + assert(parent !=3D NULL); + assert(id !=3D NULL); + obj =3D object_new_with_props_helper(typename, + parent, + id, + &data, + object_new_with_qdict_setter, + errp); + if (obj) { + object_unref(obj); + } + return obj; +} + +Object *object_new_with_props_parentless(const char *typename, + Error **errp, + ...) +{ + va_list vargs; + Object *obj; + + va_start(vargs, errp); + obj =3D object_new_with_propv_parentless(typename, vargs, errp); + va_end(vargs); + + return obj; +} + +Object *object_new_with_propv_parentless(const char *typename, + va_list vargs, + Error **errp) +{ + Object *ret; + struct ObjectNewVargsData data; + va_copy(data.vargs, vargs); + ret =3D object_new_with_props_helper(typename, NULL, NULL, &data, + object_new_with_propv_setter, errp); + va_end(vargs); + return ret; +} + +Object *object_new_with_props_from_qdict_parentless(const char *typename, + const QDict *props, + Visitor *v, + Error **errp) +{ + struct ObjectNewQDictData data =3D { props, v }; + return object_new_with_props_helper(typename, NULL, NULL, &data, + object_new_with_qdict_setter, errp= ); } =20 bool object_set_props(Object *obj, diff --git a/tests/unit/check-qom-proplist.c b/tests/unit/check-qom-proplis= t.c index 7f31735459..954c898ce1 100644 --- a/tests/unit/check-qom-proplist.c +++ b/tests/unit/check-qom-proplist.c @@ -336,7 +336,7 @@ static QemuOptsList qemu_object_opts =3D { }; =20 =20 -static void test_dummy_createv(void) +static void test_dummy_createv_tree(void) { Error *err =3D NULL; Object *parent =3D object_get_objects_root(); @@ -351,6 +351,7 @@ static void test_dummy_createv(void) NULL)); =20 g_assert(err =3D=3D NULL); + g_assert_cmpint(dobj->parent_obj.ref, =3D=3D, 1); g_assert_cmpstr(dobj->sv, =3D=3D, "Hiss hiss hiss"); g_assert(dobj->bv =3D=3D true); g_assert(dobj->av =3D=3D DUMMY_PLATYPUS); @@ -362,9 +363,30 @@ static void test_dummy_createv(void) } =20 =20 -static Object *new_helper(Error **errp, - Object *parent, - ...) +static void test_dummy_createv_parentless(void) +{ + Error *err =3D NULL; + DummyObject *dobj =3D DUMMY_OBJECT( + object_new_with_props_parentless(TYPE_DUMMY, + &err, + "bv", "yes", + "sv", "Hiss hiss hiss", + "av", "platypus", + NULL)); + + g_assert(err =3D=3D NULL); + g_assert_cmpint(dobj->parent_obj.ref, =3D=3D, 1); + g_assert_cmpstr(dobj->sv, =3D=3D, "Hiss hiss hiss"); + g_assert(dobj->bv =3D=3D true); + g_assert(dobj->av =3D=3D DUMMY_PLATYPUS); + + object_unref(OBJECT(dobj)); +} + + +static Object *new_helper_tree(Error **errp, + Object *parent, + ...) { va_list vargs; Object *obj; @@ -379,19 +401,20 @@ static Object *new_helper(Error **errp, return obj; } =20 -static void test_dummy_createlist(void) +static void test_dummy_createlist_tree(void) { Error *err =3D NULL; Object *parent =3D object_get_objects_root(); DummyObject *dobj =3D DUMMY_OBJECT( - new_helper(&err, - parent, - "bv", "yes", - "sv", "Hiss hiss hiss", - "av", "platypus", - NULL)); + new_helper_tree(&err, + parent, + "bv", "yes", + "sv", "Hiss hiss hiss", + "av", "platypus", + NULL)); =20 g_assert(err =3D=3D NULL); + g_assert_cmpint(dobj->parent_obj.ref, =3D=3D, 1); g_assert_cmpstr(dobj->sv, =3D=3D, "Hiss hiss hiss"); g_assert(dobj->bv =3D=3D true); g_assert(dobj->av =3D=3D DUMMY_PLATYPUS); @@ -402,6 +425,39 @@ static void test_dummy_createlist(void) object_unparent(OBJECT(dobj)); } =20 +static Object *new_helper_parentless(Error **errp, + ...) +{ + va_list vargs; + Object *obj; + + va_start(vargs, errp); + obj =3D object_new_with_propv_parentless(TYPE_DUMMY, + vargs, + errp); + va_end(vargs); + return obj; +} + +static void test_dummy_createlist_parentless(void) +{ + Error *err =3D NULL; + DummyObject *dobj =3D DUMMY_OBJECT( + new_helper_parentless(&err, + "bv", "yes", + "sv", "Hiss hiss hiss", + "av", "platypus", + NULL)); + + g_assert(err =3D=3D NULL); + g_assert_cmpint(dobj->parent_obj.ref, =3D=3D, 1); + g_assert_cmpstr(dobj->sv, =3D=3D, "Hiss hiss hiss"); + g_assert(dobj->bv =3D=3D true); + g_assert(dobj->av =3D=3D DUMMY_PLATYPUS); + + object_unref(OBJECT(dobj)); +} + static bool test_create_obj(QDict *qdict, Error **errp) { Visitor *v =3D qobject_input_visitor_new_keyval(QOBJECT(qdict)); @@ -658,8 +714,14 @@ int main(int argc, char **argv) type_register_static(&dummy_bus_info); type_register_static(&dummy_backend_info); =20 - g_test_add_func("/qom/proplist/createlist", test_dummy_createlist); - g_test_add_func("/qom/proplist/createv", test_dummy_createv); + g_test_add_func("/qom/proplist/createlist/tree", + test_dummy_createlist_tree); + g_test_add_func("/qom/proplist/createlist/parentless", + test_dummy_createlist_parentless); + g_test_add_func("/qom/proplist/createv/tree", + test_dummy_createv_tree); + g_test_add_func("/qom/proplist/createv/parentless", + test_dummy_createv_parentless); g_test_add_func("/qom/proplist/createcmdline", test_dummy_createcmdl); g_test_add_func("/qom/proplist/badenum", test_dummy_badenum); g_test_add_func("/qom/proplist/getenum", test_dummy_getenum); --=20 2.54.0 From nobody Mon May 25 20:31:51 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778509034; cv=none; d=zohomail.com; s=zohoarc; b=kS8gCWGCQ20cnalHtct92r38fVVjXMusZkVVDq9GnfnFdP3JbHA+yGA42zljMGc9NBpf0TjVnnMHrpIzyq4yWbD6ue6NJk9yQaXWZDGHoDeUBD5pYADOAzJEPLvcBCTGpRurl0NLoCeFn8d1UBVqlTMi2UAfk+b6oM0xreCPWYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778509034; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qhlW/bygR0j1xQgqKjePfNn5OWKRUFO+mA0cVfVD5IA=; b=dAhMQ8UmOBKljtNzMXsyum5/jjlP09KEcluAnBgFi6oY+NW0bXn0kUebjP3+KyuF1muh2Dh5M0CBxHALi3G89FYVP8KqPNaddsAv7+UwBLCmKC1BAWtn2Ana6zhG2s0pPzAAZZRAVdVdPelDTWBmxrcrJhFqRn98NXnxQagB/LY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778509034544723.696646508143; Mon, 11 May 2026 07:17:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMRPT-0003Cz-95; Mon, 11 May 2026 10:15:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMRPN-0003BY-49 for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:58 -0400 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 1wMRPK-00015l-4S for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:55 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-rq79YfdhMxe6pTaZFgWA1Q-1; Mon, 11 May 2026 10:14:49 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DBC511800359; Mon, 11 May 2026 14:14:48 +0000 (UTC) Received: from berrange.com (unknown [10.44.50.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BA2EC19560A6; Mon, 11 May 2026 14:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778508893; 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=qhlW/bygR0j1xQgqKjePfNn5OWKRUFO+mA0cVfVD5IA=; b=hjUtgMoE2lnraWDwy246yOznxTNgDo5UVzlCx6yT7V1aYFAJNUxl9yC7ldHtZmXI7+tTRW Cb0jUr5s+3dyziOPmXSgnUYv5xQADarwvZxjiGkDBLwi7wc0IOceWFLToBzopFDTHz2ld3 SFqZi6rd3Lj4TUmzuTO4nM9T5Ll/tzE= X-MC-Unique: rq79YfdhMxe6pTaZFgWA1Q-1 X-Mimecast-MFC-AGG-ID: rq79YfdhMxe6pTaZFgWA1Q_1778508889 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 09/10] qom: allow object_new_with_prop* to trigger module loading Date: Mon, 11 May 2026 15:14:19 +0100 Message-ID: <20260511141420.229023-10-berrange@redhat.com> In-Reply-To: <20260511141420.229023-1-berrange@redhat.com> References: <20260511141420.229023-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1778509035868154100 The object_new_with_prop* methods will shortly be replacing the user_creatable_add_type method. In order to do that, the object_new_with_prop* methods must allow module loading to be triggered for any types. Signed-off-by: Daniel P. Berrang=C3=A9 --- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qom/object.c b/qom/object.c index e4a0179468..89b5ff57e8 100644 --- a/qom/object.c +++ b/qom/object.c @@ -783,7 +783,7 @@ object_new_with_props_helper(const char *typename, return NULL; } =20 - klass =3D object_class_by_name(typename); + klass =3D module_object_class_by_name(typename); if (!klass) { error_setg(errp, "invalid object type: %s", typename); return NULL; --=20 2.54.0 From nobody Mon May 25 20:31:51 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778509011; cv=none; d=zohomail.com; s=zohoarc; b=H9SMOHW1ztRk+UOLWZ84wwRwkEyPwUr8xqQtDf/a4+9agoA3exYCPl79ImjZO6cj9GsJfQFKZ6bW1zvLK5GB5z1Y/eteOW5pDCJmUBTjIUhjHWybpBJ0gE+ii8g9cZHYBVNLAwb0yrO0VbCbSZho9Wn1bsfTQzyGK3gxs0O2/0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778509011; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=19Mg2EdExOT050N3vQjL+MBdUKKskeVvo0VAIBOOz8Q=; b=Vqtr8h1moq06x61uhXz59nnmKWVHy65mwQlXGsiNaPwTBZIgH6JutTbE2GdpFDOdI8GB2hmWwSiNq14mFNi7802d++4rtxdAdYFm0IbBz6ZuLDJxvPtNIDDc2KBTN9Ua97VuEGiu5LXAkfe37LT6kWoBq8G/Ydt5Nkvsxzgucew= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778509011273213.39662094669063; Mon, 11 May 2026 07:16:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wMRPU-0003DR-Kq; Mon, 11 May 2026 10:15:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wMRPN-0003BZ-42 for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:58 -0400 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 1wMRPK-00015o-Nt for qemu-devel@nongnu.org; Mon, 11 May 2026 10:14:56 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-360-B9pd9srSNhuQIAHBDxhUGg-1; Mon, 11 May 2026 10:14:52 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3C9F41800612; Mon, 11 May 2026 14:14:51 +0000 (UTC) Received: from berrange.com (unknown [10.44.50.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6777419560A6; Mon, 11 May 2026 14:14:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778508893; 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=19Mg2EdExOT050N3vQjL+MBdUKKskeVvo0VAIBOOz8Q=; b=KMt6z5pR/4JpRGSCRqNTo/v7QdGU1xNGDlZ8Mz0v8y6IZunWuQQuooWuiF9cjxKGfNccfC 4IxkC++de4Tz/TxVctbNQue8hXWWLCuPm3IrV8wH/ob4n7CmjwKsJacAEpcD1Ie4U1k6jm YVn/gihm4lFBiYSh9vK/CmBINXR7Dek= X-MC-Unique: B9pd9srSNhuQIAHBDxhUGg-1 X-Mimecast-MFC-AGG-ID: B9pd9srSNhuQIAHBDxhUGg_1778508891 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 10/10] qom: drop user_creatable_add_type method Date: Mon, 11 May 2026 15:14:20 +0100 Message-ID: <20260511141420.229023-11-berrange@redhat.com> In-Reply-To: <20260511141420.229023-1-berrange@redhat.com> References: <20260511141420.229023-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: qemu development 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: 1778509013598154100 This can be replaced by object_new_with_props_from_qdict, which does functionally the same job, but the caller does not own the returned reference, instead the parent object owns it. In one case we can use object_new_with_props_from_qdict_owned instead since the object is not intended to have any parent. Signed-off-by: Daniel P. Berrang=C3=A9 --- authz/listfile.c | 4 +- include/qom/object_interfaces.h | 18 --------- qom/object_interfaces.c | 70 ++------------------------------- tests/unit/check-qom-proplist.c | 5 +-- 4 files changed, 7 insertions(+), 90 deletions(-) diff --git a/authz/listfile.c b/authz/listfile.c index 13741d5a72..23655f8663 100644 --- a/authz/listfile.c +++ b/authz/listfile.c @@ -79,8 +79,8 @@ qauthz_list_file_load(QAuthZListFile *fauthz, Error **err= p) =20 v =3D qobject_input_visitor_new(obj); =20 - ret =3D (QAuthZ *)user_creatable_add_type(TYPE_QAUTHZ_LIST, - NULL, pdict, v, errp); + ret =3D QAUTHZ(object_new_with_props_from_qdict_parentless( + TYPE_QAUTHZ_LIST, pdict, v, errp)); =20 cleanup: visit_free(v); diff --git a/include/qom/object_interfaces.h b/include/qom/object_interface= s.h index 02b11a7ef0..e2b8615617 100644 --- a/include/qom/object_interfaces.h +++ b/include/qom/object_interfaces.h @@ -69,24 +69,6 @@ bool user_creatable_complete(UserCreatable *uc, Error **= errp); */ bool user_creatable_can_be_deleted(UserCreatable *uc); =20 -/** - * user_creatable_add_type: - * @type: the object type name - * @id: the unique ID for the object - * @qdict: the object properties - * @v: the visitor - * @errp: if an error occurs, a pointer to an area to store the error - * - * Create an instance of the user creatable object @type, placing - * it in the object composition tree with name @id, initializing - * it with properties from @qdict - * - * Returns: the newly created object or NULL on error - */ -Object *user_creatable_add_type(const char *type, const char *id, - const QDict *qdict, - Visitor *v, Error **errp); - /** * user_creatable_add_qapi: * @options: the object definition diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index e0a3cd8d0f..7080f85f95 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -44,75 +44,11 @@ bool user_creatable_can_be_deleted(UserCreatable *uc) } } =20 -Object *user_creatable_add_type(const char *type, const char *id, - const QDict *qdict, - Visitor *v, Error **errp) -{ - ERRP_GUARD(); - Object *obj; - ObjectClass *klass; - Error *local_err =3D NULL; - - if (id !=3D NULL && !id_wellformed(id)) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id", "an identifie= r"); - error_append_hint(errp, "Identifiers consist of letters, digits, " - "'-', '.', '_', starting with a letter.\n"); - return NULL; - } - - klass =3D module_object_class_by_name(type); - if (!klass) { - error_setg(errp, "invalid object type: %s", type); - return NULL; - } - - if (!object_class_dynamic_cast(klass, TYPE_USER_CREATABLE)) { - error_setg(errp, "object type '%s' isn't supported by object-add", - type); - return NULL; - } - - if (object_class_is_abstract(klass)) { - error_setg(errp, "object type '%s' is abstract", type); - return NULL; - } - - assert(qdict); - obj =3D object_new_with_class(klass); - object_set_props_from_qdict(obj, qdict, v, &local_err); - if (local_err) { - goto out; - } - - if (id !=3D NULL) { - object_property_try_add_child(object_get_objects_root(), - id, obj, &local_err); - if (local_err) { - goto out; - } - } - - if (!user_creatable_complete(USER_CREATABLE(obj), &local_err)) { - if (id !=3D NULL) { - object_property_del(object_get_objects_root(), id); - } - goto out; - } -out: - if (local_err) { - error_propagate(errp, local_err); - object_unref(obj); - return NULL; - } - return obj; -} - void user_creatable_add_qapi(ObjectOptions *options, Error **errp) { Visitor *v; QObject *qobj; QDict *props; - Object *obj; =20 v =3D qobject_output_visitor_new(&qobj); visit_type_ObjectOptions(v, NULL, &options, &error_abort); @@ -124,9 +60,9 @@ void user_creatable_add_qapi(ObjectOptions *options, Err= or **errp) qdict_del(props, "id"); =20 v =3D qobject_input_visitor_new(QOBJECT(props)); - obj =3D user_creatable_add_type(ObjectType_str(options->qom_type), - options->id, props, v, errp); - object_unref(obj); + object_new_with_props_from_qdict(ObjectType_str(options->qom_type), + object_get_objects_root(), + options->id, props, v, errp); qobject_unref(qobj); visit_free(v); } diff --git a/tests/unit/check-qom-proplist.c b/tests/unit/check-qom-proplis= t.c index 954c898ce1..89de92b7d9 100644 --- a/tests/unit/check-qom-proplist.c +++ b/tests/unit/check-qom-proplist.c @@ -461,10 +461,9 @@ static void test_dummy_createlist_parentless(void) static bool test_create_obj(QDict *qdict, Error **errp) { Visitor *v =3D qobject_input_visitor_new_keyval(QOBJECT(qdict)); - Object *obj =3D user_creatable_add_type(TYPE_DUMMY, "dev0", qdict, v, = errp); - + Object *obj =3D object_new_with_props_from_qdict( + TYPE_DUMMY, object_get_objects_root(), "dev0", qdict, v, errp); visit_free(v); - object_unref(obj); return !!obj; } =20 --=20 2.54.0