* [Qemu-devel] [PATCH] chardev: Add 'help' option to print all available chardev backend types
@ 2016-08-16 17:13 Lin Ma
2016-08-16 17:25 ` Marc-André Lureau
2016-09-02 10:50 ` [Qemu-devel] " Paolo Bonzini
0 siblings, 2 replies; 7+ messages in thread
From: Lin Ma @ 2016-08-16 17:13 UTC (permalink / raw)
To: pbonzini, qemu-devel
Signed-off-by: Lin Ma <lma@suse.com>
---
qemu-char.c | 21 ++++++++++++++++-----
qemu-options.hx | 3 +++
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/qemu-char.c b/qemu-char.c
index 8a0ab05..8a7aef3 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -39,6 +39,7 @@
#include "io/channel-file.h"
#include "io/channel-tls.h"
#include "sysemu/replay.h"
+#include "qemu/help_option.h"
#include <zlib.h>
@@ -3877,16 +3878,26 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
const char *id = qemu_opts_id(opts);
char *bid = NULL;
- if (id == NULL) {
- error_setg(errp, "chardev: no id specified");
- goto err;
- }
-
if (qemu_opt_get(opts, "backend") == NULL) {
error_setg(errp, "chardev: \"%s\" missing backend",
qemu_opts_id(opts));
goto err;
}
+
+ if (is_help_option(qemu_opt_get(opts, "backend"))) {
+ fprintf(stderr, "Available chardev backend types:\n");
+ for (i = backends; i; i = i->next) {
+ cd = i->data;
+ fprintf(stderr, "%s\n", cd->name);
+ }
+ exit(!is_help_option(qemu_opt_get(opts, "backend")));
+ }
+
+ if (id == NULL) {
+ error_setg(errp, "chardev: no id specified");
+ goto err;
+ }
+
for (i = backends; i; i = i->next) {
cd = i->data;
diff --git a/qemu-options.hx b/qemu-options.hx
index a71aaf8..379f7a5 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2148,6 +2148,7 @@ The general form of a character device option is:
ETEXI
DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
+ "-chardev help\n"
"-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
"-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4][,ipv6][,nodelay][,reconnect=seconds]\n"
" [,server][,nowait][,telnet][,reconnect=seconds][,mux=on|off]\n"
@@ -2213,6 +2214,8 @@ Backend is one of:
@option{spiceport}.
The specific backend will determine the applicable options.
+Use "-chardev help" to print all available chardev backend types.
+
All devices must have an id, which can be any string up to 127 characters long.
It is used to uniquely identify this device in other command line directives.
--
2.9.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] chardev: Add 'help' option to print all available chardev backend types
2016-08-16 17:13 [Qemu-devel] [PATCH] chardev: Add 'help' option to print all available chardev backend types Lin Ma
@ 2016-08-16 17:25 ` Marc-André Lureau
2016-08-17 3:11 ` [Qemu-devel] 答复: " Lin Ma
2016-09-02 10:50 ` [Qemu-devel] " Paolo Bonzini
1 sibling, 1 reply; 7+ messages in thread
From: Marc-André Lureau @ 2016-08-16 17:25 UTC (permalink / raw)
To: Lin Ma, pbonzini, qemu-devel
Hi
On Tue, Aug 16, 2016 at 9:18 PM Lin Ma <lma@suse.com> wrote:
> Signed-off-by: Lin Ma <lma@suse.com>
> ---
> qemu-char.c | 21 ++++++++++++++++-----
> qemu-options.hx | 3 +++
> 2 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index 8a0ab05..8a7aef3 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -39,6 +39,7 @@
> #include "io/channel-file.h"
> #include "io/channel-tls.h"
> #include "sysemu/replay.h"
> +#include "qemu/help_option.h"
>
> #include <zlib.h>
>
> @@ -3877,16 +3878,26 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts
> *opts,
> const char *id = qemu_opts_id(opts);
> char *bid = NULL;
>
> - if (id == NULL) {
> - error_setg(errp, "chardev: no id specified");
> - goto err;
> - }
> -
> if (qemu_opt_get(opts, "backend") == NULL) {
> error_setg(errp, "chardev: \"%s\" missing backend",
> qemu_opts_id(opts));
> goto err;
> }
> +
> + if (is_help_option(qemu_opt_get(opts, "backend"))) {
> + fprintf(stderr, "Available chardev backend types:\n");
> + for (i = backends; i; i = i->next) {
> + cd = i->data;
> + fprintf(stderr, "%s\n", cd->name);
> + }
> + exit(!is_help_option(qemu_opt_get(opts, "backend")));
> + }
> +
> + if (id == NULL) {
> + error_setg(errp, "chardev: no id specified");
> + goto err;
> + }
> +
> for (i = backends; i; i = i->next) {
> cd = i->data;
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index a71aaf8..379f7a5 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2148,6 +2148,7 @@ The general form of a character device option is:
> ETEXI
>
> DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
> + "-chardev help\n"
> "-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
> "-chardev
> socket,id=id[,host=host],port=port[,to=to][,ipv4][,ipv6][,nodelay][,reconnect=seconds]\n"
> "
> [,server][,nowait][,telnet][,reconnect=seconds][,mux=on|off]\n"
> @@ -2213,6 +2214,8 @@ Backend is one of:
> @option{spiceport}.
> The specific backend will determine the applicable options.
>
> +Use "-chardev help" to print all available chardev backend types.
> +
>
How different is it from the list in qemu -help ? Why duplicate that list
with less informations (arguments and details) ? Do you expect it to be
easily machine readable?
> All devices must have an id, which can be any string up to 127 characters
> long.
> It is used to uniquely identify this device in other command line
> directives.
>
> --
> 2.9.2
>
>
> --
Marc-André Lureau
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] 答复: Re: [PATCH] chardev: Add 'help' option to print all available chardev backend types
2016-08-16 17:25 ` Marc-André Lureau
@ 2016-08-17 3:11 ` Lin Ma
2016-08-17 6:52 ` Markus Armbruster
0 siblings, 1 reply; 7+ messages in thread
From: Lin Ma @ 2016-08-17 3:11 UTC (permalink / raw)
To: Marc-André Lureau, qemu-devel, pbonzini
>>> Marc-André Lureau <marcandre.lureau@gmail.com> 8/17/2016 1:25 上午 >>>
>Hi
>
>On Tue, Aug 16, 2016 at 9:18 PM Lin Ma <lma@suse.com> wrote:
>
>> Signed-off-by: Lin Ma <lma@suse.com>
>> ---
>> qemu-char.c | 21 ++++++++++++++++-----
>> qemu-options.hx | 3 +++
>> 2 files changed, 19 insertions(+), 5 deletions(-)
>>
>> diff --git a/qemu-char.c b/qemu-char.c
>> index 8a0ab05..8a7aef3 100644
>> --- a/qemu-char.c
>> +++ b/qemu-char.c
>> @@ -39,6 +39,7 @@
>> #include "io/channel-file.h"
>> #include "io/channel-tls.h"
>> #include "sysemu/replay.h"
>> +#include "qemu/help_option.h"
>>
>> #include <zlib.h>
>>
>> @@ -3877,16 +3878,26 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts
>> *opts,
>> const char *id = qemu_opts_id(opts);
>> char *bid = NULL;
>>
>> - if (id == NULL) {
>> - error_setg(errp, "chardev: no id specified");
>> - goto err;
>> - }
>> -
>> if (qemu_opt_get(opts, "backend") == NULL) {
>> error_setg(errp, "chardev: \"%s\" missing backend",
>> qemu_opts_id(opts));
>> goto err;
>> }
>> +
>> + if (is_help_option(qemu_opt_get(opts, "backend"))) {
>> + fprintf(stderr, "Available chardev backend types:\n");
>> + for (i = backends; i; i = i->next) {
>> + cd = i->data;
>> + fprintf(stderr, "%s\n", cd->name);
>> + }
>> + exit(!is_help_option(qemu_opt_get(opts, "backend")));
>> + }
>> +
>> + if (id == NULL) {
>> + error_setg(errp, "chardev: no id specified");
>> + goto err;
>> + }
>> +
>> for (i = backends; i; i = i->next) {
>> cd = i->data;
>>
>> diff --git a/qemu-options.hx b/qemu-options.hx
>> index a71aaf8..379f7a5 100644
>> --- a/qemu-options.hx
>> +++ b/qemu-options.hx
>> @@ -2148,6 +2148,7 @@ The general form of a character device option is:
>> ETEXI
>>
>> DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
>> + "-chardev help\n"
>> "-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
>> "-chardev
>> socket,id=id[,host=host],port=port[,to=to][,ipv4][,ipv6][,nodelay][,reconnect=seconds]\n"
>> "
>> [,server][,nowait][,telnet][,reconnect=seconds][,mux=on|off]\n"
>> @@ -2213,6 +2214,8 @@ Backend is one of:
>> @option{spiceport}.
>> The specific backend will determine the applicable options.
>>
>> +Use "-chardev help" to print all available chardev backend types.
>> +
>>
>
>How different is it from the list in qemu -help ? Why duplicate that list
>with less informations (arguments and details) ? Do you expect it to be
>easily machine readable?
>
No special reason, Just add 'help' option to make it more friendly, like the
output of '-watchdog help' or '-tpmdev help', Sometimes I forget the chardev
backend names which I want to try, I'd like to have a very easy&fast way to
get the backend list :-).
Various backends have various arguments, Printing all of them causes the
complex output, that was my thought before I send the patch.
Now...yes, it makes sense that including the arguments in output, I can add
them if the patch's idea is acceptable.
Lin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] 答复: Re: [PATCH] chardev: Add 'help' option to print all available chardev backend types
2016-08-17 3:11 ` [Qemu-devel] 答复: " Lin Ma
@ 2016-08-17 6:52 ` Markus Armbruster
2016-08-25 6:08 ` Lin Ma
0 siblings, 1 reply; 7+ messages in thread
From: Markus Armbruster @ 2016-08-17 6:52 UTC (permalink / raw)
To: Lin Ma; +Cc: Marc-André Lureau, qemu-devel, pbonzini
"Lin Ma" <lma@suse.com> writes:
>>>> Marc-André Lureau <marcandre.lureau@gmail.com> 8/17/2016 1:25 上午 >>>
[...]
>>How different is it from the list in qemu -help ? Why duplicate that list
>>with less informations (arguments and details) ? Do you expect it to be
>>easily machine readable?
>>
> No special reason, Just add 'help' option to make it more friendly, like the
> output of '-watchdog help' or '-tpmdev help', Sometimes I forget the chardev
> backend names which I want to try, I'd like to have a very easy&fast way to
> get the backend list :-).
>
> Various backends have various arguments, Printing all of them causes the
> complex output, that was my thought before I send the patch.
> Now...yes, it makes sense that including the arguments in output, I can add
> them if the patch's idea is acceptable.
You could do it like -device / device_add: argument help lists types,
and argument T,help shows additional help for type T.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] 答复: Re: [PATCH] chardev: Add 'help' option to print all available chardev backend types
2016-08-17 6:52 ` Markus Armbruster
@ 2016-08-25 6:08 ` Lin Ma
2016-09-02 10:50 ` Paolo Bonzini
0 siblings, 1 reply; 7+ messages in thread
From: Lin Ma @ 2016-08-25 6:08 UTC (permalink / raw)
To: Markus Armbruster; +Cc: marcandre.lureau, qemu-devel, pbonzini
>>> Markus Armbruster <armbru@redhat.com> 2016/8/17 星期三 下午 2:52 >>>
>"Lin Ma" <lma@suse.com> writes:
>
>>>>> Marc-André Lureau <marcandre.lureau@gmail.com> 8/17/2016 1:25 上午 >>>
>[...]
>>>How different is it from the list in qemu -help ? Why duplicate that list
>>>with less informations (arguments and details) ? Do you expect it to be
>>>easily machine readable?
>>>
>> No special reason, Just add 'help' option to make it more friendly, like the
>> output of '-watchdog help' or '-tpmdev help', Sometimes I forget the chardev
>> backend names which I want to try, I'd like to have a very easy&fast way to
>> get the backend list :-).
>>
>> Various backends have various arguments, Printing all of them causes the
>> complex output, that was my thought before I send the patch.
>> Now...yes, it makes sense that including the arguments in output, I can add
>> them if the patch's idea is acceptable.
>
>You could do it like -device / device_add: argument help lists types,
>and argument T,help shows additional help for type T.
Because chardev doesn't have qdev properties, most of chardev options are defined
in qemu_chardev_opts in qemu-char.c, I'd like to hard code the argument output
like these format:
......
vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]
socket,id=id[,host=host],port=host[,to=to][,ipv4][,ipv6][,nodelay]
stdio,id=id[,mux=on|off][,signal=on|off]
......
May I have your thought?
Thanks,
Lin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] 答复: Re: [PATCH] chardev: Add 'help' option to print all available chardev backend types
2016-08-25 6:08 ` Lin Ma
@ 2016-09-02 10:50 ` Paolo Bonzini
0 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2016-09-02 10:50 UTC (permalink / raw)
To: Lin Ma, Markus Armbruster; +Cc: marcandre.lureau, qemu-devel
On 25/08/2016 08:08, Lin Ma wrote:
>
>
>>>> Markus Armbruster <armbru@redhat.com> 2016/8/17 星期三 下午 2:52 >>>
>>"Lin Ma" <lma@suse.com> writes:
>>
>>>>>> Marc-André Lureau <marcandre.lureau@gmail.com> 8/17/2016 1:25 上午 >>>
>>[...]
>>>>How different is it from the list in qemu -help ? Why duplicate that list
>>>>with less informations (arguments and details) ? Do you expect it to be
>>>>easily machine readable?
>>>>
>>> No special reason, Just add 'help' option to make it more friendly,
> like the
>>> output of '-watchdog help' or '-tpmdev help', Sometimes I forget the
> chardev
>>> backend names which I want to try, I'd like to have a very easy&fast
> way to
>>> get the backend list :-).
>>>
>>> Various backends have various arguments, Printing all of them causes the
>>> complex output, that was my thought before I send the patch.
>>> Now...yes, it makes sense that including the arguments in output, I
> can add
>>> them if the patch's idea is acceptable.
>>
>>You could do it like -device / device_add: argument help lists types,
>>and argument T,help shows additional help for type T.
> Because chardev doesn't have qdev properties, most of chardev options
> are defined
> in qemu_chardev_opts in qemu-char.c, I'd like to hard code the argument
> output
> like these format:
> ......
> vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]
> socket,id=id[,host=host],port=host[,to=to][,ipv4][,ipv6][,nodelay]
> stdio,id=id[,mux=on|off][,signal=on|off]
I don't think this is a good idea if you want the output to be
machine-readable. I think a simple "-chardev help" is good because it's
a simple addition and something obvious for users to try.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] chardev: Add 'help' option to print all available chardev backend types
2016-08-16 17:13 [Qemu-devel] [PATCH] chardev: Add 'help' option to print all available chardev backend types Lin Ma
2016-08-16 17:25 ` Marc-André Lureau
@ 2016-09-02 10:50 ` Paolo Bonzini
1 sibling, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2016-09-02 10:50 UTC (permalink / raw)
To: Lin Ma, qemu-devel
On 16/08/2016 19:13, Lin Ma wrote:
> Signed-off-by: Lin Ma <lma@suse.com>
> ---
> qemu-char.c | 21 ++++++++++++++++-----
> qemu-options.hx | 3 +++
> 2 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index 8a0ab05..8a7aef3 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -39,6 +39,7 @@
> #include "io/channel-file.h"
> #include "io/channel-tls.h"
> #include "sysemu/replay.h"
> +#include "qemu/help_option.h"
>
> #include <zlib.h>
>
> @@ -3877,16 +3878,26 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
> const char *id = qemu_opts_id(opts);
> char *bid = NULL;
>
> - if (id == NULL) {
> - error_setg(errp, "chardev: no id specified");
> - goto err;
> - }
> -
> if (qemu_opt_get(opts, "backend") == NULL) {
> error_setg(errp, "chardev: \"%s\" missing backend",
> qemu_opts_id(opts));
> goto err;
> }
> +
> + if (is_help_option(qemu_opt_get(opts, "backend"))) {
> + fprintf(stderr, "Available chardev backend types:\n");
> + for (i = backends; i; i = i->next) {
> + cd = i->data;
> + fprintf(stderr, "%s\n", cd->name);
> + }
> + exit(!is_help_option(qemu_opt_get(opts, "backend")));
> + }
> +
> + if (id == NULL) {
> + error_setg(errp, "chardev: no id specified");
> + goto err;
> + }
> +
> for (i = backends; i; i = i->next) {
> cd = i->data;
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index a71aaf8..379f7a5 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2148,6 +2148,7 @@ The general form of a character device option is:
> ETEXI
>
> DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
> + "-chardev help\n"
> "-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
> "-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4][,ipv6][,nodelay][,reconnect=seconds]\n"
> " [,server][,nowait][,telnet][,reconnect=seconds][,mux=on|off]\n"
> @@ -2213,6 +2214,8 @@ Backend is one of:
> @option{spiceport}.
> The specific backend will determine the applicable options.
>
> +Use "-chardev help" to print all available chardev backend types.
> +
> All devices must have an id, which can be any string up to 127 characters long.
> It is used to uniquely identify this device in other command line directives.
>
>
Queued for 2.8, thanks.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-09-02 10:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-16 17:13 [Qemu-devel] [PATCH] chardev: Add 'help' option to print all available chardev backend types Lin Ma
2016-08-16 17:25 ` Marc-André Lureau
2016-08-17 3:11 ` [Qemu-devel] 答复: " Lin Ma
2016-08-17 6:52 ` Markus Armbruster
2016-08-25 6:08 ` Lin Ma
2016-09-02 10:50 ` Paolo Bonzini
2016-09-02 10:50 ` [Qemu-devel] " Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.