Skip to contentSkip to conversation

object: Add 'help' option to print all available object backend types

PATCH In review Lin Ma 3 participants 4 messages Aug 16, 2016 – Aug 18, 2016

lore
Share & tools
lore

Lin Ma

author
#0 lore raw

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
index a71aaf8..c5f4a12 100644
@@ -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
index bf59846..8f820a4 100644
@@ -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
#1 lore raw
Quoted 34 lines · Lin Ma
---
 qemu-options.hx         |  5 ++++-
 qom/object_interfaces.c | 16 ++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
qemu-options.hx +4 -1
index a71aaf8..c5f4a12 100644
@@ -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
index bf59846..8f820a4 100644

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) {
author
#2 lore raw
Quoted 42 lines
Quoted 3 lines
Quoted 3 lines

Markus Armbruster <[email protected]> 2016/8/17 星期三 下午 2:48 >>>

Quoted 37 lines · Lin Ma
---
 qemu-options.hx   	  |  5 ++++-
 qom/object_interfaces.c | 16 ++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
qemu-options.hx +4 -1
index a71aaf8..c5f4a12 100644
@@ -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
index bf59846..8f820a4 100644
@@ -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) {
#3 lore raw

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
---
 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
index a71aaf8..c5f4a12 100644
@@ -3752,7 +3752,8 @@ DEF("object", HAS_ARG, QEMU_OPTION_object,
     "                create a new object of type TYPENAME setting

properties\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 placed

in 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 backend

types.\n",

Quoted 4 lines

qemu-options.hx in the order they are specified. Note that the

Quoted 4 lines
qemu-options.hx +0 -0
     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'

Quoted 8 lines

qemu-options.hx in the order they are specified. Note that the 'id'

Quoted 8 lines
qemu-options.hx +2 -0
 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}

Quoted 8 lines
Quoted 8 lines
qom/object_interfaces.c +0 -0
index bf59846..8f820a4 100644
@@ -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)