From nobody Mon Feb 9 04:46:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601400518; cv=none; d=zohomail.com; s=zohoarc; b=TfqLQ8GMEUsEadzGDsjDALXCVgEv0/mUGCtrNp9HK4izGyOcByWG+LWh37k/97xIbDkIKqTqHTNMxNPpEkQi8ZN4JbdG2w4q7jOHv6q4601zDmEMZwwa3PMcqNVa97ZtCKzLSGkPnzrvjbQFXI3o3tjR2UDcGM/Eu6r8IggMC7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601400518; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0qhokdQOgbhVy3MgKGiOb7ZzJj6In6Bnya/WTLi8Abs=; b=iOD0N1tJCX4c2S+qIhOGT3ViugJdO5wRqL7IH7A30Ft/WcdBcsGnSuN8WzPllR26gDqLTXmNuciqPh1L/+2+ymzQxQC5Tvxr35RduRfQ8liD9UlK05Xle4UHON94+/SVbXWfzckPmkSz63DvQ6cIUE6YS86xpo5/kNN0+Lb6IPM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1601400518000304.4892156788261; Tue, 29 Sep 2020 10:28:38 -0700 (PDT) Received: from localhost ([::1]:40454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNJQa-0002f5-Ob for importer@patchew.org; Tue, 29 Sep 2020 13:28:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNJPB-0001Jw-UC for qemu-devel@nongnu.org; Tue, 29 Sep 2020 13:27:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22297) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kNJPA-0004dk-3w for qemu-devel@nongnu.org; Tue, 29 Sep 2020 13:27:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-249-DlaEqeYtP7SE-dKVz_V6yA-1; Tue, 29 Sep 2020 13:27:05 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6DFA4107B26B; Tue, 29 Sep 2020 17:27:03 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-115-44.ams2.redhat.com [10.36.115.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50FEC1002C01; Tue, 29 Sep 2020 17:27:02 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601400427; 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=0qhokdQOgbhVy3MgKGiOb7ZzJj6In6Bnya/WTLi8Abs=; b=IMBNucyrg00PwEktQImdcePswT5SyVkt+1d5D83EhihPC4NvwCkgFQTImskriBwBDpJrfq JHf8BBjnhAl1Agj/pZnQ4lyUFYDPw9kudIc9Lxq3Ik4CM2o3BgKfpv98vN9uqqKXjg7irK snw/QxeuWnD8f19ACcADen5+3H0VSFU= X-MC-Unique: DlaEqeYtP7SE-dKVz_V6yA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH 2/4] qom: Factor out helpers from user_creatable_print_help() Date: Tue, 29 Sep 2020 19:26:47 +0200 Message-Id: <20200929172649.158086-3-kwolf@redhat.com> In-Reply-To: <20200929172649.158086-1-kwolf@redhat.com> References: <20200929172649.158086-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/29 02:22:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.687, 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_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This creates separate helper functions for printing a list of user creatable object types and for printing a list of properties of a given type. This allows using these parts without having a QemuOpts. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- qom/object_interfaces.c | 90 ++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index e8e1523960..3fd1da157e 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -214,54 +214,68 @@ char *object_property_help(const char *name, const ch= ar *type, return g_string_free(str, false); } =20 -bool user_creatable_print_help(const char *type, QemuOpts *opts) +static void user_creatable_print_types(void) +{ + GSList *l, *list; + + printf("List of user creatable objects:\n"); + list =3D object_class_get_list_sorted(TYPE_USER_CREATABLE, false); + for (l =3D list; l !=3D NULL; l =3D l->next) { + ObjectClass *oc =3D OBJECT_CLASS(l->data); + printf(" %s\n", object_class_get_name(oc)); + } + g_slist_free(list); +} + +static bool user_creatable_print_type_properites(const char *type) { ObjectClass *klass; + ObjectPropertyIterator iter; + ObjectProperty *prop; + GPtrArray *array; + int i; =20 - if (is_help_option(type)) { - GSList *l, *list; + klass =3D object_class_by_name(type); + if (!klass) { + return false; + } =20 - printf("List of user creatable objects:\n"); - list =3D object_class_get_list_sorted(TYPE_USER_CREATABLE, false); - for (l =3D list; l !=3D NULL; l =3D l->next) { - ObjectClass *oc =3D OBJECT_CLASS(l->data); - printf(" %s\n", object_class_get_name(oc)); + array =3D g_ptr_array_new(); + object_class_property_iter_init(&iter, klass); + while ((prop =3D object_property_iter_next(&iter))) { + if (!prop->set) { + continue; } - g_slist_free(list); - return true; + + g_ptr_array_add(array, + object_property_help(prop->name, prop->type, + prop->defval, prop->descripti= on)); } + g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); + if (array->len > 0) { + printf("%s options:\n", type); + } else { + printf("There are no options for %s.\n", type); + } + for (i =3D 0; i < array->len; i++) { + printf("%s\n", (char *)array->pdata[i]); + } + g_ptr_array_set_free_func(array, g_free); + g_ptr_array_free(array, true); + return true; +} =20 - klass =3D object_class_by_name(type); - if (klass && qemu_opt_has_help_opt(opts)) { - ObjectPropertyIterator iter; - ObjectProperty *prop; - GPtrArray *array =3D g_ptr_array_new(); - int i; - - object_class_property_iter_init(&iter, klass); - while ((prop =3D object_property_iter_next(&iter))) { - if (!prop->set) { - continue; - } - - g_ptr_array_add(array, - object_property_help(prop->name, prop->type, - prop->defval, prop->descr= iption)); - } - g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); - if (array->len > 0) { - printf("%s options:\n", type); - } else { - printf("There are no options for %s.\n", type); - } - for (i =3D 0; i < array->len; i++) { - printf("%s\n", (char *)array->pdata[i]); - } - g_ptr_array_set_free_func(array, g_free); - g_ptr_array_free(array, true); +bool user_creatable_print_help(const char *type, QemuOpts *opts) +{ + if (is_help_option(type)) { + user_creatable_print_types(); return true; } =20 + if (qemu_opt_has_help_opt(opts)) { + return user_creatable_print_type_properites(type); + } + return false; } =20 --=20 2.25.4