object: Add 'help' option to print all available object backend types
PATCH 1/1 object: Add 'help' option to print all available object backend types
--- qemu-options.hx | 5 ++++- qom/object_interfaces.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-)
qemu-options.hx +4 -1
@@ -3752,7 +3752,8 @@ DEF("object", HAS_ARG, QEMU_OPTION_object, " create a new object of type TYPENAME setting properties\n" " in the order they are specified. Note that the 'id'\n" " property must be set. These objects are placed in the\n" - " '/objects' path.\n", + " '/objects' path.\n" + " Use '-object help' to print available backend types.\n", QEMU_ARCH_ALL) STEXI @item -object @var{typename}[,@var{prop1}=@var{value1},...]
@@ -3762,6 +3763,8 @@ in the order they are specified. Note that the 'id' property must be set. These objects are placed in the '/objects' path. +Use '-object help' to print available backend types. + @table @option @item -object memory-backend-file,id=@var{id},size=@var{size},mem-path=@var{dir},share=@var{on|off}
qom/object_interfaces.c +16 -0
@@ -58,6 +58,22 @@ Object *user_creatable_add(const QDict *qdict, goto out_visit; } +if (!strcmp (type,"help" )) { +printf ("Available object backend types:\n" ); +GSList *list =object_class_get_list (TYPE_USER_CREATABLE , false); +while (list) { +const char *name; + name =object_class_get_name (OBJECT_CLASS (list->data)); +/* Ignore user-creatable. */ +if (strcmp (name,TYPE_USER_CREATABLE )) { +printf ("%s\n" , name); + } + list = list->next; + } +g_slist_free (list); +exit (0 ); + } +qdict_del (pdict,"id" );visit_type_str (v,"id" , &id, &local_err);if (local_err) {
Signature · 1 line
2.9.2
Quoted 34 lines · Lin Ma
Signed-off-by Lin Ma <[email protected]>--- qemu-options.hx | 5 ++++- qom/object_interfaces.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-)qemu-options.hx +4
-1@@ -3752,7 +3752,8 @@ DEF("object", HAS_ARG, QEMU_OPTION_object, " create a new object of type TYPENAME setting properties\n" " in the order they are specified. Note that the 'id'\n" " property must be set. These objects are placed in the\n" - " '/objects' path.\n", + " '/objects' path.\n" + " Use '-object help' to print available backend types.\n", QEMU_ARCH_ALL) STEXI @item -object @var{typename}[,@var{prop1}=@var{value1},...]@@ -3762,6 +3763,8 @@ in the order they are specified. Note that the 'id' property must be set. These objects are placed in the '/objects' path. +Use '-object help' to print available backend types. + @table @option @item -object memory-backend-file,id=@var{id},size=@var{size},mem-path=@var{dir},share=@var{on|off}qom/object_interfaces.c +0
-0
qom/object_interfaces.c Object *user_creatable_add(const QDict *qdict, · line 61
Quoted 4 lines
qom/object_interfaces.c +1
-0@@ -58,6 +58,22 @@ Object *user_creatable_add(const QDict *qdict, goto out_visit; } +if (!strcmp (type,"help" )) {
Please use is_help_option().
Quoted 18 lines
qom/object_interfaces.c +15
-0+printf ("Available object backend types:\n" ); +GSList *list =object_class_get_list (TYPE_USER_CREATABLE , false); +while (list) { +const char *name; + name =object_class_get_name (OBJECT_CLASS (list->data)); +/* Ignore user-creatable. */ +if (strcmp (name,TYPE_USER_CREATABLE )) { +printf ("%s\n" , name); + } + list = list->next; + } +g_slist_free (list); +exit (0 ); + } +qdict_del (pdict,"id" );visit_type_str (v,"id" , &id, &local_err);if (local_err) {
Quoted 42 lines
Quoted 3 lines
Quoted 3 lines
Markus Armbruster <[email protected]> 2016/8/17 星期三 下午 2:48 >>>
Quoted 37 lines · Lin Ma
Signed-off-by Lin Ma <[email protected]>--- qemu-options.hx | 5 ++++- qom/object_interfaces.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-)qemu-options.hx +4
-1@@ -3752,7 +3752,8 @@ DEF("object", HAS_ARG, QEMU_OPTION_object, " create a new object of type TYPENAME setting properties\n" " in the order they are specified. Note that the 'id'\n" " property must be set. These objects are placed in the\n" - " '/objects' path.\n", + " '/objects' path.\n" + " Use '-object help' to print available backend types.\n", QEMU_ARCH_ALL) STEXI @item -object @var{typename}[,@var{prop1}=@var{value1},...]@@ -3762,6 +3763,8 @@ in the order they are specified. Note that the 'id' property must be set. These objects are placed in the '/objects' path. +Use '-object help' to print available backend types. + @table @option @item -object memory-backend-file,id=@var{id},size=@var{size},mem-path=@var{dir},share=@var{on|off}qom/object_interfaces.c +0
-0@@ -58,6 +58,22 @@ Object *user_creatable_add(const QDict *qdict, goto out_visit; }
Quoted 3 lines
qom/object_interfaces.c Object *user_creatable_add(const QDict *qdict, · line 61
Quoted 1 line
qom/object_interfaces.c +1
-0+if (!strcmp (type,"help" )) {Please use
is_help_option().
ok, will do it.
btw, Should I add the behaviour like -device argument T,help to show additional help for type T ?
Quoted 18 lines
Quoted 18 lines
qom/object_interfaces.c +15
-0+printf ("Available object backend types:\n" ); +GSList *list =object_class_get_list (TYPE_USER_CREATABLE , false); +while (list) { +const char *name; + name =object_class_get_name (OBJECT_CLASS (list->data)); +/* Ignore user-creatable. */ +if (strcmp (name,TYPE_USER_CREATABLE )) { +printf ("%s\n" , name); + } + list = list->next; + } +g_slist_free (list); +exit (0 ); + } +qdict_del (pdict,"id" );visit_type_str (v,"id" , &id, &local_err);if (local_err) {
Am 18.08.2016 um 11:57 schrieb Lin Ma:
Quoted 46 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Markus Armbruster <[email protected]> 2016/8/17 星期三 下午 2:48 >>>
Quoted 6 lines · Lin Ma
Signed-off-by Lin Ma <[email protected]>--- qemu-options.hx | 5 ++++- qom/object_interfaces.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-)Quoted 6 lines
qemu-options.hx DEF("object", HAS_ARG, QEMU_OPTION_object, · line 3752
Quoted 6 lines
qemu-options.hx +0
-0@@ -3752,7 +3752,8 @@ DEF("object", HAS_ARG, QEMU_OPTION_object, " create a new object of type TYPENAME settingproperties\n"
Quoted 1 line
qemu-options.hx DEF("object", HAS_ARG, QEMU_OPTION_object, · line 3753
Quoted 1 line
qemu-options.hx +0
-0" in the order they are specified. Note that the'id'\n"
Quoted 1 line
qemu-options.hx DEF("object", HAS_ARG, QEMU_OPTION_object, · line 3754
Quoted 1 line
qemu-options.hx +0
-0" property must be set. These objects are placedin the\n"
Quoted 3 lines
qemu-options.hx DEF("object", HAS_ARG, QEMU_OPTION_object,
Quoted 3 lines
qemu-options.hx +2
-1- " '/objects' path.\n", + " '/objects' path.\n" + " Use '-object help' to print available backendtypes.\n",
Quoted 4 lines
qemu-options.hx in the order they are specified. Note that the
Quoted 4 lines
qemu-options.hx +0
-0QEMU_ARCH_ALL) STEXI @item -object @var{typename}[,@var{prop1}=@var{value1},...]@@ -3762,6 +3763,8 @@ in the order they are specified. Note that the'id'
Quoted 8 lines
qemu-options.hx in the order they are specified. Note that the 'id'
Quoted 8 lines
qemu-options.hx +2
-0property must be set. These objects are placed in the '/objects' path. +Use '-object help' to print available backend types. + @table @option @item -objectmemory-backend-file,id=@var{id},size=@var{size},mem-path=@var{dir},share=@var{on|off}
Quoted 8 lines
Quoted 8 lines
qom/object_interfaces.c +0
-0@@ -58,6 +58,22 @@ Object *user_creatable_add(const QDict *qdict, goto out_visit; }
Quoted 4 lines
Quoted 3 lines
qom/object_interfaces.c Object *user_creatable_add(const QDict *qdict, · line 61
Quoted 1 line
qom/object_interfaces.c +1
-0+if (!strcmp (type,"help" )) {Please use
is_help_option().ok, will do it.
Thanks, otherwise looks good to me. However, I am not really the maintainer of object_interfaces.c, please check the git log and also CC Stefan/Paolo or whomever it was for review.
Quoted 2 lines
btw, Should I add the behaviour like -device argument T,help to show additional help for type T ?
Not necessarily in this patch, could be done as follow-up.
Cheers,
Andreas
Quoted 19 lines
Quoted 2 lines
qom/object_interfaces.c Object *user_creatable_add(const QDict *qdict, · line 63
Quoted 2 lines
qom/object_interfaces.c +2
-0+printf ("Available object backend types:\n" ); + GSList *list = object_class_get_list(TYPE_USER_CREATABLE,false);
Quoted 16 lines
Quoted 16 lines
qom/object_interfaces.c +13
-0+while (list) { +const char *name; + name =object_class_get_name (OBJECT_CLASS (list->data)); +/* Ignore user-creatable. */ +if (strcmp (name,TYPE_USER_CREATABLE )) { +printf ("%s\n" , name); + } + list = list->next; + } +g_slist_free (list); +exit (0 ); + } +qdict_del (pdict,"id" );visit_type_str (v,"id" , &id, &local_err);if (local_err) {
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg)