qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-block@nongnu.org
Subject: [PATCH v4 6/7] qom: Add user_creatable_print_help_from_qdict()
Date: Sun, 11 Oct 2020 09:35:04 +0200	[thread overview]
Message-ID: <20201011073505.1185335-7-armbru@redhat.com> (raw)
In-Reply-To: <20201011073505.1185335-1-armbru@redhat.com>

From: Kevin Wolf <kwolf@redhat.com>

This adds a function that, given a QDict of non-help options, prints
help for user creatable objects.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
 include/qom/object_interfaces.h | 21 ++++++++++++++++++---
 qom/object_interfaces.c         |  9 +++++++++
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index f118fb516b..07d5cc8832 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -154,13 +154,28 @@ int user_creatable_add_opts_foreach(void *opaque,
  * @type: the QOM type to be added
  * @opts: options to create
  *
- * Prints help if requested in @opts.
+ * Prints help if requested in @type or @opts. Note that if @type is neither
+ * "help"/"?" nor a valid user creatable type, no help will be printed
+ * regardless of @opts.
  *
- * Returns: true if @opts contained a help option and help was printed, false
- * if no help option was found.
+ * Returns: true if a help option was found and help was printed, false
+ * otherwise.
  */
 bool user_creatable_print_help(const char *type, QemuOpts *opts);
 
+/**
+ * user_creatable_print_help_from_qdict:
+ * @args: options to create
+ *
+ * Prints help considering the other options given in @args (if "qom-type" is
+ * given and valid, print properties for the type, otherwise print valid types)
+ *
+ * In contrast to user_creatable_print_help(), this function can't return that
+ * no help was requested. It should only be called if we know that help is
+ * requested and it will always print some help.
+ */
+void user_creatable_print_help_from_qdict(QDict *args);
+
 /**
  * user_creatable_del:
  * @id: the unique ID for the object
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 3fd1da157e..ed896fe764 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -279,6 +279,15 @@ bool user_creatable_print_help(const char *type, QemuOpts *opts)
     return false;
 }
 
+void user_creatable_print_help_from_qdict(QDict *args)
+{
+    const char *type = qdict_get_try_str(args, "qom-type");
+
+    if (!type || !user_creatable_print_type_properites(type)) {
+        user_creatable_print_types();
+    }
+}
+
 bool user_creatable_del(const char *id, Error **errp)
 {
     Object *container;
-- 
2.26.2



  parent reply	other threads:[~2020-10-11  7:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-11  7:34 [PATCH v4 0/7] qemu-storage-daemon: Remove QemuOpts from --object Markus Armbruster
2020-10-11  7:34 ` [PATCH v4 1/7] keyval: Fix and clarify grammar Markus Armbruster
2020-10-12 11:43   ` Eric Blake
2020-10-19  9:03     ` Markus Armbruster
2020-10-11  7:35 ` [PATCH v4 2/7] test-keyval: Demonstrate misparse of ', ' with implied key Markus Armbruster
2020-10-12 11:44   ` [PATCH v4 2/7] test-keyval: Demonstrate misparse of ',' " Eric Blake
2020-10-11  7:35 ` [PATCH v4 3/7] keyval: Fix parsing of ',' in value of " Markus Armbruster
2020-10-12 11:46   ` [PATCH v4 3/7] keyval: Fix parsing of ', ' " Eric Blake
2020-10-11  7:35 ` [PATCH v4 4/7] keyval: Parse help options Markus Armbruster
2020-10-12 11:51   ` Eric Blake
2020-10-19  9:06     ` Markus Armbruster
2020-10-12 14:35   ` Kevin Wolf
2020-10-19  9:04     ` Markus Armbruster
2020-10-11  7:35 ` [PATCH v4 5/7] qom: Factor out helpers from user_creatable_print_help() Markus Armbruster
2020-10-11  7:35 ` Markus Armbruster [this message]
2020-10-11  7:35 ` [PATCH v4 7/7] qemu-storage-daemon: Remove QemuOpts from --object parser Markus Armbruster
2020-10-12 14:39 ` [PATCH v4 0/7] qemu-storage-daemon: Remove QemuOpts from --object Kevin Wolf
2020-10-19  9:08   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201011073505.1185335-7-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).