@@ -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
@@ -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;