From nobody Wed Nov 5 18:41:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536247119468130.32993121705692; Thu, 6 Sep 2018 08:18:39 -0700 (PDT) Received: from localhost ([::1]:34178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxw3K-0004L5-8U for importer@patchew.org; Thu, 06 Sep 2018 11:18:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxvyK-0000cF-DN for qemu-devel@nongnu.org; Thu, 06 Sep 2018 11:13:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fxvyG-0002GI-EX for qemu-devel@nongnu.org; Thu, 06 Sep 2018 11:13:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46230 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fxvyG-0002Ex-7m for qemu-devel@nongnu.org; Thu, 06 Sep 2018 11:13:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1A468010FDF; Thu, 6 Sep 2018 15:13:23 +0000 (UTC) Received: from localhost (ovpn-112-18.ams2.redhat.com [10.36.112.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E883621B9; Thu, 6 Sep 2018 15:13:20 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Thu, 6 Sep 2018 19:12:27 +0400 Message-Id: <20180906151227.25514-11-marcandre.lureau@redhat.com> In-Reply-To: <20180906151227.25514-1-marcandre.lureau@redhat.com> References: <20180906151227.25514-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 06 Sep 2018 15:13:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 06 Sep 2018 15:13:23 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 10/10] vl: list user creatable propeties if '?' as argument X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Igor Mammedov , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Iterate over the writable class properties, sort and print them out with the description if available. Ex: qemu -object memory-backend-memfd,? memory-backend-memfd.dump=3Dbool (Set to 'off' to exclude from core dump) memory-backend-memfd.host-nodes=3Dint (Binds memory to the list of NUMA hos= t nodes) memory-backend-memfd.hugetlb=3Dbool (Use huge pages) memory-backend-memfd.hugetlbsize=3Dint (Huge pages size (ex: 2M, 1G)) memory-backend-memfd.merge=3Dbool (Mark memory as mergeable) memory-backend-memfd.policy=3DHostMemPolicy (Set the NUMA policy) memory-backend-memfd.prealloc=3Dbool (Preallocate memory) memory-backend-memfd.seal=3Dbool (Seal growing & shrinking) memory-backend-memfd.share=3Dbool (Mark the memory as private to QEMU or sh= ared) memory-backend-memfd.size=3Dint (Size of the memory region (ex: 500M)) Signed-off-by: Marc-Andr=C3=A9 Lureau --- qom/object_interfaces.c | 6 +++--- vl.c | 45 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 72b97a8bed..941fd63afd 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -141,14 +141,14 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error= **errp) =20 int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **= errp) { - bool (*type_predicate)(const char *) =3D opaque; + bool (*type_opt_predicate)(const char *, QemuOpts *) =3D opaque; Object *obj =3D NULL; Error *err =3D NULL; const char *type; =20 type =3D qemu_opt_get(opts, "qom-type"); - if (type && type_predicate && - !type_predicate(type)) { + if (type && type_opt_predicate && + !type_opt_predicate(type, opts)) { return 0; } =20 diff --git a/vl.c b/vl.c index 8a5fd0c81f..75c2bd5130 100644 --- a/vl.c +++ b/vl.c @@ -2721,6 +2721,11 @@ static int machine_set_property(void *opaque, return 0; } =20 +static gint +pstrcmp(const char **a, const char **b) +{ + return g_strcmp0(*a, *b); +} =20 /* * Initial object creation happens before all other @@ -2729,8 +2734,10 @@ static int machine_set_property(void *opaque, * cannot be created here, as it depends on the chardev * already existing. */ -static bool object_create_initial(const char *type) +static bool object_create_initial(const char *type, QemuOpts *opts) { + ObjectClass *klass; + if (is_help_option(type)) { GSList *l, *list; =20 @@ -2744,6 +2751,38 @@ static bool object_create_initial(const char *type) exit(0); } =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))) { + GString *str; + + if (!prop->set) { + continue; + } + + str =3D g_string_new(NULL); + g_string_append_printf(str, "%s.%s=3D%s", type, + prop->name, prop->type); + if (prop->description) { + g_string_append_printf(str, " (%s)", prop->description); + } + g_ptr_array_add(array, g_string_free(str, false)); + } + g_ptr_array_sort(array, (GCompareFunc)pstrcmp); + for (i =3D 0; i < array->len; i++) { + error_printf("%s\n", (char *)array->pdata[i]); + } + g_ptr_array_set_free_func(array, g_free); + g_ptr_array_free(array, true); + exit(0); + } + if (g_str_equal(type, "rng-egd") || g_str_has_prefix(type, "pr-manager-")) { return false; @@ -2790,9 +2829,9 @@ static bool object_create_initial(const char *type) * The remainder of object creation happens after the * creation of chardev, fsdev, net clients and device data types. */ -static bool object_create_delayed(const char *type) +static bool object_create_delayed(const char *type, QemuOpts *opts) { - return !object_create_initial(type); + return !object_create_initial(type, opts); } =20 =20 --=20 2.19.0.rc1