chardev hotplug patch series
v2 cover chardev hotplug patch series
Hi,
Next round of chardev hotplug support patches, Updated according to the review comments from Paolo & Eric. Simplified QMP syntax a bit, mostly due to to dropping fd passing support as this can handled via add-fd + magic "/dev/fdset/..." path. Improved documentation.
cheers,
Gerd
Gerd Hoffmann (10):
chardev: add error reporting for qemu_chr_new_from_opts
chardev: fix QemuOpts lifecycle
chardev: reduce chardev ifdef mess a bit
chardev: add qmp hotplug commands, with null chardev support
chardev: add hmp hotplug commands
chardev: add file chardev support to chardev-add (qmp)
chardev: add serial chardev support to chardev-add (qmp)
chardev: add parallel chardev support to chardev-add (qmp)
chardev: add socket chardev support to chardev-add (qmp)
chardev: add pty chardev support to chardev-add (qmp)
hmp-commands.hx | 32 ++++ hmp.c | 23 +++ hmp.h | 2 + include/char/char.h | 4 +- qapi-schema.json | 89 ++++++++++ qemu-char.c | 454 +++++++++++++++++++++++++++++++++++++++------------ qemu-options.hx | 14 +- qmp-commands.hx | 61 +++++++ vl.c | 9 +- 9 files changed, 575 insertions(+), 113 deletions(-)
PATCH v2 1/10 chardev: add error reporting for qemu_chr_new_from_opts
--- include/char/char.h | 3 ++- qemu-char.c | 24 +++++++++++++++--------- vl.c | 9 ++++++--- 3 files changed, 23 insertions(+), 13 deletions(-)
include/char/char.h +2 -1
@@ -89,7 +89,8 @@ struct CharDriverState {* Returns: a new character backend */ CharDriverState *qemu_chr_new_from_opts (QemuOpts *opts, -void (*init)(struct CharDriverState *s)); +void (*init)(struct CharDriverState *s), +Error **errp);/** * @qemu_chr_new:
qemu-char.c +15 -9
@@ -2779,19 +2779,20 @@ static const struct { };CharDriverState *qemu_chr_new_from_opts (QemuOpts *opts, -void (*init)(struct CharDriverState *s)) +void (*init)(struct CharDriverState *s), +Error **errp) {CharDriverState *chr;int i;if (qemu_opts_id (opts) ==NULL ) { -fprintf (stderr,"chardev: no id specified\n" ); +error_setg (errp,"chardev: no id specified\n" );return NULL ; }if (qemu_opt_get (opts,"backend" ) ==NULL ) { -fprintf (stderr,"chardev: \"%s\" missing backend\n" , -qemu_opts_id (opts)); +error_setg (errp,"chardev: \"%s\" missing backend\n" , +qemu_opts_id (opts));return NULL ; }for (i =0 ; i <ARRAY_SIZE (backend_table); i++) {
@@ -2799,15 +2800,15 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,break ; }if (i ==ARRAY_SIZE (backend_table)) { -fprintf (stderr,"chardev: backend \"%s\" not found\n" , -qemu_opt_get (opts,"backend" )); +error_setg (errp,"chardev: backend \"%s\" not found\n" , +qemu_opt_get (opts,"backend" ));return NULL ; } chr = backend_table[i].open (opts);if (!chr) { -fprintf (stderr,"chardev: opening backend \"%s\" failed\n" , -qemu_opt_get (opts,"backend" )); +error_setg (errp,"chardev: opening backend \"%s\" failed\n" , +qemu_opt_get (opts,"backend" ));return NULL ; }
@@ -2837,6 +2838,7 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*inconst char *p;CharDriverState *chr;QemuOpts *opts; +Error *err =NULL ;if (strstart (filename,"chardev:" , &p)) {return qemu_chr_find (p);
@@ -2846,7 +2848,11 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*inif (!opts)return NULL ; - chr =qemu_chr_new_from_opts (opts, init); + chr =qemu_chr_new_from_opts (opts, init, &err); +if (error_is_set (&err)) { +fprintf (stderr,"%s\n" ,error_get_pretty (err)); +error_free (err); + }if (chr &&qemu_opt_get_bool (opts,"mux" ,0 )) {monitor_init (chr,MONITOR_USE_READLINE ); }
vl.c +6 -3
@@ -2052,11 +2052,14 @@ static int device_init_func(QemuOpts *opts, void *opaque)static int chardev_init_func (QemuOpts *opts,void *opaque) { -CharDriverState *chr; +Error *local_err =NULL ; - chr =qemu_chr_new_from_opts (opts,NULL ); -if (!chr) +qemu_chr_new_from_opts (opts,NULL , &local_err); +if (error_is_set (&local_err)) { +fprintf (stderr,"%s\n" ,error_get_pretty (local_err)); +error_free (local_err);return -1 ; + }return 0 ; }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 01/10] chardev: add error reporting for qemu_chr_new_from_opts
Quoted 6 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>--- include/char/char.h | 3 ++- qemu-char.c | 24 +++++++++++++++--------- vl.c | 9 ++++++--- 3 files changed, 23 insertions(+), 13 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v2 2/10 chardev: fix QemuOpts lifecycle
In reply to Gerd Hoffmannqemu_chr_new_from_opts handles QemuOpts release now, so callers don't have to worry. It will either be saved in CharDriverState, then released in qemu_chr_delete, or in the error case released instantly.
--- include/char/char.h | 1 + qemu-char.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-)
include/char/char.h +1 -0
@@ -75,6 +75,7 @@ struct CharDriverState {char *filename;int opened;int avail_connections; +QemuOpts *opts;QTAILQ_ENTRY (CharDriverState) next; };
qemu-char.c +14 -6
@@ -2787,13 +2787,13 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,if (qemu_opts_id (opts) ==NULL ) {error_setg (errp,"chardev: no id specified\n" ); -return NULL ; + goto err; }if (qemu_opt_get (opts,"backend" ) ==NULL ) {error_setg (errp,"chardev: \"%s\" missing backend\n" ,qemu_opts_id (opts)); -return NULL ; + goto err; }for (i =0 ; i <ARRAY_SIZE (backend_table); i++) {if (strcmp (backend_table[i].name,qemu_opt_get (opts,"backend" )) ==0 )
@@ -2802,14 +2802,14 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,if (i ==ARRAY_SIZE (backend_table)) {error_setg (errp,"chardev: backend \"%s\" not found\n" ,qemu_opt_get (opts,"backend" )); -return NULL ; + goto err; } chr = backend_table[i].open (opts);if (!chr) {error_setg (errp,"chardev: opening backend \"%s\" failed\n" ,qemu_opt_get (opts,"backend" )); -return NULL ; + goto err; }if (!chr->filename)
@@ -2830,7 +2830,12 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, chr->avail_connections =1 ; } chr->label =g_strdup (qemu_opts_id (opts)); + chr->opts = opts;return chr; + +err: +qemu_opts_del (opts); +return NULL ; }CharDriverState *qemu_chr_new (const char *label,const char *filename,void (*init)(struct CharDriverState *s))
@@ -2856,7 +2861,6 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*inif (chr &&qemu_opt_get_bool (opts,"mux" ,0 )) {monitor_init (chr,MONITOR_USE_READLINE ); } -qemu_opts_del (opts);return chr; }
@@ -2884,10 +2888,14 @@ void qemu_chr_fe_close(struct CharDriverState *chr)void qemu_chr_delete (CharDriverState *chr) {QTAILQ_REMOVE (&chardevs, chr, next); -if (chr->chr_close) +if (chr->chr_close) { chr->chr_close (chr); + }g_free (chr->filename);g_free (chr->label); +if (chr->opts) { +qemu_opts_del (chr->opts); + }g_free (chr); }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 02/10] chardev: fix QemuOpts lifecycle
Quoted 9 lines · Gerd Hoffmann
qemu_chr_new_from_optshandles QemuOpts release now, so callers don't have to worry. It will either be saved in CharDriverState, then released inqemu_chr_delete, or in the error case released instantly.Signed-off-by Gerd Hoffmann <[email protected]>--- include/char/char.h | 1 + qemu-char.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v2 3/10 chardev: reduce chardev ifdef mess a bit
In reply to Gerd Hoffmann--- qemu-char.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-)
qemu-char.c +11 -11
@@ -856,6 +856,8 @@ static void cfmakeraw (struct termios *termios_p) ||defined (__NetBSD__) ||defined (__OpenBSD__) ||defined (__DragonFly__) \ || defined(__GLIBC__) +#define HAVE_CHARDEV_TTY 1 + typedef struct { int fd; int connected;
@@ -1244,14 +1246,12 @@ static CharDriverState *qemu_chr_open_tty(QemuOpts *opts) chr->chr_close = qemu_chr_close_tty;return chr; } -#else /* ! __linux__ && ! __sun__ */ -static CharDriverState *qemu_chr_open_pty (QemuOpts *opts) -{ -return NULL ; -}#endif /* __linux__ || __sun__ */ #if defined(__linux__) + +#define HAVE_CHARDEV_PARPORT 1 + typedef struct { int fd; int mode;
@@ -1395,6 +1395,9 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts)#endif /* __linux__ */ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + +#define HAVE_CHARDEV_PARPORT 1 +static int pp_ioctl (CharDriverState *chr,int cmd,void *arg) {int fd = (int )(intptr_t )chr->opaque;
@@ -2755,19 +2758,16 @@ static const struct { #else { .name = "file", .open = qemu_chr_open_file_out }, { .name = "pipe", .open = qemu_chr_open_pipe }, - { .name = "pty", .open = qemu_chr_open_pty }, { .name = "stdio", .open = qemu_chr_open_stdio }, #endif #ifdef CONFIG_BRLAPI { .name = "braille", .open = chr_baum_init }, #endif -#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ - || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \ - || defined(__FreeBSD_kernel__) +#ifdef HAVE_CHARDEV_TTY { .name = "tty", .open = qemu_chr_open_tty }, + { .name = "pty", .open = qemu_chr_open_pty }, #endif -#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) \ - || defined(__FreeBSD_kernel__) +#ifdef HAVE_CHARDEV_PARPORT { .name = "parport", .open = qemu_chr_open_pp }, #endif #ifdef CONFIG_SPICE
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 03/10] chardev: reduce chardev ifdef mess a bit
Quoted 4 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>--- qemu-char.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v2 4/10 chardev: add qmp hotplug commands, with null chardev support
In reply to Gerd HoffmannAdd chardev-add and chardev-remove qmp commands. Hotplugging a null chardev is supported for now, more will be added later.
--- qapi-schema.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ qemu-char.c | 42 ++++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 0 deletions(-)
qapi-schema.json +49 -0
@@ -3017,3 +3017,52 @@ # Since: 1.3.0 ## { 'command': 'nbd-server-stop' } + +## +# @ChardevBackend: +# +# Configuration info for the new chardev backend. +# +# Since: 1.4 +## +{ 'type': 'ChardevDummy', 'data': { } } + +{ 'union': 'ChardevBackend', 'data': { 'null' : 'ChardevDummy' } } + +## +# @ChardevReturn: +# +# Return infos about the chardev backend just created. +# +# Since: 1.4 +## +{ 'type' : 'ChardevReturn', 'data': { } } + +## +# @chardev-add: +# +# Add a file chardev +# +# @id: the chardev's ID, must be unique +# @backend: backend type and parameters +# +# Returns: chardev info. +# +# Since: 1.4 +## +{ 'command': 'chardev-add', 'data': {'id' : 'str', + 'backend' : 'ChardevBackend' }, + 'returns': 'ChardevReturn' } + +## +# @chardev-remove: +# +# Remove a chardev +# +# @id: the chardev's ID, must exist and not be in use +# +# Returns: Nothing on success +# +# Since: 1.4 +## +{ 'command': 'chardev-remove', 'data': {'id': 'str'} }
qemu-char.c +42 -0
45 lines not on this page · raw message
qmp-commands.hx +50 -0
53 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 04/10] chardev: add qmp hotplug commands, with null chardev support
qapi-schema.json line 3035
Quoted 11 lines · Gerd Hoffmann
Add chardev-add and chardev-remove qmp commands. Hotplugging a null chardev is supported for now, more will be added later.
Signed-off-by Gerd Hoffmann <[email protected]>---
qapi-schema.json +5
-0+ +## +# @ChardevReturn: +# +# Return infos about the chardev backend just created.
s/infos/info/ or maybe s/infos/details/
qemu-char.c CharDriverState *qemu_char_get_next_serial(void) · line 2946
Quoted 6 lines
qemu-char.c +6
-0+ChardevReturn *qmp_chardev_add (const char *id,ChardevBackend *backend, +Error **errp) +{ +ChardevReturn *ret =g_new0 (ChardevReturn,1 ); +CharDriverState *chr =NULL ; +
Should you add:
chr = qemu_chr_find(id);
if (chr) {
error_setg(errp, "Chardev '%s' already exists", id);
return NULL;
}Quoted 8 lines
qemu-char.c +8
-0+switch (backend->kind) { +case CHARDEV_BACKEND_KIND_NULL : + chr =qemu_chr_open_null (NULL ); +break ; +default : +error_setg (errp,"unknown chardev backend (%d)" , backend->kind); +break ; + }
qemu-char.c CharDriverState *qemu_char_get_next_serial(void) · line 2964
Quoted 10 lines
qemu-char.c +10
-0+ +if (chr ==NULL && !error_is_set (errp)) { +error_setg (errp,"Failed to create chardev" ); + } +if (chr) { + chr->label =g_strdup (id); + chr->avail_connections =1 ; +QTAILQ_INSERT_TAIL (&chardevs, chr, next); + } +return ret;
Do you really want to be returning a successful object even when the error is set, or should you start with ret = NULL, and only do the g_new0(ChardevReturn, 1) on success?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v2 5/10 chardev: add hmp hotplug commands
In reply to Gerd HoffmannAdd chardev-add and chardev-remove commands to the human monitor. chardev-add accepts the same syntax as -chardev, chardev-remove expects a chardev id.
--- hmp-commands.hx | 32 ++++++++++++++++++++++++++++++++ hmp.c | 23 +++++++++++++++++++++++ hmp.h | 2 ++ 3 files changed, 57 insertions(+), 0 deletions(-)
hmp-commands.hx +32 -0
@@ -1485,6 +1485,38 @@ passed since 1970, i.e. unix epoch. ETEXI { + .name = "chardev-add", + .args_type = "args:s", + .params = "args", + .help = "add chardev", + .mhandler.cmd = hmp_chardev_add, + }, + +STEXI +@item chardev_add args +@findex chardev_add + +chardev_add accepts the same parameters as the -chardev command line switch. + +ETEXI + + { + .name = "chardev-remove", + .args_type = "id:s", + .params = "id", + .help = "remove chardev", + .mhandler.cmd = hmp_chardev_remove, + }, + +STEXI +@item chardev_remove id +@findex chardev_remove + +Removes the chardev @var{id}. + +ETEXI + + { .name = "info", .args_type = "item:s?", .params = "[subcommand]",
hmp.c +23 -0
@@ -1336,3 +1336,26 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)qmp_nbd_server_stop (&errp);hmp_handle_error (mon, &errp); } + +void hmp_chardev_add (Monitor *mon,const QDict *qdict) +{ +const char *args =qdict_get_str (qdict,"args" ); +Error *err =NULL ; +QemuOpts *opts; + + opts =qemu_opts_parse (qemu_find_opts ("chardev" ), args,1 ); +if (opts ==NULL ) { +error_setg (&err,"Parsing chardev args failed\n" ); + }else { +qemu_chr_new_from_opts (opts,NULL , &err); + } +hmp_handle_error (mon, &err); +} + +void hmp_chardev_remove (Monitor *mon,const QDict *qdict) +{ +Error *local_err =NULL ; + +qmp_chardev_remove (qdict_get_str (qdict,"id" ), &local_err); +hmp_handle_error (mon, &local_err); +}
hmp.h +2 -0
@@ -80,5 +80,7 @@ void hmp_screen_dump(Monitor *mon, const QDict *qdict);void hmp_nbd_server_start (Monitor *mon,const QDict *qdict);void hmp_nbd_server_add (Monitor *mon,const QDict *qdict);void hmp_nbd_server_stop (Monitor *mon,const QDict *qdict); +void hmp_chardev_add (Monitor *mon,const QDict *qdict); +void hmp_chardev_remove (Monitor *mon,const QDict *qdict);#endif
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 05/10] chardev: add hmp hotplug commands
Quoted 11 lines · Gerd Hoffmann
Add chardev-add and chardev-remove commands to the human monitor. chardev-add accepts the same syntax as -chardev, chardev-remove expects a chardev id.
Signed-off-by Gerd Hoffmann <[email protected]>--- hmp-commands.hx | 32 ++++++++++++++++++++++++++++++++ hmp.c | 23 +++++++++++++++++++++++ hmp.h | 2 ++ 3 files changed, 57 insertions(+), 0 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v2 6/10 chardev: add file chardev support to chardev-add (qmp)
In reply to Gerd HoffmannAdd support for file chardevs. Output file is mandatory, input file is optional.
--- qapi-schema.json | 13 ++++++++++- qemu-char.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 8 ++++++- 3 files changed, 80 insertions(+), 2 deletions(-)
qapi-schema.json +12 -1
@@ -3019,6 +3019,16 @@ { 'command': 'nbd-server-stop' } ## +# @ChardevFile: +# +# Configuration info for file chardevs. +# +# Since: 1.4 +## +{ 'type': 'ChardevFile', 'data': { '*in' : 'str', + 'out' : 'str' } } + +## # @ChardevBackend: # # Configuration info for the new chardev backend.
@@ -3027,7 +3037,8 @@ ## { 'type': 'ChardevDummy', 'data': { } } -{ 'union': 'ChardevBackend', 'data': { 'null' : 'ChardevDummy' } } +{ 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', + 'null' : 'ChardevDummy' } } ## # @ChardevReturn:
qemu-char.c +61 -0
73 lines not on this page · raw message
qmp-commands.hx +7 -1
@@ -2672,13 +2672,19 @@ Arguments: - "id": the chardev's ID, must be unique (json-string) - "backend": chardev backend type + parameters -Example: +Examples: -> { "execute" : "chardev-add", "arguments" : { "id" : "foo", "backend" : { "type" : "null", "data" : {} } } } <- { "return": {} } +-> { "execute" : "chardev-add", + "arguments" : { "id" : "bar", + "backend" : { "type" : "file", + "data" : { "out" : "/tmp/bar.log" } } } } +<- { "return": {} } + EQMP {
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 06/10] chardev: add file chardev support to chardev-add (qmp)
Quoted 15 lines · Gerd Hoffmann
Add support for file chardevs. Output file is mandatory, input file is optional.
Signed-off-by Gerd Hoffmann <[email protected]>--- qapi-schema.json | 13 ++++++++++- qemu-char.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 8 ++++++- 3 files changed, 80 insertions(+), 2 deletions(-)qapi-schema.json +0
-0
qapi-schema.json line 3022
Quoted 4 lines
qapi-schema.json +1
-0@@ -3019,6 +3019,16 @@ { 'command': 'nbd-server-stop' } ## +# @ChardevFile:
Should you mention '@in: #optional' and '@out:' in any further detail?
qapi-schema.json line 3029
Quoted 7 lines
qapi-schema.json +7
-0+# +# Configuration info for file chardevs. +# +# Since: 1.4 +## +{ 'type': 'ChardevFile', 'data': { '*in' : 'str', + 'out' : 'str' } }
Hmm; here you document ChardevFile as a separate type, but you didn't document ChardevDummy in patch 4/10.
qapi-schema.json line 3033
Quoted 4 lines
qapi-schema.json +3
-0+#ifdef _WIN32 + +#else /* WIN32 */
Wouldn't this be /* !_WIN32 */?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v2 06/10] chardev: add file chardev support to chardev-add (qmp)
Quoted 4 lines
Quoted 1 line
## +# @ChardevFile:
Should you mention '@in: #optional' and '@out:' in any further detail?
Done.
Quoted 2 lines
Hmm; here you document ChardevFile as a separate type, but you didn't document ChardevDummy in patch 4/10.
As the name says it is just a dummy passed when the backend in question doesn't need any parameters. Therefore it is empty. Does it really need its own documentation stanza?
cheers,
Gerd
PATCH v2 7/10 chardev: add serial chardev support to chardev-add (qmp)
In reply to Gerd HoffmannSimliar to file, except that no separate in/out files are supported because it's pointless for direct device access. Also the special tty ioctl hooks (pass through linespeed settings etc) are activated on Unix.
--- qapi-schema.json | 13 +++++++++++ qemu-char.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++------- qemu-options.hx | 9 +++---- 3 files changed, 71 insertions(+), 13 deletions(-)
qapi-schema.json +13 -0
@@ -3029,6 +3029,18 @@ 'out' : 'str' } } ## +# @ChardevPort: +# +# Configuration info for device chardevs. +# +# Since: 1.4 +## +{ 'enum': 'ChardevPortKind', 'data': [ 'serial' ] } + +{ 'type': 'ChardevPort', 'data': { 'device' : 'str', + 'type' : 'ChardevPortKind'} } + +## # @ChardevBackend: # # Configuration info for the new chardev backend.
@@ -3038,6 +3050,7 @@ { 'type': 'ChardevDummy', 'data': { } } { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', + 'port' : 'ChardevPort', 'null' : 'ChardevDummy' } } ##
qemu-char.c +54 -8
114 lines not on this page · raw message
qemu-options.hx +4 -5
@@ -1742,6 +1742,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, #endif #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) + "-chardev serial,id=id,path=path[,mux=on|off]\n" "-chardev tty,id=id,path=path[,mux=on|off]\n" #endif #if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
@@ -1910,8 +1911,8 @@ take any options. Send traffic from the guest to a serial device on the host. -@option{serial} is -only available on Windows hosts. +On Unix hosts serial will actually accept any tty device, +not only serial lines. @option{path} specifies the name of the serial device to open.
@@ -1937,10 +1938,8 @@ Connect to a local BrlAPI server. @option{braille} does not take any options. @item -chardev tty ,id=@var{id} ,path=@var{path} -Connect to a local tty device. - @option{tty} is only available on Linux, Sun, FreeBSD, NetBSD, OpenBSD and -DragonFlyBSD hosts. +DragonFlyBSD hosts. It is an alias for -serial. @option{path} specifies the path to the tty. @option{path} is required.
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 07/10] chardev: add serial chardev support to chardev-add (qmp)
Quoted 1 line · Gerd Hoffmann
Simliar to file, except that no separate in/out files are supported
s/Simliar/Similar/
Quoted 15 lines
because it's pointless for direct device access. Also the special tty ioctl hooks (pass through linespeed settings etc) are activated on Unix.
Signed-off-by Gerd Hoffmann <[email protected]>--- qapi-schema.json | 13 +++++++++++ qemu-char.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++------- qemu-options.hx | 9 +++---- 3 files changed, 71 insertions(+), 13 deletions(-)qemu-char.c +3
-0+static CharDriverState *qmp_chardev_open_port (ChardevPort *port,Error **errp) +{ +int flags, fd;
qemu-char.c static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp) · line 3031
Quoted 10 lines
qemu-char.c +10
-0+ +switch (port->type) { +#ifdef HAVE_CHARDEV_TTY +case CHARDEV_PORT_KIND_SERIAL : + flags =O_RDWR ; + fd =qmp_chardev_open_file_source (port->device, flags, errp); +if (error_is_set (errp)) { +return NULL ; + } +socket_set_nonblock (fd);
Can this fail? And if so, should you react to failure?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v2 07/10] chardev: add serial chardev support to chardev-add (qmp)
Quoted 5 lines · Eric Blake
Quoted 2 lines · Gerd Hoffmann
Simliar to file, except that no separate in/out files are supported
s/Simliar/Similar/
Fixed.
Quoted 3 lines
Quoted 1 line
+
socket_set_nonblock(fd);Can this fail?
No.
cheers,
Gerd
PATCH v2 8/10 chardev: add parallel chardev support to chardev-add (qmp)
In reply to Gerd HoffmannAlso alias the old parport name to parallel for -chardev.
--- qapi-schema.json | 3 ++- qemu-char.c | 44 ++++++++++++++++++++++++++++---------------- qemu-options.hx | 5 ++++- 3 files changed, 34 insertions(+), 18 deletions(-)
qapi-schema.json +2 -1
@@ -3035,7 +3035,8 @@ # # Since: 1.4 ## -{ 'enum': 'ChardevPortKind', 'data': [ 'serial' ] } +{ 'enum': 'ChardevPortKind', 'data': [ 'serial', + 'parallel' ] } { 'type': 'ChardevPort', 'data': { 'device' : 'str', 'type' : 'ChardevPortKind'} }
qemu-char.c +28 -16
79 lines not on this page · raw message
qemu-options.hx +4 -1
@@ -1746,6 +1746,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, "-chardev tty,id=id,path=path[,mux=on|off]\n" #endif #if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) + "-chardev parallel,id=id,path=path[,mux=on|off]\n" "-chardev parport,id=id,path=path[,mux=on|off]\n" #endif #if defined(CONFIG_SPICE)
@@ -1776,6 +1777,7 @@ Backend is one of: @option{stdio}, @option{braille}, @option{tty}, +@option{parallel}, @option{parport}, @option{spicevmc}. @option{spiceport}.
@@ -1943,9 +1945,10 @@ DragonFlyBSD hosts. It is an alias for -serial. @option{path} specifies the path to the tty. @option{path} is required. +@item -chardev parallel ,id=@var{id} ,path=@var{path} @item -chardev parport ,id=@var{id} ,path=@var{path} -@option{parport} is only available on Linux, FreeBSD and DragonFlyBSD hosts. +@option{parallel} is only available on Linux, FreeBSD and DragonFlyBSD hosts. Connect to a local parallel port.
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 08/10] chardev: add parallel chardev support to chardev-add (qmp)
Quoted 11 lines · Gerd Hoffmann
Also alias the old parport name to parallel for -chardev.
Signed-off-by Gerd Hoffmann <[email protected]>--- qapi-schema.json | 3 ++- qemu-char.c | 44 ++++++++++++++++++++++++++++---------------- qemu-options.hx | 5 ++++- 3 files changed, 34 insertions(+), 18 deletions(-)##
qapi-schema.json line 3042
Quoted 6 lines
qapi-schema.json +2
-1-{ 'enum': 'ChardevPortKind', 'data': [ 'serial' ] } +{ 'enum': 'ChardevPortKind', 'data': [ 'serial', + 'parallel' ] } { 'type': 'ChardevPort', 'data': { 'device' : 'str', 'type' : 'ChardevPortKind'} }
In patch 7, should the enum and type have separate documentation?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v2 08/10] chardev: add parallel chardev support to chardev-add (qmp)
Quoted 9 lines · Eric Blake
Quoted 7 lines · Gerd Hoffmann
Also alias the old parport name to parallel for -chardev.
Signed-off-by Gerd Hoffmann <[email protected]> ---qapi-schema.json | 3 ++-
qemu-char.c| 44
++++++++++++++++++++++++++++---------------- qemu-options.hx | 5 ++++- 3 files changed, 34 insertions(+), 18 deletions(-)
Quoted 8 lines
Quoted 6 lines
## -{ 'enum': 'ChardevPortKind', 'data': [ 'serial' ] } +{ 'enum': 'ChardevPortKind', 'data': [ 'serial', + 'parallel' ] }
{ 'type': 'ChardevPort', 'data': { 'device' : 'str', 'type' :
'ChardevPortKind'} }In patch 7, should the enum and type have separate documentation?
IMHO no, they belong together as ChardevPortKind is only used by ChardevPort.
cheers,
Gerd
PATCH v2 9/10 chardev: add socket chardev support to chardev-add (qmp)
In reply to Gerd Hoffmannqemu_chr_open_socket is splitted into two functions. All initialization after creating the socket file handler is splitted away into the new qemu_chr_open_socket_fd function.
chr->filename doesn't get filled from QemuOpts any more. Qemu gathers the information using getsockname and getnameinfo instead. This way it will also work correctly for file handles passed via file descriptor passing.
Finally qmp_chardev_open_socket() is the actual qmp hotplug implementation which basically just calls socket_listen or socket_connect and the new qemu_chr_open_socket_fd function.
--- qapi-schema.json | 20 ++++++- qemu-char.c | 168 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 131 insertions(+), 57 deletions(-)
qapi-schema.json +17 -3
@@ -3042,6 +3042,19 @@ 'type' : 'ChardevPortKind'} } ## +# @ChardevSocket: +# +# Configuration info for socket chardevs. +# +# Since: 1.4 +## +{ 'type': 'ChardevSocket', 'data': { 'addr' : 'SocketAddress', + '*server' : 'bool', + '*wait' : 'bool', + '*delay' : 'bool', + '*telnet' : 'bool' } } + +## # @ChardevBackend: # # Configuration info for the new chardev backend.
@@ -3050,9 +3063,10 @@ ## { 'type': 'ChardevDummy', 'data': { } } -{ 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', - 'port' : 'ChardevPort', - 'null' : 'ChardevDummy' } } +{ 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', + 'port' : 'ChardevPort', + 'socket' : 'ChardevSocket', + 'null' : 'ChardevDummy' } } ## # @ChardevReturn:
qemu-char.c +114 -54
210 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 09/10] chardev: add socket chardev support to chardev-add (qmp)
Quoted 1 line · Gerd Hoffmann
qemu_chr_open_socketis splitted into two functions. All initialization
s/splitted/split/
Quoted 1 line
after creating the socket file handler is splitted away into the new
and again
Quoted 14 lines
qemu_chr_open_socket_fdfunction.
chr->filenamedoesn't get filled from QemuOpts any more. Qemu gathers the information using getsockname and getnameinfo instead. This way it will also work correctly for file handles passed via file descriptor passing.Finally
qmp_chardev_open_socket()is the actual qmp hotplug implementation which basically just callssocket_listenorsocket_connectand the newqemu_chr_open_socket_fdfunction.Signed-off-by Gerd Hoffmann <[email protected]>---
qapi-schema.json line 3047
Quoted 3 lines
qapi-schema.json +3
-0+# @ChardevSocket: +# +# Configuration info for socket chardevs.
Do you need any further doc details for individual fields?
Quoted 5 lines
qapi-schema.json +5
-0+# +# Since: 1.4 +## +{ 'type': 'ChardevSocket', 'data': { 'addr' : 'SocketAddress', + '*server' : 'bool',
qapi-schema.json
Quoted 10 lines
qapi-schema.json +8
-1+ '*wait' : 'bool', + '*delay' : 'bool', + '*telnet' : 'bool' } } + -static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) +static CharDriverState *qemu_chr_open_socket_fd(int fd, int do_nodelay, + int is_listen, int is_telnet, + int is_waitconnect, + Error **errp)
You didn't pick up on my v1 comment of converting these parameters to bool.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v2 10/10 chardev: add pty chardev support to chardev-add (qmp)
In reply to Gerd HoffmannThe ptsname is returned directly, so there is no need to use query-chardev to figure the pty device path.
--- qapi-schema.json | 3 ++- qemu-char.c | 13 +++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 20 insertions(+), 1 deletions(-)
qapi-schema.json +2 -1
@@ -3066,6 +3066,7 @@ { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', 'port' : 'ChardevPort', 'socket' : 'ChardevSocket', + 'pty' : 'ChardevDummy', 'null' : 'ChardevDummy' } } ##
@@ -3075,7 +3076,7 @@ # # Since: 1.4 ## -{ 'type' : 'ChardevReturn', 'data': { } } +{ 'type' : 'ChardevReturn', 'data': { '*pty' : 'str' } } ## # @chardev-add:
qemu-char.c +13 -0
@@ -3124,6 +3124,19 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend,case CHARDEV_BACKEND_KIND_SOCKET : chr =qmp_chardev_open_socket (backend->socket, errp);break ; +#ifdef HAVE_CHARDEV_TTY +case CHARDEV_BACKEND_KIND_PTY : + { +/* qemu_chr_open_pty sets "path" in opts */ +QemuOpts *opts; + opts =qemu_opts_create_nofail (qemu_find_opts ("chardev" )); + chr =qemu_chr_open_pty (opts); + ret->pty =g_strdup (qemu_opt_get (opts,"path" )); + ret->has_pty = true; +qemu_opts_del (opts); +break ; + } +#endif case CHARDEV_BACKEND_KIND_NULL : chr =qemu_chr_open_null (NULL );break ;
qmp-commands.hx +5 -0
@@ -2685,6 +2685,11 @@ Examples: "data" : { "out" : "/tmp/bar.log" } } } } <- { "return": {} } +-> { "execute" : "chardev-add", + "arguments" : { "id" : "baz", + "backend" : { "type" : "pty", "data" : {} } } } +<- { "return": { "pty" : "/dev/pty/42" } } + EQMP {
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 10/10] chardev: add pty chardev support to chardev-add (qmp)
Quoted 12 lines · Gerd Hoffmann
The ptsname is returned directly, so there is no need to use query-chardev to figure the pty device path.
Signed-off-by Gerd Hoffmann <[email protected]>--- qapi-schema.json | 3 ++- qemu-char.c | 13 +++++++++++++ qmp-commands.hx | 5 +++++ 3 files changed, 20 insertions(+), 1 deletions(-)+++ b/qmp-commands.hx
qmp-commands.hx Examples: · line 2691
Quoted 7 lines
qmp-commands.hx +4
-0@@ -2685,6 +2685,11 @@ Examples: "data" : { "out" : "/tmp/bar.log" } } } } <- { "return": {} } +-> { "execute" : "chardev-add", + "arguments" : { "id" : "baz", + "backend" : { "type" : "pty", "data" : {} } } } +<- { "return": { "pty" : "/dev/pty/42" } }
I like it. The QMP API is looking saner now, although I still pointed out enough questions that you might need a v3.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org