qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] qdev: Allow hot-plug for lists with pre-filled descriptors
@ 2011-02-10 10:16 Amit Shah
  2011-02-10 10:16 ` [Qemu-devel] [PATCH 2/2] qdev: Allow chardevs to be hot-plugged Amit Shah
  2011-02-10 11:57 ` [Qemu-devel] [PATCH 1/2] qdev: Allow hot-plug for lists with pre-filled descriptors Markus Armbruster
  0 siblings, 2 replies; 4+ messages in thread
From: Amit Shah @ 2011-02-10 10:16 UTC (permalink / raw)
  To: qemu list; +Cc: Amit Shah, Gerd Hoffmann, Markus Armbruster, Luiz Capitulino

This will be needed for hot-plugging chardevs.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 monitor.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 7fc311d..f3d7ab3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -74,8 +74,6 @@
  * 'O'          option string of the form NAME=VALUE,...
  *              parsed according to QemuOptsList given by its name
  *              Example: 'device:O' uses qemu_device_opts.
- *              Restriction: only lists with empty desc are supported
- *              TODO lift the restriction
  * 'i'          32 bit integer
  * 'l'          target long (32 or 64 bit)
  * 'M'          just like 'l', except in user mode the value is
@@ -4064,7 +4062,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                 QemuOpts *opts;
 
                 opts_list = qemu_find_opts(key);
-                if (!opts_list || opts_list->desc->name) {
+                if (!opts_list) {
                     goto bad_type;
                 }
                 while (qemu_isspace(*p)) {
-- 
1.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH 2/2] qdev: Allow chardevs to be hot-plugged
  2011-02-10 10:16 [Qemu-devel] [PATCH 1/2] qdev: Allow hot-plug for lists with pre-filled descriptors Amit Shah
@ 2011-02-10 10:16 ` Amit Shah
  2011-02-10 11:57 ` [Qemu-devel] [PATCH 1/2] qdev: Allow hot-plug for lists with pre-filled descriptors Markus Armbruster
  1 sibling, 0 replies; 4+ messages in thread
From: Amit Shah @ 2011-02-10 10:16 UTC (permalink / raw)
  To: qemu list; +Cc: Amit Shah, Gerd Hoffmann, Markus Armbruster, Luiz Capitulino

This commit enables chardevs to be hot-plugged to a running qemu
machine.  The syntax is similar to the -chardev command line:

(qemu) chardev_add socket,path=/tmp/foo,server,nowait,id=char0

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hmp-commands.hx |   16 ++++++++++++++++
 hw/qdev.c       |   15 +++++++++++++++
 hw/qdev.h       |    1 +
 qmp-commands.hx |   23 +++++++++++++++++++++++
 4 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 38e1eb7..e0e6fc8 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -554,6 +554,22 @@ command @code{info usb} to see the devices you can remove.
 ETEXI
 
     {
+        .name       = "chardev_add",
+        .args_type  = "chardev:O",
+        .params     = "backend[,prop=value][,...],id=str",
+        .help       = "add chardev, like -chardev on the command line",
+        .user_print = monitor_user_noop,
+        .mhandler.cmd_new = do_chardev_add,
+    },
+
+STEXI
+@item chardev_add @var{config}
+@findex chardev_add
+
+Add chardev.
+ETEXI
+
+    {
         .name       = "device_add",
         .args_type  = "device:O",
         .params     = "driver[,prop=value][,...]",
diff --git a/hw/qdev.c b/hw/qdev.c
index c7fec44..1e24f58 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -861,6 +861,21 @@ void do_info_qdm(Monitor *mon)
     }
 }
 
+int do_chardev_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+    QemuOpts *opts;
+
+    opts = qemu_opts_from_qdict(qemu_find_opts("chardev"), qdict);
+    if (!opts) {
+        return -1;
+    }
+    if (!qemu_chr_open_opts(opts, NULL)) {
+        qemu_opts_del(opts);
+        return -1;
+    }
+    return 0;
+}
+
 int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     QemuOpts *opts;
diff --git a/hw/qdev.h b/hw/qdev.h
index 9808f85..5698713 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -212,6 +212,7 @@ BusState *sysbus_get_default(void);
 
 void do_info_qtree(Monitor *mon);
 void do_info_qdm(Monitor *mon);
+int do_chardev_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
 int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
 int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
 
diff --git a/qmp-commands.hx b/qmp-commands.hx
index df40a3d..255da9a 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -275,6 +275,29 @@ Example:
 EQMP
 
     {
+        .name       = "chardev_add",
+        .args_type  = "device:O",
+        .params     = "backend[,prop=value][,...],id=str",
+        .help       = "add chardev, like -chardev on the command line",
+        .user_print = monitor_user_noop,
+        .mhandler.cmd_new = do_chardev_add,
+    },
+
+SQMP
+chardev_add
+----------
+
+Add a chardev.
+
+Arguments:
+
+- "backend": the backend of the new chardev (json-string)
+- "id": the chardev's ID, must be unique (json-string)
+- chardev properties
+
+EQMP
+
+    {
         .name       = "device_add",
         .args_type  = "device:O",
         .params     = "driver[,prop=value][,...]",
-- 
1.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] qdev: Allow hot-plug for lists with pre-filled descriptors
  2011-02-10 10:16 [Qemu-devel] [PATCH 1/2] qdev: Allow hot-plug for lists with pre-filled descriptors Amit Shah
  2011-02-10 10:16 ` [Qemu-devel] [PATCH 2/2] qdev: Allow chardevs to be hot-plugged Amit Shah
@ 2011-02-10 11:57 ` Markus Armbruster
  2011-02-10 12:08   ` Amit Shah
  1 sibling, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2011-02-10 11:57 UTC (permalink / raw)
  To: Amit Shah; +Cc: Luiz Capitulino, qemu list, Gerd Hoffmann

Amit Shah <amit.shah@redhat.com> writes:

> This will be needed for hot-plugging chardevs.
>
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
>  monitor.c |    4 +---
>  1 files changed, 1 insertions(+), 3 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 7fc311d..f3d7ab3 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -74,8 +74,6 @@
>   * 'O'          option string of the form NAME=VALUE,...
>   *              parsed according to QemuOptsList given by its name
>   *              Example: 'device:O' uses qemu_device_opts.
> - *              Restriction: only lists with empty desc are supported
> - *              TODO lift the restriction
>   * 'i'          32 bit integer
>   * 'l'          target long (32 or 64 bit)
>   * 'M'          just like 'l', except in user mode the value is
> @@ -4064,7 +4062,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
>                  QemuOpts *opts;
>  
>                  opts_list = qemu_find_opts(key);
> -                if (!opts_list || opts_list->desc->name) {
> +                if (!opts_list) {
>                      goto bad_type;
>                  }
>                  while (qemu_isspace(*p)) {

Uh, there's more to do that just kill the check (that's why I put in the
TODO in the first place), but my virus-addled brain can't quite remember
the details right now :(

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] qdev: Allow hot-plug for lists with pre-filled descriptors
  2011-02-10 11:57 ` [Qemu-devel] [PATCH 1/2] qdev: Allow hot-plug for lists with pre-filled descriptors Markus Armbruster
@ 2011-02-10 12:08   ` Amit Shah
  0 siblings, 0 replies; 4+ messages in thread
From: Amit Shah @ 2011-02-10 12:08 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Luiz Capitulino, qemu list, Gerd Hoffmann

On (Thu) 10 Feb 2011 [12:57:30], Markus Armbruster wrote:
> Amit Shah <amit.shah@redhat.com> writes:
> 
> > This will be needed for hot-plugging chardevs.
> >
> > Signed-off-by: Amit Shah <amit.shah@redhat.com>
> > ---
> >  monitor.c |    4 +---
> >  1 files changed, 1 insertions(+), 3 deletions(-)
> >
> > diff --git a/monitor.c b/monitor.c
> > index 7fc311d..f3d7ab3 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -74,8 +74,6 @@
> >   * 'O'          option string of the form NAME=VALUE,...
> >   *              parsed according to QemuOptsList given by its name
> >   *              Example: 'device:O' uses qemu_device_opts.
> > - *              Restriction: only lists with empty desc are supported
> > - *              TODO lift the restriction
> >   * 'i'          32 bit integer
> >   * 'l'          target long (32 or 64 bit)
> >   * 'M'          just like 'l', except in user mode the value is
> > @@ -4064,7 +4062,7 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon,
> >                  QemuOpts *opts;
> >  
> >                  opts_list = qemu_find_opts(key);
> > -                if (!opts_list || opts_list->desc->name) {
> > +                if (!opts_list) {
> >                      goto bad_type;
> >                  }
> >                  while (qemu_isspace(*p)) {
> 
> Uh, there's more to do that just kill the check (that's why I put in the
> TODO in the first place),

I thought so :-)

This did work for me for a few runs, and I really haven't traversed the
depths of qdev so sent it out anyway for comment.

> but my virus-addled brain can't quite remember
> the details right now :(

Wish you a speedy recovery in the meantime!

		Amit

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-10 12:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-10 10:16 [Qemu-devel] [PATCH 1/2] qdev: Allow hot-plug for lists with pre-filled descriptors Amit Shah
2011-02-10 10:16 ` [Qemu-devel] [PATCH 2/2] qdev: Allow chardevs to be hot-plugged Amit Shah
2011-02-10 11:57 ` [Qemu-devel] [PATCH 1/2] qdev: Allow hot-plug for lists with pre-filled descriptors Markus Armbruster
2011-02-10 12:08   ` Amit Shah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).