[09/15] vl: add a new -qmp2 option to expose experimental QMP server

Submitted by Anthony Liguori on March 11, 2011, 11:05 p.m.

Details

Message ID 1299884745-521-10-git-send-email-aliguori@us.ibm.com
State New
Headers show

Commit Message

Anthony Liguori March 11, 2011, 11:05 p.m.
This is temporary until we implement all QMP commands.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Comments

Anthony Liguori March 11, 2011, 11:14 p.m.
On 03/11/2011 05:05 PM, Anthony Liguori wrote:
> This is temporary until we implement all QMP commands.

And just to be clear, they all are already implemented in my QAPI tree.  
Just batching things up for the purposes of reviewing.

Regards,

Anthony Liguori

Patch hide | download patch | download mbox

diff --git a/qemu-options.hx b/qemu-options.hx
index badb730..957d935 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1881,6 +1881,9 @@  serial port).
 The default device is @code{vc} in graphical mode and @code{stdio} in
 non graphical mode.
 ETEXI
+DEF("qmp2", HAS_ARG, QEMU_OPTION_qmp2, \
+    "-qmp2 chardev   experimental QMP server\n",
+    QEMU_ARCH_ALL)
 DEF("qmp", HAS_ARG, QEMU_OPTION_qmp, \
     "-qmp dev        like -monitor but opens in 'control' mode\n",
     QEMU_ARCH_ALL)
diff --git a/vl.c b/vl.c
index d27e750..1d1d536 100644
--- a/vl.c
+++ b/vl.c
@@ -160,6 +160,7 @@  int main(int argc, char **argv)
 #include "qemu-queue.h"
 #include "cpus.h"
 #include "arch_init.h"
+#include "qmp-core.h"
 
 #include "ui/qemu-spice.h"
 
@@ -1915,6 +1916,8 @@  static const QEMUOption *lookup_opt(int argc, char **argv,
     return popt;
 }
 
+#define MAX_QMP_CHARDEVS 16
+
 int main(int argc, char **argv, char **envp)
 {
     const char *gdbstub_dev = NULL;
@@ -1940,6 +1943,8 @@  int main(int argc, char **argv, char **envp)
     int show_vnc_port = 0;
     int defconfig = 1;
     const char *trace_file = NULL;
+    int nb_qmp_chardevs = 0;
+    const char *qmp_chardevs[MAX_QMP_CHARDEVS];
 
     atexit(qemu_run_exit_notifiers);
     error_set_progname(argv[0]);
@@ -2387,6 +2392,13 @@  int main(int argc, char **argv, char **envp)
                 monitor_parse(optarg, "control");
                 default_monitor = 0;
                 break;
+            case QEMU_OPTION_qmp2:
+                if (nb_qmp_chardevs == MAX_QMP_CHARDEVS) {
+                    fprintf(stderr, "-qmp: too many QMP chardevs\n");
+                    exit(1);
+                }
+                qmp_chardevs[nb_qmp_chardevs++] = optarg;
+                break;
             case QEMU_OPTION_mon:
                 opts = qemu_opts_parse(qemu_find_opts("mon"), optarg, 1);
                 if (!opts) {
@@ -3084,6 +3096,15 @@  int main(int argc, char **argv, char **envp)
     }
 #endif
 
+    for (i = 0; i < nb_qmp_chardevs; i++) {
+        CharDriverState *chr = qemu_chr_find(qmp_chardevs[i]);
+        if (chr == NULL) {
+            fprintf(stderr, "-qmp: unknown chardev `%s'\n", qmp_chardevs[i]);
+            exit(1);
+        }
+        qmp_init_chardev(chr);
+    }
+
     /* display setup */
     dpy_resize(ds);
     dcl = ds->listeners;