chardev hotplug patch series
cover chardev hotplug patch series
Hi,
Here comes the updated chardev hotplug patch series. Addressed most review comments. It's chardev-add and chardev-remove now. Parameters have been added to the schema. Little nits and spell fixes here and there.
Making 'backend' an enum is tricky given that the actual implementation just turns the qdict into a QemuOpts, then goes piggyback on qemu_chr_new_from_opts().
Not rebased (yet) on top of the qom queue as I expect more discussions.
please review,
Gerd
Gerd Hoffmann (3):
chardev: add error reporting for qemu_chr_new_from_opts
chardev: fix QemuOpts lifecycle
chardev: add hotplug support.
hmp-commands.hx | 32 +++++++++++++++++++++ hmp.c | 23 +++++++++++++++ hmp.h | 2 + qapi-schema.json | 47 ++++++++++++++++++++++++++++++ qemu-char.c | 83 ++++++++++++++++++++++++++++++++++++++++++++--------- qemu-char.h | 5 ++- qmp-commands.hx | 61 +++++++++++++++++++++++++++++++++++++++ vl.c | 8 ++++- 8 files changed, 244 insertions(+), 17 deletions(-)
PATCH 1/3 chardev: add error reporting for qemu_chr_new_from_opts
--- qemu-char.c | 24 +++++++++++++++--------- qemu-char.h | 3 ++- vl.c | 8 ++++++-- 3 files changed, 23 insertions(+), 12 deletions(-)
qemu-char.c +15 -9
@@ -2755,19 +2755,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++) {
@@ -2775,15 +2776,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 ; }
@@ -2813,6 +2814,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);
@@ -2822,7 +2824,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 ); }
qemu-char.h +2 -1
@@ -88,7 +88,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:
vl.c +6 -2
@@ -1940,10 +1940,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) + 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 1/3] chardev: add error reporting for qemu_chr_new_from_opts
Quoted 1 line · On Wed, 17 Oct 2012 12:09:53 +0200 Gerd Hoffmann <[email protected]> wrote:
Signed-off-by Gerd Hoffmann <[email protected]>
Quoted 111 lines
--- qemu-char.c | 24 +++++++++++++++--------- qemu-char.h | 3 ++- vl.c | 8 ++++++-- 3 files changed, 23 insertions(+), 12 deletions(-)qemu-char.c +15
-9@@ -2755,19 +2755,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++) {@@ -2775,15 +2776,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 ; }@@ -2813,6 +2814,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);@@ -2822,7 +2824,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 ); }qemu-char.h +2
-1@@ -88,7 +88,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: vl.c +6
-2@@ -1940,10 +1940,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) + 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 ; }
PATCH 2/3 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.
--- qemu-char.c | 15 ++++++++++----- qemu-char.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-)
qemu-char.c +10 -5
@@ -2763,13 +2763,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 )
@@ -2778,14 +2778,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)
@@ -2806,7 +2806,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))
@@ -2832,7 +2837,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; }
@@ -2864,6 +2868,7 @@ void qemu_chr_delete(CharDriverState *chr) chr->chr_close (chr);g_free (chr->filename);g_free (chr->label); +qemu_opts_del (chr->opts);g_free (chr); }
qemu-char.h +1 -0
@@ -74,6 +74,7 @@ struct CharDriverState {char *filename;int opened;int avail_connections; +QemuOpts *opts;QTAILQ_ENTRY (CharDriverState) next; };
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 2/3] chardev: fix QemuOpts lifecycle
Quoted 69 lines · On Wed, 17 Oct 2012 12:09:54 +0200 Gerd Hoffmann <[email protected]> wrote:
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]>--- qemu-char.c | 15 ++++++++++----- qemu-char.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-)qemu-char.c +9
-5@@ -2763,13 +2763,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 )@@ -2778,14 +2778,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)@@ -2806,7 +2806,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))@@ -2832,7 +2837,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; }
qemu-char.c void qemu_chr_delete(CharDriverState *chr) · line 2873
Quoted 6 lines
qemu-char.c +1
-0@@ -2864,6 +2868,7 @@ void qemu_chr_delete(CharDriverState *chr) chr->chr_close (chr);g_free (chr->filename);g_free (chr->label); +qemu_opts_del (chr->opts);g_free (chr); }
Didn't consider this in my first review, but is chardev_init_func() fine with this? Basically, if we chardev_remove a device created by it (is this possible?) then the opts will be freed but it will remain inserted in its QemuOptsList.
Quoted 13 lines
qemu-char.h +1
-0@@ -74,6 +74,7 @@ struct CharDriverState {char *filename;int opened;int avail_connections; +QemuOpts *opts;QTAILQ_ENTRY (CharDriverState) next; };
Re: [Qemu-devel] [PATCH 2/3] chardev: fix QemuOpts lifecycle
Hi,
Quoted 4 lines
Quoted 4 lines
qemu-char.c +0
-0@@ -2864,6 +2868,7 @@ void qemu_chr_delete(CharDriverState *chr) chr->chr_close (chr);g_free (chr->filename);g_free (chr->label);
Quoted 8 lines
qemu-char.c void qemu_chr_delete(CharDriverState *chr) · line 2873
Quoted 3 lines
qemu-char.c +1
-0+qemu_opts_del (chr->opts);g_free (chr); }Didn't consider this in my first review, but is
chardev_init_func()fine with this? Basically, if wechardev_removea device created by it (is this possible?) then the opts will be freed but it will remain inserted in its QemuOptsList.
Hmm? Don't see your issue here. qemu_opts_del will also unlink from QemuOptsList ...
cheers,
Gerd
Luiz Capitulino
Reviewed-byRe: [Qemu-devel] [PATCH 2/3] chardev: fix QemuOpts lifecycle
Quoted 15 lines · On Thu, 18 Oct 2012 11:26:39 +0200 Gerd Hoffmann <[email protected]> wrote:
Hi,
Quoted 4 lines
Quoted 4 lines
qemu-char.c +0
-0@@ -2864,6 +2868,7 @@ void qemu_chr_delete(CharDriverState *chr) chr->chr_close (chr);g_free (chr->filename);g_free (chr->label);Quoted 8 lines
qemu-char.c void qemu_chr_delete(CharDriverState *chr) · line 2873
Quoted 3 lines
qemu-char.c +1
-0+qemu_opts_del (chr->opts);g_free (chr); }Didn't consider this in my first review, but is
chardev_init_func()fine with this? Basically, if wechardev_removea device created by it (is this possible?) then the opts will be freed but it will remain inserted in its QemuOptsList.
Quoted 2 lines
Hmm? Don't see your issue here.
qemu_opts_delwill also unlink from QemuOptsList ...
Missed that fact, thanks for clarifying:
PATCH 3/3 chardev: add hotplug support.
In reply to Gerd HoffmannThis patch adds chardev_add and chardev_remove monitor commands.
They work similar to the netdev_{add,del} commands. The hmp version of chardev_add accepts like the -chardev command line option does. The qmp version expects the arguments being passed as named parameters.
chardev_del just takes an id argument and zaps the chardev specified.
--- hmp-commands.hx | 32 ++++++++++++++++++++++++++++ hmp.c | 23 ++++++++++++++++++++ hmp.h | 2 + qapi-schema.json | 47 +++++++++++++++++++++++++++++++++++++++++ qemu-char.c | 44 ++++++++++++++++++++++++++++++++++++++ qemu-char.h | 1 + qmp-commands.hx | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 210 insertions(+), 0 deletions(-)
hmp-commands.hx +32 -0
@@ -1404,6 +1404,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
@@ -1209,3 +1209,26 @@ void hmp_screen_dump(Monitor *mon, const QDict *qdict)qmp_screendump (filename, &err);hmp_handle_error (mon, &err); } + +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 *err =NULL ; +qmp_chardev_remove (qdict_get_str (qdict,"id" ), + &err); +hmp_handle_error (mon, &err); +}
hmp.h +2 -0
@@ -75,5 +75,7 @@ void hmp_getfd(Monitor *mon, const QDict *qdict);void hmp_closefd (Monitor *mon,const QDict *qdict);void hmp_send_key (Monitor *mon,const QDict *qdict);void hmp_screen_dump (Monitor *mon,const QDict *qdict); +void hmp_chardev_add (Monitor *mon,const QDict *qdict); +void hmp_chardev_remove (Monitor *mon,const QDict *qdict);#endif
qapi-schema.json +47 -0
50 lines not on this page · raw message
qemu-char.c +44 -0
47 lines not on this page · raw message
qemu-char.h +1 -0
@@ -238,6 +238,7 @@ void qemu_chr_info(Monitor *mon, QObject **ret_data);CharDriverState *qemu_chr_find (const char *name);QemuOpts *qemu_chr_parse_compat (const char *label,const char *filename); +int qmp_chardev_add (Monitor *mon,const QDict *qdict,QObject **ret);/* add an eventfd to the qemu devices that are polled */ CharDriverState *qemu_chr_open_eventfd (int eventfd);
qmp-commands.hx +61 -0
64 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 3/3] chardev: add hotplug support.
Quoted 11 lines · Gerd Hoffmann
This patch adds
chardev_addandchardev_removemonitor commands.They work similar to the netdev_{add,del} commands. The hmp version of
chardev_addaccepts like the -chardev command line option does. The qmp version expects the arguments being passed as named parameters.
chardev_deljust takes an id argument and zaps the chardev specified.Signed-off-by Gerd Hoffmann <[email protected]>---
qapi-schema.json line 2806
Quoted 7 lines
qapi-schema.json +7
-0+## +# @chardev-add: +# +# Add a chardev +# +# @id: the chardev's ID, must be unique +# @backend: the chardev backend: "file", "socket", ...
This still needs to be an enum.
qapi-schema.json line 2815
Quoted 9 lines
qapi-schema.json +9
-0+# @path: file / device / unix socket path +# @name: spice channel name +# @host: host name +# @port: port number +# @server: create socket in server mode +# @wait: wait for connect +# @ipv4: force ipv4-only +# @ipv6: force ipv6-only +# @telnet: telnet negotiation
But this part looks nicer.
Signature · 2 lines
Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 3/3] chardev: add hotplug support.
Il 17/10/2012 17:26, Eric Blake ha scritto:
Quoted 22 lines · Gerd Hoffmann
Quoted 11 lines
This patch adds
chardev_addandchardev_removemonitor commands.They work similar to the netdev_{add,del} commands. The hmp version of
chardev_addaccepts like the -chardev command line option does. The qmp version expects the arguments being passed as named parameters.
chardev_deljust takes an id argument and zaps the chardev specified.Signed-off-by Gerd Hoffmann <[email protected]>---
qapi-schema.json line 2806
Quoted 7 lines
qapi-schema.json +7
-0+## +# @chardev-add: +# +# Add a chardev +# +# @id: the chardev's ID, must be unique +# @backend: the chardev backend: "file", "socket", ...This still needs to be an enum.
Quoted 11 lines
qapi-schema.json line 2815
Quoted 9 lines
qapi-schema.json +9
-0+# @path: file / device / unix socket path +# @name: spice channel name +# @host: host name +# @port: port number +# @server: create socket in server mode +# @wait: wait for connect +# @ipv4: force ipv4-only +# @ipv6: force ipv6-only +# @telnet: telnet negotiationBut this part looks nicer.
Note that this schema is just for documentation. It is not used at QEMU build time.
Paolo
Re: [Qemu-devel] [PATCH 3/3] chardev: add hotplug support.
In reply to Gerd HoffmannQuoted 5 lines · Gerd Hoffmann
This patch adds
chardev_addandchardev_removemonitor commands.They work similar to the netdev_{add,del} commands. The hmp version of
chardev_addaccepts like the -chardev command line option does. The qmp version expects the arguments being passed as named parameters.
Trying another approach, see attached patch. This adds backend-specific qemu commands to add chardevs, with just the parameters needed for the specific backend. Starting with file and tty, both accepting a path. 'file' is nice for testing, 'tty' very useful when hotplugging serial devices on the host. Others can be added as needed. We probably don't need all of them. For example hotplugging the 'stdio' chardev doesn't make much sense.
Advantage #1: Cleaner API.
Advantage #2: No legacy syntax headache when qomifying chardevs.
Comments?
cheers,
Gerd
From 7f80af55530c9a448e4aed5a41c76a8e9514a27c Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Thu, 11 Oct 2012 14:53:00 +0200
Subject: [PATCH] chardev: add hotplug support.
This patch adds chardev_add_file, chardev_add_tty and chardev_remove monitor commands.
chardev_add_file and chardev_add_tty expect an id and a path, they create a file/tty chardev.
chardev_del just takes an id argument and zaps the chardev specified.
--- hmp-commands.hx | 44 +++++++++++++++++++++++++++++++ hmp.c | 29 ++++++++++++++++++++ hmp.h | 3 ++ qapi-schema.json | 43 ++++++++++++++++++++++++++++++ qemu-char.c | 41 +++++++++++++++++++++++++++++ qemu-char.h | 2 + qmp-commands.hx | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 238 insertions(+), 0 deletions(-)
hmp-commands.hx +44 -0
@@ -1404,6 +1404,50 @@ passed since 1970, i.e. unix epoch. ETEXI { + .name = "chardev_add_file", + .args_type = "id:s,path:s", + .params = "id path ", + .help = "add file chardev", + .mhandler.cmd = hmp_chardev_add_file, + }, + +STEXI +@item chardev_add_file id path +@findex chardev_add_file + +ETEXI + + { + .name = "chardev_add_tty", + .args_type = "id:s,path:s", + .params = "id path ", + .help = "add tty chardev", + .mhandler.cmd = hmp_chardev_add_tty, + }, + +STEXI +@item chardev_add_tty id path +@findex chardev_add_tty + +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 +29 -0
@@ -1209,3 +1209,32 @@ void hmp_screen_dump(Monitor *mon, const QDict *qdict)qmp_screendump (filename, &err);hmp_handle_error (mon, &err); } + +static void hmp_chardev_add_path (Monitor *mon,const QDict *qdict, +const char *backend) +{ +const char *id =qdict_get_str (qdict,"args" ); +const char *path =qdict_get_str (qdict,"path" ); +Error *local_err =NULL ; + +qmp_chardev_add_path (id, path, backend, &local_err); +hmp_handle_error (mon, &local_err); +} + +void hmp_chardev_add_file (Monitor *mon,const QDict *qdict) +{ +hmp_chardev_add_path (mon, qdict,"file" ); +} + +void hmp_chardev_add_tty (Monitor *mon,const QDict *qdict) +{ +hmp_chardev_add_path (mon, qdict,"tty" ); +} + +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 +3 -0
@@ -75,5 +75,8 @@ void hmp_getfd(Monitor *mon, const QDict *qdict);void hmp_closefd (Monitor *mon,const QDict *qdict);void hmp_send_key (Monitor *mon,const QDict *qdict);void hmp_screen_dump (Monitor *mon,const QDict *qdict); +void hmp_chardev_add_file (Monitor *mon,const QDict *qdict); +void hmp_chardev_add_tty (Monitor *mon,const QDict *qdict); +void hmp_chardev_remove (Monitor *mon,const QDict *qdict);#endif
qapi-schema.json +43 -0
46 lines not on this page · raw message
qemu-char.c +41 -0
44 lines not on this page · raw message
qemu-char.h +2 -0
@@ -238,6 +238,8 @@ void qemu_chr_info(Monitor *mon, QObject **ret_data);CharDriverState *qemu_chr_find (const char *name);QemuOpts *qemu_chr_parse_compat (const char *label,const char *filename); +void qmp_chardev_add_path (const char *id,const char *path, +const char *backend,Error **errp);/* add an eventfd to the qemu devices that are polled */ CharDriverState *qemu_chr_open_eventfd (int eventfd);
qmp-commands.hx +76 -0
79 lines not on this page · raw message
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH 3/3] chardev: add hotplug support.
Il 18/10/2012 12:03, Gerd Hoffmann ha scritto:
Quoted 10 lines
Trying another approach, see attached patch. This adds backend-specific qemu commands to add chardevs, with just the parameters needed for the specific backend. Starting with file and tty, both accepting a path. 'file' is nice for testing, 'tty' very useful when hotplugging serial devices on the host. Others can be added as needed. We probably don't need all of them. For example hotplugging the 'stdio' chardev doesn't make much sense.
Advantage #1: Cleaner API.
Advantage #2: No legacy syntax headache when qomifying chardevs.
Disadvantage #1: Harder to extend, more code Disadvantage #2: Different from all other kinds of host devices.
I still prefer the other one.
Paolo