qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd
@ 2014-08-01  5:26 Benoît Canet
  2014-08-01  5:26 ` [Qemu-devel] [PATCH v1 01/24] qmp: Extract system emulation related code from qmp.c into qmp-system.c Benoît Canet
                   ` (23 more replies)
  0 siblings, 24 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, stefanha, mreitz

Hi,

Here are the follow up patches to the block QAPI extractions patches.
After this patchset the qemu-nbd command has a -qmp parameters allowing the user
to execute block related qmp commands.

Best regards

Benoît

Benoît Canet (24):
  qmp: Extract system emulation related code from qmp.c into
    qmp-system.c
  monitor: Make some function public
  monitor: Extract monitor-system.h header
  monitor: Make monitor_fprintf public before extracting it
  monitor: Extract monitor_fprintf to monitor-system.c
  monitor: Extract qmp_human_monitor_command into monitor-system.c
  monitor: Make some function to extract public
  monitor: Extract a couple of function to monitor-system.c
  monitor: Make do_info_help public
  monitor: Extract do_info_help in monitor-system.c
  monitor: Make some monitor functions public before moving them in
    monitor-system.c
  monitor: Make do_loadvm public before moving it to monitor-system.c
  monitor: Move do_loadvm from monitor.c to monitor-system.c
  monitor: Make commands public before moving them to monitor-system.c
  monitor: Move mon_cmd_t arrays and some function from monitor.c to
    monitor-system.c
  monitor: Move more functions from monitor.c to monitor-system.c
  monitor: Move two net functions from monitor.c to monitor-system.c
  monitor: Move qmp_rtc_reset_reinjection from monitor.c to
    monitor-system.c
  monitor-system: Switch back functions to static
  monitor: Extract hardware dependent completion function from monitor.c
    to monitor-system.c
  monitor: Cleanup monitor.c includes after extracting monitor-system.c
  qemu-nbd: build QAPI block core into qemu-nbd
  qapi: Add a script to filter qmp-commands-old.h to generate a subset
    of it.
  qemu-nbd: Add --qmp option to qemu-nbd.

 Makefile                                    |   40 +-
 Makefile.objs                               |   15 +-
 Makefile.target                             |    1 +
 block/Makefile.objs                         |   11 +-
 include/monitor/monitor-init.h              |   34 +
 include/monitor/monitor-system.h            |   99 +
 include/monitor/monitor.h                   |   10 +
 monitor-init.c                              |  121 +
 monitor-system.c                            | 2806 ++++++++++++++++++++++
 monitor.c                                   | 3467 +++------------------------
 qapi/Makefile.objs                          |    2 +
 qemu-nbd.c                                  |   33 +-
 qmp-system.c                                |  376 +++
 qmp.c                                       |  361 +--
 qobject/Makefile.objs                       |    2 +
 qom/Makefile.objs                           |    8 +-
 scripts/filter_qmp_commands_old.py          |   93 +
 stubs/Makefile.objs                         |   15 +
 stubs/arch-type.c                           |    3 +
 stubs/autostart.c                           |    1 +
 stubs/cpus-list.c                           |    3 +
 stubs/get-double.c                          |    8 +
 stubs/get-expr.c                            |    8 +
 stubs/kvm-allowed.c                         |    3 +
 stubs/kvm-cpu-synchronize-post-init.c       |    5 +
 stubs/kvm-cpu-synchronize-state.c           |    5 +
 stubs/qemu-add-machine-init-done-notifier.c |    5 +
 stubs/qemu-chr-open-msmouse.c               |    7 +
 stubs/runstate-is-running.c                 |    6 +
 stubs/serial-hds.c                          |    3 +
 stubs/vmstate-info-buffer.c                 |    8 +
 stubs/vmstate-info-uint32.c                 |    8 +
 util/Makefile.objs                          |    2 +
 vl.c                                        |   88 +-
 34 files changed, 4058 insertions(+), 3599 deletions(-)
 create mode 100644 include/monitor/monitor-init.h
 create mode 100644 include/monitor/monitor-system.h
 create mode 100644 monitor-init.c
 create mode 100644 monitor-system.c
 create mode 100644 qmp-system.c
 create mode 100755 scripts/filter_qmp_commands_old.py
 create mode 100644 stubs/arch-type.c
 create mode 100644 stubs/autostart.c
 create mode 100644 stubs/cpus-list.c
 create mode 100644 stubs/get-double.c
 create mode 100644 stubs/get-expr.c
 create mode 100644 stubs/kvm-allowed.c
 create mode 100644 stubs/kvm-cpu-synchronize-post-init.c
 create mode 100644 stubs/kvm-cpu-synchronize-state.c
 create mode 100644 stubs/qemu-add-machine-init-done-notifier.c
 create mode 100644 stubs/qemu-chr-open-msmouse.c
 create mode 100644 stubs/runstate-is-running.c
 create mode 100644 stubs/serial-hds.c
 create mode 100644 stubs/vmstate-info-buffer.c
 create mode 100644 stubs/vmstate-info-uint32.c

-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 01/24] qmp: Extract system emulation related code from qmp.c into qmp-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
@ 2014-08-01  5:26 ` Benoît Canet
  2014-08-05 12:40   ` Eric Blake
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 02/24] monitor: Make some function public Benoît Canet
                   ` (22 subsequent siblings)
  23 siblings, 1 reply; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

This patch will allow to link qmp.o with utility binaries without dragging too
much unrelated object files and externals dependencies.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 Makefile.objs |   2 +-
 qmp-system.c  | 376 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 qmp.c         | 361 +------------------------------------------------------
 3 files changed, 379 insertions(+), 360 deletions(-)
 create mode 100644 qmp-system.c

diff --git a/Makefile.objs b/Makefile.objs
index 1f76cea..0f0f298 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -85,7 +85,7 @@ common-obj-$(CONFIG_SMARTCARD_NSS) += $(libcacard-y)
 # qapi
 
 common-obj-y += qmp-marshal.o
-common-obj-y += qmp.o hmp.o
+common-obj-y += qmp.o qmp-system.o hmp.o
 endif
 
 ######################################################################
diff --git a/qmp-system.c b/qmp-system.c
new file mode 100644
index 0000000..8abd1a8
--- /dev/null
+++ b/qmp-system.c
@@ -0,0 +1,376 @@
+/*
+ * QEMU Management Protocol
+ *
+ * Copyright IBM, Corp. 2011
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ * Contributions after 2012-01-13 are licensed under the terms of the
+ * GNU GPL, version 2 or (at your option) any later version.
+ */
+
+/* Contains QMP code related to system emulation */
+
+#include "sysemu/sysemu.h"
+#include "sysemu/char.h"
+#include "ui/qemu-spice.h"
+#include "ui/vnc.h"
+#include "sysemu/kvm.h"
+#include "sysemu/arch_init.h"
+#include "hw/mem/pc-dimm.h"
+#include "hw/boards.h"
+#include "hw/acpi/acpi_dev_interface.h"
+
+NameInfo *qmp_query_name(Error **errp)
+{
+    NameInfo *info = g_malloc0(sizeof(*info));
+
+    if (qemu_name) {
+        info->has_name = true;
+        info->name = g_strdup(qemu_name);
+    }
+
+    return info;
+}
+
+void qmp_set_password(const char *protocol, const char *password,
+                      bool has_connected, const char *connected, Error **errp)
+{
+    int disconnect_if_connected = 0;
+    int fail_if_connected = 0;
+    int rc;
+
+    if (has_connected) {
+        if (strcmp(connected, "fail") == 0) {
+            fail_if_connected = 1;
+        } else if (strcmp(connected, "disconnect") == 0) {
+            disconnect_if_connected = 1;
+        } else if (strcmp(connected, "keep") == 0) {
+            /* nothing */
+        } else {
+            error_set(errp, QERR_INVALID_PARAMETER, "connected");
+            return;
+        }
+    }
+
+    if (strcmp(protocol, "spice") == 0) {
+        if (!using_spice) {
+            /* correct one? spice isn't a device ,,, */
+            error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
+            return;
+        }
+        rc = qemu_spice_set_passwd(password, fail_if_connected,
+                                   disconnect_if_connected);
+        if (rc != 0) {
+            error_set(errp, QERR_SET_PASSWD_FAILED);
+        }
+        return;
+    }
+
+    if (strcmp(protocol, "vnc") == 0) {
+        if (fail_if_connected || disconnect_if_connected) {
+            /* vnc supports "connected=keep" only */
+            error_set(errp, QERR_INVALID_PARAMETER, "connected");
+            return;
+        }
+        /* Note that setting an empty password will not disable login through
+         * this interface. */
+        rc = vnc_display_password(NULL, password);
+        if (rc < 0) {
+            error_set(errp, QERR_SET_PASSWD_FAILED);
+        }
+        return;
+    }
+
+    error_set(errp, QERR_INVALID_PARAMETER, "protocol");
+}
+
+void qmp_expire_password(const char *protocol, const char *whenstr,
+                         Error **errp)
+{
+    time_t when;
+    int rc;
+
+    if (strcmp(whenstr, "now") == 0) {
+        when = 0;
+    } else if (strcmp(whenstr, "never") == 0) {
+        when = TIME_MAX;
+    } else if (whenstr[0] == '+') {
+        when = time(NULL) + strtoull(whenstr+1, NULL, 10);
+    } else {
+        when = strtoull(whenstr, NULL, 10);
+    }
+
+    if (strcmp(protocol, "spice") == 0) {
+        if (!using_spice) {
+            /* correct one? spice isn't a device ,,, */
+            error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
+            return;
+        }
+        rc = qemu_spice_set_pw_expire(when);
+        if (rc != 0) {
+            error_set(errp, QERR_SET_PASSWD_FAILED);
+        }
+        return;
+    }
+
+    if (strcmp(protocol, "vnc") == 0) {
+        rc = vnc_display_pw_expire(NULL, when);
+        if (rc != 0) {
+            error_set(errp, QERR_SET_PASSWD_FAILED);
+        }
+        return;
+    }
+
+    error_set(errp, QERR_INVALID_PARAMETER, "protocol");
+}
+
+#ifdef CONFIG_VNC
+void qmp_change_vnc_password(const char *password, Error **errp)
+{
+    if (vnc_display_password(NULL, password) < 0) {
+        error_set(errp, QERR_SET_PASSWD_FAILED);
+    }
+}
+
+static void qmp_change_vnc_listen(const char *target, Error **errp)
+{
+    vnc_display_open(NULL, target, errp);
+}
+
+static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
+                           Error **errp)
+{
+    if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) {
+        if (!has_arg) {
+            error_set(errp, QERR_MISSING_PARAMETER, "password");
+        } else {
+            qmp_change_vnc_password(arg, errp);
+        }
+    } else {
+        qmp_change_vnc_listen(target, errp);
+    }
+}
+#else
+void qmp_change_vnc_password(const char *password, Error **errp)
+{
+    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+}
+static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
+                           Error **errp)
+{
+    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+}
+#endif /* !CONFIG_VNC */
+
+void qmp_change(const char *device, const char *target,
+                bool has_arg, const char *arg, Error **errp)
+{
+    if (strcmp(device, "vnc") == 0) {
+        qmp_change_vnc(target, has_arg, arg, errp);
+    } else {
+        qmp_change_blockdev(device, target, arg, errp);
+    }
+}
+
+void qmp_quit(Error **errp)
+{
+    no_shutdown = 0;
+    qemu_system_shutdown_request();
+}
+
+void qmp_stop(Error **errp)
+{
+    if (runstate_check(RUN_STATE_INMIGRATE)) {
+        autostart = 0;
+    } else {
+        vm_stop(RUN_STATE_PAUSED);
+    }
+}
+
+void qmp_system_reset(Error **errp)
+{
+    qemu_system_reset_request();
+}
+
+void qmp_system_powerdown(Error **erp)
+{
+    qemu_system_powerdown_request();
+}
+
+void qmp_cpu_add(int64_t id, Error **errp)
+{
+    MachineClass *mc;
+
+    mc = MACHINE_GET_CLASS(current_machine);
+    if (mc->hot_add_cpu) {
+        mc->hot_add_cpu(id, errp);
+    } else {
+        error_setg(errp, "Not supported");
+    }
+}
+
+#ifndef CONFIG_VNC
+/* If VNC support is enabled, the "true" query-vnc command is
+   defined in the VNC subsystem */
+VncInfo *qmp_query_vnc(Error **errp)
+{
+    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+    return NULL;
+};
+#endif
+
+#ifndef CONFIG_SPICE
+/* If SPICE support is enabled, the "true" query-spice command is
+   defined in the SPICE subsystem. Also note that we use a small
+   trick to maintain query-spice's original behavior, which is not
+   to be available in the namespace if SPICE is not compiled in */
+SpiceInfo *qmp_query_spice(Error **errp)
+{
+    error_set(errp, QERR_COMMAND_NOT_FOUND, "query-spice");
+    return NULL;
+};
+#endif
+
+void qmp_cont(Error **errp)
+{
+    BlockDriverState *bs;
+
+    if (runstate_needs_reset()) {
+        error_setg(errp, "Resetting the Virtual Machine is required");
+        return;
+    } else if (runstate_check(RUN_STATE_SUSPENDED)) {
+        return;
+    }
+
+    for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
+        bdrv_iostatus_reset(bs);
+    }
+    for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
+        if (bdrv_key_required(bs)) {
+            error_set(errp, QERR_DEVICE_ENCRYPTED,
+                      bdrv_get_device_name(bs),
+                      bdrv_get_encrypted_filename(bs));
+            return;
+        }
+    }
+
+    if (runstate_check(RUN_STATE_INMIGRATE)) {
+        autostart = 1;
+    } else {
+        vm_start();
+    }
+}
+
+void qmp_system_wakeup(Error **errp)
+{
+    qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
+}
+
+KvmInfo *qmp_query_kvm(Error **errp)
+{
+    KvmInfo *info = g_malloc0(sizeof(*info));
+
+    info->enabled = kvm_enabled();
+    info->present = kvm_available();
+
+    return info;
+}
+
+UuidInfo *qmp_query_uuid(Error **errp)
+{
+    UuidInfo *info = g_malloc0(sizeof(*info));
+    char uuid[64];
+
+    snprintf(uuid, sizeof(uuid), UUID_FMT, qemu_uuid[0], qemu_uuid[1],
+                   qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5],
+                   qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9],
+                   qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13],
+                   qemu_uuid[14], qemu_uuid[15]);
+
+    info->UUID = g_strdup(uuid);
+    return info;
+}
+
+CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
+{
+    return arch_query_cpu_definitions(errp);
+}
+
+void qmp_add_client(const char *protocol, const char *fdname,
+                    bool has_skipauth, bool skipauth, bool has_tls, bool tls,
+                    Error **errp)
+{
+    CharDriverState *s;
+    int fd;
+
+    fd = monitor_get_fd(cur_mon, fdname, errp);
+    if (fd < 0) {
+        return;
+    }
+
+    if (strcmp(protocol, "spice") == 0) {
+        if (!using_spice) {
+            error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
+            close(fd);
+            return;
+        }
+        skipauth = has_skipauth ? skipauth : false;
+        tls = has_tls ? tls : false;
+        if (qemu_spice_display_add_client(fd, skipauth, tls) < 0) {
+            error_setg(errp, "spice failed to add client");
+            close(fd);
+        }
+        return;
+#ifdef CONFIG_VNC
+    } else if (strcmp(protocol, "vnc") == 0) {
+        skipauth = has_skipauth ? skipauth : false;
+        vnc_display_add_client(NULL, fd, skipauth);
+        return;
+#endif
+    } else if ((s = qemu_chr_find(protocol)) != NULL) {
+        if (qemu_chr_add_client(s, fd) < 0) {
+            error_setg(errp, "failed to add client");
+            close(fd);
+            return;
+        }
+        return;
+    }
+
+    error_setg(errp, "protocol '%s' is invalid", protocol);
+    close(fd);
+}
+
+
+MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
+{
+    MemoryDeviceInfoList *head = NULL;
+    MemoryDeviceInfoList **prev = &head;
+
+    qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
+
+    return head;
+}
+
+ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
+{
+    bool ambig;
+    ACPIOSTInfoList *head = NULL;
+    ACPIOSTInfoList **prev = &head;
+    Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, &ambig);
+
+    if (obj) {
+        AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);
+        AcpiDeviceIf *adev = ACPI_DEVICE_IF(obj);
+
+        adevc->ospm_status(adev, &prev);
+    } else {
+        error_setg(errp, "command is not supported, missing ACPI device");
+    }
+
+    return head;
+}
diff --git a/qmp.c b/qmp.c
index 0d2553a..dd68ea0 100644
--- a/qmp.c
+++ b/qmp.c
@@ -13,35 +13,15 @@
  * GNU GPL, version 2 or (at your option) any later version.
  */
 
-#include "qemu-common.h"
+/* Contains core QMP code that can be linked with any binary. */
+
 #include "sysemu/sysemu.h"
-#include "qmp-commands.h"
-#include "sysemu/char.h"
-#include "ui/qemu-spice.h"
 #include "ui/vnc.h"
-#include "sysemu/kvm.h"
 #include "sysemu/arch_init.h"
-#include "hw/qdev.h"
-#include "sysemu/blockdev.h"
 #include "qom/qom-qobject.h"
-#include "qapi/qmp/qobject.h"
 #include "qapi/qmp-input-visitor.h"
 #include "hw/boards.h"
 #include "qom/object_interfaces.h"
-#include "hw/mem/pc-dimm.h"
-#include "hw/acpi/acpi_dev_interface.h"
-
-NameInfo *qmp_query_name(Error **errp)
-{
-    NameInfo *info = g_malloc0(sizeof(*info));
-
-    if (qemu_name) {
-        info->has_name = true;
-        info->name = g_strdup(qemu_name);
-    }
-
-    return info;
-}
 
 VersionInfo *qmp_query_version(Error **errp)
 {
@@ -59,130 +39,11 @@ VersionInfo *qmp_query_version(Error **errp)
     return info;
 }
 
-KvmInfo *qmp_query_kvm(Error **errp)
-{
-    KvmInfo *info = g_malloc0(sizeof(*info));
-
-    info->enabled = kvm_enabled();
-    info->present = kvm_available();
-
-    return info;
-}
-
-UuidInfo *qmp_query_uuid(Error **errp)
-{
-    UuidInfo *info = g_malloc0(sizeof(*info));
-    char uuid[64];
-
-    snprintf(uuid, sizeof(uuid), UUID_FMT, qemu_uuid[0], qemu_uuid[1],
-                   qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5],
-                   qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9],
-                   qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13],
-                   qemu_uuid[14], qemu_uuid[15]);
-
-    info->UUID = g_strdup(uuid);
-    return info;
-}
-
-void qmp_quit(Error **errp)
-{
-    no_shutdown = 0;
-    qemu_system_shutdown_request();
-}
-
-void qmp_stop(Error **errp)
-{
-    if (runstate_check(RUN_STATE_INMIGRATE)) {
-        autostart = 0;
-    } else {
-        vm_stop(RUN_STATE_PAUSED);
-    }
-}
-
-void qmp_system_reset(Error **errp)
-{
-    qemu_system_reset_request();
-}
-
-void qmp_system_powerdown(Error **erp)
-{
-    qemu_system_powerdown_request();
-}
-
 void qmp_cpu(int64_t index, Error **errp)
 {
     /* Just do nothing */
 }
 
-void qmp_cpu_add(int64_t id, Error **errp)
-{
-    MachineClass *mc;
-
-    mc = MACHINE_GET_CLASS(current_machine);
-    if (mc->hot_add_cpu) {
-        mc->hot_add_cpu(id, errp);
-    } else {
-        error_setg(errp, "Not supported");
-    }
-}
-
-#ifndef CONFIG_VNC
-/* If VNC support is enabled, the "true" query-vnc command is
-   defined in the VNC subsystem */
-VncInfo *qmp_query_vnc(Error **errp)
-{
-    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
-    return NULL;
-};
-#endif
-
-#ifndef CONFIG_SPICE
-/* If SPICE support is enabled, the "true" query-spice command is
-   defined in the SPICE subsystem. Also note that we use a small
-   trick to maintain query-spice's original behavior, which is not
-   to be available in the namespace if SPICE is not compiled in */
-SpiceInfo *qmp_query_spice(Error **errp)
-{
-    error_set(errp, QERR_COMMAND_NOT_FOUND, "query-spice");
-    return NULL;
-};
-#endif
-
-void qmp_cont(Error **errp)
-{
-    BlockDriverState *bs;
-
-    if (runstate_needs_reset()) {
-        error_setg(errp, "Resetting the Virtual Machine is required");
-        return;
-    } else if (runstate_check(RUN_STATE_SUSPENDED)) {
-        return;
-    }
-
-    for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
-        bdrv_iostatus_reset(bs);
-    }
-    for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
-        if (bdrv_key_required(bs)) {
-            error_set(errp, QERR_DEVICE_ENCRYPTED,
-                      bdrv_get_device_name(bs),
-                      bdrv_get_encrypted_filename(bs));
-            return;
-        }
-    }
-
-    if (runstate_check(RUN_STATE_INMIGRATE)) {
-        autostart = 1;
-    } else {
-        vm_start();
-    }
-}
-
-void qmp_system_wakeup(Error **errp)
-{
-    qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
-}
-
 ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
 {
     Object *obj;
@@ -266,146 +127,6 @@ out:
     return 0;
 }
 
-void qmp_set_password(const char *protocol, const char *password,
-                      bool has_connected, const char *connected, Error **errp)
-{
-    int disconnect_if_connected = 0;
-    int fail_if_connected = 0;
-    int rc;
-
-    if (has_connected) {
-        if (strcmp(connected, "fail") == 0) {
-            fail_if_connected = 1;
-        } else if (strcmp(connected, "disconnect") == 0) {
-            disconnect_if_connected = 1;
-        } else if (strcmp(connected, "keep") == 0) {
-            /* nothing */
-        } else {
-            error_set(errp, QERR_INVALID_PARAMETER, "connected");
-            return;
-        }
-    }
-
-    if (strcmp(protocol, "spice") == 0) {
-        if (!using_spice) {
-            /* correct one? spice isn't a device ,,, */
-            error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
-            return;
-        }
-        rc = qemu_spice_set_passwd(password, fail_if_connected,
-                                   disconnect_if_connected);
-        if (rc != 0) {
-            error_set(errp, QERR_SET_PASSWD_FAILED);
-        }
-        return;
-    }
-
-    if (strcmp(protocol, "vnc") == 0) {
-        if (fail_if_connected || disconnect_if_connected) {
-            /* vnc supports "connected=keep" only */
-            error_set(errp, QERR_INVALID_PARAMETER, "connected");
-            return;
-        }
-        /* Note that setting an empty password will not disable login through
-         * this interface. */
-        rc = vnc_display_password(NULL, password);
-        if (rc < 0) {
-            error_set(errp, QERR_SET_PASSWD_FAILED);
-        }
-        return;
-    }
-
-    error_set(errp, QERR_INVALID_PARAMETER, "protocol");
-}
-
-void qmp_expire_password(const char *protocol, const char *whenstr,
-                         Error **errp)
-{
-    time_t when;
-    int rc;
-
-    if (strcmp(whenstr, "now") == 0) {
-        when = 0;
-    } else if (strcmp(whenstr, "never") == 0) {
-        when = TIME_MAX;
-    } else if (whenstr[0] == '+') {
-        when = time(NULL) + strtoull(whenstr+1, NULL, 10);
-    } else {
-        when = strtoull(whenstr, NULL, 10);
-    }
-
-    if (strcmp(protocol, "spice") == 0) {
-        if (!using_spice) {
-            /* correct one? spice isn't a device ,,, */
-            error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
-            return;
-        }
-        rc = qemu_spice_set_pw_expire(when);
-        if (rc != 0) {
-            error_set(errp, QERR_SET_PASSWD_FAILED);
-        }
-        return;
-    }
-
-    if (strcmp(protocol, "vnc") == 0) {
-        rc = vnc_display_pw_expire(NULL, when);
-        if (rc != 0) {
-            error_set(errp, QERR_SET_PASSWD_FAILED);
-        }
-        return;
-    }
-
-    error_set(errp, QERR_INVALID_PARAMETER, "protocol");
-}
-
-#ifdef CONFIG_VNC
-void qmp_change_vnc_password(const char *password, Error **errp)
-{
-    if (vnc_display_password(NULL, password) < 0) {
-        error_set(errp, QERR_SET_PASSWD_FAILED);
-    }
-}
-
-static void qmp_change_vnc_listen(const char *target, Error **errp)
-{
-    vnc_display_open(NULL, target, errp);
-}
-
-static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
-                           Error **errp)
-{
-    if (strcmp(target, "passwd") == 0 || strcmp(target, "password") == 0) {
-        if (!has_arg) {
-            error_set(errp, QERR_MISSING_PARAMETER, "password");
-        } else {
-            qmp_change_vnc_password(arg, errp);
-        }
-    } else {
-        qmp_change_vnc_listen(target, errp);
-    }
-}
-#else
-void qmp_change_vnc_password(const char *password, Error **errp)
-{
-    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
-}
-static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
-                           Error **errp)
-{
-    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
-}
-#endif /* !CONFIG_VNC */
-
-void qmp_change(const char *device, const char *target,
-                bool has_arg, const char *arg, Error **errp)
-{
-    if (strcmp(device, "vnc") == 0) {
-        qmp_change_vnc(target, has_arg, arg, errp);
-    } else {
-        qmp_change_blockdev(device, target, arg, errp);
-    }
-}
-
 static void qom_list_types_tramp(ObjectClass *klass, void *data)
 {
     ObjectTypeInfoList *e, **pret = data;
@@ -536,55 +257,6 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
     return prop_list;
 }
 
-CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
-{
-    return arch_query_cpu_definitions(errp);
-}
-
-void qmp_add_client(const char *protocol, const char *fdname,
-                    bool has_skipauth, bool skipauth, bool has_tls, bool tls,
-                    Error **errp)
-{
-    CharDriverState *s;
-    int fd;
-
-    fd = monitor_get_fd(cur_mon, fdname, errp);
-    if (fd < 0) {
-        return;
-    }
-
-    if (strcmp(protocol, "spice") == 0) {
-        if (!using_spice) {
-            error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
-            close(fd);
-            return;
-        }
-        skipauth = has_skipauth ? skipauth : false;
-        tls = has_tls ? tls : false;
-        if (qemu_spice_display_add_client(fd, skipauth, tls) < 0) {
-            error_setg(errp, "spice failed to add client");
-            close(fd);
-        }
-        return;
-#ifdef CONFIG_VNC
-    } else if (strcmp(protocol, "vnc") == 0) {
-        skipauth = has_skipauth ? skipauth : false;
-        vnc_display_add_client(NULL, fd, skipauth);
-        return;
-#endif
-    } else if ((s = qemu_chr_find(protocol)) != NULL) {
-        if (qemu_chr_add_client(s, fd) < 0) {
-            error_setg(errp, "failed to add client");
-            close(fd);
-            return;
-        }
-        return;
-    }
-
-    error_setg(errp, "protocol '%s' is invalid", protocol);
-    close(fd);
-}
-
 void object_add(const char *type, const char *id, const QDict *qdict,
                 Visitor *v, Error **errp)
 {
@@ -683,32 +355,3 @@ void qmp_object_del(const char *id, Error **errp)
     }
     object_unparent(obj);
 }
-
-MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
-{
-    MemoryDeviceInfoList *head = NULL;
-    MemoryDeviceInfoList **prev = &head;
-
-    qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
-
-    return head;
-}
-
-ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
-{
-    bool ambig;
-    ACPIOSTInfoList *head = NULL;
-    ACPIOSTInfoList **prev = &head;
-    Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, &ambig);
-
-    if (obj) {
-        AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);
-        AcpiDeviceIf *adev = ACPI_DEVICE_IF(obj);
-
-        adevc->ospm_status(adev, &prev);
-    } else {
-        error_setg(errp, "command is not supported, missing ACPI device");
-    }
-
-    return head;
-}
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 02/24] monitor: Make some function public
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
  2014-08-01  5:26 ` [Qemu-devel] [PATCH v1 01/24] qmp: Extract system emulation related code from qmp.c into qmp-system.c Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-05 12:41   ` Eric Blake
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 03/24] monitor: Extract monitor-system.h header Benoît Canet
                   ` (21 subsequent siblings)
  23 siblings, 1 reply; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Next commits will split monitor.c in monitor.c and monitor-system.c.

Change some function from static to public in order to prepare this.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 include/monitor/monitor.h | 10 ++++++++++
 monitor.c                 | 24 ++++++++++--------------
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 3d6929d..bd9a1f2 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -66,5 +66,15 @@ int monitor_fdset_get_fd(int64_t fdset_id, int flags);
 int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd);
 int monitor_fdset_dup_fd_remove(int dup_fd);
 int monitor_fdset_dup_fd_find(int dup_fd);
+int monitor_ctrl_mode(const Monitor *mon);
+void monitor_data_init(Monitor *mon);
+int compare_cmd(const char *name, const char *list);
+int parse_cmdline(const char *cmdline, int *pnb_args, char **args);
+void free_cmdline_args(char **args, int nb_args);
+void handle_user_command(Monitor *mon, const char *cmdline);
+void add_completion_option(ReadLineState *rs, const char *str,
+                           const char *option);
+void monitor_user_noop(Monitor *mon, const QObject *data);
+int do_qmp_capabilities(Monitor *mon, const QDict *params, QObject **ret_data);
 
 #endif /* !MONITOR_H */
diff --git a/monitor.c b/monitor.c
index 5bc70a6..ed0cd86 100644
--- a/monitor.c
+++ b/monitor.c
@@ -241,7 +241,7 @@ static inline int qmp_cmd_mode(const Monitor *mon)
 }
 
 /* Return true if in control mode, false otherwise */
-static inline int monitor_ctrl_mode(const Monitor *mon)
+inline int monitor_ctrl_mode(const Monitor *mon)
 {
     return (mon->flags & MONITOR_USE_CONTROL);
 }
@@ -389,7 +389,7 @@ static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
     return 0;
 }
 
-static void monitor_user_noop(Monitor *mon, const QObject *data) { }
+void monitor_user_noop(Monitor *mon, const QObject *data) { }
 
 static inline int handler_is_qobject(const mon_cmd_t *cmd)
 {
@@ -593,8 +593,7 @@ static void monitor_qapi_event_init(void)
     qmp_event_set_func_emit(monitor_qapi_event_queue);
 }
 
-static int do_qmp_capabilities(Monitor *mon, const QDict *params,
-                               QObject **ret_data)
+int do_qmp_capabilities(Monitor *mon, const QDict *params, QObject **ret_data)
 {
     /* Will setup QMP capabilities in the future */
     if (monitor_ctrl_mode(mon)) {
@@ -604,9 +603,7 @@ static int do_qmp_capabilities(Monitor *mon, const QDict *params,
     return 0;
 }
 
-static void handle_user_command(Monitor *mon, const char *cmdline);
-
-static void monitor_data_init(Monitor *mon)
+void monitor_data_init(Monitor *mon)
 {
     memset(mon, 0, sizeof(Monitor));
     qemu_mutex_init(&mon->out_lock);
@@ -659,7 +656,7 @@ out:
     return output;
 }
 
-static int compare_cmd(const char *name, const char *list)
+int compare_cmd(const char *name, const char *list)
 {
     const char *p, *pstart;
     int len;
@@ -747,7 +744,7 @@ static int get_str(char *buf, int buf_size, const char **pp)
 
 #define MAX_ARGS 16
 
-static void free_cmdline_args(char **args, int nb_args)
+void free_cmdline_args(char **args, int nb_args)
 {
     int i;
 
@@ -772,8 +769,7 @@ static void free_cmdline_args(char **args, int nb_args)
  *       of args have a limit of MAX_ARGS. If cmdline contains more, it will
  *       return with failure.
  */
-static int parse_cmdline(const char *cmdline,
-                         int *pnb_args, char **args)
+int parse_cmdline(const char *cmdline, int *pnb_args, char **args)
 {
     const char *p;
     int nb_args, ret;
@@ -4092,7 +4088,7 @@ static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)
     }
 }
 
-static void handle_user_command(Monitor *mon, const char *cmdline)
+void handle_user_command(Monitor *mon, const char *cmdline)
 {
     QDict *qdict;
     const mon_cmd_t *cmd;
@@ -4229,8 +4225,8 @@ static const char *next_arg_type(const char *typestr)
     return (p != NULL ? ++p : typestr);
 }
 
-static void add_completion_option(ReadLineState *rs, const char *str,
-                                  const char *option)
+void add_completion_option(ReadLineState *rs, const char *str,
+                           const char *option)
 {
     if (!str || !option) {
         return;
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 03/24] monitor: Extract monitor-system.h header
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
  2014-08-01  5:26 ` [Qemu-devel] [PATCH v1 01/24] qmp: Extract system emulation related code from qmp.c into qmp-system.c Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 02/24] monitor: Make some function public Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-05 12:47   ` Eric Blake
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 04/24] monitor: Make monitor_fprintf public before extracting it Benoît Canet
                   ` (20 subsequent siblings)
  23 siblings, 1 reply; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

This header will allow to split monitor in two parts.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 include/monitor/monitor-system.h | 99 ++++++++++++++++++++++++++++++++++++++++
 monitor.c                        | 57 ++---------------------
 2 files changed, 102 insertions(+), 54 deletions(-)
 create mode 100644 include/monitor/monitor-system.h

diff --git a/include/monitor/monitor-system.h b/include/monitor/monitor-system.h
new file mode 100644
index 0000000..5d3827c
--- /dev/null
+++ b/include/monitor/monitor-system.h
@@ -0,0 +1,99 @@
+/*
+ * QEMU monitor
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MONITOR_COMMANDS_H
+#define MONITOR_COMMANDS_H
+
+#include "monitor/monitor.h"
+#include "qapi/error.h"
+#include "qapi/qmp/qlist.h"
+#include "qapi/qmp/qstring.h"
+#include "qapi/qmp/qjson.h"
+#include "qapi/qmp/json-streamer.h"
+#include "qapi/qmp/json-parser.h"
+#include <qom/object_interfaces.h>
+#include "hw/pci/pci.h"
+
+#include <stdint.h>
+
+#define MAX_ARGS 16
+
+struct mon_cmd_t;
+
+typedef struct MonitorControl {
+    QObject *id;
+    JSONMessageParser parser;
+    int command_mode;
+} MonitorControl;
+
+struct Monitor {
+    CharDriverState *chr;
+    int reset_seen;
+    int flags;
+    int suspend_cnt;
+    bool skip_flush;
+
+    QemuMutex out_lock;
+    QString *outbuf;
+    guint out_watch;
+
+    /* Read under either BQL or out_lock, written with BQL+out_lock.  */
+    int mux_out;
+
+    ReadLineState *rs;
+    MonitorControl *mc;
+    CPUState *mon_cpu;
+    BlockDriverCompletionFunc *password_completion_cb;
+    void *password_opaque;
+    struct mon_cmd_t *cmd_table;
+    QError *error;
+    QLIST_HEAD(,mon_fd_t) fds;
+    QLIST_ENTRY(Monitor) entry;
+};
+
+typedef struct mon_cmd_t {
+    const char *name;
+    const char *args_type;
+    const char *params;
+    const char *help;
+    void (*user_print)(Monitor *mon, const QObject *data);
+    union {
+        void (*cmd)(Monitor *mon, const QDict *qdict);
+        int  (*cmd_new)(Monitor *mon, const QDict *params, QObject **ret_data);
+        int  (*cmd_async)(Monitor *mon, const QDict *params,
+                          MonitorCompletion *cb, void *opaque);
+    } mhandler;
+    int flags;
+    /* @sub_table is a list of 2nd level of commands. If it do not exist,
+     * mhandler should be used. If it exist, sub_table[?].mhandler should be
+     * used, and mhandler of 1st level plays the role of help function.
+     */
+    struct mon_cmd_t *sub_table;
+    void (*command_completion)(ReadLineState *rs, int nb_args, const char *str);
+} mon_cmd_t;
+
+int get_expr(Monitor *mon, int64_t *pval, const char **pp);
+int get_double(Monitor *mon, double *pval, const char **pp);
+
+#endif
diff --git a/monitor.c b/monitor.c
index ed0cd86..703f5e9 100644
--- a/monitor.c
+++ b/monitor.c
@@ -37,6 +37,7 @@
 #include "ui/qemu-spice.h"
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
+#include "monitor/monitor-system.h"
 #include "qemu/readline.h"
 #include "ui/console.h"
 #include "ui/input.h"
@@ -123,27 +124,6 @@ struct MonitorCompletionData {
     void (*user_print)(Monitor *mon, const QObject *data);
 };
 
-typedef struct mon_cmd_t {
-    const char *name;
-    const char *args_type;
-    const char *params;
-    const char *help;
-    void (*user_print)(Monitor *mon, const QObject *data);
-    union {
-        void (*cmd)(Monitor *mon, const QDict *qdict);
-        int  (*cmd_new)(Monitor *mon, const QDict *params, QObject **ret_data);
-        int  (*cmd_async)(Monitor *mon, const QDict *params,
-                          MonitorCompletion *cb, void *opaque);
-    } mhandler;
-    int flags;
-    /* @sub_table is a list of 2nd level of commands. If it do not exist,
-     * mhandler should be used. If it exist, sub_table[?].mhandler should be
-     * used, and mhandler of 1st level plays the role of help function.
-     */
-    struct mon_cmd_t *sub_table;
-    void (*command_completion)(ReadLineState *rs, int nb_args, const char *str);
-} mon_cmd_t;
-
 /* file descriptors passed via SCM_RIGHTS */
 typedef struct mon_fd_t mon_fd_t;
 struct mon_fd_t {
@@ -170,12 +150,6 @@ struct MonFdset {
     QLIST_ENTRY(MonFdset) next;
 };
 
-typedef struct MonitorControl {
-    QObject *id;
-    JSONMessageParser parser;
-    int command_mode;
-} MonitorControl;
-
 /*
  * To prevent flooding clients, events can be throttled. The
  * throttling is calculated globally, rather than per-Monitor
@@ -189,31 +163,6 @@ typedef struct MonitorQAPIEventState {
     QObject *data;      /* Event pending delayed dispatch */
 } MonitorQAPIEventState;
 
-struct Monitor {
-    CharDriverState *chr;
-    int reset_seen;
-    int flags;
-    int suspend_cnt;
-    bool skip_flush;
-
-    QemuMutex out_lock;
-    QString *outbuf;
-    guint out_watch;
-
-    /* Read under either BQL or out_lock, written with BQL+out_lock.  */
-    int mux_out;
-
-    ReadLineState *rs;
-    MonitorControl *mc;
-    CPUState *mon_cpu;
-    BlockDriverCompletionFunc *password_completion_cb;
-    void *password_opaque;
-    mon_cmd_t *cmd_table;
-    QError *error;
-    QLIST_HEAD(,mon_fd_t) fds;
-    QLIST_ENTRY(Monitor) entry;
-};
-
 /* QMP checker flags */
 #define QMP_ACCEPT_UNKNOWNS 1
 
@@ -3538,7 +3487,7 @@ static int64_t expr_sum(Monitor *mon)
     return val;
 }
 
-static int get_expr(Monitor *mon, int64_t *pval, const char **pp)
+int get_expr(Monitor *mon, int64_t *pval, const char **pp)
 {
     pch = *pp;
     if (sigsetjmp(expr_env, 0)) {
@@ -3552,7 +3501,7 @@ static int get_expr(Monitor *mon, int64_t *pval, const char **pp)
     return 0;
 }
 
-static int get_double(Monitor *mon, double *pval, const char **pp)
+int get_double(Monitor *mon, double *pval, const char **pp)
 {
     const char *p = *pp;
     char *tailp;
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 04/24] monitor: Make monitor_fprintf public before extracting it
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (2 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 03/24] monitor: Extract monitor-system.h header Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-05 12:48   ` Eric Blake
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 05/24] monitor: Extract monitor_fprintf to monitor-system.c Benoît Canet
                   ` (19 subsequent siblings)
  23 siblings, 1 reply; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 disas.c                   | 10 ----------
 include/monitor/monitor.h |  2 ++
 monitor.c                 |  4 ++--
 3 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/disas.c b/disas.c
index 44a019a..b174f26 100644
--- a/disas.c
+++ b/disas.c
@@ -435,16 +435,6 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,
     return 0;
 }
 
-static int GCC_FMT_ATTR(2, 3)
-monitor_fprintf(FILE *stream, const char *fmt, ...)
-{
-    va_list ap;
-    va_start(ap, fmt);
-    monitor_vprintf((Monitor *)stream, fmt, ap);
-    va_end(ap);
-    return 0;
-}
-
 /* Disassembler for the monitor.
    See target_disas for a description of flags. */
 void monitor_disas(Monitor *mon, CPUArchState *env,
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index bd9a1f2..0155390 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -77,4 +77,6 @@ void add_completion_option(ReadLineState *rs, const char *str,
 void monitor_user_noop(Monitor *mon, const QObject *data);
 int do_qmp_capabilities(Monitor *mon, const QDict *params, QObject **ret_data);
 
+int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, const char *fmt, ...);
+
 #endif /* !MONITOR_H */
diff --git a/monitor.c b/monitor.c
index 703f5e9..e06f9b5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -328,8 +328,8 @@ void monitor_printf(Monitor *mon, const char *fmt, ...)
     va_end(ap);
 }
 
-static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
-                                              const char *fmt, ...)
+int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
+                                       const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 05/24] monitor: Extract monitor_fprintf to monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (3 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 04/24] monitor: Make monitor_fprintf public before extracting it Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 06/24] monitor: Extract qmp_human_monitor_command into monitor-system.c Benoît Canet
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 Makefile.target                  |  1 +
 disas.c                          | 10 ++++++
 include/monitor/monitor-system.h |  3 ++
 include/monitor/monitor.h        |  2 --
 monitor-system.c                 | 69 ++++++++++++++++++++++++++++++++++++++++
 monitor.c                        | 10 ------
 6 files changed, 83 insertions(+), 12 deletions(-)
 create mode 100644 monitor-system.c

diff --git a/Makefile.target b/Makefile.target
index 137d0b0..684a82f 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -120,6 +120,7 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU
 obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
+obj-y += monitor-system.o
 obj-y += qtest.o
 obj-y += hw/
 obj-$(CONFIG_FDT) += device_tree.o
diff --git a/disas.c b/disas.c
index b174f26..44a019a 100644
--- a/disas.c
+++ b/disas.c
@@ -435,6 +435,16 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,
     return 0;
 }
 
+static int GCC_FMT_ATTR(2, 3)
+monitor_fprintf(FILE *stream, const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    monitor_vprintf((Monitor *)stream, fmt, ap);
+    va_end(ap);
+    return 0;
+}
+
 /* Disassembler for the monitor.
    See target_disas for a description of flags. */
 void monitor_disas(Monitor *mon, CPUArchState *env,
diff --git a/include/monitor/monitor-system.h b/include/monitor/monitor-system.h
index 5d3827c..f06f66e 100644
--- a/include/monitor/monitor-system.h
+++ b/include/monitor/monitor-system.h
@@ -96,4 +96,7 @@ typedef struct mon_cmd_t {
 int get_expr(Monitor *mon, int64_t *pval, const char **pp);
 int get_double(Monitor *mon, double *pval, const char **pp);
 
+int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
+                                       const char *fmt, ...);
+
 #endif
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 0155390..bd9a1f2 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -77,6 +77,4 @@ void add_completion_option(ReadLineState *rs, const char *str,
 void monitor_user_noop(Monitor *mon, const QObject *data);
 int do_qmp_capabilities(Monitor *mon, const QDict *params, QObject **ret_data);
 
-int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, const char *fmt, ...);
-
 #endif /* !MONITOR_H */
diff --git a/monitor-system.c b/monitor-system.c
new file mode 100644
index 0000000..51ca21f
--- /dev/null
+++ b/monitor-system.c
@@ -0,0 +1,69 @@
+/*
+ * QEMU monitor
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/* Monitor system related parts */
+
+#include "net/net.h"
+#include "exec/address-spaces.h"
+#include "exec/gdbstub.h"
+#include "hw/usb.h"
+#include "hw/pcmcia.h"
+#include "hw/i386/pc.h"
+#include "monitor/monitor-system.h"
+#include "qemu/acl.h"
+#include "qmp-commands.h"
+#include "sysemu/watchdog.h"
+#include "trace/control.h"
+#ifdef CONFIG_TRACE_SIMPLE
+#include "trace/simple.h"
+#endif
+#include "ui/console.h"
+#include "ui/qemu-spice.h"
+#include "ui/input.h"
+#include "monitor/qdev.h"
+#include "audio/audio.h"
+#include "hmp.h"
+#include "hw/loader.h"
+#include "net/slirp.h"
+#include "sysemu/blockdev.h"
+#include "qemu/config-file.h"
+
+/* for pic/irq_info */
+#if defined(TARGET_SPARC)
+#include "hw/sparc/sun4m.h"
+#endif
+#include "hw/lm32/lm32_pic.h"
+
+extern const char *monitor_event_names[];
+
+int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
+                                       const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    monitor_vprintf((Monitor *)stream, fmt, ap);
+    va_end(ap);
+    return 0;
+}
+
diff --git a/monitor.c b/monitor.c
index e06f9b5..a31d1d0 100644
--- a/monitor.c
+++ b/monitor.c
@@ -328,16 +328,6 @@ void monitor_printf(Monitor *mon, const char *fmt, ...)
     va_end(ap);
 }
 
-int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
-                                       const char *fmt, ...)
-{
-    va_list ap;
-    va_start(ap, fmt);
-    monitor_vprintf((Monitor *)stream, fmt, ap);
-    va_end(ap);
-    return 0;
-}
-
 void monitor_user_noop(Monitor *mon, const QObject *data) { }
 
 static inline int handler_is_qobject(const mon_cmd_t *cmd)
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 06/24] monitor: Extract qmp_human_monitor_command into monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (4 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 05/24] monitor: Extract monitor_fprintf to monitor-system.c Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 07/24] monitor: Make some function to extract public Benoît Canet
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor-system.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 monitor.c        | 44 --------------------------------------------
 2 files changed, 43 insertions(+), 44 deletions(-)

diff --git a/monitor-system.c b/monitor-system.c
index 51ca21f..90758db 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -67,3 +67,46 @@ int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
     return 0;
 }
 
+static void monitor_data_destroy(Monitor *mon)
+{
+    QDECREF(mon->outbuf);
+    qemu_mutex_destroy(&mon->out_lock);
+}
+
+char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
+                                int64_t cpu_index, Error **errp)
+{
+    char *output = NULL;
+    Monitor *old_mon, hmp;
+
+    monitor_data_init(&hmp);
+    hmp.skip_flush = true;
+
+    old_mon = cur_mon;
+    cur_mon = &hmp;
+
+    if (has_cpu_index) {
+        int ret = monitor_set_cpu(cpu_index);
+        if (ret < 0) {
+            cur_mon = old_mon;
+            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
+                      "a CPU number");
+            goto out;
+        }
+    }
+
+    handle_user_command(&hmp, command_line);
+    cur_mon = old_mon;
+
+    qemu_mutex_lock(&hmp.out_lock);
+    if (qstring_get_length(hmp.outbuf) > 0) {
+        output = g_strdup(qstring_get_str(hmp.outbuf));
+    } else {
+        output = g_strdup("");
+    }
+    qemu_mutex_unlock(&hmp.out_lock);
+
+out:
+    monitor_data_destroy(&hmp);
+    return output;
+}
diff --git a/monitor.c b/monitor.c
index a31d1d0..30d8eda 100644
--- a/monitor.c
+++ b/monitor.c
@@ -551,50 +551,6 @@ void monitor_data_init(Monitor *mon)
     mon->cmd_table = mon_cmds;
 }
 
-static void monitor_data_destroy(Monitor *mon)
-{
-    QDECREF(mon->outbuf);
-    qemu_mutex_destroy(&mon->out_lock);
-}
-
-char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
-                                int64_t cpu_index, Error **errp)
-{
-    char *output = NULL;
-    Monitor *old_mon, hmp;
-
-    monitor_data_init(&hmp);
-    hmp.skip_flush = true;
-
-    old_mon = cur_mon;
-    cur_mon = &hmp;
-
-    if (has_cpu_index) {
-        int ret = monitor_set_cpu(cpu_index);
-        if (ret < 0) {
-            cur_mon = old_mon;
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
-                      "a CPU number");
-            goto out;
-        }
-    }
-
-    handle_user_command(&hmp, command_line);
-    cur_mon = old_mon;
-
-    qemu_mutex_lock(&hmp.out_lock);
-    if (qstring_get_length(hmp.outbuf) > 0) {
-        output = g_strdup(qstring_get_str(hmp.outbuf));
-    } else {
-        output = g_strdup("");
-    }
-    qemu_mutex_unlock(&hmp.out_lock);
-
-out:
-    monitor_data_destroy(&hmp);
-    return output;
-}
-
 int compare_cmd(const char *name, const char *list)
 {
     const char *p, *pstart;
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 07/24] monitor: Make some function to extract public
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (5 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 06/24] monitor: Extract qmp_human_monitor_command into monitor-system.c Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 08/24] monitor: Extract a couple of function to monitor-system.c Benoît Canet
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

The functions made public are: help_cmd, do_help_cmd, do_trace_event_set_state
and do_trace_file.

Put the header declaration in monitor/monitor-system.h directly to avoid a
type conflict.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 include/monitor/monitor-system.h | 4 ++++
 monitor.c                        | 8 ++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/monitor/monitor-system.h b/include/monitor/monitor-system.h
index f06f66e..6cbf2a4 100644
--- a/include/monitor/monitor-system.h
+++ b/include/monitor/monitor-system.h
@@ -98,5 +98,9 @@ int get_double(Monitor *mon, double *pval, const char **pp);
 
 int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
                                        const char *fmt, ...);
+void help_cmd(Monitor *mon, const char *name);
+void do_help_cmd(Monitor *mon, const QDict *qdict);
+void do_trace_event_set_state(Monitor *mon, const QDict *qdict);
+void do_trace_file(Monitor *mon, const QDict *qdict);
 
 #endif
diff --git a/monitor.c b/monitor.c
index 30d8eda..488777e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -739,7 +739,7 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
     }
 }
 
-static void help_cmd(Monitor *mon, const char *name)
+void help_cmd(Monitor *mon, const char *name)
 {
     char *args[MAX_ARGS];
     int nb_args = 0;
@@ -768,12 +768,12 @@ static void help_cmd(Monitor *mon, const char *name)
     free_cmdline_args(args, nb_args);
 }
 
-static void do_help_cmd(Monitor *mon, const QDict *qdict)
+void do_help_cmd(Monitor *mon, const QDict *qdict)
 {
     help_cmd(mon, qdict_get_try_str(qdict, "name"));
 }
 
-static void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
+void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
 {
     const char *tp_name = qdict_get_str(qdict, "name");
     bool new_state = qdict_get_bool(qdict, "option");
@@ -794,7 +794,7 @@ static void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
 }
 
 #ifdef CONFIG_TRACE_SIMPLE
-static void do_trace_file(Monitor *mon, const QDict *qdict)
+void do_trace_file(Monitor *mon, const QDict *qdict)
 {
     const char *op = qdict_get_try_str(qdict, "op");
     const char *arg = qdict_get_try_str(qdict, "arg");
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 08/24] monitor: Extract a couple of function to monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (6 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 07/24] monitor: Make some function to extract public Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 09/24] monitor: Make do_info_help public Benoît Canet
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

The extracted function are help_cmd, do_help_cmd, do_trace_event_set_state,
and do_trace_file.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor-system.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 monitor.c        | 121 -------------------------------------------------------
 2 files changed, 121 insertions(+), 121 deletions(-)

diff --git a/monitor-system.c b/monitor-system.c
index 90758db..25a132a 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -110,3 +110,124 @@ out:
     monitor_data_destroy(&hmp);
     return output;
 }
+
+static void help_cmd_dump_one(Monitor *mon,
+                              const mon_cmd_t *cmd,
+                              char **prefix_args,
+                              int prefix_args_nb)
+{
+    int i;
+
+    for (i = 0; i < prefix_args_nb; i++) {
+        monitor_printf(mon, "%s ", prefix_args[i]);
+    }
+    monitor_printf(mon, "%s %s -- %s\n", cmd->name, cmd->params, cmd->help);
+}
+
+/* @args[@arg_index] is the valid command need to find in @cmds */
+static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
+                          char **args, int nb_args, int arg_index)
+{
+    const mon_cmd_t *cmd;
+
+    /* No valid arg need to compare with, dump all in *cmds */
+    if (arg_index >= nb_args) {
+        for (cmd = cmds; cmd->name != NULL; cmd++) {
+            help_cmd_dump_one(mon, cmd, args, arg_index);
+        }
+        return;
+    }
+
+    /* Find one entry to dump */
+    for (cmd = cmds; cmd->name != NULL; cmd++) {
+        if (compare_cmd(args[arg_index], cmd->name)) {
+            if (cmd->sub_table) {
+                /* continue with next arg */
+                help_cmd_dump(mon, cmd->sub_table,
+                              args, nb_args, arg_index + 1);
+            } else {
+                help_cmd_dump_one(mon, cmd, args, arg_index);
+            }
+            break;
+        }
+    }
+}
+
+void help_cmd(Monitor *mon, const char *name)
+{
+    char *args[MAX_ARGS];
+    int nb_args = 0;
+
+    /* 1. parse user input */
+    if (name) {
+        /* special case for log, directly dump and return */
+        if (!strcmp(name, "log")) {
+            const QEMULogItem *item;
+            monitor_printf(mon, "Log items (comma separated):\n");
+            monitor_printf(mon, "%-10s %s\n", "none", "remove all logs");
+            for (item = qemu_log_items; item->mask != 0; item++) {
+                monitor_printf(mon, "%-10s %s\n", item->name, item->help);
+            }
+            return;
+        }
+
+        if (parse_cmdline(name, &nb_args, args) < 0) {
+            return;
+        }
+    }
+
+    /* 2. dump the contents according to parsed args */
+    help_cmd_dump(mon, mon->cmd_table, args, nb_args, 0);
+
+    free_cmdline_args(args, nb_args);
+}
+
+void do_help_cmd(Monitor *mon, const QDict *qdict)
+{
+    help_cmd(mon, qdict_get_try_str(qdict, "name"));
+}
+
+void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
+{
+    const char *tp_name = qdict_get_str(qdict, "name");
+    bool new_state = qdict_get_bool(qdict, "option");
+
+    bool found = false;
+    TraceEvent *ev = NULL;
+    while ((ev = trace_event_pattern(tp_name, ev)) != NULL) {
+        found = true;
+        if (!trace_event_get_state_static(ev)) {
+            monitor_printf(mon, "event \"%s\" is not traceable\n", tp_name);
+        } else {
+            trace_event_set_state_dynamic(ev, new_state);
+        }
+    }
+    if (!trace_event_is_pattern(tp_name) && !found) {
+        monitor_printf(mon, "unknown event name \"%s\"\n", tp_name);
+    }
+}
+
+#ifdef CONFIG_TRACE_SIMPLE
+void do_trace_file(Monitor *mon, const QDict *qdict)
+{
+    const char *op = qdict_get_try_str(qdict, "op");
+    const char *arg = qdict_get_try_str(qdict, "arg");
+
+    if (!op) {
+        st_print_trace_file_status((FILE *)mon, &monitor_fprintf);
+    } else if (!strcmp(op, "on")) {
+        st_set_trace_file_enabled(true);
+    } else if (!strcmp(op, "off")) {
+        st_set_trace_file_enabled(false);
+    } else if (!strcmp(op, "flush")) {
+        st_flush_trace_buffer();
+    } else if (!strcmp(op, "set")) {
+        if (arg) {
+            st_set_trace_file(arg);
+        }
+    } else {
+        monitor_printf(mon, "unexpected argument \"%s\"\n", op);
+        help_cmd(mon, "trace-file");
+    }
+}
+#endif
diff --git a/monitor.c b/monitor.c
index 488777e..b3ac060 100644
--- a/monitor.c
+++ b/monitor.c
@@ -697,127 +697,6 @@ int parse_cmdline(const char *cmdline, int *pnb_args, char **args)
     return -1;
 }
 
-static void help_cmd_dump_one(Monitor *mon,
-                              const mon_cmd_t *cmd,
-                              char **prefix_args,
-                              int prefix_args_nb)
-{
-    int i;
-
-    for (i = 0; i < prefix_args_nb; i++) {
-        monitor_printf(mon, "%s ", prefix_args[i]);
-    }
-    monitor_printf(mon, "%s %s -- %s\n", cmd->name, cmd->params, cmd->help);
-}
-
-/* @args[@arg_index] is the valid command need to find in @cmds */
-static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
-                          char **args, int nb_args, int arg_index)
-{
-    const mon_cmd_t *cmd;
-
-    /* No valid arg need to compare with, dump all in *cmds */
-    if (arg_index >= nb_args) {
-        for (cmd = cmds; cmd->name != NULL; cmd++) {
-            help_cmd_dump_one(mon, cmd, args, arg_index);
-        }
-        return;
-    }
-
-    /* Find one entry to dump */
-    for (cmd = cmds; cmd->name != NULL; cmd++) {
-        if (compare_cmd(args[arg_index], cmd->name)) {
-            if (cmd->sub_table) {
-                /* continue with next arg */
-                help_cmd_dump(mon, cmd->sub_table,
-                              args, nb_args, arg_index + 1);
-            } else {
-                help_cmd_dump_one(mon, cmd, args, arg_index);
-            }
-            break;
-        }
-    }
-}
-
-void help_cmd(Monitor *mon, const char *name)
-{
-    char *args[MAX_ARGS];
-    int nb_args = 0;
-
-    /* 1. parse user input */
-    if (name) {
-        /* special case for log, directly dump and return */
-        if (!strcmp(name, "log")) {
-            const QEMULogItem *item;
-            monitor_printf(mon, "Log items (comma separated):\n");
-            monitor_printf(mon, "%-10s %s\n", "none", "remove all logs");
-            for (item = qemu_log_items; item->mask != 0; item++) {
-                monitor_printf(mon, "%-10s %s\n", item->name, item->help);
-            }
-            return;
-        }
-
-        if (parse_cmdline(name, &nb_args, args) < 0) {
-            return;
-        }
-    }
-
-    /* 2. dump the contents according to parsed args */
-    help_cmd_dump(mon, mon->cmd_table, args, nb_args, 0);
-
-    free_cmdline_args(args, nb_args);
-}
-
-void do_help_cmd(Monitor *mon, const QDict *qdict)
-{
-    help_cmd(mon, qdict_get_try_str(qdict, "name"));
-}
-
-void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
-{
-    const char *tp_name = qdict_get_str(qdict, "name");
-    bool new_state = qdict_get_bool(qdict, "option");
-
-    bool found = false;
-    TraceEvent *ev = NULL;
-    while ((ev = trace_event_pattern(tp_name, ev)) != NULL) {
-        found = true;
-        if (!trace_event_get_state_static(ev)) {
-            monitor_printf(mon, "event \"%s\" is not traceable\n", tp_name);
-        } else {
-            trace_event_set_state_dynamic(ev, new_state);
-        }
-    }
-    if (!trace_event_is_pattern(tp_name) && !found) {
-        monitor_printf(mon, "unknown event name \"%s\"\n", tp_name);
-    }
-}
-
-#ifdef CONFIG_TRACE_SIMPLE
-void do_trace_file(Monitor *mon, const QDict *qdict)
-{
-    const char *op = qdict_get_try_str(qdict, "op");
-    const char *arg = qdict_get_try_str(qdict, "arg");
-
-    if (!op) {
-        st_print_trace_file_status((FILE *)mon, &monitor_fprintf);
-    } else if (!strcmp(op, "on")) {
-        st_set_trace_file_enabled(true);
-    } else if (!strcmp(op, "off")) {
-        st_set_trace_file_enabled(false);
-    } else if (!strcmp(op, "flush")) {
-        st_flush_trace_buffer();
-    } else if (!strcmp(op, "set")) {
-        if (arg) {
-            st_set_trace_file(arg);
-        }
-    } else {
-        monitor_printf(mon, "unexpected argument \"%s\"\n", op);
-        help_cmd(mon, "trace-file");
-    }
-}
-#endif
-
 static void user_monitor_complete(void *opaque, QObject *ret_data)
 {
     MonitorCompletionData *data = (MonitorCompletionData *)opaque; 
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 09/24] monitor: Make do_info_help public
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (7 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 08/24] monitor: Extract a couple of function to monitor-system.c Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 10/24] monitor: Extract do_info_help in monitor-system.c Benoît Canet
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 include/monitor/monitor-system.h | 1 +
 monitor.c                        | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/monitor/monitor-system.h b/include/monitor/monitor-system.h
index 6cbf2a4..76d87c7 100644
--- a/include/monitor/monitor-system.h
+++ b/include/monitor/monitor-system.h
@@ -102,5 +102,6 @@ void help_cmd(Monitor *mon, const char *name);
 void do_help_cmd(Monitor *mon, const QDict *qdict);
 void do_trace_event_set_state(Monitor *mon, const QDict *qdict);
 void do_trace_file(Monitor *mon, const QDict *qdict);
+void do_info_help(Monitor *mon, const QDict *qdict);
 
 #endif
diff --git a/monitor.c b/monitor.c
index b3ac060..5da52cc 100644
--- a/monitor.c
+++ b/monitor.c
@@ -736,7 +736,7 @@ static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
     }
 }
 
-static void do_info_help(Monitor *mon, const QDict *qdict)
+void do_info_help(Monitor *mon, const QDict *qdict)
 {
     help_cmd(mon, "info");
 }
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 10/24] monitor: Extract do_info_help in monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (8 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 09/24] monitor: Make do_info_help public Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 11/24] monitor: Make some monitor functions public before moving them " Benoît Canet
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor-system.c | 5 +++++
 monitor.c        | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/monitor-system.c b/monitor-system.c
index 25a132a..f5fb15a 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -231,3 +231,8 @@ void do_trace_file(Monitor *mon, const QDict *qdict)
     }
 }
 #endif
+
+void do_info_help(Monitor *mon, const QDict *qdict)
+{
+    help_cmd(mon, "info");
+}
diff --git a/monitor.c b/monitor.c
index 5da52cc..371374f 100644
--- a/monitor.c
+++ b/monitor.c
@@ -736,11 +736,6 @@ static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
     }
 }
 
-void do_info_help(Monitor *mon, const QDict *qdict)
-{
-    help_cmd(mon, "info");
-}
-
 CommandInfoList *qmp_query_commands(Error **errp)
 {
     CommandInfoList *info, *cmd_list = NULL;
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 11/24] monitor: Make some monitor functions public before moving them in monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (9 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 10/24] monitor: Extract do_info_help in monitor-system.c Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 12/24] monitor: Make do_loadvm public before moving it to monitor-system.c Benoît Canet
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

This will allow monitor.c to access these functions once they are moved in
monitor-system.c

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 include/monitor/monitor-system.h |   37 ++
 monitor-system.c                 | 1163 ++++++++++++++++++++++++++++++++++++++
 monitor.c                        | 1162 -------------------------------------
 3 files changed, 1200 insertions(+), 1162 deletions(-)

diff --git a/include/monitor/monitor-system.h b/include/monitor/monitor-system.h
index 76d87c7..2e98091 100644
--- a/include/monitor/monitor-system.h
+++ b/include/monitor/monitor-system.h
@@ -104,4 +104,41 @@ void do_trace_event_set_state(Monitor *mon, const QDict *qdict);
 void do_trace_file(Monitor *mon, const QDict *qdict);
 void do_info_help(Monitor *mon, const QDict *qdict);
 
+void do_info_registers(Monitor *mon, const QDict *qdict);
+void do_info_jit(Monitor *mon, const QDict *qdict);
+void do_info_history(Monitor *mon, const QDict *qdict);
+void tlb_info(Monitor *mon, const QDict *qdict);
+void mem_info(Monitor *mon, const QDict *qdict);
+void do_info_mtree(Monitor *mon, const QDict *qdict);
+void do_info_numa(Monitor *mon, const QDict *qdict);
+void do_info_profile(Monitor *mon, const QDict *qdict);
+void do_info_capture(Monitor *mon, const QDict *qdict);
+void do_info_cpu_stats(Monitor *mon, const QDict *qdict);
+void do_trace_print_events(Monitor *mon, const QDict *qdict);
+void do_logfile(Monitor *mon, const QDict *qdict);
+void do_log(Monitor *mon, const QDict *qdict);
+void do_singlestep(Monitor *mon, const QDict *qdict);
+void do_gdbserver(Monitor *mon, const QDict *qdict);
+void do_memory_dump(Monitor *mon, const QDict *qdict);
+void do_physical_memory_dump(Monitor *mon, const QDict *qdict);
+void do_print(Monitor *mon, const QDict *qdict);
+void do_ioport_read(Monitor *mon, const QDict *qdict);
+void do_ioport_write(Monitor *mon, const QDict *qdict);
+void do_sum(Monitor *mon, const QDict *qdict);
+void do_mouse_move(Monitor *mon, const QDict *qdict);
+void do_mouse_button(Monitor *mon, const QDict *qdict);
+void do_wav_capture(Monitor *mon, const QDict *qdict);
+void do_stop_capture(Monitor *mon, const QDict *qdict);
+void do_boot_set(Monitor *mon, const QDict *qdict);
+int client_migrate_info(Monitor *mon, const QDict *qdict,
+                        MonitorCompletion cb, void *opaque);
+void do_watchdog_action(Monitor *mon, const QDict *qdict);
+void do_acl_show(Monitor *mon, const QDict *qdict);
+void do_acl_policy(Monitor *mon, const QDict *qdict);
+void do_acl_add(Monitor *mon, const QDict *qdict);
+void do_acl_remove(Monitor *mon, const QDict *qdict);
+void do_acl_reset(Monitor *mon, const QDict *qdict);
+void do_inject_mce(Monitor *mon, const QDict *qdict);
+CPUArchState *mon_get_cpu(void);
+
 #endif
diff --git a/monitor-system.c b/monitor-system.c
index f5fb15a..2d49c76 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -26,6 +26,7 @@
 
 #include "net/net.h"
 #include "exec/address-spaces.h"
+#include "exec/cpu_ldst.h"
 #include "exec/gdbstub.h"
 #include "hw/usb.h"
 #include "hw/pcmcia.h"
@@ -236,3 +237,1165 @@ void do_info_help(Monitor *mon, const QDict *qdict)
 {
     help_cmd(mon, "info");
 }
+
+/* set the current CPU defined by the user */
+int monitor_set_cpu(int cpu_index)
+{
+    CPUState *cpu;
+
+    cpu = qemu_get_cpu(cpu_index);
+    if (cpu == NULL) {
+        return -1;
+    }
+    cur_mon->mon_cpu = cpu;
+    return 0;
+}
+
+CPUArchState *mon_get_cpu(void)
+{
+    if (!cur_mon->mon_cpu) {
+        monitor_set_cpu(0);
+    }
+    cpu_synchronize_state(cur_mon->mon_cpu);
+    return cur_mon->mon_cpu->env_ptr;
+}
+
+int monitor_get_cpu_index(void)
+{
+    CPUState *cpu = ENV_GET_CPU(mon_get_cpu());
+    return cpu->cpu_index;
+}
+
+void do_info_registers(Monitor *mon, const QDict *qdict)
+{
+    CPUState *cpu;
+    CPUArchState *env;
+    env = mon_get_cpu();
+    cpu = ENV_GET_CPU(env);
+    cpu_dump_state(cpu, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU);
+}
+
+void do_info_jit(Monitor *mon, const QDict *qdict)
+{
+    dump_exec_info((FILE *)mon, monitor_fprintf);
+}
+
+void do_info_history(Monitor *mon, const QDict *qdict)
+{
+    int i;
+    const char *str;
+
+    if (!mon->rs)
+        return;
+    i = 0;
+    for(;;) {
+        str = readline_get_history(mon->rs, i);
+        if (!str)
+            break;
+        monitor_printf(mon, "%d: '%s'\n", i, str);
+        i++;
+    }
+}
+
+void do_info_cpu_stats(Monitor *mon, const QDict *qdict)
+{
+    CPUState *cpu;
+    CPUArchState *env;
+
+    env = mon_get_cpu();
+    cpu = ENV_GET_CPU(env);
+    cpu_dump_statistics(cpu, (FILE *)mon, &monitor_fprintf, 0);
+}
+
+void do_trace_print_events(Monitor *mon, const QDict *qdict)
+{
+    trace_print_events((FILE *)mon, &monitor_fprintf);
+}
+
+int client_migrate_info(Monitor *mon, const QDict *qdict,
+                        MonitorCompletion cb, void *opaque)
+{
+    const char *protocol = qdict_get_str(qdict, "protocol");
+    const char *hostname = qdict_get_str(qdict, "hostname");
+    const char *subject  = qdict_get_try_str(qdict, "cert-subject");
+    int port             = qdict_get_try_int(qdict, "port", -1);
+    int tls_port         = qdict_get_try_int(qdict, "tls-port", -1);
+    int ret;
+
+    if (strcmp(protocol, "spice") == 0) {
+        if (!using_spice) {
+            qerror_report(QERR_DEVICE_NOT_ACTIVE, "spice");
+            return -1;
+        }
+
+        if (port == -1 && tls_port == -1) {
+            qerror_report(QERR_MISSING_PARAMETER, "port/tls-port");
+            return -1;
+        }
+
+        ret = qemu_spice_migrate_info(hostname, port, tls_port, subject,
+                                      cb, opaque);
+        if (ret != 0) {
+            qerror_report(QERR_UNDEFINED_ERROR);
+            return -1;
+        }
+        return 0;
+    }
+
+    qerror_report(QERR_INVALID_PARAMETER, "protocol");
+    return -1;
+}
+
+void do_logfile(Monitor *mon, const QDict *qdict)
+{
+    qemu_set_log_filename(qdict_get_str(qdict, "filename"));
+}
+
+void do_log(Monitor *mon, const QDict *qdict)
+{
+    int mask;
+    const char *items = qdict_get_str(qdict, "items");
+
+    if (!strcmp(items, "none")) {
+        mask = 0;
+    } else {
+        mask = qemu_str_to_log_mask(items);
+        if (!mask) {
+            help_cmd(mon, "log");
+            return;
+        }
+    }
+    qemu_set_log(mask);
+}
+
+void do_singlestep(Monitor *mon, const QDict *qdict)
+{
+    const char *option = qdict_get_try_str(qdict, "option");
+    if (!option || !strcmp(option, "on")) {
+        singlestep = 1;
+    } else if (!strcmp(option, "off")) {
+        singlestep = 0;
+    } else {
+        monitor_printf(mon, "unexpected option %s\n", option);
+    }
+}
+
+void do_gdbserver(Monitor *mon, const QDict *qdict)
+{
+    const char *device = qdict_get_try_str(qdict, "device");
+    if (!device)
+        device = "tcp::" DEFAULT_GDBSTUB_PORT;
+    if (gdbserver_start(device) < 0) {
+        monitor_printf(mon, "Could not open gdbserver on device '%s'\n",
+                       device);
+    } else if (strcmp(device, "none") == 0) {
+        monitor_printf(mon, "Disabled gdbserver\n");
+    } else {
+        monitor_printf(mon, "Waiting for gdb connection on device '%s'\n",
+                       device);
+    }
+}
+
+void do_watchdog_action(Monitor *mon, const QDict *qdict)
+{
+    const char *action = qdict_get_str(qdict, "action");
+    if (select_watchdog_action(action) == -1) {
+        monitor_printf(mon, "Unknown watchdog action '%s'\n", action);
+    }
+}
+
+static void monitor_printc(Monitor *mon, int c)
+{
+    monitor_printf(mon, "'");
+    switch(c) {
+    case '\'':
+        monitor_printf(mon, "\\'");
+        break;
+    case '\\':
+        monitor_printf(mon, "\\\\");
+        break;
+    case '\n':
+        monitor_printf(mon, "\\n");
+        break;
+    case '\r':
+        monitor_printf(mon, "\\r");
+        break;
+    default:
+        if (c >= 32 && c <= 126) {
+            monitor_printf(mon, "%c", c);
+        } else {
+            monitor_printf(mon, "\\x%02x", c);
+        }
+        break;
+    }
+    monitor_printf(mon, "'");
+}
+
+static void memory_dump(Monitor *mon, int count, int format, int wsize,
+                        hwaddr addr, int is_physical)
+{
+    CPUArchState *env;
+    int l, line_size, i, max_digits, len;
+    uint8_t buf[16];
+    uint64_t v;
+
+    if (format == 'i') {
+        int flags;
+        flags = 0;
+        env = mon_get_cpu();
+#ifdef TARGET_I386
+        if (wsize == 2) {
+            flags = 1;
+        } else if (wsize == 4) {
+            flags = 0;
+        } else {
+            /* as default we use the current CS size */
+            flags = 0;
+            if (env) {
+#ifdef TARGET_X86_64
+                if ((env->efer & MSR_EFER_LMA) &&
+                    (env->segs[R_CS].flags & DESC_L_MASK))
+                    flags = 2;
+                else
+#endif
+                if (!(env->segs[R_CS].flags & DESC_B_MASK))
+                    flags = 1;
+            }
+        }
+#endif
+#ifdef TARGET_PPC
+        flags = msr_le << 16;
+        flags |= env->bfd_mach;
+#endif
+        monitor_disas(mon, env, addr, count, is_physical, flags);
+        return;
+    }
+
+    len = wsize * count;
+    if (wsize == 1)
+        line_size = 8;
+    else
+        line_size = 16;
+    max_digits = 0;
+
+    switch(format) {
+    case 'o':
+        max_digits = (wsize * 8 + 2) / 3;
+        break;
+    default:
+    case 'x':
+        max_digits = (wsize * 8) / 4;
+        break;
+    case 'u':
+    case 'd':
+        max_digits = (wsize * 8 * 10 + 32) / 33;
+        break;
+    case 'c':
+        wsize = 1;
+        break;
+    }
+
+    while (len > 0) {
+        if (is_physical)
+            monitor_printf(mon, TARGET_FMT_plx ":", addr);
+        else
+            monitor_printf(mon, TARGET_FMT_lx ":", (target_ulong)addr);
+        l = len;
+        if (l > line_size)
+            l = line_size;
+        if (is_physical) {
+            cpu_physical_memory_read(addr, buf, l);
+        } else {
+            env = mon_get_cpu();
+            if (cpu_memory_rw_debug(ENV_GET_CPU(env), addr, buf, l, 0) < 0) {
+                monitor_printf(mon, " Cannot access memory\n");
+                break;
+            }
+        }
+        i = 0;
+        while (i < l) {
+            switch(wsize) {
+            default:
+            case 1:
+                v = ldub_raw(buf + i);
+                break;
+            case 2:
+                v = lduw_raw(buf + i);
+                break;
+            case 4:
+                v = (uint32_t)ldl_raw(buf + i);
+                break;
+            case 8:
+                v = ldq_raw(buf + i);
+                break;
+            }
+            monitor_printf(mon, " ");
+            switch(format) {
+            case 'o':
+                monitor_printf(mon, "%#*" PRIo64, max_digits, v);
+                break;
+            case 'x':
+                monitor_printf(mon, "0x%0*" PRIx64, max_digits, v);
+                break;
+            case 'u':
+                monitor_printf(mon, "%*" PRIu64, max_digits, v);
+                break;
+            case 'd':
+                monitor_printf(mon, "%*" PRId64, max_digits, v);
+                break;
+            case 'c':
+                monitor_printc(mon, v);
+                break;
+            }
+            i += wsize;
+        }
+        monitor_printf(mon, "\n");
+        addr += l;
+        len -= l;
+    }
+}
+
+void do_memory_dump(Monitor *mon, const QDict *qdict)
+{
+    int count = qdict_get_int(qdict, "count");
+    int format = qdict_get_int(qdict, "format");
+    int size = qdict_get_int(qdict, "size");
+    target_long addr = qdict_get_int(qdict, "addr");
+
+    memory_dump(mon, count, format, size, addr, 0);
+}
+
+void do_physical_memory_dump(Monitor *mon, const QDict *qdict)
+{
+    int count = qdict_get_int(qdict, "count");
+    int format = qdict_get_int(qdict, "format");
+    int size = qdict_get_int(qdict, "size");
+    hwaddr addr = qdict_get_int(qdict, "addr");
+
+    memory_dump(mon, count, format, size, addr, 1);
+}
+
+void do_print(Monitor *mon, const QDict *qdict)
+{
+    int format = qdict_get_int(qdict, "format");
+    hwaddr val = qdict_get_int(qdict, "val");
+
+    switch(format) {
+    case 'o':
+        monitor_printf(mon, "%#" HWADDR_PRIo, val);
+        break;
+    case 'x':
+        monitor_printf(mon, "%#" HWADDR_PRIx, val);
+        break;
+    case 'u':
+        monitor_printf(mon, "%" HWADDR_PRIu, val);
+        break;
+    default:
+    case 'd':
+        monitor_printf(mon, "%" HWADDR_PRId, val);
+        break;
+    case 'c':
+        monitor_printc(mon, val);
+        break;
+    }
+    monitor_printf(mon, "\n");
+}
+
+void do_sum(Monitor *mon, const QDict *qdict)
+{
+    uint32_t addr;
+    uint16_t sum;
+    uint32_t start = qdict_get_int(qdict, "start");
+    uint32_t size = qdict_get_int(qdict, "size");
+
+    sum = 0;
+    for(addr = start; addr < (start + size); addr++) {
+        uint8_t val = ldub_phys(&address_space_memory, addr);
+        /* BSD sum algorithm ('sum' Unix command) */
+        sum = (sum >> 1) | (sum << 15);
+        sum += val;
+    }
+    monitor_printf(mon, "%05d\n", sum);
+}
+
+static int mouse_button_state;
+
+void do_mouse_move(Monitor *mon, const QDict *qdict)
+{
+    int dx, dy, dz, button;
+    const char *dx_str = qdict_get_str(qdict, "dx_str");
+    const char *dy_str = qdict_get_str(qdict, "dy_str");
+    const char *dz_str = qdict_get_try_str(qdict, "dz_str");
+
+    dx = strtol(dx_str, NULL, 0);
+    dy = strtol(dy_str, NULL, 0);
+    qemu_input_queue_rel(NULL, INPUT_AXIS_X, dx);
+    qemu_input_queue_rel(NULL, INPUT_AXIS_Y, dy);
+
+    if (dz_str) {
+        dz = strtol(dz_str, NULL, 0);
+        if (dz != 0) {
+            button = (dz > 0) ? INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
+            qemu_input_queue_btn(NULL, button, true);
+            qemu_input_event_sync();
+            qemu_input_queue_btn(NULL, button, false);
+        }
+    }
+    qemu_input_event_sync();
+}
+
+void do_mouse_button(Monitor *mon, const QDict *qdict)
+{
+    static uint32_t bmap[INPUT_BUTTON_MAX] = {
+        [INPUT_BUTTON_LEFT]       = MOUSE_EVENT_LBUTTON,
+        [INPUT_BUTTON_MIDDLE]     = MOUSE_EVENT_MBUTTON,
+        [INPUT_BUTTON_RIGHT]      = MOUSE_EVENT_RBUTTON,
+    };
+    int button_state = qdict_get_int(qdict, "button_state");
+
+    if (mouse_button_state == button_state) {
+        return;
+    }
+    qemu_input_update_buttons(NULL, bmap, mouse_button_state, button_state);
+    qemu_input_event_sync();
+    mouse_button_state = button_state;
+}
+
+void do_ioport_read(Monitor *mon, const QDict *qdict)
+{
+    int size = qdict_get_int(qdict, "size");
+    int addr = qdict_get_int(qdict, "addr");
+    int has_index = qdict_haskey(qdict, "index");
+    uint32_t val;
+    int suffix;
+
+    if (has_index) {
+        int index = qdict_get_int(qdict, "index");
+        cpu_outb(addr & IOPORTS_MASK, index & 0xff);
+        addr++;
+    }
+    addr &= 0xffff;
+
+    switch(size) {
+    default:
+    case 1:
+        val = cpu_inb(addr);
+        suffix = 'b';
+        break;
+    case 2:
+        val = cpu_inw(addr);
+        suffix = 'w';
+        break;
+    case 4:
+        val = cpu_inl(addr);
+        suffix = 'l';
+        break;
+    }
+    monitor_printf(mon, "port%c[0x%04x] = %#0*x\n",
+                   suffix, addr, size * 2, val);
+}
+
+void do_ioport_write(Monitor *mon, const QDict *qdict)
+{
+    int size = qdict_get_int(qdict, "size");
+    int addr = qdict_get_int(qdict, "addr");
+    int val = qdict_get_int(qdict, "val");
+
+    addr &= IOPORTS_MASK;
+
+    switch (size) {
+    default:
+    case 1:
+        cpu_outb(addr, val);
+        break;
+    case 2:
+        cpu_outw(addr, val);
+        break;
+    case 4:
+        cpu_outl(addr, val);
+        break;
+    }
+}
+
+void do_boot_set(Monitor *mon, const QDict *qdict)
+{
+    int res;
+    const char *bootdevice = qdict_get_str(qdict, "bootdevice");
+
+    res = qemu_boot_set(bootdevice);
+    if (res == 0) {
+        monitor_printf(mon, "boot device list now set to %s\n", bootdevice);
+    } else if (res > 0) {
+        monitor_printf(mon, "setting boot device list failed\n");
+    } else {
+        monitor_printf(mon, "no function defined to set boot device list for "
+                       "this architecture\n");
+    }
+}
+
+#if defined(TARGET_I386)
+static void print_pte(Monitor *mon, hwaddr addr,
+                      hwaddr pte,
+                      hwaddr mask)
+{
+#ifdef TARGET_X86_64
+    if (addr & (1ULL << 47)) {
+        addr |= -1LL << 48;
+    }
+#endif
+    monitor_printf(mon, TARGET_FMT_plx ": " TARGET_FMT_plx
+                   " %c%c%c%c%c%c%c%c%c\n",
+                   addr,
+                   pte & mask,
+                   pte & PG_NX_MASK ? 'X' : '-',
+                   pte & PG_GLOBAL_MASK ? 'G' : '-',
+                   pte & PG_PSE_MASK ? 'P' : '-',
+                   pte & PG_DIRTY_MASK ? 'D' : '-',
+                   pte & PG_ACCESSED_MASK ? 'A' : '-',
+                   pte & PG_PCD_MASK ? 'C' : '-',
+                   pte & PG_PWT_MASK ? 'T' : '-',
+                   pte & PG_USER_MASK ? 'U' : '-',
+                   pte & PG_RW_MASK ? 'W' : '-');
+}
+
+static void tlb_info_32(Monitor *mon, CPUArchState *env)
+{
+    unsigned int l1, l2;
+    uint32_t pgd, pde, pte;
+
+    pgd = env->cr[3] & ~0xfff;
+    for(l1 = 0; l1 < 1024; l1++) {
+        cpu_physical_memory_read(pgd + l1 * 4, &pde, 4);
+        pde = le32_to_cpu(pde);
+        if (pde & PG_PRESENT_MASK) {
+            if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
+                /* 4M pages */
+                print_pte(mon, (l1 << 22), pde, ~((1 << 21) - 1));
+            } else {
+                for(l2 = 0; l2 < 1024; l2++) {
+                    cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, &pte, 4);
+                    pte = le32_to_cpu(pte);
+                    if (pte & PG_PRESENT_MASK) {
+                        print_pte(mon, (l1 << 22) + (l2 << 12),
+                                  pte & ~PG_PSE_MASK,
+                                  ~0xfff);
+                    }
+                }
+            }
+        }
+    }
+}
+
+static void tlb_info_pae32(Monitor *mon, CPUArchState *env)
+{
+    unsigned int l1, l2, l3;
+    uint64_t pdpe, pde, pte;
+    uint64_t pdp_addr, pd_addr, pt_addr;
+
+    pdp_addr = env->cr[3] & ~0x1f;
+    for (l1 = 0; l1 < 4; l1++) {
+        cpu_physical_memory_read(pdp_addr + l1 * 8, &pdpe, 8);
+        pdpe = le64_to_cpu(pdpe);
+        if (pdpe & PG_PRESENT_MASK) {
+            pd_addr = pdpe & 0x3fffffffff000ULL;
+            for (l2 = 0; l2 < 512; l2++) {
+                cpu_physical_memory_read(pd_addr + l2 * 8, &pde, 8);
+                pde = le64_to_cpu(pde);
+                if (pde & PG_PRESENT_MASK) {
+                    if (pde & PG_PSE_MASK) {
+                        /* 2M pages with PAE, CR4.PSE is ignored */
+                        print_pte(mon, (l1 << 30 ) + (l2 << 21), pde,
+                                  ~((hwaddr)(1 << 20) - 1));
+                    } else {
+                        pt_addr = pde & 0x3fffffffff000ULL;
+                        for (l3 = 0; l3 < 512; l3++) {
+                            cpu_physical_memory_read(pt_addr + l3 * 8, &pte, 8);
+                            pte = le64_to_cpu(pte);
+                            if (pte & PG_PRESENT_MASK) {
+                                print_pte(mon, (l1 << 30 ) + (l2 << 21)
+                                          + (l3 << 12),
+                                          pte & ~PG_PSE_MASK,
+                                          ~(hwaddr)0xfff);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+#ifdef TARGET_X86_64
+static void tlb_info_64(Monitor *mon, CPUArchState *env)
+{
+    uint64_t l1, l2, l3, l4;
+    uint64_t pml4e, pdpe, pde, pte;
+    uint64_t pml4_addr, pdp_addr, pd_addr, pt_addr;
+
+    pml4_addr = env->cr[3] & 0x3fffffffff000ULL;
+    for (l1 = 0; l1 < 512; l1++) {
+        cpu_physical_memory_read(pml4_addr + l1 * 8, &pml4e, 8);
+        pml4e = le64_to_cpu(pml4e);
+        if (pml4e & PG_PRESENT_MASK) {
+            pdp_addr = pml4e & 0x3fffffffff000ULL;
+            for (l2 = 0; l2 < 512; l2++) {
+                cpu_physical_memory_read(pdp_addr + l2 * 8, &pdpe, 8);
+                pdpe = le64_to_cpu(pdpe);
+                if (pdpe & PG_PRESENT_MASK) {
+                    if (pdpe & PG_PSE_MASK) {
+                        /* 1G pages, CR4.PSE is ignored */
+                        print_pte(mon, (l1 << 39) + (l2 << 30), pdpe,
+                                  0x3ffffc0000000ULL);
+                    } else {
+                        pd_addr = pdpe & 0x3fffffffff000ULL;
+                        for (l3 = 0; l3 < 512; l3++) {
+                            cpu_physical_memory_read(pd_addr + l3 * 8, &pde, 8);
+                            pde = le64_to_cpu(pde);
+                            if (pde & PG_PRESENT_MASK) {
+                                if (pde & PG_PSE_MASK) {
+                                    /* 2M pages, CR4.PSE is ignored */
+                                    print_pte(mon, (l1 << 39) + (l2 << 30) +
+                                              (l3 << 21), pde,
+                                              0x3ffffffe00000ULL);
+                                } else {
+                                    pt_addr = pde & 0x3fffffffff000ULL;
+                                    for (l4 = 0; l4 < 512; l4++) {
+                                        cpu_physical_memory_read(pt_addr
+                                                                 + l4 * 8,
+                                                                 &pte, 8);
+                                        pte = le64_to_cpu(pte);
+                                        if (pte & PG_PRESENT_MASK) {
+                                            print_pte(mon, (l1 << 39) +
+                                                      (l2 << 30) +
+                                                      (l3 << 21) + (l4 << 12),
+                                                      pte & ~PG_PSE_MASK,
+                                                      0x3fffffffff000ULL);
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+#endif
+
+void tlb_info(Monitor *mon, const QDict *qdict)
+{
+    CPUArchState *env;
+
+    env = mon_get_cpu();
+
+    if (!(env->cr[0] & CR0_PG_MASK)) {
+        monitor_printf(mon, "PG disabled\n");
+        return;
+    }
+    if (env->cr[4] & CR4_PAE_MASK) {
+#ifdef TARGET_X86_64
+        if (env->hflags & HF_LMA_MASK) {
+            tlb_info_64(mon, env);
+        } else
+#endif
+        {
+            tlb_info_pae32(mon, env);
+        }
+    } else {
+        tlb_info_32(mon, env);
+    }
+}
+
+static void mem_print(Monitor *mon, hwaddr *pstart,
+                      int *plast_prot,
+                      hwaddr end, int prot)
+{
+    int prot1;
+    prot1 = *plast_prot;
+    if (prot != prot1) {
+        if (*pstart != -1) {
+            monitor_printf(mon, TARGET_FMT_plx "-" TARGET_FMT_plx " "
+                           TARGET_FMT_plx " %c%c%c\n",
+                           *pstart, end, end - *pstart,
+                           prot1 & PG_USER_MASK ? 'u' : '-',
+                           'r',
+                           prot1 & PG_RW_MASK ? 'w' : '-');
+        }
+        if (prot != 0)
+            *pstart = end;
+        else
+            *pstart = -1;
+        *plast_prot = prot;
+    }
+}
+
+static void mem_info_32(Monitor *mon, CPUArchState *env)
+{
+    unsigned int l1, l2;
+    int prot, last_prot;
+    uint32_t pgd, pde, pte;
+    hwaddr start, end;
+
+    pgd = env->cr[3] & ~0xfff;
+    last_prot = 0;
+    start = -1;
+    for(l1 = 0; l1 < 1024; l1++) {
+        cpu_physical_memory_read(pgd + l1 * 4, &pde, 4);
+        pde = le32_to_cpu(pde);
+        end = l1 << 22;
+        if (pde & PG_PRESENT_MASK) {
+            if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
+                prot = pde & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);
+                mem_print(mon, &start, &last_prot, end, prot);
+            } else {
+                for(l2 = 0; l2 < 1024; l2++) {
+                    cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, &pte, 4);
+                    pte = le32_to_cpu(pte);
+                    end = (l1 << 22) + (l2 << 12);
+                    if (pte & PG_PRESENT_MASK) {
+                        prot = pte & pde &
+                            (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);
+                    } else {
+                        prot = 0;
+                    }
+                    mem_print(mon, &start, &last_prot, end, prot);
+                }
+            }
+        } else {
+            prot = 0;
+            mem_print(mon, &start, &last_prot, end, prot);
+        }
+    }
+    /* Flush last range */
+    mem_print(mon, &start, &last_prot, (hwaddr)1 << 32, 0);
+}
+
+static void mem_info_pae32(Monitor *mon, CPUArchState *env)
+{
+    unsigned int l1, l2, l3;
+    int prot, last_prot;
+    uint64_t pdpe, pde, pte;
+    uint64_t pdp_addr, pd_addr, pt_addr;
+    hwaddr start, end;
+
+    pdp_addr = env->cr[3] & ~0x1f;
+    last_prot = 0;
+    start = -1;
+    for (l1 = 0; l1 < 4; l1++) {
+        cpu_physical_memory_read(pdp_addr + l1 * 8, &pdpe, 8);
+        pdpe = le64_to_cpu(pdpe);
+        end = l1 << 30;
+        if (pdpe & PG_PRESENT_MASK) {
+            pd_addr = pdpe & 0x3fffffffff000ULL;
+            for (l2 = 0; l2 < 512; l2++) {
+                cpu_physical_memory_read(pd_addr + l2 * 8, &pde, 8);
+                pde = le64_to_cpu(pde);
+                end = (l1 << 30) + (l2 << 21);
+                if (pde & PG_PRESENT_MASK) {
+                    if (pde & PG_PSE_MASK) {
+                        prot = pde & (PG_USER_MASK | PG_RW_MASK |
+                                      PG_PRESENT_MASK);
+                        mem_print(mon, &start, &last_prot, end, prot);
+                    } else {
+                        pt_addr = pde & 0x3fffffffff000ULL;
+                        for (l3 = 0; l3 < 512; l3++) {
+                            cpu_physical_memory_read(pt_addr + l3 * 8, &pte, 8);
+                            pte = le64_to_cpu(pte);
+                            end = (l1 << 30) + (l2 << 21) + (l3 << 12);
+                            if (pte & PG_PRESENT_MASK) {
+                                prot = pte & pde & (PG_USER_MASK | PG_RW_MASK |
+                                                    PG_PRESENT_MASK);
+                            } else {
+                                prot = 0;
+                            }
+                            mem_print(mon, &start, &last_prot, end, prot);
+                        }
+                    }
+                } else {
+                    prot = 0;
+                    mem_print(mon, &start, &last_prot, end, prot);
+                }
+            }
+        } else {
+            prot = 0;
+            mem_print(mon, &start, &last_prot, end, prot);
+        }
+    }
+    /* Flush last range */
+    mem_print(mon, &start, &last_prot, (hwaddr)1 << 32, 0);
+}
+
+
+#ifdef TARGET_X86_64
+static void mem_info_64(Monitor *mon, CPUArchState *env)
+{
+    int prot, last_prot;
+    uint64_t l1, l2, l3, l4;
+    uint64_t pml4e, pdpe, pde, pte;
+    uint64_t pml4_addr, pdp_addr, pd_addr, pt_addr, start, end;
+
+    pml4_addr = env->cr[3] & 0x3fffffffff000ULL;
+    last_prot = 0;
+    start = -1;
+    for (l1 = 0; l1 < 512; l1++) {
+        cpu_physical_memory_read(pml4_addr + l1 * 8, &pml4e, 8);
+        pml4e = le64_to_cpu(pml4e);
+        end = l1 << 39;
+        if (pml4e & PG_PRESENT_MASK) {
+            pdp_addr = pml4e & 0x3fffffffff000ULL;
+            for (l2 = 0; l2 < 512; l2++) {
+                cpu_physical_memory_read(pdp_addr + l2 * 8, &pdpe, 8);
+                pdpe = le64_to_cpu(pdpe);
+                end = (l1 << 39) + (l2 << 30);
+                if (pdpe & PG_PRESENT_MASK) {
+                    if (pdpe & PG_PSE_MASK) {
+                        prot = pdpe & (PG_USER_MASK | PG_RW_MASK |
+                                       PG_PRESENT_MASK);
+                        prot &= pml4e;
+                        mem_print(mon, &start, &last_prot, end, prot);
+                    } else {
+                        pd_addr = pdpe & 0x3fffffffff000ULL;
+                        for (l3 = 0; l3 < 512; l3++) {
+                            cpu_physical_memory_read(pd_addr + l3 * 8, &pde, 8);
+                            pde = le64_to_cpu(pde);
+                            end = (l1 << 39) + (l2 << 30) + (l3 << 21);
+                            if (pde & PG_PRESENT_MASK) {
+                                if (pde & PG_PSE_MASK) {
+                                    prot = pde & (PG_USER_MASK | PG_RW_MASK |
+                                                  PG_PRESENT_MASK);
+                                    prot &= pml4e & pdpe;
+                                    mem_print(mon, &start, &last_prot, end, prot);
+                                } else {
+                                    pt_addr = pde & 0x3fffffffff000ULL;
+                                    for (l4 = 0; l4 < 512; l4++) {
+                                        cpu_physical_memory_read(pt_addr
+                                                                 + l4 * 8,
+                                                                 &pte, 8);
+                                        pte = le64_to_cpu(pte);
+                                        end = (l1 << 39) + (l2 << 30) +
+                                            (l3 << 21) + (l4 << 12);
+                                        if (pte & PG_PRESENT_MASK) {
+                                            prot = pte & (PG_USER_MASK | PG_RW_MASK |
+                                                          PG_PRESENT_MASK);
+                                            prot &= pml4e & pdpe & pde;
+                                        } else {
+                                            prot = 0;
+                                        }
+                                        mem_print(mon, &start, &last_prot, end, prot);
+                                    }
+                                }
+                            } else {
+                                prot = 0;
+                                mem_print(mon, &start, &last_prot, end, prot);
+                            }
+                        }
+                    }
+                } else {
+                    prot = 0;
+                    mem_print(mon, &start, &last_prot, end, prot);
+                }
+            }
+        } else {
+            prot = 0;
+            mem_print(mon, &start, &last_prot, end, prot);
+        }
+    }
+    /* Flush last range */
+    mem_print(mon, &start, &last_prot, (hwaddr)1 << 48, 0);
+}
+#endif
+
+void mem_info(Monitor *mon, const QDict *qdict)
+{
+    CPUArchState *env;
+
+    env = mon_get_cpu();
+
+    if (!(env->cr[0] & CR0_PG_MASK)) {
+        monitor_printf(mon, "PG disabled\n");
+        return;
+    }
+    if (env->cr[4] & CR4_PAE_MASK) {
+#ifdef TARGET_X86_64
+        if (env->hflags & HF_LMA_MASK) {
+            mem_info_64(mon, env);
+        } else
+#endif
+        {
+            mem_info_pae32(mon, env);
+        }
+    } else {
+        mem_info_32(mon, env);
+    }
+}
+#endif
+
+#if defined(TARGET_SH4)
+
+static void print_tlb(Monitor *mon, int idx, tlb_t *tlb)
+{
+    monitor_printf(mon, " tlb%i:\t"
+                   "asid=%hhu vpn=%x\tppn=%x\tsz=%hhu size=%u\t"
+                   "v=%hhu shared=%hhu cached=%hhu prot=%hhu "
+                   "dirty=%hhu writethrough=%hhu\n",
+                   idx,
+                   tlb->asid, tlb->vpn, tlb->ppn, tlb->sz, tlb->size,
+                   tlb->v, tlb->sh, tlb->c, tlb->pr,
+                   tlb->d, tlb->wt);
+}
+
+void tlb_info(Monitor *mon, const QDict *qdict)
+{
+    CPUArchState *env = mon_get_cpu();
+    int i;
+
+    monitor_printf (mon, "ITLB:\n");
+    for (i = 0 ; i < ITLB_SIZE ; i++)
+        print_tlb (mon, i, &env->itlb[i]);
+    monitor_printf (mon, "UTLB:\n");
+    for (i = 0 ; i < UTLB_SIZE ; i++)
+        print_tlb (mon, i, &env->utlb[i]);
+}
+
+#endif
+
+#if defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_XTENSA)
+void tlb_info(Monitor *mon, const QDict *qdict)
+{
+    CPUArchState *env1 = mon_get_cpu();
+
+    dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1);
+}
+#endif
+
+void do_info_mtree(Monitor *mon, const QDict *qdict)
+{
+    mtree_info((fprintf_function)monitor_printf, mon);
+}
+
+void do_info_numa(Monitor *mon, const QDict *qdict)
+{
+    int i;
+    CPUState *cpu;
+
+    monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
+    for (i = 0; i < nb_numa_nodes; i++) {
+        monitor_printf(mon, "node %d cpus:", i);
+        CPU_FOREACH(cpu) {
+            if (cpu->numa_node == i) {
+                monitor_printf(mon, " %d", cpu->cpu_index);
+            }
+        }
+        monitor_printf(mon, "\n");
+        monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
+            numa_info[i].node_mem >> 20);
+    }
+}
+
+#ifdef CONFIG_PROFILER
+
+int64_t qemu_time;
+int64_t dev_time;
+
+void do_info_profile(Monitor *mon, const QDict *qdict)
+{
+    monitor_printf(mon, "async time  %" PRId64 " (%0.3f)\n",
+                   dev_time, dev_time / (double)get_ticks_per_sec());
+    monitor_printf(mon, "qemu time   %" PRId64 " (%0.3f)\n",
+                   qemu_time, qemu_time / (double)get_ticks_per_sec());
+    qemu_time = 0;
+    dev_time = 0;
+}
+#else
+void do_info_profile(Monitor *mon, const QDict *qdict)
+{
+    monitor_printf(mon, "Internal profiler not compiled\n");
+}
+#endif
+
+/* Capture support */
+static QLIST_HEAD (capture_list_head, CaptureState) capture_head;
+
+void do_info_capture(Monitor *mon, const QDict *qdict)
+{
+    int i;
+    CaptureState *s;
+
+    for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) {
+        monitor_printf(mon, "[%d]: ", i);
+        s->ops.info (s->opaque);
+    }
+}
+
+void do_stop_capture(Monitor *mon, const QDict *qdict)
+{
+    int i;
+    int n = qdict_get_int(qdict, "n");
+    CaptureState *s;
+
+    for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) {
+        if (i == n) {
+            s->ops.destroy (s->opaque);
+            QLIST_REMOVE (s, entries);
+            g_free (s);
+            return;
+        }
+    }
+}
+
+void do_wav_capture(Monitor *mon, const QDict *qdict)
+{
+    const char *path = qdict_get_str(qdict, "path");
+    int has_freq = qdict_haskey(qdict, "freq");
+    int freq = qdict_get_try_int(qdict, "freq", -1);
+    int has_bits = qdict_haskey(qdict, "bits");
+    int bits = qdict_get_try_int(qdict, "bits", -1);
+    int has_channels = qdict_haskey(qdict, "nchannels");
+    int nchannels = qdict_get_try_int(qdict, "nchannels", -1);
+    CaptureState *s;
+
+    s = g_malloc0 (sizeof (*s));
+
+    freq = has_freq ? freq : 44100;
+    bits = has_bits ? bits : 16;
+    nchannels = has_channels ? nchannels : 2;
+
+    if (wav_start_capture (s, path, freq, bits, nchannels)) {
+        monitor_printf(mon, "Failed to add wave capture\n");
+        g_free (s);
+        return;
+    }
+    QLIST_INSERT_HEAD (&capture_head, s, entries);
+}
+
+static qemu_acl *find_acl(Monitor *mon, const char *name)
+{
+    qemu_acl *acl = qemu_acl_find(name);
+
+    if (!acl) {
+        monitor_printf(mon, "acl: unknown list '%s'\n", name);
+    }
+    return acl;
+}
+
+void do_acl_show(Monitor *mon, const QDict *qdict)
+{
+    const char *aclname = qdict_get_str(qdict, "aclname");
+    qemu_acl *acl = find_acl(mon, aclname);
+    qemu_acl_entry *entry;
+    int i = 0;
+
+    if (acl) {
+        monitor_printf(mon, "policy: %s\n",
+                       acl->defaultDeny ? "deny" : "allow");
+        QTAILQ_FOREACH(entry, &acl->entries, next) {
+            i++;
+            monitor_printf(mon, "%d: %s %s\n", i,
+                           entry->deny ? "deny" : "allow", entry->match);
+        }
+    }
+}
+
+void do_acl_reset(Monitor *mon, const QDict *qdict)
+{
+    const char *aclname = qdict_get_str(qdict, "aclname");
+    qemu_acl *acl = find_acl(mon, aclname);
+
+    if (acl) {
+        qemu_acl_reset(acl);
+        monitor_printf(mon, "acl: removed all rules\n");
+    }
+}
+
+void do_acl_policy(Monitor *mon, const QDict *qdict)
+{
+    const char *aclname = qdict_get_str(qdict, "aclname");
+    const char *policy = qdict_get_str(qdict, "policy");
+    qemu_acl *acl = find_acl(mon, aclname);
+
+    if (acl) {
+        if (strcmp(policy, "allow") == 0) {
+            acl->defaultDeny = 0;
+            monitor_printf(mon, "acl: policy set to 'allow'\n");
+        } else if (strcmp(policy, "deny") == 0) {
+            acl->defaultDeny = 1;
+            monitor_printf(mon, "acl: policy set to 'deny'\n");
+        } else {
+            monitor_printf(mon, "acl: unknown policy '%s', "
+                           "expected 'deny' or 'allow'\n", policy);
+        }
+    }
+}
+
+void do_acl_add(Monitor *mon, const QDict *qdict)
+{
+    const char *aclname = qdict_get_str(qdict, "aclname");
+    const char *match = qdict_get_str(qdict, "match");
+    const char *policy = qdict_get_str(qdict, "policy");
+    int has_index = qdict_haskey(qdict, "index");
+    int index = qdict_get_try_int(qdict, "index", -1);
+    qemu_acl *acl = find_acl(mon, aclname);
+    int deny, ret;
+
+    if (acl) {
+        if (strcmp(policy, "allow") == 0) {
+            deny = 0;
+        } else if (strcmp(policy, "deny") == 0) {
+            deny = 1;
+        } else {
+            monitor_printf(mon, "acl: unknown policy '%s', "
+                           "expected 'deny' or 'allow'\n", policy);
+            return;
+        }
+        if (has_index)
+            ret = qemu_acl_insert(acl, deny, match, index);
+        else
+            ret = qemu_acl_append(acl, deny, match);
+        if (ret < 0)
+            monitor_printf(mon, "acl: unable to add acl entry\n");
+        else
+            monitor_printf(mon, "acl: added rule at position %d\n", ret);
+    }
+}
+
+void do_acl_remove(Monitor *mon, const QDict *qdict)
+{
+    const char *aclname = qdict_get_str(qdict, "aclname");
+    const char *match = qdict_get_str(qdict, "match");
+    qemu_acl *acl = find_acl(mon, aclname);
+    int ret;
+
+    if (acl) {
+        ret = qemu_acl_remove(acl, match);
+        if (ret < 0)
+            monitor_printf(mon, "acl: no matching acl entry\n");
+        else
+            monitor_printf(mon, "acl: removed rule at position %d\n", ret);
+    }
+}
+
+#if defined(TARGET_I386)
+void do_inject_mce(Monitor *mon, const QDict *qdict)
+{
+    X86CPU *cpu;
+    CPUState *cs;
+    int cpu_index = qdict_get_int(qdict, "cpu_index");
+    int bank = qdict_get_int(qdict, "bank");
+    uint64_t status = qdict_get_int(qdict, "status");
+    uint64_t mcg_status = qdict_get_int(qdict, "mcg_status");
+    uint64_t addr = qdict_get_int(qdict, "addr");
+    uint64_t misc = qdict_get_int(qdict, "misc");
+    int flags = MCE_INJECT_UNCOND_AO;
+
+    if (qdict_get_try_bool(qdict, "broadcast", 0)) {
+        flags |= MCE_INJECT_BROADCAST;
+    }
+    cs = qemu_get_cpu(cpu_index);
+    if (cs != NULL) {
+        cpu = X86_CPU(cs);
+        cpu_x86_inject_mce(mon, cpu, bank, status, mcg_status, addr, misc,
+                           flags);
+    }
+}
+#endif
diff --git a/monitor.c b/monitor.c
index 371374f..06c70dd 100644
--- a/monitor.c
+++ b/monitor.c
@@ -772,1168 +772,6 @@ EventInfoList *qmp_query_events(Error **errp)
     return ev_list;
 }
 
-/* set the current CPU defined by the user */
-int monitor_set_cpu(int cpu_index)
-{
-    CPUState *cpu;
-
-    cpu = qemu_get_cpu(cpu_index);
-    if (cpu == NULL) {
-        return -1;
-    }
-    cur_mon->mon_cpu = cpu;
-    return 0;
-}
-
-static CPUArchState *mon_get_cpu(void)
-{
-    if (!cur_mon->mon_cpu) {
-        monitor_set_cpu(0);
-    }
-    cpu_synchronize_state(cur_mon->mon_cpu);
-    return cur_mon->mon_cpu->env_ptr;
-}
-
-int monitor_get_cpu_index(void)
-{
-    CPUState *cpu = ENV_GET_CPU(mon_get_cpu());
-    return cpu->cpu_index;
-}
-
-static void do_info_registers(Monitor *mon, const QDict *qdict)
-{
-    CPUState *cpu;
-    CPUArchState *env;
-    env = mon_get_cpu();
-    cpu = ENV_GET_CPU(env);
-    cpu_dump_state(cpu, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU);
-}
-
-static void do_info_jit(Monitor *mon, const QDict *qdict)
-{
-    dump_exec_info((FILE *)mon, monitor_fprintf);
-}
-
-static void do_info_history(Monitor *mon, const QDict *qdict)
-{
-    int i;
-    const char *str;
-
-    if (!mon->rs)
-        return;
-    i = 0;
-    for(;;) {
-        str = readline_get_history(mon->rs, i);
-        if (!str)
-            break;
-        monitor_printf(mon, "%d: '%s'\n", i, str);
-        i++;
-    }
-}
-
-static void do_info_cpu_stats(Monitor *mon, const QDict *qdict)
-{
-    CPUState *cpu;
-    CPUArchState *env;
-
-    env = mon_get_cpu();
-    cpu = ENV_GET_CPU(env);
-    cpu_dump_statistics(cpu, (FILE *)mon, &monitor_fprintf, 0);
-}
-
-static void do_trace_print_events(Monitor *mon, const QDict *qdict)
-{
-    trace_print_events((FILE *)mon, &monitor_fprintf);
-}
-
-static int client_migrate_info(Monitor *mon, const QDict *qdict,
-                               MonitorCompletion cb, void *opaque)
-{
-    const char *protocol = qdict_get_str(qdict, "protocol");
-    const char *hostname = qdict_get_str(qdict, "hostname");
-    const char *subject  = qdict_get_try_str(qdict, "cert-subject");
-    int port             = qdict_get_try_int(qdict, "port", -1);
-    int tls_port         = qdict_get_try_int(qdict, "tls-port", -1);
-    int ret;
-
-    if (strcmp(protocol, "spice") == 0) {
-        if (!using_spice) {
-            qerror_report(QERR_DEVICE_NOT_ACTIVE, "spice");
-            return -1;
-        }
-
-        if (port == -1 && tls_port == -1) {
-            qerror_report(QERR_MISSING_PARAMETER, "port/tls-port");
-            return -1;
-        }
-
-        ret = qemu_spice_migrate_info(hostname, port, tls_port, subject,
-                                      cb, opaque);
-        if (ret != 0) {
-            qerror_report(QERR_UNDEFINED_ERROR);
-            return -1;
-        }
-        return 0;
-    }
-
-    qerror_report(QERR_INVALID_PARAMETER, "protocol");
-    return -1;
-}
-
-static void do_logfile(Monitor *mon, const QDict *qdict)
-{
-    qemu_set_log_filename(qdict_get_str(qdict, "filename"));
-}
-
-static void do_log(Monitor *mon, const QDict *qdict)
-{
-    int mask;
-    const char *items = qdict_get_str(qdict, "items");
-
-    if (!strcmp(items, "none")) {
-        mask = 0;
-    } else {
-        mask = qemu_str_to_log_mask(items);
-        if (!mask) {
-            help_cmd(mon, "log");
-            return;
-        }
-    }
-    qemu_set_log(mask);
-}
-
-static void do_singlestep(Monitor *mon, const QDict *qdict)
-{
-    const char *option = qdict_get_try_str(qdict, "option");
-    if (!option || !strcmp(option, "on")) {
-        singlestep = 1;
-    } else if (!strcmp(option, "off")) {
-        singlestep = 0;
-    } else {
-        monitor_printf(mon, "unexpected option %s\n", option);
-    }
-}
-
-static void do_gdbserver(Monitor *mon, const QDict *qdict)
-{
-    const char *device = qdict_get_try_str(qdict, "device");
-    if (!device)
-        device = "tcp::" DEFAULT_GDBSTUB_PORT;
-    if (gdbserver_start(device) < 0) {
-        monitor_printf(mon, "Could not open gdbserver on device '%s'\n",
-                       device);
-    } else if (strcmp(device, "none") == 0) {
-        monitor_printf(mon, "Disabled gdbserver\n");
-    } else {
-        monitor_printf(mon, "Waiting for gdb connection on device '%s'\n",
-                       device);
-    }
-}
-
-static void do_watchdog_action(Monitor *mon, const QDict *qdict)
-{
-    const char *action = qdict_get_str(qdict, "action");
-    if (select_watchdog_action(action) == -1) {
-        monitor_printf(mon, "Unknown watchdog action '%s'\n", action);
-    }
-}
-
-static void monitor_printc(Monitor *mon, int c)
-{
-    monitor_printf(mon, "'");
-    switch(c) {
-    case '\'':
-        monitor_printf(mon, "\\'");
-        break;
-    case '\\':
-        monitor_printf(mon, "\\\\");
-        break;
-    case '\n':
-        monitor_printf(mon, "\\n");
-        break;
-    case '\r':
-        monitor_printf(mon, "\\r");
-        break;
-    default:
-        if (c >= 32 && c <= 126) {
-            monitor_printf(mon, "%c", c);
-        } else {
-            monitor_printf(mon, "\\x%02x", c);
-        }
-        break;
-    }
-    monitor_printf(mon, "'");
-}
-
-static void memory_dump(Monitor *mon, int count, int format, int wsize,
-                        hwaddr addr, int is_physical)
-{
-    CPUArchState *env;
-    int l, line_size, i, max_digits, len;
-    uint8_t buf[16];
-    uint64_t v;
-
-    if (format == 'i') {
-        int flags;
-        flags = 0;
-        env = mon_get_cpu();
-#ifdef TARGET_I386
-        if (wsize == 2) {
-            flags = 1;
-        } else if (wsize == 4) {
-            flags = 0;
-        } else {
-            /* as default we use the current CS size */
-            flags = 0;
-            if (env) {
-#ifdef TARGET_X86_64
-                if ((env->efer & MSR_EFER_LMA) &&
-                    (env->segs[R_CS].flags & DESC_L_MASK))
-                    flags = 2;
-                else
-#endif
-                if (!(env->segs[R_CS].flags & DESC_B_MASK))
-                    flags = 1;
-            }
-        }
-#endif
-#ifdef TARGET_PPC
-        flags = msr_le << 16;
-        flags |= env->bfd_mach;
-#endif
-        monitor_disas(mon, env, addr, count, is_physical, flags);
-        return;
-    }
-
-    len = wsize * count;
-    if (wsize == 1)
-        line_size = 8;
-    else
-        line_size = 16;
-    max_digits = 0;
-
-    switch(format) {
-    case 'o':
-        max_digits = (wsize * 8 + 2) / 3;
-        break;
-    default:
-    case 'x':
-        max_digits = (wsize * 8) / 4;
-        break;
-    case 'u':
-    case 'd':
-        max_digits = (wsize * 8 * 10 + 32) / 33;
-        break;
-    case 'c':
-        wsize = 1;
-        break;
-    }
-
-    while (len > 0) {
-        if (is_physical)
-            monitor_printf(mon, TARGET_FMT_plx ":", addr);
-        else
-            monitor_printf(mon, TARGET_FMT_lx ":", (target_ulong)addr);
-        l = len;
-        if (l > line_size)
-            l = line_size;
-        if (is_physical) {
-            cpu_physical_memory_read(addr, buf, l);
-        } else {
-            env = mon_get_cpu();
-            if (cpu_memory_rw_debug(ENV_GET_CPU(env), addr, buf, l, 0) < 0) {
-                monitor_printf(mon, " Cannot access memory\n");
-                break;
-            }
-        }
-        i = 0;
-        while (i < l) {
-            switch(wsize) {
-            default:
-            case 1:
-                v = ldub_raw(buf + i);
-                break;
-            case 2:
-                v = lduw_raw(buf + i);
-                break;
-            case 4:
-                v = (uint32_t)ldl_raw(buf + i);
-                break;
-            case 8:
-                v = ldq_raw(buf + i);
-                break;
-            }
-            monitor_printf(mon, " ");
-            switch(format) {
-            case 'o':
-                monitor_printf(mon, "%#*" PRIo64, max_digits, v);
-                break;
-            case 'x':
-                monitor_printf(mon, "0x%0*" PRIx64, max_digits, v);
-                break;
-            case 'u':
-                monitor_printf(mon, "%*" PRIu64, max_digits, v);
-                break;
-            case 'd':
-                monitor_printf(mon, "%*" PRId64, max_digits, v);
-                break;
-            case 'c':
-                monitor_printc(mon, v);
-                break;
-            }
-            i += wsize;
-        }
-        monitor_printf(mon, "\n");
-        addr += l;
-        len -= l;
-    }
-}
-
-static void do_memory_dump(Monitor *mon, const QDict *qdict)
-{
-    int count = qdict_get_int(qdict, "count");
-    int format = qdict_get_int(qdict, "format");
-    int size = qdict_get_int(qdict, "size");
-    target_long addr = qdict_get_int(qdict, "addr");
-
-    memory_dump(mon, count, format, size, addr, 0);
-}
-
-static void do_physical_memory_dump(Monitor *mon, const QDict *qdict)
-{
-    int count = qdict_get_int(qdict, "count");
-    int format = qdict_get_int(qdict, "format");
-    int size = qdict_get_int(qdict, "size");
-    hwaddr addr = qdict_get_int(qdict, "addr");
-
-    memory_dump(mon, count, format, size, addr, 1);
-}
-
-static void do_print(Monitor *mon, const QDict *qdict)
-{
-    int format = qdict_get_int(qdict, "format");
-    hwaddr val = qdict_get_int(qdict, "val");
-
-    switch(format) {
-    case 'o':
-        monitor_printf(mon, "%#" HWADDR_PRIo, val);
-        break;
-    case 'x':
-        monitor_printf(mon, "%#" HWADDR_PRIx, val);
-        break;
-    case 'u':
-        monitor_printf(mon, "%" HWADDR_PRIu, val);
-        break;
-    default:
-    case 'd':
-        monitor_printf(mon, "%" HWADDR_PRId, val);
-        break;
-    case 'c':
-        monitor_printc(mon, val);
-        break;
-    }
-    monitor_printf(mon, "\n");
-}
-
-static void do_sum(Monitor *mon, const QDict *qdict)
-{
-    uint32_t addr;
-    uint16_t sum;
-    uint32_t start = qdict_get_int(qdict, "start");
-    uint32_t size = qdict_get_int(qdict, "size");
-
-    sum = 0;
-    for(addr = start; addr < (start + size); addr++) {
-        uint8_t val = ldub_phys(&address_space_memory, addr);
-        /* BSD sum algorithm ('sum' Unix command) */
-        sum = (sum >> 1) | (sum << 15);
-        sum += val;
-    }
-    monitor_printf(mon, "%05d\n", sum);
-}
-
-static int mouse_button_state;
-
-static void do_mouse_move(Monitor *mon, const QDict *qdict)
-{
-    int dx, dy, dz, button;
-    const char *dx_str = qdict_get_str(qdict, "dx_str");
-    const char *dy_str = qdict_get_str(qdict, "dy_str");
-    const char *dz_str = qdict_get_try_str(qdict, "dz_str");
-
-    dx = strtol(dx_str, NULL, 0);
-    dy = strtol(dy_str, NULL, 0);
-    qemu_input_queue_rel(NULL, INPUT_AXIS_X, dx);
-    qemu_input_queue_rel(NULL, INPUT_AXIS_Y, dy);
-
-    if (dz_str) {
-        dz = strtol(dz_str, NULL, 0);
-        if (dz != 0) {
-            button = (dz > 0) ? INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
-            qemu_input_queue_btn(NULL, button, true);
-            qemu_input_event_sync();
-            qemu_input_queue_btn(NULL, button, false);
-        }
-    }
-    qemu_input_event_sync();
-}
-
-static void do_mouse_button(Monitor *mon, const QDict *qdict)
-{
-    static uint32_t bmap[INPUT_BUTTON_MAX] = {
-        [INPUT_BUTTON_LEFT]       = MOUSE_EVENT_LBUTTON,
-        [INPUT_BUTTON_MIDDLE]     = MOUSE_EVENT_MBUTTON,
-        [INPUT_BUTTON_RIGHT]      = MOUSE_EVENT_RBUTTON,
-    };
-    int button_state = qdict_get_int(qdict, "button_state");
-
-    if (mouse_button_state == button_state) {
-        return;
-    }
-    qemu_input_update_buttons(NULL, bmap, mouse_button_state, button_state);
-    qemu_input_event_sync();
-    mouse_button_state = button_state;
-}
-
-static void do_ioport_read(Monitor *mon, const QDict *qdict)
-{
-    int size = qdict_get_int(qdict, "size");
-    int addr = qdict_get_int(qdict, "addr");
-    int has_index = qdict_haskey(qdict, "index");
-    uint32_t val;
-    int suffix;
-
-    if (has_index) {
-        int index = qdict_get_int(qdict, "index");
-        cpu_outb(addr & IOPORTS_MASK, index & 0xff);
-        addr++;
-    }
-    addr &= 0xffff;
-
-    switch(size) {
-    default:
-    case 1:
-        val = cpu_inb(addr);
-        suffix = 'b';
-        break;
-    case 2:
-        val = cpu_inw(addr);
-        suffix = 'w';
-        break;
-    case 4:
-        val = cpu_inl(addr);
-        suffix = 'l';
-        break;
-    }
-    monitor_printf(mon, "port%c[0x%04x] = %#0*x\n",
-                   suffix, addr, size * 2, val);
-}
-
-static void do_ioport_write(Monitor *mon, const QDict *qdict)
-{
-    int size = qdict_get_int(qdict, "size");
-    int addr = qdict_get_int(qdict, "addr");
-    int val = qdict_get_int(qdict, "val");
-
-    addr &= IOPORTS_MASK;
-
-    switch (size) {
-    default:
-    case 1:
-        cpu_outb(addr, val);
-        break;
-    case 2:
-        cpu_outw(addr, val);
-        break;
-    case 4:
-        cpu_outl(addr, val);
-        break;
-    }
-}
-
-static void do_boot_set(Monitor *mon, const QDict *qdict)
-{
-    int res;
-    const char *bootdevice = qdict_get_str(qdict, "bootdevice");
-
-    res = qemu_boot_set(bootdevice);
-    if (res == 0) {
-        monitor_printf(mon, "boot device list now set to %s\n", bootdevice);
-    } else if (res > 0) {
-        monitor_printf(mon, "setting boot device list failed\n");
-    } else {
-        monitor_printf(mon, "no function defined to set boot device list for "
-                       "this architecture\n");
-    }
-}
-
-#if defined(TARGET_I386)
-static void print_pte(Monitor *mon, hwaddr addr,
-                      hwaddr pte,
-                      hwaddr mask)
-{
-#ifdef TARGET_X86_64
-    if (addr & (1ULL << 47)) {
-        addr |= -1LL << 48;
-    }
-#endif
-    monitor_printf(mon, TARGET_FMT_plx ": " TARGET_FMT_plx
-                   " %c%c%c%c%c%c%c%c%c\n",
-                   addr,
-                   pte & mask,
-                   pte & PG_NX_MASK ? 'X' : '-',
-                   pte & PG_GLOBAL_MASK ? 'G' : '-',
-                   pte & PG_PSE_MASK ? 'P' : '-',
-                   pte & PG_DIRTY_MASK ? 'D' : '-',
-                   pte & PG_ACCESSED_MASK ? 'A' : '-',
-                   pte & PG_PCD_MASK ? 'C' : '-',
-                   pte & PG_PWT_MASK ? 'T' : '-',
-                   pte & PG_USER_MASK ? 'U' : '-',
-                   pte & PG_RW_MASK ? 'W' : '-');
-}
-
-static void tlb_info_32(Monitor *mon, CPUArchState *env)
-{
-    unsigned int l1, l2;
-    uint32_t pgd, pde, pte;
-
-    pgd = env->cr[3] & ~0xfff;
-    for(l1 = 0; l1 < 1024; l1++) {
-        cpu_physical_memory_read(pgd + l1 * 4, &pde, 4);
-        pde = le32_to_cpu(pde);
-        if (pde & PG_PRESENT_MASK) {
-            if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
-                /* 4M pages */
-                print_pte(mon, (l1 << 22), pde, ~((1 << 21) - 1));
-            } else {
-                for(l2 = 0; l2 < 1024; l2++) {
-                    cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, &pte, 4);
-                    pte = le32_to_cpu(pte);
-                    if (pte & PG_PRESENT_MASK) {
-                        print_pte(mon, (l1 << 22) + (l2 << 12),
-                                  pte & ~PG_PSE_MASK,
-                                  ~0xfff);
-                    }
-                }
-            }
-        }
-    }
-}
-
-static void tlb_info_pae32(Monitor *mon, CPUArchState *env)
-{
-    unsigned int l1, l2, l3;
-    uint64_t pdpe, pde, pte;
-    uint64_t pdp_addr, pd_addr, pt_addr;
-
-    pdp_addr = env->cr[3] & ~0x1f;
-    for (l1 = 0; l1 < 4; l1++) {
-        cpu_physical_memory_read(pdp_addr + l1 * 8, &pdpe, 8);
-        pdpe = le64_to_cpu(pdpe);
-        if (pdpe & PG_PRESENT_MASK) {
-            pd_addr = pdpe & 0x3fffffffff000ULL;
-            for (l2 = 0; l2 < 512; l2++) {
-                cpu_physical_memory_read(pd_addr + l2 * 8, &pde, 8);
-                pde = le64_to_cpu(pde);
-                if (pde & PG_PRESENT_MASK) {
-                    if (pde & PG_PSE_MASK) {
-                        /* 2M pages with PAE, CR4.PSE is ignored */
-                        print_pte(mon, (l1 << 30 ) + (l2 << 21), pde,
-                                  ~((hwaddr)(1 << 20) - 1));
-                    } else {
-                        pt_addr = pde & 0x3fffffffff000ULL;
-                        for (l3 = 0; l3 < 512; l3++) {
-                            cpu_physical_memory_read(pt_addr + l3 * 8, &pte, 8);
-                            pte = le64_to_cpu(pte);
-                            if (pte & PG_PRESENT_MASK) {
-                                print_pte(mon, (l1 << 30 ) + (l2 << 21)
-                                          + (l3 << 12),
-                                          pte & ~PG_PSE_MASK,
-                                          ~(hwaddr)0xfff);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-}
-
-#ifdef TARGET_X86_64
-static void tlb_info_64(Monitor *mon, CPUArchState *env)
-{
-    uint64_t l1, l2, l3, l4;
-    uint64_t pml4e, pdpe, pde, pte;
-    uint64_t pml4_addr, pdp_addr, pd_addr, pt_addr;
-
-    pml4_addr = env->cr[3] & 0x3fffffffff000ULL;
-    for (l1 = 0; l1 < 512; l1++) {
-        cpu_physical_memory_read(pml4_addr + l1 * 8, &pml4e, 8);
-        pml4e = le64_to_cpu(pml4e);
-        if (pml4e & PG_PRESENT_MASK) {
-            pdp_addr = pml4e & 0x3fffffffff000ULL;
-            for (l2 = 0; l2 < 512; l2++) {
-                cpu_physical_memory_read(pdp_addr + l2 * 8, &pdpe, 8);
-                pdpe = le64_to_cpu(pdpe);
-                if (pdpe & PG_PRESENT_MASK) {
-                    if (pdpe & PG_PSE_MASK) {
-                        /* 1G pages, CR4.PSE is ignored */
-                        print_pte(mon, (l1 << 39) + (l2 << 30), pdpe,
-                                  0x3ffffc0000000ULL);
-                    } else {
-                        pd_addr = pdpe & 0x3fffffffff000ULL;
-                        for (l3 = 0; l3 < 512; l3++) {
-                            cpu_physical_memory_read(pd_addr + l3 * 8, &pde, 8);
-                            pde = le64_to_cpu(pde);
-                            if (pde & PG_PRESENT_MASK) {
-                                if (pde & PG_PSE_MASK) {
-                                    /* 2M pages, CR4.PSE is ignored */
-                                    print_pte(mon, (l1 << 39) + (l2 << 30) +
-                                              (l3 << 21), pde,
-                                              0x3ffffffe00000ULL);
-                                } else {
-                                    pt_addr = pde & 0x3fffffffff000ULL;
-                                    for (l4 = 0; l4 < 512; l4++) {
-                                        cpu_physical_memory_read(pt_addr
-                                                                 + l4 * 8,
-                                                                 &pte, 8);
-                                        pte = le64_to_cpu(pte);
-                                        if (pte & PG_PRESENT_MASK) {
-                                            print_pte(mon, (l1 << 39) +
-                                                      (l2 << 30) +
-                                                      (l3 << 21) + (l4 << 12),
-                                                      pte & ~PG_PSE_MASK,
-                                                      0x3fffffffff000ULL);
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-}
-#endif
-
-static void tlb_info(Monitor *mon, const QDict *qdict)
-{
-    CPUArchState *env;
-
-    env = mon_get_cpu();
-
-    if (!(env->cr[0] & CR0_PG_MASK)) {
-        monitor_printf(mon, "PG disabled\n");
-        return;
-    }
-    if (env->cr[4] & CR4_PAE_MASK) {
-#ifdef TARGET_X86_64
-        if (env->hflags & HF_LMA_MASK) {
-            tlb_info_64(mon, env);
-        } else
-#endif
-        {
-            tlb_info_pae32(mon, env);
-        }
-    } else {
-        tlb_info_32(mon, env);
-    }
-}
-
-static void mem_print(Monitor *mon, hwaddr *pstart,
-                      int *plast_prot,
-                      hwaddr end, int prot)
-{
-    int prot1;
-    prot1 = *plast_prot;
-    if (prot != prot1) {
-        if (*pstart != -1) {
-            monitor_printf(mon, TARGET_FMT_plx "-" TARGET_FMT_plx " "
-                           TARGET_FMT_plx " %c%c%c\n",
-                           *pstart, end, end - *pstart,
-                           prot1 & PG_USER_MASK ? 'u' : '-',
-                           'r',
-                           prot1 & PG_RW_MASK ? 'w' : '-');
-        }
-        if (prot != 0)
-            *pstart = end;
-        else
-            *pstart = -1;
-        *plast_prot = prot;
-    }
-}
-
-static void mem_info_32(Monitor *mon, CPUArchState *env)
-{
-    unsigned int l1, l2;
-    int prot, last_prot;
-    uint32_t pgd, pde, pte;
-    hwaddr start, end;
-
-    pgd = env->cr[3] & ~0xfff;
-    last_prot = 0;
-    start = -1;
-    for(l1 = 0; l1 < 1024; l1++) {
-        cpu_physical_memory_read(pgd + l1 * 4, &pde, 4);
-        pde = le32_to_cpu(pde);
-        end = l1 << 22;
-        if (pde & PG_PRESENT_MASK) {
-            if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) {
-                prot = pde & (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);
-                mem_print(mon, &start, &last_prot, end, prot);
-            } else {
-                for(l2 = 0; l2 < 1024; l2++) {
-                    cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, &pte, 4);
-                    pte = le32_to_cpu(pte);
-                    end = (l1 << 22) + (l2 << 12);
-                    if (pte & PG_PRESENT_MASK) {
-                        prot = pte & pde &
-                            (PG_USER_MASK | PG_RW_MASK | PG_PRESENT_MASK);
-                    } else {
-                        prot = 0;
-                    }
-                    mem_print(mon, &start, &last_prot, end, prot);
-                }
-            }
-        } else {
-            prot = 0;
-            mem_print(mon, &start, &last_prot, end, prot);
-        }
-    }
-    /* Flush last range */
-    mem_print(mon, &start, &last_prot, (hwaddr)1 << 32, 0);
-}
-
-static void mem_info_pae32(Monitor *mon, CPUArchState *env)
-{
-    unsigned int l1, l2, l3;
-    int prot, last_prot;
-    uint64_t pdpe, pde, pte;
-    uint64_t pdp_addr, pd_addr, pt_addr;
-    hwaddr start, end;
-
-    pdp_addr = env->cr[3] & ~0x1f;
-    last_prot = 0;
-    start = -1;
-    for (l1 = 0; l1 < 4; l1++) {
-        cpu_physical_memory_read(pdp_addr + l1 * 8, &pdpe, 8);
-        pdpe = le64_to_cpu(pdpe);
-        end = l1 << 30;
-        if (pdpe & PG_PRESENT_MASK) {
-            pd_addr = pdpe & 0x3fffffffff000ULL;
-            for (l2 = 0; l2 < 512; l2++) {
-                cpu_physical_memory_read(pd_addr + l2 * 8, &pde, 8);
-                pde = le64_to_cpu(pde);
-                end = (l1 << 30) + (l2 << 21);
-                if (pde & PG_PRESENT_MASK) {
-                    if (pde & PG_PSE_MASK) {
-                        prot = pde & (PG_USER_MASK | PG_RW_MASK |
-                                      PG_PRESENT_MASK);
-                        mem_print(mon, &start, &last_prot, end, prot);
-                    } else {
-                        pt_addr = pde & 0x3fffffffff000ULL;
-                        for (l3 = 0; l3 < 512; l3++) {
-                            cpu_physical_memory_read(pt_addr + l3 * 8, &pte, 8);
-                            pte = le64_to_cpu(pte);
-                            end = (l1 << 30) + (l2 << 21) + (l3 << 12);
-                            if (pte & PG_PRESENT_MASK) {
-                                prot = pte & pde & (PG_USER_MASK | PG_RW_MASK |
-                                                    PG_PRESENT_MASK);
-                            } else {
-                                prot = 0;
-                            }
-                            mem_print(mon, &start, &last_prot, end, prot);
-                        }
-                    }
-                } else {
-                    prot = 0;
-                    mem_print(mon, &start, &last_prot, end, prot);
-                }
-            }
-        } else {
-            prot = 0;
-            mem_print(mon, &start, &last_prot, end, prot);
-        }
-    }
-    /* Flush last range */
-    mem_print(mon, &start, &last_prot, (hwaddr)1 << 32, 0);
-}
-
-
-#ifdef TARGET_X86_64
-static void mem_info_64(Monitor *mon, CPUArchState *env)
-{
-    int prot, last_prot;
-    uint64_t l1, l2, l3, l4;
-    uint64_t pml4e, pdpe, pde, pte;
-    uint64_t pml4_addr, pdp_addr, pd_addr, pt_addr, start, end;
-
-    pml4_addr = env->cr[3] & 0x3fffffffff000ULL;
-    last_prot = 0;
-    start = -1;
-    for (l1 = 0; l1 < 512; l1++) {
-        cpu_physical_memory_read(pml4_addr + l1 * 8, &pml4e, 8);
-        pml4e = le64_to_cpu(pml4e);
-        end = l1 << 39;
-        if (pml4e & PG_PRESENT_MASK) {
-            pdp_addr = pml4e & 0x3fffffffff000ULL;
-            for (l2 = 0; l2 < 512; l2++) {
-                cpu_physical_memory_read(pdp_addr + l2 * 8, &pdpe, 8);
-                pdpe = le64_to_cpu(pdpe);
-                end = (l1 << 39) + (l2 << 30);
-                if (pdpe & PG_PRESENT_MASK) {
-                    if (pdpe & PG_PSE_MASK) {
-                        prot = pdpe & (PG_USER_MASK | PG_RW_MASK |
-                                       PG_PRESENT_MASK);
-                        prot &= pml4e;
-                        mem_print(mon, &start, &last_prot, end, prot);
-                    } else {
-                        pd_addr = pdpe & 0x3fffffffff000ULL;
-                        for (l3 = 0; l3 < 512; l3++) {
-                            cpu_physical_memory_read(pd_addr + l3 * 8, &pde, 8);
-                            pde = le64_to_cpu(pde);
-                            end = (l1 << 39) + (l2 << 30) + (l3 << 21);
-                            if (pde & PG_PRESENT_MASK) {
-                                if (pde & PG_PSE_MASK) {
-                                    prot = pde & (PG_USER_MASK | PG_RW_MASK |
-                                                  PG_PRESENT_MASK);
-                                    prot &= pml4e & pdpe;
-                                    mem_print(mon, &start, &last_prot, end, prot);
-                                } else {
-                                    pt_addr = pde & 0x3fffffffff000ULL;
-                                    for (l4 = 0; l4 < 512; l4++) {
-                                        cpu_physical_memory_read(pt_addr
-                                                                 + l4 * 8,
-                                                                 &pte, 8);
-                                        pte = le64_to_cpu(pte);
-                                        end = (l1 << 39) + (l2 << 30) +
-                                            (l3 << 21) + (l4 << 12);
-                                        if (pte & PG_PRESENT_MASK) {
-                                            prot = pte & (PG_USER_MASK | PG_RW_MASK |
-                                                          PG_PRESENT_MASK);
-                                            prot &= pml4e & pdpe & pde;
-                                        } else {
-                                            prot = 0;
-                                        }
-                                        mem_print(mon, &start, &last_prot, end, prot);
-                                    }
-                                }
-                            } else {
-                                prot = 0;
-                                mem_print(mon, &start, &last_prot, end, prot);
-                            }
-                        }
-                    }
-                } else {
-                    prot = 0;
-                    mem_print(mon, &start, &last_prot, end, prot);
-                }
-            }
-        } else {
-            prot = 0;
-            mem_print(mon, &start, &last_prot, end, prot);
-        }
-    }
-    /* Flush last range */
-    mem_print(mon, &start, &last_prot, (hwaddr)1 << 48, 0);
-}
-#endif
-
-static void mem_info(Monitor *mon, const QDict *qdict)
-{
-    CPUArchState *env;
-
-    env = mon_get_cpu();
-
-    if (!(env->cr[0] & CR0_PG_MASK)) {
-        monitor_printf(mon, "PG disabled\n");
-        return;
-    }
-    if (env->cr[4] & CR4_PAE_MASK) {
-#ifdef TARGET_X86_64
-        if (env->hflags & HF_LMA_MASK) {
-            mem_info_64(mon, env);
-        } else
-#endif
-        {
-            mem_info_pae32(mon, env);
-        }
-    } else {
-        mem_info_32(mon, env);
-    }
-}
-#endif
-
-#if defined(TARGET_SH4)
-
-static void print_tlb(Monitor *mon, int idx, tlb_t *tlb)
-{
-    monitor_printf(mon, " tlb%i:\t"
-                   "asid=%hhu vpn=%x\tppn=%x\tsz=%hhu size=%u\t"
-                   "v=%hhu shared=%hhu cached=%hhu prot=%hhu "
-                   "dirty=%hhu writethrough=%hhu\n",
-                   idx,
-                   tlb->asid, tlb->vpn, tlb->ppn, tlb->sz, tlb->size,
-                   tlb->v, tlb->sh, tlb->c, tlb->pr,
-                   tlb->d, tlb->wt);
-}
-
-static void tlb_info(Monitor *mon, const QDict *qdict)
-{
-    CPUArchState *env = mon_get_cpu();
-    int i;
-
-    monitor_printf (mon, "ITLB:\n");
-    for (i = 0 ; i < ITLB_SIZE ; i++)
-        print_tlb (mon, i, &env->itlb[i]);
-    monitor_printf (mon, "UTLB:\n");
-    for (i = 0 ; i < UTLB_SIZE ; i++)
-        print_tlb (mon, i, &env->utlb[i]);
-}
-
-#endif
-
-#if defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_XTENSA)
-static void tlb_info(Monitor *mon, const QDict *qdict)
-{
-    CPUArchState *env1 = mon_get_cpu();
-
-    dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1);
-}
-#endif
-
-static void do_info_mtree(Monitor *mon, const QDict *qdict)
-{
-    mtree_info((fprintf_function)monitor_printf, mon);
-}
-
-static void do_info_numa(Monitor *mon, const QDict *qdict)
-{
-    int i;
-    CPUState *cpu;
-
-    monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
-    for (i = 0; i < nb_numa_nodes; i++) {
-        monitor_printf(mon, "node %d cpus:", i);
-        CPU_FOREACH(cpu) {
-            if (cpu->numa_node == i) {
-                monitor_printf(mon, " %d", cpu->cpu_index);
-            }
-        }
-        monitor_printf(mon, "\n");
-        monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
-            numa_info[i].node_mem >> 20);
-    }
-}
-
-#ifdef CONFIG_PROFILER
-
-int64_t qemu_time;
-int64_t dev_time;
-
-static void do_info_profile(Monitor *mon, const QDict *qdict)
-{
-    monitor_printf(mon, "async time  %" PRId64 " (%0.3f)\n",
-                   dev_time, dev_time / (double)get_ticks_per_sec());
-    monitor_printf(mon, "qemu time   %" PRId64 " (%0.3f)\n",
-                   qemu_time, qemu_time / (double)get_ticks_per_sec());
-    qemu_time = 0;
-    dev_time = 0;
-}
-#else
-static void do_info_profile(Monitor *mon, const QDict *qdict)
-{
-    monitor_printf(mon, "Internal profiler not compiled\n");
-}
-#endif
-
-/* Capture support */
-static QLIST_HEAD (capture_list_head, CaptureState) capture_head;
-
-static void do_info_capture(Monitor *mon, const QDict *qdict)
-{
-    int i;
-    CaptureState *s;
-
-    for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) {
-        monitor_printf(mon, "[%d]: ", i);
-        s->ops.info (s->opaque);
-    }
-}
-
-static void do_stop_capture(Monitor *mon, const QDict *qdict)
-{
-    int i;
-    int n = qdict_get_int(qdict, "n");
-    CaptureState *s;
-
-    for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) {
-        if (i == n) {
-            s->ops.destroy (s->opaque);
-            QLIST_REMOVE (s, entries);
-            g_free (s);
-            return;
-        }
-    }
-}
-
-static void do_wav_capture(Monitor *mon, const QDict *qdict)
-{
-    const char *path = qdict_get_str(qdict, "path");
-    int has_freq = qdict_haskey(qdict, "freq");
-    int freq = qdict_get_try_int(qdict, "freq", -1);
-    int has_bits = qdict_haskey(qdict, "bits");
-    int bits = qdict_get_try_int(qdict, "bits", -1);
-    int has_channels = qdict_haskey(qdict, "nchannels");
-    int nchannels = qdict_get_try_int(qdict, "nchannels", -1);
-    CaptureState *s;
-
-    s = g_malloc0 (sizeof (*s));
-
-    freq = has_freq ? freq : 44100;
-    bits = has_bits ? bits : 16;
-    nchannels = has_channels ? nchannels : 2;
-
-    if (wav_start_capture (s, path, freq, bits, nchannels)) {
-        monitor_printf(mon, "Failed to add wave capture\n");
-        g_free (s);
-        return;
-    }
-    QLIST_INSERT_HEAD (&capture_head, s, entries);
-}
-
-static qemu_acl *find_acl(Monitor *mon, const char *name)
-{
-    qemu_acl *acl = qemu_acl_find(name);
-
-    if (!acl) {
-        monitor_printf(mon, "acl: unknown list '%s'\n", name);
-    }
-    return acl;
-}
-
-static void do_acl_show(Monitor *mon, const QDict *qdict)
-{
-    const char *aclname = qdict_get_str(qdict, "aclname");
-    qemu_acl *acl = find_acl(mon, aclname);
-    qemu_acl_entry *entry;
-    int i = 0;
-
-    if (acl) {
-        monitor_printf(mon, "policy: %s\n",
-                       acl->defaultDeny ? "deny" : "allow");
-        QTAILQ_FOREACH(entry, &acl->entries, next) {
-            i++;
-            monitor_printf(mon, "%d: %s %s\n", i,
-                           entry->deny ? "deny" : "allow", entry->match);
-        }
-    }
-}
-
-static void do_acl_reset(Monitor *mon, const QDict *qdict)
-{
-    const char *aclname = qdict_get_str(qdict, "aclname");
-    qemu_acl *acl = find_acl(mon, aclname);
-
-    if (acl) {
-        qemu_acl_reset(acl);
-        monitor_printf(mon, "acl: removed all rules\n");
-    }
-}
-
-static void do_acl_policy(Monitor *mon, const QDict *qdict)
-{
-    const char *aclname = qdict_get_str(qdict, "aclname");
-    const char *policy = qdict_get_str(qdict, "policy");
-    qemu_acl *acl = find_acl(mon, aclname);
-
-    if (acl) {
-        if (strcmp(policy, "allow") == 0) {
-            acl->defaultDeny = 0;
-            monitor_printf(mon, "acl: policy set to 'allow'\n");
-        } else if (strcmp(policy, "deny") == 0) {
-            acl->defaultDeny = 1;
-            monitor_printf(mon, "acl: policy set to 'deny'\n");
-        } else {
-            monitor_printf(mon, "acl: unknown policy '%s', "
-                           "expected 'deny' or 'allow'\n", policy);
-        }
-    }
-}
-
-static void do_acl_add(Monitor *mon, const QDict *qdict)
-{
-    const char *aclname = qdict_get_str(qdict, "aclname");
-    const char *match = qdict_get_str(qdict, "match");
-    const char *policy = qdict_get_str(qdict, "policy");
-    int has_index = qdict_haskey(qdict, "index");
-    int index = qdict_get_try_int(qdict, "index", -1);
-    qemu_acl *acl = find_acl(mon, aclname);
-    int deny, ret;
-
-    if (acl) {
-        if (strcmp(policy, "allow") == 0) {
-            deny = 0;
-        } else if (strcmp(policy, "deny") == 0) {
-            deny = 1;
-        } else {
-            monitor_printf(mon, "acl: unknown policy '%s', "
-                           "expected 'deny' or 'allow'\n", policy);
-            return;
-        }
-        if (has_index)
-            ret = qemu_acl_insert(acl, deny, match, index);
-        else
-            ret = qemu_acl_append(acl, deny, match);
-        if (ret < 0)
-            monitor_printf(mon, "acl: unable to add acl entry\n");
-        else
-            monitor_printf(mon, "acl: added rule at position %d\n", ret);
-    }
-}
-
-static void do_acl_remove(Monitor *mon, const QDict *qdict)
-{
-    const char *aclname = qdict_get_str(qdict, "aclname");
-    const char *match = qdict_get_str(qdict, "match");
-    qemu_acl *acl = find_acl(mon, aclname);
-    int ret;
-
-    if (acl) {
-        ret = qemu_acl_remove(acl, match);
-        if (ret < 0)
-            monitor_printf(mon, "acl: no matching acl entry\n");
-        else
-            monitor_printf(mon, "acl: removed rule at position %d\n", ret);
-    }
-}
-
-#if defined(TARGET_I386)
-static void do_inject_mce(Monitor *mon, const QDict *qdict)
-{
-    X86CPU *cpu;
-    CPUState *cs;
-    int cpu_index = qdict_get_int(qdict, "cpu_index");
-    int bank = qdict_get_int(qdict, "bank");
-    uint64_t status = qdict_get_int(qdict, "status");
-    uint64_t mcg_status = qdict_get_int(qdict, "mcg_status");
-    uint64_t addr = qdict_get_int(qdict, "addr");
-    uint64_t misc = qdict_get_int(qdict, "misc");
-    int flags = MCE_INJECT_UNCOND_AO;
-
-    if (qdict_get_try_bool(qdict, "broadcast", 0)) {
-        flags |= MCE_INJECT_BROADCAST;
-    }
-    cs = qemu_get_cpu(cpu_index);
-    if (cs != NULL) {
-        cpu = X86_CPU(cs);
-        cpu_x86_inject_mce(mon, cpu, bank, status, mcg_status, addr, misc,
-                           flags);
-    }
-}
-#endif
-
 void qmp_getfd(const char *fdname, Error **errp)
 {
     mon_fd_t *monfd;
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 12/24] monitor: Make do_loadvm public before moving it to monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (10 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 11/24] monitor: Make some monitor functions public before moving them " Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 13/24] monitor: Move do_loadvm from monitor.c " Benoît Canet
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 include/monitor/monitor-system.h | 1 +
 monitor.c                        | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/monitor/monitor-system.h b/include/monitor/monitor-system.h
index 2e98091..3bc7167 100644
--- a/include/monitor/monitor-system.h
+++ b/include/monitor/monitor-system.h
@@ -140,5 +140,6 @@ void do_acl_remove(Monitor *mon, const QDict *qdict);
 void do_acl_reset(Monitor *mon, const QDict *qdict);
 void do_inject_mce(Monitor *mon, const QDict *qdict);
 CPUArchState *mon_get_cpu(void);
+void do_loadvm(Monitor *mon, const QDict *qdict);
 
 #endif
diff --git a/monitor.c b/monitor.c
index 06c70dd..9aeafd3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -826,7 +826,7 @@ void qmp_closefd(const char *fdname, Error **errp)
     error_set(errp, QERR_FD_NOT_FOUND, fdname);
 }
 
-static void do_loadvm(Monitor *mon, const QDict *qdict)
+void do_loadvm(Monitor *mon, const QDict *qdict)
 {
     int saved_vm_running  = runstate_is_running();
     const char *name = qdict_get_str(qdict, "name");
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 13/24] monitor: Move do_loadvm from monitor.c to monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (11 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 12/24] monitor: Make do_loadvm public before moving it to monitor-system.c Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 14/24] monitor: Make commands public before moving them " Benoît Canet
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor-system.c | 12 ++++++++++++
 monitor.c        | 12 ------------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/monitor-system.c b/monitor-system.c
index 2d49c76..9e9a4ac 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -1399,3 +1399,15 @@ void do_inject_mce(Monitor *mon, const QDict *qdict)
     }
 }
 #endif
+
+void do_loadvm(Monitor *mon, const QDict *qdict)
+{
+    int saved_vm_running  = runstate_is_running();
+    const char *name = qdict_get_str(qdict, "name");
+
+    vm_stop(RUN_STATE_RESTORE_VM);
+
+    if (load_vmstate(name) == 0 && saved_vm_running) {
+        vm_start();
+    }
+}
diff --git a/monitor.c b/monitor.c
index 9aeafd3..d2e56f8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -826,18 +826,6 @@ void qmp_closefd(const char *fdname, Error **errp)
     error_set(errp, QERR_FD_NOT_FOUND, fdname);
 }
 
-void do_loadvm(Monitor *mon, const QDict *qdict)
-{
-    int saved_vm_running  = runstate_is_running();
-    const char *name = qdict_get_str(qdict, "name");
-
-    vm_stop(RUN_STATE_RESTORE_VM);
-
-    if (load_vmstate(name) == 0 && saved_vm_running) {
-        vm_start();
-    }
-}
-
 int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
 {
     mon_fd_t *monfd;
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 14/24] monitor: Make commands public before moving them to monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (12 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 13/24] monitor: Move do_loadvm from monitor.c " Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 15/24] monitor: Move mon_cmd_t arrays and some function from monitor.c " Benoît Canet
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/monitor.c b/monitor.c
index d2e56f8..560d5e4 100644
--- a/monitor.c
+++ b/monitor.c
@@ -173,10 +173,10 @@ static QLIST_HEAD(mon_list, Monitor) mon_list;
 static QLIST_HEAD(mon_fdsets, MonFdset) mon_fdsets;
 static int mon_refcount;
 
-static mon_cmd_t mon_cmds[];
-static mon_cmd_t info_cmds[];
+mon_cmd_t mon_cmds[];
+mon_cmd_t info_cmds[];
 
-static const mon_cmd_t qmp_cmds[];
+const mon_cmd_t qmp_cmds[];
 
 Monitor *cur_mon;
 Monitor *default_mon;
@@ -1188,7 +1188,7 @@ int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp)
 }
 
 /* Please update hmp-commands.hx when adding or changing commands */
-static mon_cmd_t info_cmds[] = {
+mon_cmd_t info_cmds[] = {
     {
         .name       = "version",
         .args_type  = "",
@@ -1514,12 +1514,12 @@ static mon_cmd_t info_cmds[] = {
 };
 
 /* mon_cmds and info_cmds would be sorted at runtime */
-static mon_cmd_t mon_cmds[] = {
+mon_cmd_t mon_cmds[] = {
 #include "hmp-commands.h"
     { NULL, NULL, },
 };
 
-static const mon_cmd_t qmp_cmds[] = {
+const mon_cmd_t qmp_cmds[] = {
 #include "qmp-commands-old.h"
     { /* NULL */ },
 };
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 15/24] monitor: Move mon_cmd_t arrays and some function from monitor.c to monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (13 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 14/24] monitor: Make commands public before moving them " Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 16/24] monitor: Move more functions " Benoît Canet
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Also add sizeof variables for mon_cmd_t arrays for cross modules usage.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor-system.c |  984 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 monitor.c        | 1010 ++----------------------------------------------------
 2 files changed, 1007 insertions(+), 987 deletions(-)

diff --git a/monitor-system.c b/monitor-system.c
index 9e9a4ac..5b5f1ed 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -1411,3 +1411,987 @@ void do_loadvm(Monitor *mon, const QDict *qdict)
         vm_start();
     }
 }
+
+/* Please update hmp-commands.hx when adding or changing commands */
+mon_cmd_t info_cmds[] = {
+    {
+        .name       = "version",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the version of QEMU",
+        .mhandler.cmd = hmp_info_version,
+    },
+    {
+        .name       = "network",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the network state",
+        .mhandler.cmd = do_info_network,
+    },
+    {
+        .name       = "chardev",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the character devices",
+        .mhandler.cmd = hmp_info_chardev,
+    },
+    {
+        .name       = "block",
+        .args_type  = "verbose:-v,device:B?",
+        .params     = "[-v] [device]",
+        .help       = "show info of one block device or all block devices "
+                      "(and details of images with -v option)",
+        .mhandler.cmd = hmp_info_block,
+    },
+    {
+        .name       = "blockstats",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show block device statistics",
+        .mhandler.cmd = hmp_info_blockstats,
+    },
+    {
+        .name       = "block-jobs",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show progress of ongoing block device operations",
+        .mhandler.cmd = hmp_info_block_jobs,
+    },
+    {
+        .name       = "registers",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the cpu registers",
+        .mhandler.cmd = do_info_registers,
+    },
+    {
+        .name       = "cpus",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show infos for each CPU",
+        .mhandler.cmd = hmp_info_cpus,
+    },
+    {
+        .name       = "history",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the command line history",
+        .mhandler.cmd = do_info_history,
+    },
+#if defined(TARGET_I386) || defined(TARGET_PPC) || defined(TARGET_MIPS) || \
+    defined(TARGET_LM32) || (defined(TARGET_SPARC) && !defined(TARGET_SPARC64))
+    {
+        .name       = "irq",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the interrupts statistics (if available)",
+#ifdef TARGET_SPARC
+        .mhandler.cmd = sun4m_irq_info,
+#elif defined(TARGET_LM32)
+        .mhandler.cmd = lm32_irq_info,
+#else
+        .mhandler.cmd = irq_info,
+#endif
+    },
+    {
+        .name       = "pic",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show i8259 (PIC) state",
+#ifdef TARGET_SPARC
+        .mhandler.cmd = sun4m_pic_info,
+#elif defined(TARGET_LM32)
+        .mhandler.cmd = lm32_do_pic_info,
+#else
+        .mhandler.cmd = pic_info,
+#endif
+    },
+#endif
+    {
+        .name       = "pci",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show PCI info",
+        .mhandler.cmd = hmp_info_pci,
+    },
+#if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \
+    defined(TARGET_PPC) || defined(TARGET_XTENSA)
+    {
+        .name       = "tlb",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show virtual to physical memory mappings",
+        .mhandler.cmd = tlb_info,
+    },
+#endif
+#if defined(TARGET_I386)
+    {
+        .name       = "mem",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the active virtual memory mappings",
+        .mhandler.cmd = mem_info,
+    },
+#endif
+    {
+        .name       = "mtree",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show memory tree",
+        .mhandler.cmd = do_info_mtree,
+    },
+    {
+        .name       = "jit",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show dynamic compiler info",
+        .mhandler.cmd = do_info_jit,
+    },
+    {
+        .name       = "kvm",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show KVM information",
+        .mhandler.cmd = hmp_info_kvm,
+    },
+    {
+        .name       = "numa",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show NUMA information",
+        .mhandler.cmd = do_info_numa,
+    },
+    {
+        .name       = "usb",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show guest USB devices",
+        .mhandler.cmd = usb_info,
+    },
+    {
+        .name       = "usbhost",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show host USB devices",
+        .mhandler.cmd = usb_host_info,
+    },
+    {
+        .name       = "profile",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show profiling information",
+        .mhandler.cmd = do_info_profile,
+    },
+    {
+        .name       = "capture",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show capture information",
+        .mhandler.cmd = do_info_capture,
+    },
+    {
+        .name       = "snapshots",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the currently saved VM snapshots",
+        .mhandler.cmd = do_info_snapshots,
+    },
+    {
+        .name       = "status",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the current VM status (running|paused)",
+        .mhandler.cmd = hmp_info_status,
+    },
+    {
+        .name       = "pcmcia",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show guest PCMCIA status",
+        .mhandler.cmd = pcmcia_info,
+    },
+    {
+        .name       = "mice",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show which guest mouse is receiving events",
+        .mhandler.cmd = hmp_info_mice,
+    },
+    {
+        .name       = "vnc",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the vnc server status",
+        .mhandler.cmd = hmp_info_vnc,
+    },
+#if defined(CONFIG_SPICE)
+    {
+        .name       = "spice",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the spice server status",
+        .mhandler.cmd = hmp_info_spice,
+    },
+#endif
+    {
+        .name       = "name",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the current VM name",
+        .mhandler.cmd = hmp_info_name,
+    },
+    {
+        .name       = "uuid",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the current VM UUID",
+        .mhandler.cmd = hmp_info_uuid,
+    },
+    {
+        .name       = "cpustats",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show CPU statistics",
+        .mhandler.cmd = do_info_cpu_stats,
+    },
+#if defined(CONFIG_SLIRP)
+    {
+        .name       = "usernet",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show user network stack connection states",
+        .mhandler.cmd = do_info_usernet,
+    },
+#endif
+    {
+        .name       = "migrate",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show migration status",
+        .mhandler.cmd = hmp_info_migrate,
+    },
+    {
+        .name       = "migrate_capabilities",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show current migration capabilities",
+        .mhandler.cmd = hmp_info_migrate_capabilities,
+    },
+    {
+        .name       = "migrate_cache_size",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show current migration xbzrle cache size",
+        .mhandler.cmd = hmp_info_migrate_cache_size,
+    },
+    {
+        .name       = "balloon",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show balloon information",
+        .mhandler.cmd = hmp_info_balloon,
+    },
+    {
+        .name       = "qtree",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show device tree",
+        .mhandler.cmd = do_info_qtree,
+    },
+    {
+        .name       = "qdm",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show qdev device model list",
+        .mhandler.cmd = do_info_qdm,
+    },
+    {
+        .name       = "roms",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show roms",
+        .mhandler.cmd = do_info_roms,
+    },
+    {
+        .name       = "trace-events",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show available trace-events & their state",
+        .mhandler.cmd = do_trace_print_events,
+    },
+    {
+        .name       = "tpm",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show the TPM device",
+        .mhandler.cmd = hmp_info_tpm,
+    },
+    {
+        .name       = "memdev",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show memory backends",
+        .mhandler.cmd = hmp_info_memdev,
+    },
+    {
+        .name       = NULL,
+    },
+};
+
+/* mon_cmds and info_cmds would be sorted at runtime */
+mon_cmd_t mon_cmds[] = {
+#include "hmp-commands.h"
+    { NULL, NULL, },
+};
+
+const mon_cmd_t qmp_cmds[] = {
+#include "qmp-commands-old.h"
+    { /* NULL */ },
+};
+
+/*******************************************************************/
+
+static const char *pch;
+static sigjmp_buf expr_env;
+
+#define MD_TLONG 0
+#define MD_I32   1
+
+typedef struct MonitorDef {
+    const char *name;
+    int offset;
+    target_long (*get_value)(const struct MonitorDef *md, int val);
+    int type;
+} MonitorDef;
+
+#if defined(TARGET_I386)
+static target_long monitor_get_pc (const struct MonitorDef *md, int val)
+{
+    CPUArchState *env = mon_get_cpu();
+    return env->eip + env->segs[R_CS].base;
+}
+#endif
+
+#if defined(TARGET_PPC)
+static target_long monitor_get_ccr (const struct MonitorDef *md, int val)
+{
+    CPUArchState *env = mon_get_cpu();
+    unsigned int u;
+    int i;
+
+    u = 0;
+    for (i = 0; i < 8; i++)
+        u |= env->crf[i] << (32 - (4 * i));
+
+    return u;
+}
+
+static target_long monitor_get_msr (const struct MonitorDef *md, int val)
+{
+    CPUArchState *env = mon_get_cpu();
+    return env->msr;
+}
+
+static target_long monitor_get_xer (const struct MonitorDef *md, int val)
+{
+    CPUArchState *env = mon_get_cpu();
+    return env->xer;
+}
+
+static target_long monitor_get_decr (const struct MonitorDef *md, int val)
+{
+    CPUArchState *env = mon_get_cpu();
+    return cpu_ppc_load_decr(env);
+}
+
+static target_long monitor_get_tbu (const struct MonitorDef *md, int val)
+{
+    CPUArchState *env = mon_get_cpu();
+    return cpu_ppc_load_tbu(env);
+}
+
+static target_long monitor_get_tbl (const struct MonitorDef *md, int val)
+{
+    CPUArchState *env = mon_get_cpu();
+    return cpu_ppc_load_tbl(env);
+}
+#endif
+
+#if defined(TARGET_SPARC)
+#ifndef TARGET_SPARC64
+static target_long monitor_get_psr (const struct MonitorDef *md, int val)
+{
+    CPUArchState *env = mon_get_cpu();
+
+    return cpu_get_psr(env);
+}
+#endif
+
+static target_long monitor_get_reg(const struct MonitorDef *md, int val)
+{
+    CPUArchState *env = mon_get_cpu();
+    return env->regwptr[val];
+}
+#endif
+
+static const MonitorDef monitor_defs[] = {
+#ifdef TARGET_I386
+
+#define SEG(name, seg) \
+    { name, offsetof(CPUX86State, segs[seg].selector), NULL, MD_I32 },\
+    { name ".base", offsetof(CPUX86State, segs[seg].base) },\
+    { name ".limit", offsetof(CPUX86State, segs[seg].limit), NULL, MD_I32 },
+
+    { "eax", offsetof(CPUX86State, regs[0]) },
+    { "ecx", offsetof(CPUX86State, regs[1]) },
+    { "edx", offsetof(CPUX86State, regs[2]) },
+    { "ebx", offsetof(CPUX86State, regs[3]) },
+    { "esp|sp", offsetof(CPUX86State, regs[4]) },
+    { "ebp|fp", offsetof(CPUX86State, regs[5]) },
+    { "esi", offsetof(CPUX86State, regs[6]) },
+    { "edi", offsetof(CPUX86State, regs[7]) },
+#ifdef TARGET_X86_64
+    { "r8", offsetof(CPUX86State, regs[8]) },
+    { "r9", offsetof(CPUX86State, regs[9]) },
+    { "r10", offsetof(CPUX86State, regs[10]) },
+    { "r11", offsetof(CPUX86State, regs[11]) },
+    { "r12", offsetof(CPUX86State, regs[12]) },
+    { "r13", offsetof(CPUX86State, regs[13]) },
+    { "r14", offsetof(CPUX86State, regs[14]) },
+    { "r15", offsetof(CPUX86State, regs[15]) },
+#endif
+    { "eflags", offsetof(CPUX86State, eflags) },
+    { "eip", offsetof(CPUX86State, eip) },
+    SEG("cs", R_CS)
+    SEG("ds", R_DS)
+    SEG("es", R_ES)
+    SEG("ss", R_SS)
+    SEG("fs", R_FS)
+    SEG("gs", R_GS)
+    { "pc", 0, monitor_get_pc, },
+#elif defined(TARGET_PPC)
+    /* General purpose registers */
+    { "r0", offsetof(CPUPPCState, gpr[0]) },
+    { "r1", offsetof(CPUPPCState, gpr[1]) },
+    { "r2", offsetof(CPUPPCState, gpr[2]) },
+    { "r3", offsetof(CPUPPCState, gpr[3]) },
+    { "r4", offsetof(CPUPPCState, gpr[4]) },
+    { "r5", offsetof(CPUPPCState, gpr[5]) },
+    { "r6", offsetof(CPUPPCState, gpr[6]) },
+    { "r7", offsetof(CPUPPCState, gpr[7]) },
+    { "r8", offsetof(CPUPPCState, gpr[8]) },
+    { "r9", offsetof(CPUPPCState, gpr[9]) },
+    { "r10", offsetof(CPUPPCState, gpr[10]) },
+    { "r11", offsetof(CPUPPCState, gpr[11]) },
+    { "r12", offsetof(CPUPPCState, gpr[12]) },
+    { "r13", offsetof(CPUPPCState, gpr[13]) },
+    { "r14", offsetof(CPUPPCState, gpr[14]) },
+    { "r15", offsetof(CPUPPCState, gpr[15]) },
+    { "r16", offsetof(CPUPPCState, gpr[16]) },
+    { "r17", offsetof(CPUPPCState, gpr[17]) },
+    { "r18", offsetof(CPUPPCState, gpr[18]) },
+    { "r19", offsetof(CPUPPCState, gpr[19]) },
+    { "r20", offsetof(CPUPPCState, gpr[20]) },
+    { "r21", offsetof(CPUPPCState, gpr[21]) },
+    { "r22", offsetof(CPUPPCState, gpr[22]) },
+    { "r23", offsetof(CPUPPCState, gpr[23]) },
+    { "r24", offsetof(CPUPPCState, gpr[24]) },
+    { "r25", offsetof(CPUPPCState, gpr[25]) },
+    { "r26", offsetof(CPUPPCState, gpr[26]) },
+    { "r27", offsetof(CPUPPCState, gpr[27]) },
+    { "r28", offsetof(CPUPPCState, gpr[28]) },
+    { "r29", offsetof(CPUPPCState, gpr[29]) },
+    { "r30", offsetof(CPUPPCState, gpr[30]) },
+    { "r31", offsetof(CPUPPCState, gpr[31]) },
+    /* Floating point registers */
+    { "f0", offsetof(CPUPPCState, fpr[0]) },
+    { "f1", offsetof(CPUPPCState, fpr[1]) },
+    { "f2", offsetof(CPUPPCState, fpr[2]) },
+    { "f3", offsetof(CPUPPCState, fpr[3]) },
+    { "f4", offsetof(CPUPPCState, fpr[4]) },
+    { "f5", offsetof(CPUPPCState, fpr[5]) },
+    { "f6", offsetof(CPUPPCState, fpr[6]) },
+    { "f7", offsetof(CPUPPCState, fpr[7]) },
+    { "f8", offsetof(CPUPPCState, fpr[8]) },
+    { "f9", offsetof(CPUPPCState, fpr[9]) },
+    { "f10", offsetof(CPUPPCState, fpr[10]) },
+    { "f11", offsetof(CPUPPCState, fpr[11]) },
+    { "f12", offsetof(CPUPPCState, fpr[12]) },
+    { "f13", offsetof(CPUPPCState, fpr[13]) },
+    { "f14", offsetof(CPUPPCState, fpr[14]) },
+    { "f15", offsetof(CPUPPCState, fpr[15]) },
+    { "f16", offsetof(CPUPPCState, fpr[16]) },
+    { "f17", offsetof(CPUPPCState, fpr[17]) },
+    { "f18", offsetof(CPUPPCState, fpr[18]) },
+    { "f19", offsetof(CPUPPCState, fpr[19]) },
+    { "f20", offsetof(CPUPPCState, fpr[20]) },
+    { "f21", offsetof(CPUPPCState, fpr[21]) },
+    { "f22", offsetof(CPUPPCState, fpr[22]) },
+    { "f23", offsetof(CPUPPCState, fpr[23]) },
+    { "f24", offsetof(CPUPPCState, fpr[24]) },
+    { "f25", offsetof(CPUPPCState, fpr[25]) },
+    { "f26", offsetof(CPUPPCState, fpr[26]) },
+    { "f27", offsetof(CPUPPCState, fpr[27]) },
+    { "f28", offsetof(CPUPPCState, fpr[28]) },
+    { "f29", offsetof(CPUPPCState, fpr[29]) },
+    { "f30", offsetof(CPUPPCState, fpr[30]) },
+    { "f31", offsetof(CPUPPCState, fpr[31]) },
+    { "fpscr", offsetof(CPUPPCState, fpscr) },
+    /* Next instruction pointer */
+    { "nip|pc", offsetof(CPUPPCState, nip) },
+    { "lr", offsetof(CPUPPCState, lr) },
+    { "ctr", offsetof(CPUPPCState, ctr) },
+    { "decr", 0, &monitor_get_decr, },
+    { "ccr", 0, &monitor_get_ccr, },
+    /* Machine state register */
+    { "msr", 0, &monitor_get_msr, },
+    { "xer", 0, &monitor_get_xer, },
+    { "tbu", 0, &monitor_get_tbu, },
+    { "tbl", 0, &monitor_get_tbl, },
+    /* Segment registers */
+    { "sdr1", offsetof(CPUPPCState, spr[SPR_SDR1]) },
+    { "sr0", offsetof(CPUPPCState, sr[0]) },
+    { "sr1", offsetof(CPUPPCState, sr[1]) },
+    { "sr2", offsetof(CPUPPCState, sr[2]) },
+    { "sr3", offsetof(CPUPPCState, sr[3]) },
+    { "sr4", offsetof(CPUPPCState, sr[4]) },
+    { "sr5", offsetof(CPUPPCState, sr[5]) },
+    { "sr6", offsetof(CPUPPCState, sr[6]) },
+    { "sr7", offsetof(CPUPPCState, sr[7]) },
+    { "sr8", offsetof(CPUPPCState, sr[8]) },
+    { "sr9", offsetof(CPUPPCState, sr[9]) },
+    { "sr10", offsetof(CPUPPCState, sr[10]) },
+    { "sr11", offsetof(CPUPPCState, sr[11]) },
+    { "sr12", offsetof(CPUPPCState, sr[12]) },
+    { "sr13", offsetof(CPUPPCState, sr[13]) },
+    { "sr14", offsetof(CPUPPCState, sr[14]) },
+    { "sr15", offsetof(CPUPPCState, sr[15]) },
+    /* Too lazy to put BATs... */
+    { "pvr", offsetof(CPUPPCState, spr[SPR_PVR]) },
+
+    { "srr0", offsetof(CPUPPCState, spr[SPR_SRR0]) },
+    { "srr1", offsetof(CPUPPCState, spr[SPR_SRR1]) },
+    { "dar", offsetof(CPUPPCState, spr[SPR_DAR]) },
+    { "dsisr", offsetof(CPUPPCState, spr[SPR_DSISR]) },
+    { "cfar", offsetof(CPUPPCState, spr[SPR_CFAR]) },
+    { "sprg0", offsetof(CPUPPCState, spr[SPR_SPRG0]) },
+    { "sprg1", offsetof(CPUPPCState, spr[SPR_SPRG1]) },
+    { "sprg2", offsetof(CPUPPCState, spr[SPR_SPRG2]) },
+    { "sprg3", offsetof(CPUPPCState, spr[SPR_SPRG3]) },
+    { "sprg4", offsetof(CPUPPCState, spr[SPR_SPRG4]) },
+    { "sprg5", offsetof(CPUPPCState, spr[SPR_SPRG5]) },
+    { "sprg6", offsetof(CPUPPCState, spr[SPR_SPRG6]) },
+    { "sprg7", offsetof(CPUPPCState, spr[SPR_SPRG7]) },
+    { "pid", offsetof(CPUPPCState, spr[SPR_BOOKE_PID]) },
+    { "csrr0", offsetof(CPUPPCState, spr[SPR_BOOKE_CSRR0]) },
+    { "csrr1", offsetof(CPUPPCState, spr[SPR_BOOKE_CSRR1]) },
+    { "esr", offsetof(CPUPPCState, spr[SPR_BOOKE_ESR]) },
+    { "dear", offsetof(CPUPPCState, spr[SPR_BOOKE_DEAR]) },
+    { "mcsr", offsetof(CPUPPCState, spr[SPR_BOOKE_MCSR]) },
+    { "tsr", offsetof(CPUPPCState, spr[SPR_BOOKE_TSR]) },
+    { "tcr", offsetof(CPUPPCState, spr[SPR_BOOKE_TCR]) },
+    { "vrsave", offsetof(CPUPPCState, spr[SPR_VRSAVE]) },
+    { "pir", offsetof(CPUPPCState, spr[SPR_BOOKE_PIR]) },
+    { "mcsrr0", offsetof(CPUPPCState, spr[SPR_BOOKE_MCSRR0]) },
+    { "mcsrr1", offsetof(CPUPPCState, spr[SPR_BOOKE_MCSRR1]) },
+    { "decar", offsetof(CPUPPCState, spr[SPR_BOOKE_DECAR]) },
+    { "ivpr", offsetof(CPUPPCState, spr[SPR_BOOKE_IVPR]) },
+    { "epcr", offsetof(CPUPPCState, spr[SPR_BOOKE_EPCR]) },
+    { "sprg8", offsetof(CPUPPCState, spr[SPR_BOOKE_SPRG8]) },
+    { "ivor0", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR0]) },
+    { "ivor1", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR1]) },
+    { "ivor2", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR2]) },
+    { "ivor3", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR3]) },
+    { "ivor4", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR4]) },
+    { "ivor5", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR5]) },
+    { "ivor6", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR6]) },
+    { "ivor7", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR7]) },
+    { "ivor8", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR8]) },
+    { "ivor9", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR9]) },
+    { "ivor10", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR10]) },
+    { "ivor11", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR11]) },
+    { "ivor12", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR12]) },
+    { "ivor13", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR13]) },
+    { "ivor14", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR14]) },
+    { "ivor15", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR15]) },
+    { "ivor32", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR32]) },
+    { "ivor33", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR33]) },
+    { "ivor34", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR34]) },
+    { "ivor35", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR35]) },
+    { "ivor36", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR36]) },
+    { "ivor37", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR37]) },
+    { "mas0", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS0]) },
+    { "mas1", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS1]) },
+    { "mas2", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS2]) },
+    { "mas3", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS3]) },
+    { "mas4", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS4]) },
+    { "mas6", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS6]) },
+    { "mas7", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS7]) },
+    { "mmucfg", offsetof(CPUPPCState, spr[SPR_MMUCFG]) },
+    { "tlb0cfg", offsetof(CPUPPCState, spr[SPR_BOOKE_TLB0CFG]) },
+    { "tlb1cfg", offsetof(CPUPPCState, spr[SPR_BOOKE_TLB1CFG]) },
+    { "epr", offsetof(CPUPPCState, spr[SPR_BOOKE_EPR]) },
+    { "eplc", offsetof(CPUPPCState, spr[SPR_BOOKE_EPLC]) },
+    { "epsc", offsetof(CPUPPCState, spr[SPR_BOOKE_EPSC]) },
+    { "svr", offsetof(CPUPPCState, spr[SPR_E500_SVR]) },
+    { "mcar", offsetof(CPUPPCState, spr[SPR_Exxx_MCAR]) },
+    { "pid1", offsetof(CPUPPCState, spr[SPR_BOOKE_PID1]) },
+    { "pid2", offsetof(CPUPPCState, spr[SPR_BOOKE_PID2]) },
+    { "hid0", offsetof(CPUPPCState, spr[SPR_HID0]) },
+
+#elif defined(TARGET_SPARC)
+    { "g0", offsetof(CPUSPARCState, gregs[0]) },
+    { "g1", offsetof(CPUSPARCState, gregs[1]) },
+    { "g2", offsetof(CPUSPARCState, gregs[2]) },
+    { "g3", offsetof(CPUSPARCState, gregs[3]) },
+    { "g4", offsetof(CPUSPARCState, gregs[4]) },
+    { "g5", offsetof(CPUSPARCState, gregs[5]) },
+    { "g6", offsetof(CPUSPARCState, gregs[6]) },
+    { "g7", offsetof(CPUSPARCState, gregs[7]) },
+    { "o0", 0, monitor_get_reg },
+    { "o1", 1, monitor_get_reg },
+    { "o2", 2, monitor_get_reg },
+    { "o3", 3, monitor_get_reg },
+    { "o4", 4, monitor_get_reg },
+    { "o5", 5, monitor_get_reg },
+    { "o6", 6, monitor_get_reg },
+    { "o7", 7, monitor_get_reg },
+    { "l0", 8, monitor_get_reg },
+    { "l1", 9, monitor_get_reg },
+    { "l2", 10, monitor_get_reg },
+    { "l3", 11, monitor_get_reg },
+    { "l4", 12, monitor_get_reg },
+    { "l5", 13, monitor_get_reg },
+    { "l6", 14, monitor_get_reg },
+    { "l7", 15, monitor_get_reg },
+    { "i0", 16, monitor_get_reg },
+    { "i1", 17, monitor_get_reg },
+    { "i2", 18, monitor_get_reg },
+    { "i3", 19, monitor_get_reg },
+    { "i4", 20, monitor_get_reg },
+    { "i5", 21, monitor_get_reg },
+    { "i6", 22, monitor_get_reg },
+    { "i7", 23, monitor_get_reg },
+    { "pc", offsetof(CPUSPARCState, pc) },
+    { "npc", offsetof(CPUSPARCState, npc) },
+    { "y", offsetof(CPUSPARCState, y) },
+#ifndef TARGET_SPARC64
+    { "psr", 0, &monitor_get_psr, },
+    { "wim", offsetof(CPUSPARCState, wim) },
+#endif
+    { "tbr", offsetof(CPUSPARCState, tbr) },
+    { "fsr", offsetof(CPUSPARCState, fsr) },
+    { "f0", offsetof(CPUSPARCState, fpr[0].l.upper) },
+    { "f1", offsetof(CPUSPARCState, fpr[0].l.lower) },
+    { "f2", offsetof(CPUSPARCState, fpr[1].l.upper) },
+    { "f3", offsetof(CPUSPARCState, fpr[1].l.lower) },
+    { "f4", offsetof(CPUSPARCState, fpr[2].l.upper) },
+    { "f5", offsetof(CPUSPARCState, fpr[2].l.lower) },
+    { "f6", offsetof(CPUSPARCState, fpr[3].l.upper) },
+    { "f7", offsetof(CPUSPARCState, fpr[3].l.lower) },
+    { "f8", offsetof(CPUSPARCState, fpr[4].l.upper) },
+    { "f9", offsetof(CPUSPARCState, fpr[4].l.lower) },
+    { "f10", offsetof(CPUSPARCState, fpr[5].l.upper) },
+    { "f11", offsetof(CPUSPARCState, fpr[5].l.lower) },
+    { "f12", offsetof(CPUSPARCState, fpr[6].l.upper) },
+    { "f13", offsetof(CPUSPARCState, fpr[6].l.lower) },
+    { "f14", offsetof(CPUSPARCState, fpr[7].l.upper) },
+    { "f15", offsetof(CPUSPARCState, fpr[7].l.lower) },
+    { "f16", offsetof(CPUSPARCState, fpr[8].l.upper) },
+    { "f17", offsetof(CPUSPARCState, fpr[8].l.lower) },
+    { "f18", offsetof(CPUSPARCState, fpr[9].l.upper) },
+    { "f19", offsetof(CPUSPARCState, fpr[9].l.lower) },
+    { "f20", offsetof(CPUSPARCState, fpr[10].l.upper) },
+    { "f21", offsetof(CPUSPARCState, fpr[10].l.lower) },
+    { "f22", offsetof(CPUSPARCState, fpr[11].l.upper) },
+    { "f23", offsetof(CPUSPARCState, fpr[11].l.lower) },
+    { "f24", offsetof(CPUSPARCState, fpr[12].l.upper) },
+    { "f25", offsetof(CPUSPARCState, fpr[12].l.lower) },
+    { "f26", offsetof(CPUSPARCState, fpr[13].l.upper) },
+    { "f27", offsetof(CPUSPARCState, fpr[13].l.lower) },
+    { "f28", offsetof(CPUSPARCState, fpr[14].l.upper) },
+    { "f29", offsetof(CPUSPARCState, fpr[14].l.lower) },
+    { "f30", offsetof(CPUSPARCState, fpr[15].l.upper) },
+    { "f31", offsetof(CPUSPARCState, fpr[15].l.lower) },
+#ifdef TARGET_SPARC64
+    { "f32", offsetof(CPUSPARCState, fpr[16]) },
+    { "f34", offsetof(CPUSPARCState, fpr[17]) },
+    { "f36", offsetof(CPUSPARCState, fpr[18]) },
+    { "f38", offsetof(CPUSPARCState, fpr[19]) },
+    { "f40", offsetof(CPUSPARCState, fpr[20]) },
+    { "f42", offsetof(CPUSPARCState, fpr[21]) },
+    { "f44", offsetof(CPUSPARCState, fpr[22]) },
+    { "f46", offsetof(CPUSPARCState, fpr[23]) },
+    { "f48", offsetof(CPUSPARCState, fpr[24]) },
+    { "f50", offsetof(CPUSPARCState, fpr[25]) },
+    { "f52", offsetof(CPUSPARCState, fpr[26]) },
+    { "f54", offsetof(CPUSPARCState, fpr[27]) },
+    { "f56", offsetof(CPUSPARCState, fpr[28]) },
+    { "f58", offsetof(CPUSPARCState, fpr[29]) },
+    { "f60", offsetof(CPUSPARCState, fpr[30]) },
+    { "f62", offsetof(CPUSPARCState, fpr[31]) },
+    { "asi", offsetof(CPUSPARCState, asi) },
+    { "pstate", offsetof(CPUSPARCState, pstate) },
+    { "cansave", offsetof(CPUSPARCState, cansave) },
+    { "canrestore", offsetof(CPUSPARCState, canrestore) },
+    { "otherwin", offsetof(CPUSPARCState, otherwin) },
+    { "wstate", offsetof(CPUSPARCState, wstate) },
+    { "cleanwin", offsetof(CPUSPARCState, cleanwin) },
+    { "fprs", offsetof(CPUSPARCState, fprs) },
+#endif
+#endif
+    { NULL },
+};
+
+static void GCC_FMT_ATTR(2, 3) QEMU_NORETURN
+expr_error(Monitor *mon, const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    monitor_vprintf(mon, fmt, ap);
+    monitor_printf(mon, "\n");
+    va_end(ap);
+    siglongjmp(expr_env, 1);
+}
+
+/* return 0 if OK, -1 if not found */
+static int get_monitor_def(target_long *pval, const char *name)
+{
+    const MonitorDef *md;
+    void *ptr;
+
+    for(md = monitor_defs; md->name != NULL; md++) {
+        if (compare_cmd(name, md->name)) {
+            if (md->get_value) {
+                *pval = md->get_value(md, md->offset);
+            } else {
+                CPUArchState *env = mon_get_cpu();
+                ptr = (uint8_t *)env + md->offset;
+                switch(md->type) {
+                case MD_I32:
+                    *pval = *(int32_t *)ptr;
+                    break;
+                case MD_TLONG:
+                    *pval = *(target_long *)ptr;
+                    break;
+                default:
+                    *pval = 0;
+                    break;
+                }
+            }
+            return 0;
+        }
+    }
+    return -1;
+}
+
+static void next(void)
+{
+    if (*pch != '\0') {
+        pch++;
+        while (qemu_isspace(*pch))
+            pch++;
+    }
+}
+
+static int64_t expr_sum(Monitor *mon);
+
+static int64_t expr_unary(Monitor *mon)
+{
+    int64_t n;
+    char *p;
+    int ret;
+
+    switch(*pch) {
+    case '+':
+        next();
+        n = expr_unary(mon);
+        break;
+    case '-':
+        next();
+        n = -expr_unary(mon);
+        break;
+    case '~':
+        next();
+        n = ~expr_unary(mon);
+        break;
+    case '(':
+        next();
+        n = expr_sum(mon);
+        if (*pch != ')') {
+            expr_error(mon, "')' expected");
+        }
+        next();
+        break;
+    case '\'':
+        pch++;
+        if (*pch == '\0')
+            expr_error(mon, "character constant expected");
+        n = *pch;
+        pch++;
+        if (*pch != '\'')
+            expr_error(mon, "missing terminating \' character");
+        next();
+        break;
+    case '$':
+        {
+            char buf[128], *q;
+            target_long reg=0;
+
+            pch++;
+            q = buf;
+            while ((*pch >= 'a' && *pch <= 'z') ||
+                   (*pch >= 'A' && *pch <= 'Z') ||
+                   (*pch >= '0' && *pch <= '9') ||
+                   *pch == '_' || *pch == '.') {
+                if ((q - buf) < sizeof(buf) - 1)
+                    *q++ = *pch;
+                pch++;
+            }
+            while (qemu_isspace(*pch))
+                pch++;
+            *q = 0;
+            ret = get_monitor_def(&reg, buf);
+            if (ret < 0)
+                expr_error(mon, "unknown register");
+            n = reg;
+        }
+        break;
+    case '\0':
+        expr_error(mon, "unexpected end of expression");
+        n = 0;
+        break;
+    default:
+        errno = 0;
+        n = strtoull(pch, &p, 0);
+        if (errno == ERANGE) {
+            expr_error(mon, "number too large");
+        }
+        if (pch == p) {
+            expr_error(mon, "invalid char '%c' in expression", *p);
+        }
+        pch = p;
+        while (qemu_isspace(*pch))
+            pch++;
+        break;
+    }
+    return n;
+}
+
+
+static int64_t expr_prod(Monitor *mon)
+{
+    int64_t val, val2;
+    int op;
+
+    val = expr_unary(mon);
+    for(;;) {
+        op = *pch;
+        if (op != '*' && op != '/' && op != '%')
+            break;
+        next();
+        val2 = expr_unary(mon);
+        switch(op) {
+        default:
+        case '*':
+            val *= val2;
+            break;
+        case '/':
+        case '%':
+            if (val2 == 0)
+                expr_error(mon, "division by zero");
+            if (op == '/')
+                val /= val2;
+            else
+                val %= val2;
+            break;
+        }
+    }
+    return val;
+}
+
+static int64_t expr_logic(Monitor *mon)
+{
+    int64_t val, val2;
+    int op;
+
+    val = expr_prod(mon);
+    for(;;) {
+        op = *pch;
+        if (op != '&' && op != '|' && op != '^')
+            break;
+        next();
+        val2 = expr_prod(mon);
+        switch(op) {
+        default:
+        case '&':
+            val &= val2;
+            break;
+        case '|':
+            val |= val2;
+            break;
+        case '^':
+            val ^= val2;
+            break;
+        }
+    }
+    return val;
+}
+
+static int64_t expr_sum(Monitor *mon)
+{
+    int64_t val, val2;
+    int op;
+
+    val = expr_logic(mon);
+    for(;;) {
+        op = *pch;
+        if (op != '+' && op != '-')
+            break;
+        next();
+        val2 = expr_logic(mon);
+        if (op == '+')
+            val += val2;
+        else
+            val -= val2;
+    }
+    return val;
+}
+
+int get_expr(Monitor *mon, int64_t *pval, const char **pp)
+{
+    pch = *pp;
+    if (sigsetjmp(expr_env, 0)) {
+        *pp = pch;
+        return -1;
+    }
+    while (qemu_isspace(*pch))
+        pch++;
+    *pval = expr_sum(mon);
+    *pp = pch;
+    return 0;
+}
+
+int get_double(Monitor *mon, double *pval, const char **pp)
+{
+    const char *p = *pp;
+    char *tailp;
+    double d;
+
+    d = strtod(p, &tailp);
+    if (tailp == p) {
+        monitor_printf(mon, "Number expected\n");
+        return -1;
+    }
+    if (d != d || d - d != 0) {
+        /* NaN or infinity */
+        monitor_printf(mon, "Bad number\n");
+        return -1;
+    }
+    *pval = d;
+    *pp = tailp;
+    return 0;
+}
+
+size_t sizeof_mon_cmds = sizeof(mon_cmds);
+size_t sizeof_info_cmds = sizeof(info_cmds);
diff --git a/monitor.c b/monitor.c
index 560d5e4..419da13 100644
--- a/monitor.c
+++ b/monitor.c
@@ -173,10 +173,27 @@ static QLIST_HEAD(mon_list, Monitor) mon_list;
 static QLIST_HEAD(mon_fdsets, MonFdset) mon_fdsets;
 static int mon_refcount;
 
-mon_cmd_t mon_cmds[];
-mon_cmd_t info_cmds[];
-
-const mon_cmd_t qmp_cmds[];
+#ifdef BLOCK_COMMAND_MONITOR
+static mon_cmd_t mon_cmds[] = {
+    { NULL, NULL, },
+};
+size_t sizeof_mon_cmds = sizeof(mon_cmds);
+static mon_cmd_t info_cmds[] = {
+    {
+        .name       = NULL,
+    },
+};
+size_t sizeof_info_cmds = sizeof(info_cmds);
+static const mon_cmd_t qmp_cmds[] = {
+    { /* NULL */ },
+};
+#else
+extern mon_cmd_t mon_cmds[];
+extern size_t sizeof_mon_cmds;
+extern mon_cmd_t info_cmds[];
+extern size_t sizeof_info_cmds;
+extern const mon_cmd_t qmp_cmds[];
+#endif
 
 Monitor *cur_mon;
 Monitor *default_mon;
@@ -1187,987 +1204,6 @@ int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp)
     return fd;
 }
 
-/* Please update hmp-commands.hx when adding or changing commands */
-mon_cmd_t info_cmds[] = {
-    {
-        .name       = "version",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the version of QEMU",
-        .mhandler.cmd = hmp_info_version,
-    },
-    {
-        .name       = "network",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the network state",
-        .mhandler.cmd = do_info_network,
-    },
-    {
-        .name       = "chardev",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the character devices",
-        .mhandler.cmd = hmp_info_chardev,
-    },
-    {
-        .name       = "block",
-        .args_type  = "verbose:-v,device:B?",
-        .params     = "[-v] [device]",
-        .help       = "show info of one block device or all block devices "
-                      "(and details of images with -v option)",
-        .mhandler.cmd = hmp_info_block,
-    },
-    {
-        .name       = "blockstats",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show block device statistics",
-        .mhandler.cmd = hmp_info_blockstats,
-    },
-    {
-        .name       = "block-jobs",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show progress of ongoing block device operations",
-        .mhandler.cmd = hmp_info_block_jobs,
-    },
-    {
-        .name       = "registers",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the cpu registers",
-        .mhandler.cmd = do_info_registers,
-    },
-    {
-        .name       = "cpus",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show infos for each CPU",
-        .mhandler.cmd = hmp_info_cpus,
-    },
-    {
-        .name       = "history",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the command line history",
-        .mhandler.cmd = do_info_history,
-    },
-#if defined(TARGET_I386) || defined(TARGET_PPC) || defined(TARGET_MIPS) || \
-    defined(TARGET_LM32) || (defined(TARGET_SPARC) && !defined(TARGET_SPARC64))
-    {
-        .name       = "irq",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the interrupts statistics (if available)",
-#ifdef TARGET_SPARC
-        .mhandler.cmd = sun4m_irq_info,
-#elif defined(TARGET_LM32)
-        .mhandler.cmd = lm32_irq_info,
-#else
-        .mhandler.cmd = irq_info,
-#endif
-    },
-    {
-        .name       = "pic",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show i8259 (PIC) state",
-#ifdef TARGET_SPARC
-        .mhandler.cmd = sun4m_pic_info,
-#elif defined(TARGET_LM32)
-        .mhandler.cmd = lm32_do_pic_info,
-#else
-        .mhandler.cmd = pic_info,
-#endif
-    },
-#endif
-    {
-        .name       = "pci",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show PCI info",
-        .mhandler.cmd = hmp_info_pci,
-    },
-#if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \
-    defined(TARGET_PPC) || defined(TARGET_XTENSA)
-    {
-        .name       = "tlb",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show virtual to physical memory mappings",
-        .mhandler.cmd = tlb_info,
-    },
-#endif
-#if defined(TARGET_I386)
-    {
-        .name       = "mem",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the active virtual memory mappings",
-        .mhandler.cmd = mem_info,
-    },
-#endif
-    {
-        .name       = "mtree",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show memory tree",
-        .mhandler.cmd = do_info_mtree,
-    },
-    {
-        .name       = "jit",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show dynamic compiler info",
-        .mhandler.cmd = do_info_jit,
-    },
-    {
-        .name       = "kvm",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show KVM information",
-        .mhandler.cmd = hmp_info_kvm,
-    },
-    {
-        .name       = "numa",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show NUMA information",
-        .mhandler.cmd = do_info_numa,
-    },
-    {
-        .name       = "usb",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show guest USB devices",
-        .mhandler.cmd = usb_info,
-    },
-    {
-        .name       = "usbhost",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show host USB devices",
-        .mhandler.cmd = usb_host_info,
-    },
-    {
-        .name       = "profile",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show profiling information",
-        .mhandler.cmd = do_info_profile,
-    },
-    {
-        .name       = "capture",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show capture information",
-        .mhandler.cmd = do_info_capture,
-    },
-    {
-        .name       = "snapshots",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the currently saved VM snapshots",
-        .mhandler.cmd = do_info_snapshots,
-    },
-    {
-        .name       = "status",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the current VM status (running|paused)",
-        .mhandler.cmd = hmp_info_status,
-    },
-    {
-        .name       = "pcmcia",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show guest PCMCIA status",
-        .mhandler.cmd = pcmcia_info,
-    },
-    {
-        .name       = "mice",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show which guest mouse is receiving events",
-        .mhandler.cmd = hmp_info_mice,
-    },
-    {
-        .name       = "vnc",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the vnc server status",
-        .mhandler.cmd = hmp_info_vnc,
-    },
-#if defined(CONFIG_SPICE)
-    {
-        .name       = "spice",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the spice server status",
-        .mhandler.cmd = hmp_info_spice,
-    },
-#endif
-    {
-        .name       = "name",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the current VM name",
-        .mhandler.cmd = hmp_info_name,
-    },
-    {
-        .name       = "uuid",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the current VM UUID",
-        .mhandler.cmd = hmp_info_uuid,
-    },
-    {
-        .name       = "cpustats",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show CPU statistics",
-        .mhandler.cmd = do_info_cpu_stats,
-    },
-#if defined(CONFIG_SLIRP)
-    {
-        .name       = "usernet",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show user network stack connection states",
-        .mhandler.cmd = do_info_usernet,
-    },
-#endif
-    {
-        .name       = "migrate",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show migration status",
-        .mhandler.cmd = hmp_info_migrate,
-    },
-    {
-        .name       = "migrate_capabilities",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show current migration capabilities",
-        .mhandler.cmd = hmp_info_migrate_capabilities,
-    },
-    {
-        .name       = "migrate_cache_size",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show current migration xbzrle cache size",
-        .mhandler.cmd = hmp_info_migrate_cache_size,
-    },
-    {
-        .name       = "balloon",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show balloon information",
-        .mhandler.cmd = hmp_info_balloon,
-    },
-    {
-        .name       = "qtree",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show device tree",
-        .mhandler.cmd = do_info_qtree,
-    },
-    {
-        .name       = "qdm",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show qdev device model list",
-        .mhandler.cmd = do_info_qdm,
-    },
-    {
-        .name       = "roms",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show roms",
-        .mhandler.cmd = do_info_roms,
-    },
-    {
-        .name       = "trace-events",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show available trace-events & their state",
-        .mhandler.cmd = do_trace_print_events,
-    },
-    {
-        .name       = "tpm",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the TPM device",
-        .mhandler.cmd = hmp_info_tpm,
-    },
-    {
-        .name       = "memdev",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show memory backends",
-        .mhandler.cmd = hmp_info_memdev,
-    },
-    {
-        .name       = NULL,
-    },
-};
-
-/* mon_cmds and info_cmds would be sorted at runtime */
-mon_cmd_t mon_cmds[] = {
-#include "hmp-commands.h"
-    { NULL, NULL, },
-};
-
-const mon_cmd_t qmp_cmds[] = {
-#include "qmp-commands-old.h"
-    { /* NULL */ },
-};
-
-/*******************************************************************/
-
-static const char *pch;
-static sigjmp_buf expr_env;
-
-#define MD_TLONG 0
-#define MD_I32   1
-
-typedef struct MonitorDef {
-    const char *name;
-    int offset;
-    target_long (*get_value)(const struct MonitorDef *md, int val);
-    int type;
-} MonitorDef;
-
-#if defined(TARGET_I386)
-static target_long monitor_get_pc (const struct MonitorDef *md, int val)
-{
-    CPUArchState *env = mon_get_cpu();
-    return env->eip + env->segs[R_CS].base;
-}
-#endif
-
-#if defined(TARGET_PPC)
-static target_long monitor_get_ccr (const struct MonitorDef *md, int val)
-{
-    CPUArchState *env = mon_get_cpu();
-    unsigned int u;
-    int i;
-
-    u = 0;
-    for (i = 0; i < 8; i++)
-        u |= env->crf[i] << (32 - (4 * i));
-
-    return u;
-}
-
-static target_long monitor_get_msr (const struct MonitorDef *md, int val)
-{
-    CPUArchState *env = mon_get_cpu();
-    return env->msr;
-}
-
-static target_long monitor_get_xer (const struct MonitorDef *md, int val)
-{
-    CPUArchState *env = mon_get_cpu();
-    return env->xer;
-}
-
-static target_long monitor_get_decr (const struct MonitorDef *md, int val)
-{
-    CPUArchState *env = mon_get_cpu();
-    return cpu_ppc_load_decr(env);
-}
-
-static target_long monitor_get_tbu (const struct MonitorDef *md, int val)
-{
-    CPUArchState *env = mon_get_cpu();
-    return cpu_ppc_load_tbu(env);
-}
-
-static target_long monitor_get_tbl (const struct MonitorDef *md, int val)
-{
-    CPUArchState *env = mon_get_cpu();
-    return cpu_ppc_load_tbl(env);
-}
-#endif
-
-#if defined(TARGET_SPARC)
-#ifndef TARGET_SPARC64
-static target_long monitor_get_psr (const struct MonitorDef *md, int val)
-{
-    CPUArchState *env = mon_get_cpu();
-
-    return cpu_get_psr(env);
-}
-#endif
-
-static target_long monitor_get_reg(const struct MonitorDef *md, int val)
-{
-    CPUArchState *env = mon_get_cpu();
-    return env->regwptr[val];
-}
-#endif
-
-static const MonitorDef monitor_defs[] = {
-#ifdef TARGET_I386
-
-#define SEG(name, seg) \
-    { name, offsetof(CPUX86State, segs[seg].selector), NULL, MD_I32 },\
-    { name ".base", offsetof(CPUX86State, segs[seg].base) },\
-    { name ".limit", offsetof(CPUX86State, segs[seg].limit), NULL, MD_I32 },
-
-    { "eax", offsetof(CPUX86State, regs[0]) },
-    { "ecx", offsetof(CPUX86State, regs[1]) },
-    { "edx", offsetof(CPUX86State, regs[2]) },
-    { "ebx", offsetof(CPUX86State, regs[3]) },
-    { "esp|sp", offsetof(CPUX86State, regs[4]) },
-    { "ebp|fp", offsetof(CPUX86State, regs[5]) },
-    { "esi", offsetof(CPUX86State, regs[6]) },
-    { "edi", offsetof(CPUX86State, regs[7]) },
-#ifdef TARGET_X86_64
-    { "r8", offsetof(CPUX86State, regs[8]) },
-    { "r9", offsetof(CPUX86State, regs[9]) },
-    { "r10", offsetof(CPUX86State, regs[10]) },
-    { "r11", offsetof(CPUX86State, regs[11]) },
-    { "r12", offsetof(CPUX86State, regs[12]) },
-    { "r13", offsetof(CPUX86State, regs[13]) },
-    { "r14", offsetof(CPUX86State, regs[14]) },
-    { "r15", offsetof(CPUX86State, regs[15]) },
-#endif
-    { "eflags", offsetof(CPUX86State, eflags) },
-    { "eip", offsetof(CPUX86State, eip) },
-    SEG("cs", R_CS)
-    SEG("ds", R_DS)
-    SEG("es", R_ES)
-    SEG("ss", R_SS)
-    SEG("fs", R_FS)
-    SEG("gs", R_GS)
-    { "pc", 0, monitor_get_pc, },
-#elif defined(TARGET_PPC)
-    /* General purpose registers */
-    { "r0", offsetof(CPUPPCState, gpr[0]) },
-    { "r1", offsetof(CPUPPCState, gpr[1]) },
-    { "r2", offsetof(CPUPPCState, gpr[2]) },
-    { "r3", offsetof(CPUPPCState, gpr[3]) },
-    { "r4", offsetof(CPUPPCState, gpr[4]) },
-    { "r5", offsetof(CPUPPCState, gpr[5]) },
-    { "r6", offsetof(CPUPPCState, gpr[6]) },
-    { "r7", offsetof(CPUPPCState, gpr[7]) },
-    { "r8", offsetof(CPUPPCState, gpr[8]) },
-    { "r9", offsetof(CPUPPCState, gpr[9]) },
-    { "r10", offsetof(CPUPPCState, gpr[10]) },
-    { "r11", offsetof(CPUPPCState, gpr[11]) },
-    { "r12", offsetof(CPUPPCState, gpr[12]) },
-    { "r13", offsetof(CPUPPCState, gpr[13]) },
-    { "r14", offsetof(CPUPPCState, gpr[14]) },
-    { "r15", offsetof(CPUPPCState, gpr[15]) },
-    { "r16", offsetof(CPUPPCState, gpr[16]) },
-    { "r17", offsetof(CPUPPCState, gpr[17]) },
-    { "r18", offsetof(CPUPPCState, gpr[18]) },
-    { "r19", offsetof(CPUPPCState, gpr[19]) },
-    { "r20", offsetof(CPUPPCState, gpr[20]) },
-    { "r21", offsetof(CPUPPCState, gpr[21]) },
-    { "r22", offsetof(CPUPPCState, gpr[22]) },
-    { "r23", offsetof(CPUPPCState, gpr[23]) },
-    { "r24", offsetof(CPUPPCState, gpr[24]) },
-    { "r25", offsetof(CPUPPCState, gpr[25]) },
-    { "r26", offsetof(CPUPPCState, gpr[26]) },
-    { "r27", offsetof(CPUPPCState, gpr[27]) },
-    { "r28", offsetof(CPUPPCState, gpr[28]) },
-    { "r29", offsetof(CPUPPCState, gpr[29]) },
-    { "r30", offsetof(CPUPPCState, gpr[30]) },
-    { "r31", offsetof(CPUPPCState, gpr[31]) },
-    /* Floating point registers */
-    { "f0", offsetof(CPUPPCState, fpr[0]) },
-    { "f1", offsetof(CPUPPCState, fpr[1]) },
-    { "f2", offsetof(CPUPPCState, fpr[2]) },
-    { "f3", offsetof(CPUPPCState, fpr[3]) },
-    { "f4", offsetof(CPUPPCState, fpr[4]) },
-    { "f5", offsetof(CPUPPCState, fpr[5]) },
-    { "f6", offsetof(CPUPPCState, fpr[6]) },
-    { "f7", offsetof(CPUPPCState, fpr[7]) },
-    { "f8", offsetof(CPUPPCState, fpr[8]) },
-    { "f9", offsetof(CPUPPCState, fpr[9]) },
-    { "f10", offsetof(CPUPPCState, fpr[10]) },
-    { "f11", offsetof(CPUPPCState, fpr[11]) },
-    { "f12", offsetof(CPUPPCState, fpr[12]) },
-    { "f13", offsetof(CPUPPCState, fpr[13]) },
-    { "f14", offsetof(CPUPPCState, fpr[14]) },
-    { "f15", offsetof(CPUPPCState, fpr[15]) },
-    { "f16", offsetof(CPUPPCState, fpr[16]) },
-    { "f17", offsetof(CPUPPCState, fpr[17]) },
-    { "f18", offsetof(CPUPPCState, fpr[18]) },
-    { "f19", offsetof(CPUPPCState, fpr[19]) },
-    { "f20", offsetof(CPUPPCState, fpr[20]) },
-    { "f21", offsetof(CPUPPCState, fpr[21]) },
-    { "f22", offsetof(CPUPPCState, fpr[22]) },
-    { "f23", offsetof(CPUPPCState, fpr[23]) },
-    { "f24", offsetof(CPUPPCState, fpr[24]) },
-    { "f25", offsetof(CPUPPCState, fpr[25]) },
-    { "f26", offsetof(CPUPPCState, fpr[26]) },
-    { "f27", offsetof(CPUPPCState, fpr[27]) },
-    { "f28", offsetof(CPUPPCState, fpr[28]) },
-    { "f29", offsetof(CPUPPCState, fpr[29]) },
-    { "f30", offsetof(CPUPPCState, fpr[30]) },
-    { "f31", offsetof(CPUPPCState, fpr[31]) },
-    { "fpscr", offsetof(CPUPPCState, fpscr) },
-    /* Next instruction pointer */
-    { "nip|pc", offsetof(CPUPPCState, nip) },
-    { "lr", offsetof(CPUPPCState, lr) },
-    { "ctr", offsetof(CPUPPCState, ctr) },
-    { "decr", 0, &monitor_get_decr, },
-    { "ccr", 0, &monitor_get_ccr, },
-    /* Machine state register */
-    { "msr", 0, &monitor_get_msr, },
-    { "xer", 0, &monitor_get_xer, },
-    { "tbu", 0, &monitor_get_tbu, },
-    { "tbl", 0, &monitor_get_tbl, },
-    /* Segment registers */
-    { "sdr1", offsetof(CPUPPCState, spr[SPR_SDR1]) },
-    { "sr0", offsetof(CPUPPCState, sr[0]) },
-    { "sr1", offsetof(CPUPPCState, sr[1]) },
-    { "sr2", offsetof(CPUPPCState, sr[2]) },
-    { "sr3", offsetof(CPUPPCState, sr[3]) },
-    { "sr4", offsetof(CPUPPCState, sr[4]) },
-    { "sr5", offsetof(CPUPPCState, sr[5]) },
-    { "sr6", offsetof(CPUPPCState, sr[6]) },
-    { "sr7", offsetof(CPUPPCState, sr[7]) },
-    { "sr8", offsetof(CPUPPCState, sr[8]) },
-    { "sr9", offsetof(CPUPPCState, sr[9]) },
-    { "sr10", offsetof(CPUPPCState, sr[10]) },
-    { "sr11", offsetof(CPUPPCState, sr[11]) },
-    { "sr12", offsetof(CPUPPCState, sr[12]) },
-    { "sr13", offsetof(CPUPPCState, sr[13]) },
-    { "sr14", offsetof(CPUPPCState, sr[14]) },
-    { "sr15", offsetof(CPUPPCState, sr[15]) },
-    /* Too lazy to put BATs... */
-    { "pvr", offsetof(CPUPPCState, spr[SPR_PVR]) },
-
-    { "srr0", offsetof(CPUPPCState, spr[SPR_SRR0]) },
-    { "srr1", offsetof(CPUPPCState, spr[SPR_SRR1]) },
-    { "dar", offsetof(CPUPPCState, spr[SPR_DAR]) },
-    { "dsisr", offsetof(CPUPPCState, spr[SPR_DSISR]) },
-    { "cfar", offsetof(CPUPPCState, spr[SPR_CFAR]) },
-    { "sprg0", offsetof(CPUPPCState, spr[SPR_SPRG0]) },
-    { "sprg1", offsetof(CPUPPCState, spr[SPR_SPRG1]) },
-    { "sprg2", offsetof(CPUPPCState, spr[SPR_SPRG2]) },
-    { "sprg3", offsetof(CPUPPCState, spr[SPR_SPRG3]) },
-    { "sprg4", offsetof(CPUPPCState, spr[SPR_SPRG4]) },
-    { "sprg5", offsetof(CPUPPCState, spr[SPR_SPRG5]) },
-    { "sprg6", offsetof(CPUPPCState, spr[SPR_SPRG6]) },
-    { "sprg7", offsetof(CPUPPCState, spr[SPR_SPRG7]) },
-    { "pid", offsetof(CPUPPCState, spr[SPR_BOOKE_PID]) },
-    { "csrr0", offsetof(CPUPPCState, spr[SPR_BOOKE_CSRR0]) },
-    { "csrr1", offsetof(CPUPPCState, spr[SPR_BOOKE_CSRR1]) },
-    { "esr", offsetof(CPUPPCState, spr[SPR_BOOKE_ESR]) },
-    { "dear", offsetof(CPUPPCState, spr[SPR_BOOKE_DEAR]) },
-    { "mcsr", offsetof(CPUPPCState, spr[SPR_BOOKE_MCSR]) },
-    { "tsr", offsetof(CPUPPCState, spr[SPR_BOOKE_TSR]) },
-    { "tcr", offsetof(CPUPPCState, spr[SPR_BOOKE_TCR]) },
-    { "vrsave", offsetof(CPUPPCState, spr[SPR_VRSAVE]) },
-    { "pir", offsetof(CPUPPCState, spr[SPR_BOOKE_PIR]) },
-    { "mcsrr0", offsetof(CPUPPCState, spr[SPR_BOOKE_MCSRR0]) },
-    { "mcsrr1", offsetof(CPUPPCState, spr[SPR_BOOKE_MCSRR1]) },
-    { "decar", offsetof(CPUPPCState, spr[SPR_BOOKE_DECAR]) },
-    { "ivpr", offsetof(CPUPPCState, spr[SPR_BOOKE_IVPR]) },
-    { "epcr", offsetof(CPUPPCState, spr[SPR_BOOKE_EPCR]) },
-    { "sprg8", offsetof(CPUPPCState, spr[SPR_BOOKE_SPRG8]) },
-    { "ivor0", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR0]) },
-    { "ivor1", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR1]) },
-    { "ivor2", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR2]) },
-    { "ivor3", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR3]) },
-    { "ivor4", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR4]) },
-    { "ivor5", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR5]) },
-    { "ivor6", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR6]) },
-    { "ivor7", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR7]) },
-    { "ivor8", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR8]) },
-    { "ivor9", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR9]) },
-    { "ivor10", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR10]) },
-    { "ivor11", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR11]) },
-    { "ivor12", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR12]) },
-    { "ivor13", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR13]) },
-    { "ivor14", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR14]) },
-    { "ivor15", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR15]) },
-    { "ivor32", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR32]) },
-    { "ivor33", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR33]) },
-    { "ivor34", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR34]) },
-    { "ivor35", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR35]) },
-    { "ivor36", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR36]) },
-    { "ivor37", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR37]) },
-    { "mas0", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS0]) },
-    { "mas1", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS1]) },
-    { "mas2", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS2]) },
-    { "mas3", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS3]) },
-    { "mas4", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS4]) },
-    { "mas6", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS6]) },
-    { "mas7", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS7]) },
-    { "mmucfg", offsetof(CPUPPCState, spr[SPR_MMUCFG]) },
-    { "tlb0cfg", offsetof(CPUPPCState, spr[SPR_BOOKE_TLB0CFG]) },
-    { "tlb1cfg", offsetof(CPUPPCState, spr[SPR_BOOKE_TLB1CFG]) },
-    { "epr", offsetof(CPUPPCState, spr[SPR_BOOKE_EPR]) },
-    { "eplc", offsetof(CPUPPCState, spr[SPR_BOOKE_EPLC]) },
-    { "epsc", offsetof(CPUPPCState, spr[SPR_BOOKE_EPSC]) },
-    { "svr", offsetof(CPUPPCState, spr[SPR_E500_SVR]) },
-    { "mcar", offsetof(CPUPPCState, spr[SPR_Exxx_MCAR]) },
-    { "pid1", offsetof(CPUPPCState, spr[SPR_BOOKE_PID1]) },
-    { "pid2", offsetof(CPUPPCState, spr[SPR_BOOKE_PID2]) },
-    { "hid0", offsetof(CPUPPCState, spr[SPR_HID0]) },
-
-#elif defined(TARGET_SPARC)
-    { "g0", offsetof(CPUSPARCState, gregs[0]) },
-    { "g1", offsetof(CPUSPARCState, gregs[1]) },
-    { "g2", offsetof(CPUSPARCState, gregs[2]) },
-    { "g3", offsetof(CPUSPARCState, gregs[3]) },
-    { "g4", offsetof(CPUSPARCState, gregs[4]) },
-    { "g5", offsetof(CPUSPARCState, gregs[5]) },
-    { "g6", offsetof(CPUSPARCState, gregs[6]) },
-    { "g7", offsetof(CPUSPARCState, gregs[7]) },
-    { "o0", 0, monitor_get_reg },
-    { "o1", 1, monitor_get_reg },
-    { "o2", 2, monitor_get_reg },
-    { "o3", 3, monitor_get_reg },
-    { "o4", 4, monitor_get_reg },
-    { "o5", 5, monitor_get_reg },
-    { "o6", 6, monitor_get_reg },
-    { "o7", 7, monitor_get_reg },
-    { "l0", 8, monitor_get_reg },
-    { "l1", 9, monitor_get_reg },
-    { "l2", 10, monitor_get_reg },
-    { "l3", 11, monitor_get_reg },
-    { "l4", 12, monitor_get_reg },
-    { "l5", 13, monitor_get_reg },
-    { "l6", 14, monitor_get_reg },
-    { "l7", 15, monitor_get_reg },
-    { "i0", 16, monitor_get_reg },
-    { "i1", 17, monitor_get_reg },
-    { "i2", 18, monitor_get_reg },
-    { "i3", 19, monitor_get_reg },
-    { "i4", 20, monitor_get_reg },
-    { "i5", 21, monitor_get_reg },
-    { "i6", 22, monitor_get_reg },
-    { "i7", 23, monitor_get_reg },
-    { "pc", offsetof(CPUSPARCState, pc) },
-    { "npc", offsetof(CPUSPARCState, npc) },
-    { "y", offsetof(CPUSPARCState, y) },
-#ifndef TARGET_SPARC64
-    { "psr", 0, &monitor_get_psr, },
-    { "wim", offsetof(CPUSPARCState, wim) },
-#endif
-    { "tbr", offsetof(CPUSPARCState, tbr) },
-    { "fsr", offsetof(CPUSPARCState, fsr) },
-    { "f0", offsetof(CPUSPARCState, fpr[0].l.upper) },
-    { "f1", offsetof(CPUSPARCState, fpr[0].l.lower) },
-    { "f2", offsetof(CPUSPARCState, fpr[1].l.upper) },
-    { "f3", offsetof(CPUSPARCState, fpr[1].l.lower) },
-    { "f4", offsetof(CPUSPARCState, fpr[2].l.upper) },
-    { "f5", offsetof(CPUSPARCState, fpr[2].l.lower) },
-    { "f6", offsetof(CPUSPARCState, fpr[3].l.upper) },
-    { "f7", offsetof(CPUSPARCState, fpr[3].l.lower) },
-    { "f8", offsetof(CPUSPARCState, fpr[4].l.upper) },
-    { "f9", offsetof(CPUSPARCState, fpr[4].l.lower) },
-    { "f10", offsetof(CPUSPARCState, fpr[5].l.upper) },
-    { "f11", offsetof(CPUSPARCState, fpr[5].l.lower) },
-    { "f12", offsetof(CPUSPARCState, fpr[6].l.upper) },
-    { "f13", offsetof(CPUSPARCState, fpr[6].l.lower) },
-    { "f14", offsetof(CPUSPARCState, fpr[7].l.upper) },
-    { "f15", offsetof(CPUSPARCState, fpr[7].l.lower) },
-    { "f16", offsetof(CPUSPARCState, fpr[8].l.upper) },
-    { "f17", offsetof(CPUSPARCState, fpr[8].l.lower) },
-    { "f18", offsetof(CPUSPARCState, fpr[9].l.upper) },
-    { "f19", offsetof(CPUSPARCState, fpr[9].l.lower) },
-    { "f20", offsetof(CPUSPARCState, fpr[10].l.upper) },
-    { "f21", offsetof(CPUSPARCState, fpr[10].l.lower) },
-    { "f22", offsetof(CPUSPARCState, fpr[11].l.upper) },
-    { "f23", offsetof(CPUSPARCState, fpr[11].l.lower) },
-    { "f24", offsetof(CPUSPARCState, fpr[12].l.upper) },
-    { "f25", offsetof(CPUSPARCState, fpr[12].l.lower) },
-    { "f26", offsetof(CPUSPARCState, fpr[13].l.upper) },
-    { "f27", offsetof(CPUSPARCState, fpr[13].l.lower) },
-    { "f28", offsetof(CPUSPARCState, fpr[14].l.upper) },
-    { "f29", offsetof(CPUSPARCState, fpr[14].l.lower) },
-    { "f30", offsetof(CPUSPARCState, fpr[15].l.upper) },
-    { "f31", offsetof(CPUSPARCState, fpr[15].l.lower) },
-#ifdef TARGET_SPARC64
-    { "f32", offsetof(CPUSPARCState, fpr[16]) },
-    { "f34", offsetof(CPUSPARCState, fpr[17]) },
-    { "f36", offsetof(CPUSPARCState, fpr[18]) },
-    { "f38", offsetof(CPUSPARCState, fpr[19]) },
-    { "f40", offsetof(CPUSPARCState, fpr[20]) },
-    { "f42", offsetof(CPUSPARCState, fpr[21]) },
-    { "f44", offsetof(CPUSPARCState, fpr[22]) },
-    { "f46", offsetof(CPUSPARCState, fpr[23]) },
-    { "f48", offsetof(CPUSPARCState, fpr[24]) },
-    { "f50", offsetof(CPUSPARCState, fpr[25]) },
-    { "f52", offsetof(CPUSPARCState, fpr[26]) },
-    { "f54", offsetof(CPUSPARCState, fpr[27]) },
-    { "f56", offsetof(CPUSPARCState, fpr[28]) },
-    { "f58", offsetof(CPUSPARCState, fpr[29]) },
-    { "f60", offsetof(CPUSPARCState, fpr[30]) },
-    { "f62", offsetof(CPUSPARCState, fpr[31]) },
-    { "asi", offsetof(CPUSPARCState, asi) },
-    { "pstate", offsetof(CPUSPARCState, pstate) },
-    { "cansave", offsetof(CPUSPARCState, cansave) },
-    { "canrestore", offsetof(CPUSPARCState, canrestore) },
-    { "otherwin", offsetof(CPUSPARCState, otherwin) },
-    { "wstate", offsetof(CPUSPARCState, wstate) },
-    { "cleanwin", offsetof(CPUSPARCState, cleanwin) },
-    { "fprs", offsetof(CPUSPARCState, fprs) },
-#endif
-#endif
-    { NULL },
-};
-
-static void GCC_FMT_ATTR(2, 3) QEMU_NORETURN
-expr_error(Monitor *mon, const char *fmt, ...)
-{
-    va_list ap;
-    va_start(ap, fmt);
-    monitor_vprintf(mon, fmt, ap);
-    monitor_printf(mon, "\n");
-    va_end(ap);
-    siglongjmp(expr_env, 1);
-}
-
-/* return 0 if OK, -1 if not found */
-static int get_monitor_def(target_long *pval, const char *name)
-{
-    const MonitorDef *md;
-    void *ptr;
-
-    for(md = monitor_defs; md->name != NULL; md++) {
-        if (compare_cmd(name, md->name)) {
-            if (md->get_value) {
-                *pval = md->get_value(md, md->offset);
-            } else {
-                CPUArchState *env = mon_get_cpu();
-                ptr = (uint8_t *)env + md->offset;
-                switch(md->type) {
-                case MD_I32:
-                    *pval = *(int32_t *)ptr;
-                    break;
-                case MD_TLONG:
-                    *pval = *(target_long *)ptr;
-                    break;
-                default:
-                    *pval = 0;
-                    break;
-                }
-            }
-            return 0;
-        }
-    }
-    return -1;
-}
-
-static void next(void)
-{
-    if (*pch != '\0') {
-        pch++;
-        while (qemu_isspace(*pch))
-            pch++;
-    }
-}
-
-static int64_t expr_sum(Monitor *mon);
-
-static int64_t expr_unary(Monitor *mon)
-{
-    int64_t n;
-    char *p;
-    int ret;
-
-    switch(*pch) {
-    case '+':
-        next();
-        n = expr_unary(mon);
-        break;
-    case '-':
-        next();
-        n = -expr_unary(mon);
-        break;
-    case '~':
-        next();
-        n = ~expr_unary(mon);
-        break;
-    case '(':
-        next();
-        n = expr_sum(mon);
-        if (*pch != ')') {
-            expr_error(mon, "')' expected");
-        }
-        next();
-        break;
-    case '\'':
-        pch++;
-        if (*pch == '\0')
-            expr_error(mon, "character constant expected");
-        n = *pch;
-        pch++;
-        if (*pch != '\'')
-            expr_error(mon, "missing terminating \' character");
-        next();
-        break;
-    case '$':
-        {
-            char buf[128], *q;
-            target_long reg=0;
-
-            pch++;
-            q = buf;
-            while ((*pch >= 'a' && *pch <= 'z') ||
-                   (*pch >= 'A' && *pch <= 'Z') ||
-                   (*pch >= '0' && *pch <= '9') ||
-                   *pch == '_' || *pch == '.') {
-                if ((q - buf) < sizeof(buf) - 1)
-                    *q++ = *pch;
-                pch++;
-            }
-            while (qemu_isspace(*pch))
-                pch++;
-            *q = 0;
-            ret = get_monitor_def(&reg, buf);
-            if (ret < 0)
-                expr_error(mon, "unknown register");
-            n = reg;
-        }
-        break;
-    case '\0':
-        expr_error(mon, "unexpected end of expression");
-        n = 0;
-        break;
-    default:
-        errno = 0;
-        n = strtoull(pch, &p, 0);
-        if (errno == ERANGE) {
-            expr_error(mon, "number too large");
-        }
-        if (pch == p) {
-            expr_error(mon, "invalid char '%c' in expression", *p);
-        }
-        pch = p;
-        while (qemu_isspace(*pch))
-            pch++;
-        break;
-    }
-    return n;
-}
-
-
-static int64_t expr_prod(Monitor *mon)
-{
-    int64_t val, val2;
-    int op;
-
-    val = expr_unary(mon);
-    for(;;) {
-        op = *pch;
-        if (op != '*' && op != '/' && op != '%')
-            break;
-        next();
-        val2 = expr_unary(mon);
-        switch(op) {
-        default:
-        case '*':
-            val *= val2;
-            break;
-        case '/':
-        case '%':
-            if (val2 == 0)
-                expr_error(mon, "division by zero");
-            if (op == '/')
-                val /= val2;
-            else
-                val %= val2;
-            break;
-        }
-    }
-    return val;
-}
-
-static int64_t expr_logic(Monitor *mon)
-{
-    int64_t val, val2;
-    int op;
-
-    val = expr_prod(mon);
-    for(;;) {
-        op = *pch;
-        if (op != '&' && op != '|' && op != '^')
-            break;
-        next();
-        val2 = expr_prod(mon);
-        switch(op) {
-        default:
-        case '&':
-            val &= val2;
-            break;
-        case '|':
-            val |= val2;
-            break;
-        case '^':
-            val ^= val2;
-            break;
-        }
-    }
-    return val;
-}
-
-static int64_t expr_sum(Monitor *mon)
-{
-    int64_t val, val2;
-    int op;
-
-    val = expr_logic(mon);
-    for(;;) {
-        op = *pch;
-        if (op != '+' && op != '-')
-            break;
-        next();
-        val2 = expr_logic(mon);
-        if (op == '+')
-            val += val2;
-        else
-            val -= val2;
-    }
-    return val;
-}
-
-int get_expr(Monitor *mon, int64_t *pval, const char **pp)
-{
-    pch = *pp;
-    if (sigsetjmp(expr_env, 0)) {
-        *pp = pch;
-        return -1;
-    }
-    while (qemu_isspace(*pch))
-        pch++;
-    *pval = expr_sum(mon);
-    *pp = pch;
-    return 0;
-}
-
-int get_double(Monitor *mon, double *pval, const char **pp)
-{
-    const char *p = *pp;
-    char *tailp;
-    double d;
-
-    d = strtod(p, &tailp);
-    if (tailp == p) {
-        monitor_printf(mon, "Number expected\n");
-        return -1;
-    }
-    if (d != d || d - d != 0) {
-        /* NaN or infinity */
-        monitor_printf(mon, "Bad number\n");
-        return -1;
-    }
-    *pval = d;
-    *pp = tailp;
-    return 0;
-}
-
 /*
  * Store the command-name in cmdname, and return a pointer to
  * the remaining of the command string.
@@ -3859,10 +2895,10 @@ static void sortcmdlist(void)
     int array_num;
     int elem_size = sizeof(mon_cmd_t);
 
-    array_num = sizeof(mon_cmds)/elem_size-1;
+    array_num = sizeof_mon_cmds/elem_size-1;
     qsort((void *)mon_cmds, array_num, elem_size, compare_mon_cmd);
 
-    array_num = sizeof(info_cmds)/elem_size-1;
+    array_num = sizeof_info_cmds/elem_size-1;
     qsort((void *)info_cmds, array_num, elem_size, compare_mon_cmd);
 }
 
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 16/24] monitor: Move more functions from monitor.c to monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (14 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 15/24] monitor: Move mon_cmd_t arrays and some function from monitor.c " Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 17/24] monitor: Move two net " Benoît Canet
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor-system.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 monitor.c        | 69 --------------------------------------------------------
 2 files changed, 69 insertions(+), 69 deletions(-)

diff --git a/monitor-system.c b/monitor-system.c
index 5b5f1ed..f8e4a10 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -2395,3 +2395,72 @@ int get_double(Monitor *mon, double *pval, const char **pp)
 
 size_t sizeof_mon_cmds = sizeof(mon_cmds);
 size_t sizeof_info_cmds = sizeof(info_cmds);
+
+static void bdrv_password_cb(void *opaque, const char *password,
+                             void *readline_opaque)
+{
+    Monitor *mon = opaque;
+    BlockDriverState *bs = readline_opaque;
+    int ret = 0;
+
+    if (bdrv_set_key(bs, password) != 0) {
+        monitor_printf(mon, "invalid password\n");
+        ret = -EPERM;
+    }
+    if (mon->password_completion_cb)
+        mon->password_completion_cb(mon->password_opaque, ret);
+
+    monitor_read_command(mon, 1);
+}
+
+ReadLineState *monitor_get_rs(Monitor *mon)
+{
+    return mon->rs;
+}
+
+int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
+                                BlockDriverCompletionFunc *completion_cb,
+                                void *opaque)
+{
+    int err;
+
+    if (!bdrv_key_required(bs)) {
+        if (completion_cb)
+            completion_cb(opaque, 0);
+        return 0;
+    }
+
+    if (monitor_ctrl_mode(mon)) {
+        qerror_report(QERR_DEVICE_ENCRYPTED, bdrv_get_device_name(bs),
+                      bdrv_get_encrypted_filename(bs));
+        return -1;
+    }
+
+    monitor_printf(mon, "%s (%s) is encrypted.\n", bdrv_get_device_name(bs),
+                   bdrv_get_encrypted_filename(bs));
+
+    mon->password_completion_cb = completion_cb;
+    mon->password_opaque = opaque;
+
+    err = monitor_read_password(mon, bdrv_password_cb, bs);
+
+    if (err && completion_cb)
+        completion_cb(opaque, err);
+
+    return err;
+}
+
+int monitor_read_block_device_key(Monitor *mon, const char *device,
+                                  BlockDriverCompletionFunc *completion_cb,
+                                  void *opaque)
+{
+    BlockDriverState *bs;
+
+    bs = bdrv_find(device);
+    if (!bs) {
+        monitor_printf(mon, "Device not found %s\n", device);
+        return -1;
+    }
+
+    return monitor_read_bdrv_key_start(mon, bs, completion_cb, opaque);
+}
diff --git a/monitor.c b/monitor.c
index 419da13..79b54e1 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2978,75 +2978,6 @@ void monitor_init(CharDriverState *chr, int flags)
         default_mon = mon;
 }
 
-static void bdrv_password_cb(void *opaque, const char *password,
-                             void *readline_opaque)
-{
-    Monitor *mon = opaque;
-    BlockDriverState *bs = readline_opaque;
-    int ret = 0;
-
-    if (bdrv_set_key(bs, password) != 0) {
-        monitor_printf(mon, "invalid password\n");
-        ret = -EPERM;
-    }
-    if (mon->password_completion_cb)
-        mon->password_completion_cb(mon->password_opaque, ret);
-
-    monitor_read_command(mon, 1);
-}
-
-ReadLineState *monitor_get_rs(Monitor *mon)
-{
-    return mon->rs;
-}
-
-int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
-                                BlockDriverCompletionFunc *completion_cb,
-                                void *opaque)
-{
-    int err;
-
-    if (!bdrv_key_required(bs)) {
-        if (completion_cb)
-            completion_cb(opaque, 0);
-        return 0;
-    }
-
-    if (monitor_ctrl_mode(mon)) {
-        qerror_report(QERR_DEVICE_ENCRYPTED, bdrv_get_device_name(bs),
-                      bdrv_get_encrypted_filename(bs));
-        return -1;
-    }
-
-    monitor_printf(mon, "%s (%s) is encrypted.\n", bdrv_get_device_name(bs),
-                   bdrv_get_encrypted_filename(bs));
-
-    mon->password_completion_cb = completion_cb;
-    mon->password_opaque = opaque;
-
-    err = monitor_read_password(mon, bdrv_password_cb, bs);
-
-    if (err && completion_cb)
-        completion_cb(opaque, err);
-
-    return err;
-}
-
-int monitor_read_block_device_key(Monitor *mon, const char *device,
-                                  BlockDriverCompletionFunc *completion_cb,
-                                  void *opaque)
-{
-    BlockDriverState *bs;
-
-    bs = bdrv_find(device);
-    if (!bs) {
-        monitor_printf(mon, "Device not found %s\n", device);
-        return -1;
-    }
-
-    return monitor_read_bdrv_key_start(mon, bs, completion_cb, opaque);
-}
-
 QemuOptsList qemu_mon_opts = {
     .name = "mon",
     .implied_opt_name = "chardev",
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 17/24] monitor: Move two net functions from monitor.c to monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (15 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 16/24] monitor: Move more functions " Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 18/24] monitor: Move qmp_rtc_reset_reinjection " Benoît Canet
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

With this move the monitor.c/monitor-system.c split is complete.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor-system.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 monitor.c        | 49 -------------------------------------------------
 2 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/monitor-system.c b/monitor-system.c
index f8e4a10..d5abf73 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -2464,3 +2464,52 @@ int monitor_read_block_device_key(Monitor *mon, const char *device,
 
     return monitor_read_bdrv_key_start(mon, bs, completion_cb, opaque);
 }
+
+void set_link_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    size_t len;
+
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    if (nb_args == 2) {
+        NetClientState *ncs[255];
+        int count, i;
+        count = qemu_find_net_clients_except(NULL, ncs,
+                                             NET_CLIENT_OPTIONS_KIND_NONE, 255);
+        for (i = 0; i < count; i++) {
+            const char *name = ncs[i]->name;
+            if (!strncmp(str, name, len)) {
+                readline_add_completion(rs, name);
+            }
+        }
+    } else if (nb_args == 3) {
+        add_completion_option(rs, str, "on");
+        add_completion_option(rs, str, "off");
+    }
+}
+
+void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    int len, count, i;
+    NetClientState *ncs[255];
+
+    if (nb_args != 2) {
+        return;
+    }
+
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    count = qemu_find_net_clients_except(NULL, ncs, NET_CLIENT_OPTIONS_KIND_NIC,
+                                         255);
+    for (i = 0; i < count; i++) {
+        QemuOpts *opts;
+        const char *name = ncs[i]->name;
+        if (strncmp(str, name, len)) {
+            continue;
+        }
+        opts = qemu_opts_find(qemu_find_opts_err("netdev", NULL), name);
+        if (opts) {
+            readline_add_completion(rs, name);
+        }
+    }
+}
diff --git a/monitor.c b/monitor.c
index 79b54e1..3133f62 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2096,55 +2096,6 @@ void sendkey_completion(ReadLineState *rs, int nb_args, const char *str)
     }
 }
 
-void set_link_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    size_t len;
-
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    if (nb_args == 2) {
-        NetClientState *ncs[255];
-        int count, i;
-        count = qemu_find_net_clients_except(NULL, ncs,
-                                             NET_CLIENT_OPTIONS_KIND_NONE, 255);
-        for (i = 0; i < count; i++) {
-            const char *name = ncs[i]->name;
-            if (!strncmp(str, name, len)) {
-                readline_add_completion(rs, name);
-            }
-        }
-    } else if (nb_args == 3) {
-        add_completion_option(rs, str, "on");
-        add_completion_option(rs, str, "off");
-    }
-}
-
-void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    int len, count, i;
-    NetClientState *ncs[255];
-
-    if (nb_args != 2) {
-        return;
-    }
-
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    count = qemu_find_net_clients_except(NULL, ncs, NET_CLIENT_OPTIONS_KIND_NIC,
-                                         255);
-    for (i = 0; i < count; i++) {
-        QemuOpts *opts;
-        const char *name = ncs[i]->name;
-        if (strncmp(str, name, len)) {
-            continue;
-        }
-        opts = qemu_opts_find(qemu_find_opts_err("netdev", NULL), name);
-        if (opts) {
-            readline_add_completion(rs, name);
-        }
-    }
-}
-
 void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str)
 {
     if (nb_args != 2) {
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 18/24] monitor: Move qmp_rtc_reset_reinjection from monitor.c to monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (16 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 17/24] monitor: Move two net " Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 19/24] monitor-system: Switch back functions to static Benoît Canet
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor-system.c | 7 +++++++
 monitor.c        | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/monitor-system.c b/monitor-system.c
index d5abf73..9bbf128 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -2513,3 +2513,10 @@ void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str)
         }
     }
 }
+
+#ifndef TARGET_I386
+void qmp_rtc_reset_reinjection(Error **errp)
+{
+    error_set(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
+}
+#endif
diff --git a/monitor.c b/monitor.c
index 3133f62..a578e93 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2950,10 +2950,3 @@ QemuOptsList qemu_mon_opts = {
         { /* end of list */ }
     },
 };
-
-#ifndef TARGET_I386
-void qmp_rtc_reset_reinjection(Error **errp)
-{
-    error_set(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
-}
-#endif
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 19/24] monitor-system: Switch back functions to static
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (17 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 18/24] monitor: Move qmp_rtc_reset_reinjection " Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 20/24] monitor: Extract hardware dependent completion function from monitor.c to monitor-system.c Benoît Canet
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

The move from monitor.c to monitor-system.c is done these functions no longer
needs to be public.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 include/monitor/monitor-system.h | 46 -------------------
 monitor-system.c                 | 95 ++++++++++++++++++++--------------------
 2 files changed, 48 insertions(+), 93 deletions(-)

diff --git a/include/monitor/monitor-system.h b/include/monitor/monitor-system.h
index 3bc7167..5d3827c 100644
--- a/include/monitor/monitor-system.h
+++ b/include/monitor/monitor-system.h
@@ -96,50 +96,4 @@ typedef struct mon_cmd_t {
 int get_expr(Monitor *mon, int64_t *pval, const char **pp);
 int get_double(Monitor *mon, double *pval, const char **pp);
 
-int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
-                                       const char *fmt, ...);
-void help_cmd(Monitor *mon, const char *name);
-void do_help_cmd(Monitor *mon, const QDict *qdict);
-void do_trace_event_set_state(Monitor *mon, const QDict *qdict);
-void do_trace_file(Monitor *mon, const QDict *qdict);
-void do_info_help(Monitor *mon, const QDict *qdict);
-
-void do_info_registers(Monitor *mon, const QDict *qdict);
-void do_info_jit(Monitor *mon, const QDict *qdict);
-void do_info_history(Monitor *mon, const QDict *qdict);
-void tlb_info(Monitor *mon, const QDict *qdict);
-void mem_info(Monitor *mon, const QDict *qdict);
-void do_info_mtree(Monitor *mon, const QDict *qdict);
-void do_info_numa(Monitor *mon, const QDict *qdict);
-void do_info_profile(Monitor *mon, const QDict *qdict);
-void do_info_capture(Monitor *mon, const QDict *qdict);
-void do_info_cpu_stats(Monitor *mon, const QDict *qdict);
-void do_trace_print_events(Monitor *mon, const QDict *qdict);
-void do_logfile(Monitor *mon, const QDict *qdict);
-void do_log(Monitor *mon, const QDict *qdict);
-void do_singlestep(Monitor *mon, const QDict *qdict);
-void do_gdbserver(Monitor *mon, const QDict *qdict);
-void do_memory_dump(Monitor *mon, const QDict *qdict);
-void do_physical_memory_dump(Monitor *mon, const QDict *qdict);
-void do_print(Monitor *mon, const QDict *qdict);
-void do_ioport_read(Monitor *mon, const QDict *qdict);
-void do_ioport_write(Monitor *mon, const QDict *qdict);
-void do_sum(Monitor *mon, const QDict *qdict);
-void do_mouse_move(Monitor *mon, const QDict *qdict);
-void do_mouse_button(Monitor *mon, const QDict *qdict);
-void do_wav_capture(Monitor *mon, const QDict *qdict);
-void do_stop_capture(Monitor *mon, const QDict *qdict);
-void do_boot_set(Monitor *mon, const QDict *qdict);
-int client_migrate_info(Monitor *mon, const QDict *qdict,
-                        MonitorCompletion cb, void *opaque);
-void do_watchdog_action(Monitor *mon, const QDict *qdict);
-void do_acl_show(Monitor *mon, const QDict *qdict);
-void do_acl_policy(Monitor *mon, const QDict *qdict);
-void do_acl_add(Monitor *mon, const QDict *qdict);
-void do_acl_remove(Monitor *mon, const QDict *qdict);
-void do_acl_reset(Monitor *mon, const QDict *qdict);
-void do_inject_mce(Monitor *mon, const QDict *qdict);
-CPUArchState *mon_get_cpu(void);
-void do_loadvm(Monitor *mon, const QDict *qdict);
-
 #endif
diff --git a/monitor-system.c b/monitor-system.c
index 9bbf128..bff158e 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -58,8 +58,8 @@
 
 extern const char *monitor_event_names[];
 
-int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
-                                       const char *fmt, ...)
+static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
+                                              const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
@@ -154,7 +154,7 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
     }
 }
 
-void help_cmd(Monitor *mon, const char *name)
+static void help_cmd(Monitor *mon, const char *name)
 {
     char *args[MAX_ARGS];
     int nb_args = 0;
@@ -183,12 +183,12 @@ void help_cmd(Monitor *mon, const char *name)
     free_cmdline_args(args, nb_args);
 }
 
-void do_help_cmd(Monitor *mon, const QDict *qdict)
+static void do_help_cmd(Monitor *mon, const QDict *qdict)
 {
     help_cmd(mon, qdict_get_try_str(qdict, "name"));
 }
 
-void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
+static void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
 {
     const char *tp_name = qdict_get_str(qdict, "name");
     bool new_state = qdict_get_bool(qdict, "option");
@@ -209,7 +209,7 @@ void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
 }
 
 #ifdef CONFIG_TRACE_SIMPLE
-void do_trace_file(Monitor *mon, const QDict *qdict)
+static void do_trace_file(Monitor *mon, const QDict *qdict)
 {
     const char *op = qdict_get_try_str(qdict, "op");
     const char *arg = qdict_get_try_str(qdict, "arg");
@@ -233,7 +233,7 @@ void do_trace_file(Monitor *mon, const QDict *qdict)
 }
 #endif
 
-void do_info_help(Monitor *mon, const QDict *qdict)
+static void do_info_help(Monitor *mon, const QDict *qdict)
 {
     help_cmd(mon, "info");
 }
@@ -251,7 +251,7 @@ int monitor_set_cpu(int cpu_index)
     return 0;
 }
 
-CPUArchState *mon_get_cpu(void)
+static CPUArchState *mon_get_cpu(void)
 {
     if (!cur_mon->mon_cpu) {
         monitor_set_cpu(0);
@@ -266,7 +266,7 @@ int monitor_get_cpu_index(void)
     return cpu->cpu_index;
 }
 
-void do_info_registers(Monitor *mon, const QDict *qdict)
+static void do_info_registers(Monitor *mon, const QDict *qdict)
 {
     CPUState *cpu;
     CPUArchState *env;
@@ -275,12 +275,12 @@ void do_info_registers(Monitor *mon, const QDict *qdict)
     cpu_dump_state(cpu, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU);
 }
 
-void do_info_jit(Monitor *mon, const QDict *qdict)
+static void do_info_jit(Monitor *mon, const QDict *qdict)
 {
     dump_exec_info((FILE *)mon, monitor_fprintf);
 }
 
-void do_info_history(Monitor *mon, const QDict *qdict)
+static void do_info_history(Monitor *mon, const QDict *qdict)
 {
     int i;
     const char *str;
@@ -297,7 +297,7 @@ void do_info_history(Monitor *mon, const QDict *qdict)
     }
 }
 
-void do_info_cpu_stats(Monitor *mon, const QDict *qdict)
+static void do_info_cpu_stats(Monitor *mon, const QDict *qdict)
 {
     CPUState *cpu;
     CPUArchState *env;
@@ -307,13 +307,13 @@ void do_info_cpu_stats(Monitor *mon, const QDict *qdict)
     cpu_dump_statistics(cpu, (FILE *)mon, &monitor_fprintf, 0);
 }
 
-void do_trace_print_events(Monitor *mon, const QDict *qdict)
+static void do_trace_print_events(Monitor *mon, const QDict *qdict)
 {
     trace_print_events((FILE *)mon, &monitor_fprintf);
 }
 
-int client_migrate_info(Monitor *mon, const QDict *qdict,
-                        MonitorCompletion cb, void *opaque)
+static int client_migrate_info(Monitor *mon, const QDict *qdict,
+                               MonitorCompletion cb, void *opaque)
 {
     const char *protocol = qdict_get_str(qdict, "protocol");
     const char *hostname = qdict_get_str(qdict, "hostname");
@@ -346,12 +346,12 @@ int client_migrate_info(Monitor *mon, const QDict *qdict,
     return -1;
 }
 
-void do_logfile(Monitor *mon, const QDict *qdict)
+static void do_logfile(Monitor *mon, const QDict *qdict)
 {
     qemu_set_log_filename(qdict_get_str(qdict, "filename"));
 }
 
-void do_log(Monitor *mon, const QDict *qdict)
+static void do_log(Monitor *mon, const QDict *qdict)
 {
     int mask;
     const char *items = qdict_get_str(qdict, "items");
@@ -368,7 +368,7 @@ void do_log(Monitor *mon, const QDict *qdict)
     qemu_set_log(mask);
 }
 
-void do_singlestep(Monitor *mon, const QDict *qdict)
+static void do_singlestep(Monitor *mon, const QDict *qdict)
 {
     const char *option = qdict_get_try_str(qdict, "option");
     if (!option || !strcmp(option, "on")) {
@@ -380,7 +380,7 @@ void do_singlestep(Monitor *mon, const QDict *qdict)
     }
 }
 
-void do_gdbserver(Monitor *mon, const QDict *qdict)
+static void do_gdbserver(Monitor *mon, const QDict *qdict)
 {
     const char *device = qdict_get_try_str(qdict, "device");
     if (!device)
@@ -396,7 +396,7 @@ void do_gdbserver(Monitor *mon, const QDict *qdict)
     }
 }
 
-void do_watchdog_action(Monitor *mon, const QDict *qdict)
+static void do_watchdog_action(Monitor *mon, const QDict *qdict)
 {
     const char *action = qdict_get_str(qdict, "action");
     if (select_watchdog_action(action) == -1) {
@@ -555,7 +555,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
     }
 }
 
-void do_memory_dump(Monitor *mon, const QDict *qdict)
+static void do_memory_dump(Monitor *mon, const QDict *qdict)
 {
     int count = qdict_get_int(qdict, "count");
     int format = qdict_get_int(qdict, "format");
@@ -565,7 +565,7 @@ void do_memory_dump(Monitor *mon, const QDict *qdict)
     memory_dump(mon, count, format, size, addr, 0);
 }
 
-void do_physical_memory_dump(Monitor *mon, const QDict *qdict)
+static void do_physical_memory_dump(Monitor *mon, const QDict *qdict)
 {
     int count = qdict_get_int(qdict, "count");
     int format = qdict_get_int(qdict, "format");
@@ -575,7 +575,7 @@ void do_physical_memory_dump(Monitor *mon, const QDict *qdict)
     memory_dump(mon, count, format, size, addr, 1);
 }
 
-void do_print(Monitor *mon, const QDict *qdict)
+static void do_print(Monitor *mon, const QDict *qdict)
 {
     int format = qdict_get_int(qdict, "format");
     hwaddr val = qdict_get_int(qdict, "val");
@@ -601,7 +601,7 @@ void do_print(Monitor *mon, const QDict *qdict)
     monitor_printf(mon, "\n");
 }
 
-void do_sum(Monitor *mon, const QDict *qdict)
+static void do_sum(Monitor *mon, const QDict *qdict)
 {
     uint32_t addr;
     uint16_t sum;
@@ -620,7 +620,7 @@ void do_sum(Monitor *mon, const QDict *qdict)
 
 static int mouse_button_state;
 
-void do_mouse_move(Monitor *mon, const QDict *qdict)
+static void do_mouse_move(Monitor *mon, const QDict *qdict)
 {
     int dx, dy, dz, button;
     const char *dx_str = qdict_get_str(qdict, "dx_str");
@@ -644,7 +644,7 @@ void do_mouse_move(Monitor *mon, const QDict *qdict)
     qemu_input_event_sync();
 }
 
-void do_mouse_button(Monitor *mon, const QDict *qdict)
+static void do_mouse_button(Monitor *mon, const QDict *qdict)
 {
     static uint32_t bmap[INPUT_BUTTON_MAX] = {
         [INPUT_BUTTON_LEFT]       = MOUSE_EVENT_LBUTTON,
@@ -661,7 +661,7 @@ void do_mouse_button(Monitor *mon, const QDict *qdict)
     mouse_button_state = button_state;
 }
 
-void do_ioport_read(Monitor *mon, const QDict *qdict)
+static void do_ioport_read(Monitor *mon, const QDict *qdict)
 {
     int size = qdict_get_int(qdict, "size");
     int addr = qdict_get_int(qdict, "addr");
@@ -695,7 +695,7 @@ void do_ioport_read(Monitor *mon, const QDict *qdict)
                    suffix, addr, size * 2, val);
 }
 
-void do_ioport_write(Monitor *mon, const QDict *qdict)
+static void do_ioport_write(Monitor *mon, const QDict *qdict)
 {
     int size = qdict_get_int(qdict, "size");
     int addr = qdict_get_int(qdict, "addr");
@@ -717,7 +717,7 @@ void do_ioport_write(Monitor *mon, const QDict *qdict)
     }
 }
 
-void do_boot_set(Monitor *mon, const QDict *qdict)
+static void do_boot_set(Monitor *mon, const QDict *qdict)
 {
     int res;
     const char *bootdevice = qdict_get_str(qdict, "bootdevice");
@@ -883,7 +883,7 @@ static void tlb_info_64(Monitor *mon, CPUArchState *env)
 }
 #endif
 
-void tlb_info(Monitor *mon, const QDict *qdict)
+static void tlb_info(Monitor *mon, const QDict *qdict)
 {
     CPUArchState *env;
 
@@ -1106,7 +1106,7 @@ static void mem_info_64(Monitor *mon, CPUArchState *env)
 }
 #endif
 
-void mem_info(Monitor *mon, const QDict *qdict)
+static void mem_info(Monitor *mon, const QDict *qdict)
 {
     CPUArchState *env;
 
@@ -1145,8 +1145,9 @@ static void print_tlb(Monitor *mon, int idx, tlb_t *tlb)
                    tlb->d, tlb->wt);
 }
 
-void tlb_info(Monitor *mon, const QDict *qdict)
+static void tlb_info(Monitor *mon, const QDict *qdict)
 {
+
     CPUArchState *env = mon_get_cpu();
     int i;
 
@@ -1161,7 +1162,7 @@ void tlb_info(Monitor *mon, const QDict *qdict)
 #endif
 
 #if defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_XTENSA)
-void tlb_info(Monitor *mon, const QDict *qdict)
+static void tlb_info(Monitor *mon, const QDict *qdict)
 {
     CPUArchState *env1 = mon_get_cpu();
 
@@ -1169,12 +1170,12 @@ void tlb_info(Monitor *mon, const QDict *qdict)
 }
 #endif
 
-void do_info_mtree(Monitor *mon, const QDict *qdict)
+static void do_info_mtree(Monitor *mon, const QDict *qdict)
 {
     mtree_info((fprintf_function)monitor_printf, mon);
 }
 
-void do_info_numa(Monitor *mon, const QDict *qdict)
+static void do_info_numa(Monitor *mon, const QDict *qdict)
 {
     int i;
     CPUState *cpu;
@@ -1198,7 +1199,7 @@ void do_info_numa(Monitor *mon, const QDict *qdict)
 int64_t qemu_time;
 int64_t dev_time;
 
-void do_info_profile(Monitor *mon, const QDict *qdict)
+static void do_info_profile(Monitor *mon, const QDict *qdict)
 {
     monitor_printf(mon, "async time  %" PRId64 " (%0.3f)\n",
                    dev_time, dev_time / (double)get_ticks_per_sec());
@@ -1208,7 +1209,7 @@ void do_info_profile(Monitor *mon, const QDict *qdict)
     dev_time = 0;
 }
 #else
-void do_info_profile(Monitor *mon, const QDict *qdict)
+static void do_info_profile(Monitor *mon, const QDict *qdict)
 {
     monitor_printf(mon, "Internal profiler not compiled\n");
 }
@@ -1217,7 +1218,7 @@ void do_info_profile(Monitor *mon, const QDict *qdict)
 /* Capture support */
 static QLIST_HEAD (capture_list_head, CaptureState) capture_head;
 
-void do_info_capture(Monitor *mon, const QDict *qdict)
+static void do_info_capture(Monitor *mon, const QDict *qdict)
 {
     int i;
     CaptureState *s;
@@ -1228,7 +1229,7 @@ void do_info_capture(Monitor *mon, const QDict *qdict)
     }
 }
 
-void do_stop_capture(Monitor *mon, const QDict *qdict)
+static void do_stop_capture(Monitor *mon, const QDict *qdict)
 {
     int i;
     int n = qdict_get_int(qdict, "n");
@@ -1244,7 +1245,7 @@ void do_stop_capture(Monitor *mon, const QDict *qdict)
     }
 }
 
-void do_wav_capture(Monitor *mon, const QDict *qdict)
+static void do_wav_capture(Monitor *mon, const QDict *qdict)
 {
     const char *path = qdict_get_str(qdict, "path");
     int has_freq = qdict_haskey(qdict, "freq");
@@ -1279,7 +1280,7 @@ static qemu_acl *find_acl(Monitor *mon, const char *name)
     return acl;
 }
 
-void do_acl_show(Monitor *mon, const QDict *qdict)
+static void do_acl_show(Monitor *mon, const QDict *qdict)
 {
     const char *aclname = qdict_get_str(qdict, "aclname");
     qemu_acl *acl = find_acl(mon, aclname);
@@ -1297,7 +1298,7 @@ void do_acl_show(Monitor *mon, const QDict *qdict)
     }
 }
 
-void do_acl_reset(Monitor *mon, const QDict *qdict)
+static void do_acl_reset(Monitor *mon, const QDict *qdict)
 {
     const char *aclname = qdict_get_str(qdict, "aclname");
     qemu_acl *acl = find_acl(mon, aclname);
@@ -1308,7 +1309,7 @@ void do_acl_reset(Monitor *mon, const QDict *qdict)
     }
 }
 
-void do_acl_policy(Monitor *mon, const QDict *qdict)
+static void do_acl_policy(Monitor *mon, const QDict *qdict)
 {
     const char *aclname = qdict_get_str(qdict, "aclname");
     const char *policy = qdict_get_str(qdict, "policy");
@@ -1328,7 +1329,7 @@ void do_acl_policy(Monitor *mon, const QDict *qdict)
     }
 }
 
-void do_acl_add(Monitor *mon, const QDict *qdict)
+static void do_acl_add(Monitor *mon, const QDict *qdict)
 {
     const char *aclname = qdict_get_str(qdict, "aclname");
     const char *match = qdict_get_str(qdict, "match");
@@ -1359,7 +1360,7 @@ void do_acl_add(Monitor *mon, const QDict *qdict)
     }
 }
 
-void do_acl_remove(Monitor *mon, const QDict *qdict)
+static void do_acl_remove(Monitor *mon, const QDict *qdict)
 {
     const char *aclname = qdict_get_str(qdict, "aclname");
     const char *match = qdict_get_str(qdict, "match");
@@ -1376,7 +1377,7 @@ void do_acl_remove(Monitor *mon, const QDict *qdict)
 }
 
 #if defined(TARGET_I386)
-void do_inject_mce(Monitor *mon, const QDict *qdict)
+static void do_inject_mce(Monitor *mon, const QDict *qdict)
 {
     X86CPU *cpu;
     CPUState *cs;
@@ -1400,7 +1401,7 @@ void do_inject_mce(Monitor *mon, const QDict *qdict)
 }
 #endif
 
-void do_loadvm(Monitor *mon, const QDict *qdict)
+static void do_loadvm(Monitor *mon, const QDict *qdict)
 {
     int saved_vm_running  = runstate_is_running();
     const char *name = qdict_get_str(qdict, "name");
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 20/24] monitor: Extract hardware dependent completion function from monitor.c to monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (18 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 19/24] monitor-system: Switch back functions to static Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 21/24] monitor: Cleanup monitor.c includes after extracting monitor-system.c Benoît Canet
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor-system.c | 283 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 monitor.c        | 281 ------------------------------------------------------
 2 files changed, 283 insertions(+), 281 deletions(-)

diff --git a/monitor-system.c b/monitor-system.c
index bff158e..8dd4149 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -49,6 +49,8 @@
 #include "net/slirp.h"
 #include "sysemu/blockdev.h"
 #include "qemu/config-file.h"
+#include "block/snapshot.h"
+#include "block/qapi.h"
 
 /* for pic/irq_info */
 #if defined(TARGET_SPARC)
@@ -2521,3 +2523,284 @@ void qmp_rtc_reset_reinjection(Error **errp)
     error_set(errp, QERR_FEATURE_DISABLED, "rtc-reset-reinjection");
 }
 #endif
+
+void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    size_t len;
+    int i;
+
+    if (nb_args != 2) {
+        return;
+    }
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    for (i = 0; NetClientOptionsKind_lookup[i]; i++) {
+        add_completion_option(rs, str, NetClientOptionsKind_lookup[i]);
+    }
+}
+
+void device_add_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    GSList *list, *elt;
+    size_t len;
+
+    if (nb_args != 2) {
+        return;
+    }
+
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    list = elt = object_class_get_list(TYPE_DEVICE, false);
+    while (elt) {
+        const char *name;
+        DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
+                                             TYPE_DEVICE);
+        name = object_class_get_name(OBJECT_CLASS(dc));
+
+        if (!dc->cannot_instantiate_with_device_add_yet
+            && !strncmp(name, str, len)) {
+            readline_add_completion(rs, name);
+        }
+        elt = elt->next;
+    }
+    g_slist_free(list);
+}
+
+void object_add_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    GSList *list, *elt;
+    size_t len;
+
+    if (nb_args != 2) {
+        return;
+    }
+
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    list = elt = object_class_get_list(TYPE_USER_CREATABLE, false);
+    while (elt) {
+        const char *name;
+
+        name = object_class_get_name(OBJECT_CLASS(elt->data));
+        if (!strncmp(name, str, len) && strcmp(name, TYPE_USER_CREATABLE)) {
+            readline_add_completion(rs, name);
+        }
+        elt = elt->next;
+    }
+    g_slist_free(list);
+}
+
+static void device_del_bus_completion(ReadLineState *rs,  BusState *bus,
+                                      const char *str, size_t len)
+{
+    BusChild *kid;
+
+    QTAILQ_FOREACH(kid, &bus->children, sibling) {
+        DeviceState *dev = kid->child;
+        BusState *dev_child;
+
+        if (dev->id && !strncmp(str, dev->id, len)) {
+            readline_add_completion(rs, dev->id);
+        }
+
+        QLIST_FOREACH(dev_child, &dev->child_bus, sibling) {
+            device_del_bus_completion(rs, dev_child, str, len);
+        }
+    }
+}
+
+void device_del_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    size_t len;
+
+    if (nb_args != 2) {
+        return;
+    }
+
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    device_del_bus_completion(rs, sysbus_get_default(), str, len);
+}
+
+void object_del_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    ObjectPropertyInfoList *list, *start;
+    size_t len;
+
+    if (nb_args != 2) {
+        return;
+    }
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+
+    start = list = qmp_qom_list("/objects", NULL);
+    while (list) {
+        ObjectPropertyInfo *info = list->value;
+
+        if (!strncmp(info->type, "child<", 5)
+            && !strncmp(info->name, str, len)) {
+            readline_add_completion(rs, info->name);
+        }
+        list = list->next;
+    }
+    qapi_free_ObjectPropertyInfoList(start);
+}
+
+void sendkey_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    int i;
+    char *sep;
+    size_t len;
+
+    if (nb_args != 2) {
+        return;
+    }
+    sep = strrchr(str, '-');
+    if (sep) {
+        str = sep + 1;
+    }
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    for (i = 0; i < Q_KEY_CODE_MAX; i++) {
+        if (!strncmp(str, QKeyCode_lookup[i], len)) {
+            readline_add_completion(rs, QKeyCode_lookup[i]);
+        }
+    }
+}
+
+void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    if (nb_args != 2) {
+        return;
+    }
+    readline_set_completion_index(rs, strlen(str));
+    add_completion_option(rs, str, "reset");
+    add_completion_option(rs, str, "shutdown");
+    add_completion_option(rs, str, "poweroff");
+    add_completion_option(rs, str, "pause");
+    add_completion_option(rs, str, "debug");
+    add_completion_option(rs, str, "none");
+}
+
+void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
+                                       const char *str)
+{
+    size_t len;
+
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    if (nb_args == 2) {
+        int i;
+        for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) {
+            const char *name = MigrationCapability_lookup[i];
+            if (!strncmp(str, name, len)) {
+                readline_add_completion(rs, name);
+            }
+        }
+    } else if (nb_args == 3) {
+        add_completion_option(rs, str, "on");
+        add_completion_option(rs, str, "off");
+    }
+}
+
+void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    int i;
+    size_t len;
+    if (nb_args != 2) {
+        return;
+    }
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    for (i = 0; host_net_devices[i]; i++) {
+        if (!strncmp(host_net_devices[i], str, len)) {
+            readline_add_completion(rs, host_net_devices[i]);
+        }
+    }
+}
+
+void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    NetClientState *ncs[255];
+    int count, i, len;
+
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    if (nb_args == 2) {
+        count = qemu_find_net_clients_except(NULL, ncs,
+                                             NET_CLIENT_OPTIONS_KIND_NONE, 255);
+        for (i = 0; i < count; i++) {
+            int id;
+            char name[16];
+
+            if (net_hub_id_for_client(ncs[i], &id)) {
+                continue;
+            }
+            snprintf(name, sizeof(name), "%d", id);
+            if (!strncmp(str, name, len)) {
+                readline_add_completion(rs, name);
+            }
+        }
+        return;
+    } else if (nb_args == 3) {
+        count = qemu_find_net_clients_except(NULL, ncs,
+                                             NET_CLIENT_OPTIONS_KIND_NIC, 255);
+        for (i = 0; i < count; i++) {
+            const char *name;
+
+            name = ncs[i]->name;
+            if (!strncmp(str, name, len)) {
+                readline_add_completion(rs, name);
+            }
+        }
+        return;
+    }
+}
+
+static void vm_completion(ReadLineState *rs, const char *str)
+{
+    size_t len;
+    BlockDriverState *bs = NULL;
+
+    len = strlen(str);
+    readline_set_completion_index(rs, len);
+    while ((bs = bdrv_next(bs))) {
+        SnapshotInfoList *snapshots, *snapshot;
+
+        if (!bdrv_can_snapshot(bs)) {
+            continue;
+        }
+        if (bdrv_query_snapshot_info_list(bs, &snapshots, NULL)) {
+            continue;
+        }
+        snapshot = snapshots;
+        while (snapshot) {
+            char *completion = snapshot->value->name;
+            if (!strncmp(str, completion, len)) {
+                readline_add_completion(rs, completion);
+            }
+            completion = snapshot->value->id;
+            if (!strncmp(str, completion, len)) {
+                readline_add_completion(rs, completion);
+            }
+            snapshot = snapshot->next;
+        }
+        qapi_free_SnapshotInfoList(snapshots);
+    }
+
+}
+
+void delvm_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    if (nb_args == 2) {
+        vm_completion(rs, str);
+    }
+}
+
+void loadvm_completion(ReadLineState *rs, int nb_args, const char *str)
+{
+    if (nb_args == 2) {
+        vm_completion(rs, str);
+    }
+}
+
diff --git a/monitor.c b/monitor.c
index a578e93..85484c3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -71,7 +71,6 @@
 #include "qmp-commands.h"
 #include "hmp.h"
 #include "qemu/thread.h"
-#include "block/qapi.h"
 #include "qapi/qmp-event.h"
 #include "qapi-event.h"
 
@@ -1890,91 +1889,6 @@ void chardev_add_completion(ReadLineState *rs, int nb_args, const char *str)
     qapi_free_ChardevBackendInfoList(start);
 }
 
-void netdev_add_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    size_t len;
-    int i;
-
-    if (nb_args != 2) {
-        return;
-    }
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    for (i = 0; NetClientOptionsKind_lookup[i]; i++) {
-        add_completion_option(rs, str, NetClientOptionsKind_lookup[i]);
-    }
-}
-
-void device_add_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    GSList *list, *elt;
-    size_t len;
-
-    if (nb_args != 2) {
-        return;
-    }
-
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    list = elt = object_class_get_list(TYPE_DEVICE, false);
-    while (elt) {
-        const char *name;
-        DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
-                                             TYPE_DEVICE);
-        name = object_class_get_name(OBJECT_CLASS(dc));
-
-        if (!dc->cannot_instantiate_with_device_add_yet
-            && !strncmp(name, str, len)) {
-            readline_add_completion(rs, name);
-        }
-        elt = elt->next;
-    }
-    g_slist_free(list);
-}
-
-void object_add_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    GSList *list, *elt;
-    size_t len;
-
-    if (nb_args != 2) {
-        return;
-    }
-
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    list = elt = object_class_get_list(TYPE_USER_CREATABLE, false);
-    while (elt) {
-        const char *name;
-
-        name = object_class_get_name(OBJECT_CLASS(elt->data));
-        if (!strncmp(name, str, len) && strcmp(name, TYPE_USER_CREATABLE)) {
-            readline_add_completion(rs, name);
-        }
-        elt = elt->next;
-    }
-    g_slist_free(list);
-}
-
-static void device_del_bus_completion(ReadLineState *rs,  BusState *bus,
-                                      const char *str, size_t len)
-{
-    BusChild *kid;
-
-    QTAILQ_FOREACH(kid, &bus->children, sibling) {
-        DeviceState *dev = kid->child;
-        BusState *dev_child;
-
-        if (dev->id && !strncmp(str, dev->id, len)) {
-            readline_add_completion(rs, dev->id);
-        }
-
-        QLIST_FOREACH(dev_child, &dev->child_bus, sibling) {
-            device_del_bus_completion(rs, dev_child, str, len);
-        }
-    }
-}
-
 void chardev_remove_completion(ReadLineState *rs, int nb_args, const char *str)
 {
     size_t len;
@@ -2037,201 +1951,6 @@ void ringbuf_write_completion(ReadLineState *rs, int nb_args, const char *str)
     ringbuf_completion(rs, str);
 }
 
-void device_del_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    size_t len;
-
-    if (nb_args != 2) {
-        return;
-    }
-
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    device_del_bus_completion(rs, sysbus_get_default(), str, len);
-}
-
-void object_del_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    ObjectPropertyInfoList *list, *start;
-    size_t len;
-
-    if (nb_args != 2) {
-        return;
-    }
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-
-    start = list = qmp_qom_list("/objects", NULL);
-    while (list) {
-        ObjectPropertyInfo *info = list->value;
-
-        if (!strncmp(info->type, "child<", 5)
-            && !strncmp(info->name, str, len)) {
-            readline_add_completion(rs, info->name);
-        }
-        list = list->next;
-    }
-    qapi_free_ObjectPropertyInfoList(start);
-}
-
-void sendkey_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    int i;
-    char *sep;
-    size_t len;
-
-    if (nb_args != 2) {
-        return;
-    }
-    sep = strrchr(str, '-');
-    if (sep) {
-        str = sep + 1;
-    }
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    for (i = 0; i < Q_KEY_CODE_MAX; i++) {
-        if (!strncmp(str, QKeyCode_lookup[i], len)) {
-            readline_add_completion(rs, QKeyCode_lookup[i]);
-        }
-    }
-}
-
-void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    if (nb_args != 2) {
-        return;
-    }
-    readline_set_completion_index(rs, strlen(str));
-    add_completion_option(rs, str, "reset");
-    add_completion_option(rs, str, "shutdown");
-    add_completion_option(rs, str, "poweroff");
-    add_completion_option(rs, str, "pause");
-    add_completion_option(rs, str, "debug");
-    add_completion_option(rs, str, "none");
-}
-
-void migrate_set_capability_completion(ReadLineState *rs, int nb_args,
-                                       const char *str)
-{
-    size_t len;
-
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    if (nb_args == 2) {
-        int i;
-        for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) {
-            const char *name = MigrationCapability_lookup[i];
-            if (!strncmp(str, name, len)) {
-                readline_add_completion(rs, name);
-            }
-        }
-    } else if (nb_args == 3) {
-        add_completion_option(rs, str, "on");
-        add_completion_option(rs, str, "off");
-    }
-}
-
-void host_net_add_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    int i;
-    size_t len;
-    if (nb_args != 2) {
-        return;
-    }
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    for (i = 0; host_net_devices[i]; i++) {
-        if (!strncmp(host_net_devices[i], str, len)) {
-            readline_add_completion(rs, host_net_devices[i]);
-        }
-    }
-}
-
-void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    NetClientState *ncs[255];
-    int count, i, len;
-
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    if (nb_args == 2) {
-        count = qemu_find_net_clients_except(NULL, ncs,
-                                             NET_CLIENT_OPTIONS_KIND_NONE, 255);
-        for (i = 0; i < count; i++) {
-            int id;
-            char name[16];
-
-            if (net_hub_id_for_client(ncs[i], &id)) {
-                continue;
-            }
-            snprintf(name, sizeof(name), "%d", id);
-            if (!strncmp(str, name, len)) {
-                readline_add_completion(rs, name);
-            }
-        }
-        return;
-    } else if (nb_args == 3) {
-        count = qemu_find_net_clients_except(NULL, ncs,
-                                             NET_CLIENT_OPTIONS_KIND_NIC, 255);
-        for (i = 0; i < count; i++) {
-            const char *name;
-
-            name = ncs[i]->name;
-            if (!strncmp(str, name, len)) {
-                readline_add_completion(rs, name);
-            }
-        }
-        return;
-    }
-}
-
-static void vm_completion(ReadLineState *rs, const char *str)
-{
-    size_t len;
-    BlockDriverState *bs = NULL;
-
-    len = strlen(str);
-    readline_set_completion_index(rs, len);
-    while ((bs = bdrv_next(bs))) {
-        SnapshotInfoList *snapshots, *snapshot;
-
-        if (!bdrv_can_snapshot(bs)) {
-            continue;
-        }
-        if (bdrv_query_snapshot_info_list(bs, &snapshots, NULL)) {
-            continue;
-        }
-        snapshot = snapshots;
-        while (snapshot) {
-            char *completion = snapshot->value->name;
-            if (!strncmp(str, completion, len)) {
-                readline_add_completion(rs, completion);
-            }
-            completion = snapshot->value->id;
-            if (!strncmp(str, completion, len)) {
-                readline_add_completion(rs, completion);
-            }
-            snapshot = snapshot->next;
-        }
-        qapi_free_SnapshotInfoList(snapshots);
-    }
-
-}
-
-void delvm_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    if (nb_args == 2) {
-        vm_completion(rs, str);
-    }
-}
-
-void loadvm_completion(ReadLineState *rs, int nb_args, const char *str)
-{
-    if (nb_args == 2) {
-        vm_completion(rs, str);
-    }
-}
-
 static void monitor_find_completion_by_table(Monitor *mon,
                                              const mon_cmd_t *cmd_table,
                                              char **args,
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 21/24] monitor: Cleanup monitor.c includes after extracting monitor-system.c
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (19 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 20/24] monitor: Extract hardware dependent completion function from monitor.c to monitor-system.c Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 22/24] qemu-nbd: build QAPI block core into qemu-nbd Benoît Canet
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 monitor.c | 35 -----------------------------------
 1 file changed, 35 deletions(-)

diff --git a/monitor.c b/monitor.c
index 85484c3..bc7f3d3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -22,64 +22,29 @@
  * THE SOFTWARE.
  */
 #include <dirent.h>
-#include "hw/hw.h"
-#include "monitor/qdev.h"
-#include "hw/usb.h"
-#include "hw/pcmcia.h"
-#include "hw/i386/pc.h"
 #include "hw/pci/pci.h"
-#include "sysemu/watchdog.h"
-#include "hw/loader.h"
-#include "exec/gdbstub.h"
 #include "net/net.h"
-#include "net/slirp.h"
 #include "sysemu/char.h"
-#include "ui/qemu-spice.h"
 #include "sysemu/sysemu.h"
 #include "monitor/monitor.h"
 #include "monitor/monitor-system.h"
 #include "qemu/readline.h"
 #include "ui/console.h"
 #include "ui/input.h"
-#include "sysemu/blockdev.h"
-#include "audio/audio.h"
-#include "disas/disas.h"
-#include "sysemu/balloon.h"
-#include "qemu/timer.h"
-#include "migration/migration.h"
-#include "sysemu/kvm.h"
-#include "qemu/acl.h"
-#include "sysemu/tpm.h"
 #include "qapi/qmp/qint.h"
 #include "qapi/qmp/qfloat.h"
-#include "qapi/qmp/qlist.h"
 #include "qapi/qmp/qbool.h"
-#include "qapi/qmp/qstring.h"
-#include "qapi/qmp/qjson.h"
-#include "qapi/qmp/json-streamer.h"
-#include "qapi/qmp/json-parser.h"
-#include <qom/object_interfaces.h>
-#include "qemu/osdep.h"
-#include "cpu.h"
 #include "trace.h"
 #include "trace/control.h"
 #ifdef CONFIG_TRACE_SIMPLE
 #include "trace/simple.h"
 #endif
-#include "exec/memory.h"
-#include "exec/cpu_ldst.h"
 #include "qmp-commands.h"
 #include "hmp.h"
 #include "qemu/thread.h"
 #include "qapi/qmp-event.h"
 #include "qapi-event.h"
 
-/* for pic/irq_info */
-#if defined(TARGET_SPARC)
-#include "hw/sparc/sun4m.h"
-#endif
-#include "hw/lm32/lm32_pic.h"
-
 //#define DEBUG
 //#define DEBUG_COMPLETION
 
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 22/24] qemu-nbd: build QAPI block core into qemu-nbd
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (20 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 21/24] monitor: Cleanup monitor.c includes after extracting monitor-system.c Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 23/24] qapi: Add a script to filter qmp-commands-old.h to generate a subset of it Benoît Canet
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 24/24] qemu-nbd: Add --qmp option to qemu-nbd Benoît Canet
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Compile and link QAPI block core code into qemu-nbd.

This patch circle around unwanted dependecies by stubing some functions in
the stubs directory.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 Makefile                                    | 33 +++++++++++++++++++++++++++--
 Makefile.objs                               | 10 +++++++++
 block/Makefile.objs                         | 11 ++++++----
 qapi/Makefile.objs                          |  2 ++
 qobject/Makefile.objs                       |  2 ++
 qom/Makefile.objs                           |  8 ++++---
 stubs/Makefile.objs                         | 15 +++++++++++++
 stubs/arch-type.c                           |  3 +++
 stubs/autostart.c                           |  1 +
 stubs/cpus-list.c                           |  3 +++
 stubs/get-double.c                          |  8 +++++++
 stubs/get-expr.c                            |  8 +++++++
 stubs/kvm-allowed.c                         |  3 +++
 stubs/kvm-cpu-synchronize-post-init.c       |  5 +++++
 stubs/kvm-cpu-synchronize-state.c           |  5 +++++
 stubs/qemu-add-machine-init-done-notifier.c |  5 +++++
 stubs/qemu-chr-open-msmouse.c               |  7 ++++++
 stubs/runstate-is-running.c                 |  6 ++++++
 stubs/serial-hds.c                          |  3 +++
 stubs/vmstate-info-buffer.c                 |  8 +++++++
 stubs/vmstate-info-uint32.c                 |  8 +++++++
 util/Makefile.objs                          |  2 ++
 22 files changed, 147 insertions(+), 9 deletions(-)
 create mode 100644 stubs/arch-type.c
 create mode 100644 stubs/autostart.c
 create mode 100644 stubs/cpus-list.c
 create mode 100644 stubs/get-double.c
 create mode 100644 stubs/get-expr.c
 create mode 100644 stubs/kvm-allowed.c
 create mode 100644 stubs/kvm-cpu-synchronize-post-init.c
 create mode 100644 stubs/kvm-cpu-synchronize-state.c
 create mode 100644 stubs/qemu-add-machine-init-done-notifier.c
 create mode 100644 stubs/qemu-chr-open-msmouse.c
 create mode 100644 stubs/runstate-is-running.c
 create mode 100644 stubs/serial-hds.c
 create mode 100644 stubs/vmstate-info-buffer.c
 create mode 100644 stubs/vmstate-info-uint32.c

diff --git a/Makefile b/Makefile
index d6b9dc1..f56dcaa 100644
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,13 @@ ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
 endif
 endif
 
+GENERATED_BLOCK_HEADERS = block/qapi-generated/qmp-commands.h
+GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-types.h
+GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-visit.h
+GENERATED_BLOCK_SOURCES = block/qapi-generated/qmp-marshal.c
+GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-types.c
+GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-visit.c
+
 GENERATED_HEADERS = config-host.h qemu-options.def
 GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h
 GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
@@ -136,6 +143,7 @@ dummy := $(call unnest-vars,, \
                 qga-vss-dll-obj-y \
                 block-obj-y \
                 block-obj-m \
+                qapi-block-obj-y \
                 common-obj-y \
                 common-obj-m)
 
@@ -212,7 +220,8 @@ util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)'
 qemu-img.o: qemu-img-cmds.h
 
 qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a
-qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a
+qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) $(qapi-block-obj-y) libqemustub.a
+qemu-nbd$(EXESUF): QEMU_CFLAGS += -DBLOCK_COMMAND_MONITOR
 qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a
 
 qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
@@ -271,6 +280,22 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 		$(gen-out-type) -o "." -m -i $<, \
 		"  GEN   $@")
 
+block/qapi-generated/qapi-types.c block/qapi-generated/qapi-types.h :\
+$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
+		$(gen-out-type) -o block/qapi-generated -b -i $<, \
+		"  GEN   $@")
+block/qapi-generated/qapi-visit.c block/qapi-generated/qapi-visit.h :\
+$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
+		$(gen-out-type) -o  block/qapi-generated -b -i $<, \
+		"  GEN   $@")
+block/qapi-generated/qmp-commands.h block/qapi-generated/qmp-marshal.c :\
+$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
+		$(gen-out-type) -o  block/qapi-generated -m -i $<, \
+		"  GEN   $@")
+
 QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
 $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
 
@@ -291,8 +316,11 @@ clean:
 	rm -f trace/generated-tracers-dtrace.h*
 	rm -f $(foreach f,$(GENERATED_HEADERS),$(f) $(f)-timestamp)
 	rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp)
+	rm -f $(foreach f,$(GENERATED_BLOCK_HEADERS),$(f) $(f)-timestamp)
+	rm -f $(foreach f,$(GENERATED_BLOCK_SOURCES),$(f) $(f)-timestamp)
 	rm -rf qapi-generated
 	rm -rf qga/qapi-generated
+	rm -rf block/qapi-generated
 	for d in $(ALL_SUBDIRS); do \
 	if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
 	rm -f $$d/qemu-options.def; \
@@ -550,7 +578,8 @@ endif # CONFIG_WIN
 # Add a dependency on the generated files, so that they are always
 # rebuilt before other object files
 ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
-Makefile: $(GENERATED_HEADERS)
+Makefile: $(GENERATED_HEADERS) $(GENERATED_BLOCK_HEADERS)\
+	$(GENERATED_BLOCK_SOURCES)
 endif
 
 # Include automatically generated dependency files
diff --git a/Makefile.objs b/Makefile.objs
index 0f0f298..6fe81e9 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -21,6 +21,16 @@ block-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o
 
 block-obj-m = block/
 
+qapi-block-obj-y = block/qapi-generated/qmp-marshal.o blockdev.o qmp.o
+qapi-block-obj-y += monitor.o
+qapi-block-obj-y += qemu-char.o
+qapi-block-obj-y += qemu-log.o
+qapi-block-obj-y += qom/
+qapi-block-obj-y += util/
+qapi-block-obj-y += qobject/
+qapi-block-obj-y += block/
+qapi-block-obj-y += qapi/
+qapi-block-obj-y += stubs/
 
 ######################################################################
 # smartcard
diff --git a/block/Makefile.objs b/block/Makefile.objs
index fd88c03..a368e98 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -20,10 +20,13 @@ block-obj-$(CONFIG_GLUSTERFS) += gluster.o
 block-obj-$(CONFIG_LIBSSH2) += ssh.o
 endif
 
-common-obj-y += stream.o
-common-obj-y += commit.o
-common-obj-y += mirror.o
-common-obj-y += backup.o
+block-job-obj-y = stream.o
+block-job-obj-y += commit.o
+block-job-obj-y += mirror.o
+block-job-obj-y += backup.o
+
+common-obj-y += $(block-job-obj-y)
+qapi-block-obj-y += $(block-job-obj-y)
 
 iscsi.o-cflags     := $(LIBISCSI_CFLAGS)
 iscsi.o-libs       := $(LIBISCSI_LIBS)
diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
index d14b769..c67e110 100644
--- a/qapi/Makefile.objs
+++ b/qapi/Makefile.objs
@@ -4,3 +4,5 @@ util-obj-y += string-input-visitor.o string-output-visitor.o
 
 util-obj-y += opts-visitor.o
 util-obj-y += qmp-event.o
+
+qapi-block-obj-y += $(util-obj-y)
diff --git a/qobject/Makefile.objs b/qobject/Makefile.objs
index c9ff59c..96e652d 100644
--- a/qobject/Makefile.objs
+++ b/qobject/Makefile.objs
@@ -1,3 +1,5 @@
 util-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
 util-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
 util-obj-y += qerror.o
+
+qapi-block-obj-y += $(util-obj-y)
diff --git a/qom/Makefile.objs b/qom/Makefile.objs
index 985003b..f388fd3 100644
--- a/qom/Makefile.objs
+++ b/qom/Makefile.objs
@@ -1,3 +1,5 @@
-common-obj-y = object.o container.o qom-qobject.o
-common-obj-y += cpu.o
-common-obj-y += object_interfaces.o
+qom-obj-y = object.o container.o qom-qobject.o
+qom-obj-y += object_interfaces.o
+
+common-obj-y += $(qom-obj-y) cpu.o
+qapi-block-obj-y += $(qom-obj-y)
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 528e161..2657984 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -39,3 +39,18 @@ stub-obj-$(CONFIG_WIN32) += fd-register.o
 stub-obj-y += cpus.o
 stub-obj-y += kvm.o
 stub-obj-y += qmp_pc_dimm_device_list.o
+
+qapi-block-obj-y += arch-type.o
+qapi-block-obj-y += autostart.o
+qapi-block-obj-y += kvm-allowed.o
+qapi-block-obj-y += cpus-list.o
+qapi-block-obj-y += serial-hds.o
+qapi-block-obj-y += qemu-chr-open-msmouse.o
+qapi-block-obj-y += runstate-is-running.o
+qapi-block-obj-y += kvm-cpu-synchronize-state.o
+qapi-block-obj-y += kvm-cpu-synchronize-post-init.o
+qapi-block-obj-y += qemu-add-machine-init-done-notifier.o
+qapi-block-obj-y += get-double.o
+qapi-block-obj-y += get-expr.o
+qapi-block-obj-y += vmstate-info-buffer.o
+qapi-block-obj-y += vmstate-info-uint32.o
diff --git a/stubs/arch-type.c b/stubs/arch-type.c
new file mode 100644
index 0000000..90b2e80
--- /dev/null
+++ b/stubs/arch-type.c
@@ -0,0 +1,3 @@
+#include <stdint.h>
+
+const uint32_t arch_type = -1;
diff --git a/stubs/autostart.c b/stubs/autostart.c
new file mode 100644
index 0000000..0746d71
--- /dev/null
+++ b/stubs/autostart.c
@@ -0,0 +1 @@
+int autostart;
diff --git a/stubs/cpus-list.c b/stubs/cpus-list.c
new file mode 100644
index 0000000..c1f0455
--- /dev/null
+++ b/stubs/cpus-list.c
@@ -0,0 +1,3 @@
+#include "sysemu/kvm.h"
+
+struct CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus);
diff --git a/stubs/get-double.c b/stubs/get-double.c
new file mode 100644
index 0000000..b365266
--- /dev/null
+++ b/stubs/get-double.c
@@ -0,0 +1,8 @@
+#include <stdint.h>
+#include "monitor/monitor-system.h"
+
+int get_double(Monitor *mon, double *pval, const char **pp)
+{
+    *pval = 0;
+    return 0;
+}
diff --git a/stubs/get-expr.c b/stubs/get-expr.c
new file mode 100644
index 0000000..e05ad5c
--- /dev/null
+++ b/stubs/get-expr.c
@@ -0,0 +1,8 @@
+#include <stdint.h>
+#include "monitor/monitor-system.h"
+
+int get_expr(Monitor *mon, int64_t *pval, const char **pp)
+{
+    *pval = 0;
+    return 0;
+}
diff --git a/stubs/kvm-allowed.c b/stubs/kvm-allowed.c
new file mode 100644
index 0000000..74a2fa9
--- /dev/null
+++ b/stubs/kvm-allowed.c
@@ -0,0 +1,3 @@
+#include <stdbool.h>
+
+bool kvm_allowed;
diff --git a/stubs/kvm-cpu-synchronize-post-init.c b/stubs/kvm-cpu-synchronize-post-init.c
new file mode 100644
index 0000000..f78faa7
--- /dev/null
+++ b/stubs/kvm-cpu-synchronize-post-init.c
@@ -0,0 +1,5 @@
+#include "sysemu/kvm.h"
+
+void kvm_cpu_synchronize_post_init(CPUState *cpu)
+{
+}
diff --git a/stubs/kvm-cpu-synchronize-state.c b/stubs/kvm-cpu-synchronize-state.c
new file mode 100644
index 0000000..53fd523
--- /dev/null
+++ b/stubs/kvm-cpu-synchronize-state.c
@@ -0,0 +1,5 @@
+#include "sysemu/kvm.h"
+
+void kvm_cpu_synchronize_state(CPUState *cpu)
+{
+}
diff --git a/stubs/qemu-add-machine-init-done-notifier.c b/stubs/qemu-add-machine-init-done-notifier.c
new file mode 100644
index 0000000..744a6a9
--- /dev/null
+++ b/stubs/qemu-add-machine-init-done-notifier.c
@@ -0,0 +1,5 @@
+#include "sysemu/sysemu.h"
+
+void qemu_add_machine_init_done_notifier(Notifier *notify)
+{
+}
diff --git a/stubs/qemu-chr-open-msmouse.c b/stubs/qemu-chr-open-msmouse.c
new file mode 100644
index 0000000..459f10b
--- /dev/null
+++ b/stubs/qemu-chr-open-msmouse.c
@@ -0,0 +1,7 @@
+#include "sysemu/char.h"
+#include "ui/console.h"
+
+CharDriverState *qemu_chr_open_msmouse(void)
+{
+    return NULL;
+}
diff --git a/stubs/runstate-is-running.c b/stubs/runstate-is-running.c
new file mode 100644
index 0000000..f7e6fc2
--- /dev/null
+++ b/stubs/runstate-is-running.c
@@ -0,0 +1,6 @@
+#include "sysemu/sysemu.h"
+
+int runstate_is_running(void)
+{
+    return 1;
+}
diff --git a/stubs/serial-hds.c b/stubs/serial-hds.c
new file mode 100644
index 0000000..81d539c
--- /dev/null
+++ b/stubs/serial-hds.c
@@ -0,0 +1,3 @@
+#include "sysemu/sysemu.h"
+
+CharDriverState *serial_hds[MAX_SERIAL_PORTS];
diff --git a/stubs/vmstate-info-buffer.c b/stubs/vmstate-info-buffer.c
new file mode 100644
index 0000000..29fcaa0
--- /dev/null
+++ b/stubs/vmstate-info-buffer.c
@@ -0,0 +1,8 @@
+#include <qemu-common.h>
+#include "migration/vmstate.h"
+
+const VMStateInfo vmstate_info_buffer = {
+    .name = "buffer",
+    .get  = NULL,
+    .put  = NULL,
+};
diff --git a/stubs/vmstate-info-uint32.c b/stubs/vmstate-info-uint32.c
new file mode 100644
index 0000000..1d11233
--- /dev/null
+++ b/stubs/vmstate-info-uint32.c
@@ -0,0 +1,8 @@
+#include <qemu-common.h>
+#include "migration/vmstate.h"
+
+const VMStateInfo vmstate_info_uint32 = {
+    .name = "uint32",
+    .get  = NULL,
+    .put  = NULL,
+};
diff --git a/util/Makefile.objs b/util/Makefile.objs
index 6b3c83b..20d65c0 100644
--- a/util/Makefile.objs
+++ b/util/Makefile.objs
@@ -15,3 +15,5 @@ util-obj-y += throttle.o
 util-obj-y += getauxval.o
 util-obj-y += readline.o
 util-obj-y += rfifolock.o
+
+qapi-block-obj-y += $(util-obj-y)
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 23/24] qapi: Add a script to filter qmp-commands-old.h to generate a subset of it.
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (21 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 22/24] qemu-nbd: build QAPI block core into qemu-nbd Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  2014-08-05 12:51   ` Eric Blake
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 24/24] qemu-nbd: Add --qmp option to qemu-nbd Benoît Canet
  23 siblings, 1 reply; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

Since qmp-command-olds.h is generated from qmp-commands.hx we will sometime want
to include only a subset of it. For example when linking qapi block commands
with qemu-nbd.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 Makefile                           |  7 +++
 scripts/filter_qmp_commands_old.py | 93 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 100 insertions(+)
 create mode 100755 scripts/filter_qmp_commands_old.py

diff --git a/Makefile b/Makefile
index f56dcaa..209a859 100644
--- a/Makefile
+++ b/Makefile
@@ -47,6 +47,7 @@ endif
 GENERATED_BLOCK_HEADERS = block/qapi-generated/qmp-commands.h
 GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-types.h
 GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-visit.h
+GENERATED_BLOCK_HEADERS += block/qapi-generated/qmp-commands-old.h
 GENERATED_BLOCK_SOURCES = block/qapi-generated/qmp-marshal.c
 GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-types.c
 GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-visit.c
@@ -296,6 +297,12 @@ $(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 		$(gen-out-type) -o  block/qapi-generated -m -i $<, \
 		"  GEN   $@")
 
+block/qapi-generated/qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx \
+block/qapi-generated/qmp-commands.h
+	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< |\
+./scripts/filter_qmp_commands_old.py \
+$(SRC_PATH)/block/qapi-generated/qmp-commands.h > $@,"  GEN   $@")
+
 QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
 $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
 
diff --git a/scripts/filter_qmp_commands_old.py b/scripts/filter_qmp_commands_old.py
new file mode 100755
index 0000000..d7e02d9
--- /dev/null
+++ b/scripts/filter_qmp_commands_old.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+#
+# qmp-commands-old.h filtering
+#
+# Copyright (C) 2014 Nodalink, EURL.
+#
+# Authors:
+#  Benoit Canet <benoit.canet@irqsave.net>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.
+# See the COPYING file in the top-level directory.
+
+""" The purpose of this script is to get a subset of qmp-command-old.h
+    suitable for use in one of the block commands. (qemu-nbd, qemu-io).
+    The result is printed on stdout.
+"""
+
+import sys
+import os
+
+def usage():
+    """ Print usage """
+    print "Usage:"
+    print "\tcat /path/to/qmp-commands-old.h|%s /path/to/qmp-command.h" %\
+          sys.argv[0]
+    sys.exit(1)
+
+def get_lines(filename):
+    """ Get the lines composing a file into a list """
+    if not os.path.exists(filename):
+        print "%s does not exists" % filename
+        sys.exit(1)
+    if not os.access(filename, os.R_OK):
+        print "%s is not readable" % filename
+        sys.exit(1)
+    with open(filename) as file_object:
+        return file_object.readlines()
+
+def build_filter_list(filename):
+    """ Build a list of qmp function that will be used as a filter """
+    result = []
+    lines = get_lines(filename)
+    for line in lines:
+        line = line.strip()
+        if not "(" in line:
+            continue
+        if not "input" in line:
+            continue
+        begining, _ = line.split('(')
+        component = begining.split(' ')
+        function = component[len(component) -1]
+        result.append(function)
+    return result
+
+def filter_and_print(to_filter, filter_list):
+    """ Filter the lines from to_filter with filter_list and print on stdout """
+    result = []
+    block = []
+    in_block = False
+    line = to_filter.readline()
+    while line:
+        if (".mhandler.cmd_new" in line or
+           ".mhandler.cmd_async" in line) and in_block:
+            _, end = line.strip().split("=")
+            function_name = end[:-1].strip()
+            if function_name not in filter_list and \
+               function_name != "do_qmp_capabilities" and \
+               function_name != "qmp_marshal_input_query_commands":
+                in_block = False
+        if in_block or "}" in line:
+            block.append(line)
+        if "{" in line:
+            block = [line]
+            in_block = True
+        if "}" in line and in_block:
+            block.append("\n")
+            in_block = False
+            result += block
+        line = to_filter.readline()
+    print "".join(result)
+
+def main():
+    """ Main function of the module """
+    if len(sys.argv) != 2:
+        usage()
+    to_filter = sys.stdin
+    filename = sys.argv[1]
+
+    filter_list = build_filter_list(filename)
+    filter_and_print(to_filter, filter_list)
+
+if __name__ == "__main__":
+    main()
-- 
2.0.1

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

* [Qemu-devel] [PATCH v1 24/24] qemu-nbd: Add --qmp option to qemu-nbd.
  2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
                   ` (22 preceding siblings ...)
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 23/24] qapi: Add a script to filter qmp-commands-old.h to generate a subset of it Benoît Canet
@ 2014-08-01  5:27 ` Benoît Canet
  23 siblings, 0 replies; 30+ messages in thread
From: Benoît Canet @ 2014-08-01  5:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, Benoît Canet, Benoit Canet, mreitz, stefanha

This patch add a -qmp parameter to the qemu-nbd command line in order to be able
to manipulate the qemu-nbd block devices via qmp.

This could be used with containers to easily migrate from qemu to a container.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 Makefile.objs                  |   3 +-
 include/monitor/monitor-init.h |  34 ++++++++++++
 monitor-init.c                 | 121 +++++++++++++++++++++++++++++++++++++++++
 monitor.c                      |   1 +
 qemu-nbd.c                     |  33 ++++++++++-
 vl.c                           |  88 +-----------------------------
 6 files changed, 190 insertions(+), 90 deletions(-)
 create mode 100644 include/monitor/monitor-init.h
 create mode 100644 monitor-init.c

diff --git a/Makefile.objs b/Makefile.objs
index 6fe81e9..6116fb6 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -23,6 +23,7 @@ block-obj-m = block/
 
 qapi-block-obj-y = block/qapi-generated/qmp-marshal.o blockdev.o qmp.o
 qapi-block-obj-y += monitor.o
+qapi-block-obj-y += monitor-init.o
 qapi-block-obj-y += qemu-char.o
 qapi-block-obj-y += qemu-log.o
 qapi-block-obj-y += qom/
@@ -79,7 +80,7 @@ common-obj-y += bt-host.o bt-vhci.o
 bt-host.o-cflags := $(BLUEZ_CFLAGS)
 
 common-obj-y += dma-helpers.o
-common-obj-y += vl.o
+common-obj-y += vl.o monitor-init.o
 vl.o-cflags := $(GPROF_CFLAGS) $(SDL_CFLAGS)
 common-obj-y += tpm.o
 
diff --git a/include/monitor/monitor-init.h b/include/monitor/monitor-init.h
new file mode 100644
index 0000000..23be581
--- /dev/null
+++ b/include/monitor/monitor-init.h
@@ -0,0 +1,34 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MONITOR_INIT_H
+#define MONITOR_INIT_H
+
+#include "qemu/option.h"
+
+int chardev_init_func(QemuOpts *opts, void *opaque);
+int mon_init_func(QemuOpts *opts, void *opaque);
+void monitor_parse(const char *optarg, const char *mode);
+
+#endif
diff --git a/monitor-init.c b/monitor-init.c
new file mode 100644
index 0000000..9888286
--- /dev/null
+++ b/monitor-init.c
@@ -0,0 +1,121 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "monitor/monitor-init.h"
+#include "monitor/monitor.h"
+#include "sysemu/char.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int chardev_init_func(QemuOpts *opts, void *opaque)
+{
+    Error *local_err = NULL;
+
+    qemu_chr_new_from_opts(opts, NULL, &local_err);
+    if (local_err) {
+        error_report("%s", error_get_pretty(local_err));
+        error_free(local_err);
+        return -1;
+    }
+    return 0;
+}
+
+int mon_init_func(QemuOpts *opts, void *opaque)
+{
+    CharDriverState *chr;
+    const char *chardev;
+    const char *mode;
+    int flags;
+
+    mode = qemu_opt_get(opts, "mode");
+    if (mode == NULL) {
+        mode = "readline";
+    }
+    if (strcmp(mode, "readline") == 0) {
+        flags = MONITOR_USE_READLINE;
+    } else if (strcmp(mode, "control") == 0) {
+        flags = MONITOR_USE_CONTROL;
+    } else {
+        fprintf(stderr, "unknown monitor mode \"%s\"\n", mode);
+        exit(1);
+    }
+
+    if (qemu_opt_get_bool(opts, "pretty", 0)) {
+        flags |= MONITOR_USE_PRETTY;
+    }
+
+    if (qemu_opt_get_bool(opts, "default", 0)) {
+        flags |= MONITOR_IS_DEFAULT;
+    }
+
+    chardev = qemu_opt_get(opts, "chardev");
+    chr = qemu_chr_find(chardev);
+    if (chr == NULL) {
+        fprintf(stderr, "chardev \"%s\" not found\n", chardev);
+        exit(1);
+    }
+
+    qemu_chr_fe_claim_no_fail(chr);
+    monitor_init(chr, flags);
+    return 0;
+}
+
+void monitor_parse(const char *optarg, const char *mode)
+{
+    static int monitor_device_index;
+    QemuOpts *opts;
+    const char *p;
+    char label[32];
+    int def = 0;
+
+    if (strstart(optarg, "chardev:", &p)) {
+        snprintf(label, sizeof(label), "%s", p);
+    } else {
+        snprintf(label, sizeof(label), "compat_monitor%d",
+                 monitor_device_index);
+        if (monitor_device_index == 0) {
+            def = 1;
+        }
+        opts = qemu_chr_parse_compat(label, optarg);
+        if (!opts) {
+            fprintf(stderr, "parse error: %s\n", optarg);
+            exit(1);
+        }
+    }
+
+    opts = qemu_opts_create(qemu_find_opts("mon"), label, 1, NULL);
+    if (!opts) {
+        fprintf(stderr, "duplicate chardev: %s\n", label);
+        exit(1);
+    }
+    qemu_opt_set(opts, "mode", mode);
+    qemu_opt_set(opts, "chardev", label);
+    if (def) {
+        qemu_opt_set(opts, "default", "on");
+    }
+    monitor_device_index++;
+}
+
diff --git a/monitor.c b/monitor.c
index bc7f3d3..bf7d9a3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -149,6 +149,7 @@ static mon_cmd_t info_cmds[] = {
 };
 size_t sizeof_info_cmds = sizeof(info_cmds);
 static const mon_cmd_t qmp_cmds[] = {
+#include "block/qapi-generated/qmp-commands-old.h"
     { /* NULL */ },
 };
 #else
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 626e584..324f029 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -16,13 +16,16 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "monitor/monitor-init.h"
 #include "qemu-common.h"
 #include "block/block.h"
 #include "block/nbd.h"
+#include "qemu/config-file.h"
 #include "qemu/main-loop.h"
 #include "qemu/sockets.h"
 #include "qemu/error-report.h"
 #include "block/snapshot.h"
+#include "sysemu/sysemu.h"
 
 #include <stdarg.h>
 #include <stdio.h>
@@ -97,6 +100,9 @@ static void usage(const char *name)
 "      --aio=MODE       set AIO mode (native or threads)\n"
 #endif
 "\n"
+"Management options:\n"
+"  -q, --qmp=DEV        machine monitor listen on DEV\n"
+"\n"
 "Report bugs to <qemu-devel@nongnu.org>\n"
     , name, NBD_DEFAULT_PORT, "DEVICE");
 }
@@ -390,7 +396,7 @@ int main(int argc, char **argv)
     off_t fd_size;
     QemuOpts *sn_opts = NULL;
     const char *sn_id_or_name = NULL;
-    const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:tl:";
+    const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:tl:q:";
     struct option lopt[] = {
         { "help", 0, NULL, 'h' },
         { "version", 0, NULL, 'V' },
@@ -412,6 +418,7 @@ int main(int argc, char **argv)
         { "discard", 1, NULL, QEMU_NBD_OPT_DISCARD },
         { "shared", 1, NULL, 'e' },
         { "format", 1, NULL, 'f' },
+        { "qmp", 1, NULL, 'q' },
         { "persistent", 0, NULL, 't' },
         { "verbose", 0, NULL, 'v' },
         { NULL, 0, NULL, 0 }
@@ -432,6 +439,11 @@ int main(int argc, char **argv)
     pthread_t client_thread;
     const char *fmt = NULL;
     Error *local_err = NULL;
+    bool has_qmp = false;
+
+    module_call_init(MODULE_INIT_QOM);
+    qemu_add_opts(&qemu_mon_opts);
+    qemu_add_opts(&qemu_chardev_opts);
 
     /* The client thread uses SIGTERM to interrupt the server.  A signal
      * handler ensures that "qemu-nbd -v -c" exits with a nice status code.
@@ -553,6 +565,10 @@ int main(int argc, char **argv)
 	case 't':
 	    persistent = 1;
 	    break;
+        case 'q':
+            monitor_parse(optarg, "control");
+            has_qmp = true;
+            break;
         case 'v':
             verbose = 1;
             break;
@@ -576,6 +592,15 @@ int main(int argc, char **argv)
              argv[0]);
     }
 
+    if (qemu_opts_foreach(qemu_find_opts("chardev"), chardev_init_func,
+                          NULL, 1) != 0) {
+        exit(1);
+    }
+
+    if (qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, 1) != 0) {
+        exit(1);
+    }
+
     if (disconnect) {
         fd = open(argv[optind], O_RDWR);
         if (fd < 0) {
@@ -725,8 +750,10 @@ int main(int argc, char **argv)
                          (void *)(uintptr_t)fd);
 
     /* now when the initialization is (almost) complete, chdir("/")
-     * to free any busy filesystems */
-    if (chdir("/") < 0) {
+     * to free any busy filesystems. We don't do this when QMP is used to avoid
+     * disturbing snapshot taking.
+     */
+    if (!has_qmp && chdir("/") < 0) {
         err(EXIT_FAILURE, "Could not chdir to root directory");
     }
 
diff --git a/vl.c b/vl.c
index fe451aa..fdfe246 100644
--- a/vl.c
+++ b/vl.c
@@ -119,6 +119,8 @@ int main(int argc, char **argv)
 #include "qom/object_interfaces.h"
 #include "qapi-event.h"
 
+#include "monitor/monitor-init.h"
+
 #define DEFAULT_RAM_SIZE 128
 
 #define MAX_VIRTIO_CONSOLES 1
@@ -2351,19 +2353,6 @@ static int device_init_func(QemuOpts *opts, void *opaque)
     return 0;
 }
 
-static int chardev_init_func(QemuOpts *opts, void *opaque)
-{
-    Error *local_err = NULL;
-
-    qemu_chr_new_from_opts(opts, NULL, &local_err);
-    if (local_err) {
-        error_report("%s", error_get_pretty(local_err));
-        error_free(local_err);
-        return -1;
-    }
-    return 0;
-}
-
 #ifdef CONFIG_VIRTFS
 static int fsdev_init_func(QemuOpts *opts, void *opaque)
 {
@@ -2374,79 +2363,6 @@ static int fsdev_init_func(QemuOpts *opts, void *opaque)
 }
 #endif
 
-static int mon_init_func(QemuOpts *opts, void *opaque)
-{
-    CharDriverState *chr;
-    const char *chardev;
-    const char *mode;
-    int flags;
-
-    mode = qemu_opt_get(opts, "mode");
-    if (mode == NULL) {
-        mode = "readline";
-    }
-    if (strcmp(mode, "readline") == 0) {
-        flags = MONITOR_USE_READLINE;
-    } else if (strcmp(mode, "control") == 0) {
-        flags = MONITOR_USE_CONTROL;
-    } else {
-        fprintf(stderr, "unknown monitor mode \"%s\"\n", mode);
-        exit(1);
-    }
-
-    if (qemu_opt_get_bool(opts, "pretty", 0))
-        flags |= MONITOR_USE_PRETTY;
-
-    if (qemu_opt_get_bool(opts, "default", 0))
-        flags |= MONITOR_IS_DEFAULT;
-
-    chardev = qemu_opt_get(opts, "chardev");
-    chr = qemu_chr_find(chardev);
-    if (chr == NULL) {
-        fprintf(stderr, "chardev \"%s\" not found\n", chardev);
-        exit(1);
-    }
-
-    qemu_chr_fe_claim_no_fail(chr);
-    monitor_init(chr, flags);
-    return 0;
-}
-
-static void monitor_parse(const char *optarg, const char *mode)
-{
-    static int monitor_device_index = 0;
-    QemuOpts *opts;
-    const char *p;
-    char label[32];
-    int def = 0;
-
-    if (strstart(optarg, "chardev:", &p)) {
-        snprintf(label, sizeof(label), "%s", p);
-    } else {
-        snprintf(label, sizeof(label), "compat_monitor%d",
-                 monitor_device_index);
-        if (monitor_device_index == 0) {
-            def = 1;
-        }
-        opts = qemu_chr_parse_compat(label, optarg);
-        if (!opts) {
-            fprintf(stderr, "parse error: %s\n", optarg);
-            exit(1);
-        }
-    }
-
-    opts = qemu_opts_create(qemu_find_opts("mon"), label, 1, NULL);
-    if (!opts) {
-        fprintf(stderr, "duplicate chardev: %s\n", label);
-        exit(1);
-    }
-    qemu_opt_set(opts, "mode", mode);
-    qemu_opt_set(opts, "chardev", label);
-    if (def)
-        qemu_opt_set(opts, "default", "on");
-    monitor_device_index++;
-}
-
 struct device_config {
     enum {
         DEV_USB,       /* -usbdevice     */
-- 
2.0.1

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

* Re: [Qemu-devel] [PATCH v1 01/24] qmp: Extract system emulation related code from qmp.c into qmp-system.c
  2014-08-01  5:26 ` [Qemu-devel] [PATCH v1 01/24] qmp: Extract system emulation related code from qmp.c into qmp-system.c Benoît Canet
@ 2014-08-05 12:40   ` Eric Blake
  0 siblings, 0 replies; 30+ messages in thread
From: Eric Blake @ 2014-08-05 12:40 UTC (permalink / raw)
  To: Benoît Canet, qemu-devel; +Cc: kwolf, Benoit Canet, stefanha, mreitz

[-- Attachment #1: Type: text/plain, Size: 1238 bytes --]

On 07/31/2014 11:26 PM, Benoît Canet wrote:
> This patch will allow to link qmp.o with utility binaries without dragging too

s/allow to link/allow linking/

> much unrelated object files and externals dependencies.

s/dragging too much/dragging in too many/
s/externals/external/

> 
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  Makefile.objs |   2 +-
>  qmp-system.c  | 376 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  qmp.c         | 361 +------------------------------------------------------
>  3 files changed, 379 insertions(+), 360 deletions(-)
>  create mode 100644 qmp-system.c
> 

When reviewing code motion, I like to do:

$ diff -u <(sed -n 's/^-//p' patch) <(sed -n 's/^+//p' patch)

In the case of this patch, you rearranged functions, which makes it MUCH
harder to see if everything moved correctly (for example, the old code
has qmp_query_kvm, qmp_query_uuid, qmp_quit, qmp_stop...; the new code
has them in a different order).  It would be a lot easier if you create
the new file with the function order preserved as it was in the original
file.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

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

* Re: [Qemu-devel] [PATCH v1 02/24] monitor: Make some function public
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 02/24] monitor: Make some function public Benoît Canet
@ 2014-08-05 12:41   ` Eric Blake
  0 siblings, 0 replies; 30+ messages in thread
From: Eric Blake @ 2014-08-05 12:41 UTC (permalink / raw)
  To: Benoît Canet, qemu-devel; +Cc: kwolf, Benoit Canet, stefanha, mreitz

[-- Attachment #1: Type: text/plain, Size: 635 bytes --]

On 07/31/2014 11:27 PM, Benoît Canet wrote:
> Next commits will split monitor.c in monitor.c and monitor-system.c.

s/in/to/

> 
> Change some function from static to public in order to prepare this.

s/function/functions/
s/this/for this/

> 
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  include/monitor/monitor.h | 10 ++++++++++
>  monitor.c                 | 24 ++++++++++--------------
>  2 files changed, 20 insertions(+), 14 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

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

* Re: [Qemu-devel] [PATCH v1 03/24] monitor: Extract monitor-system.h header
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 03/24] monitor: Extract monitor-system.h header Benoît Canet
@ 2014-08-05 12:47   ` Eric Blake
  0 siblings, 0 replies; 30+ messages in thread
From: Eric Blake @ 2014-08-05 12:47 UTC (permalink / raw)
  To: Benoît Canet, qemu-devel; +Cc: kwolf, Benoit Canet, stefanha, mreitz

[-- Attachment #1: Type: text/plain, Size: 1021 bytes --]

On 07/31/2014 11:27 PM, Benoît Canet wrote:
> This header will allow to split monitor in two parts.

s/allow to split monitor in/allow splitting the monitor into/

> 
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  include/monitor/monitor-system.h | 99 ++++++++++++++++++++++++++++++++++++++++
>  monitor.c                        | 57 ++---------------------
>  2 files changed, 102 insertions(+), 54 deletions(-)
>  create mode 100644 include/monitor/monitor-system.h
> 

> +struct Monitor {
> +    CharDriverState *chr;
> +    int reset_seen;

Should we be converting this field to bool at some point in the series?
 (Probably as a separate patch, since this patch is more focused on code
motion).


> +
> +typedef struct mon_cmd_t {

This isn't typical qemu naming convention.  Can we fix that up in this
series?  (Probably best as a separate patch before this one)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

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

* Re: [Qemu-devel] [PATCH v1 04/24] monitor: Make monitor_fprintf public before extracting it
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 04/24] monitor: Make monitor_fprintf public before extracting it Benoît Canet
@ 2014-08-05 12:48   ` Eric Blake
  0 siblings, 0 replies; 30+ messages in thread
From: Eric Blake @ 2014-08-05 12:48 UTC (permalink / raw)
  To: Benoît Canet, qemu-devel; +Cc: kwolf, Benoit Canet, stefanha, mreitz

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

On 07/31/2014 11:27 PM, Benoît Canet wrote:
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  disas.c                   | 10 ----------
>  include/monitor/monitor.h |  2 ++
>  monitor.c                 |  4 ++--
>  3 files changed, 4 insertions(+), 12 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

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

* Re: [Qemu-devel] [PATCH v1 23/24] qapi: Add a script to filter qmp-commands-old.h to generate a subset of it.
  2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 23/24] qapi: Add a script to filter qmp-commands-old.h to generate a subset of it Benoît Canet
@ 2014-08-05 12:51   ` Eric Blake
  0 siblings, 0 replies; 30+ messages in thread
From: Eric Blake @ 2014-08-05 12:51 UTC (permalink / raw)
  To: Benoît Canet, qemu-devel; +Cc: kwolf, Benoit Canet, stefanha, mreitz

[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]

On 07/31/2014 11:27 PM, Benoît Canet wrote:
> Since qmp-command-olds.h is generated from qmp-commands.hx we will sometime want
> to include only a subset of it. For example when linking qapi block commands
> with qemu-nbd.
> 
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  Makefile                           |  7 +++
>  scripts/filter_qmp_commands_old.py | 93 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 100 insertions(+)
>  create mode 100755 scripts/filter_qmp_commands_old.py

> +++ b/scripts/filter_qmp_commands_old.py
> @@ -0,0 +1,93 @@
> +#!/usr/bin/env python
> +#
> +# qmp-commands-old.h filtering
> +#
> +# Copyright (C) 2014 Nodalink, EURL.
> +#
> +# Authors:
> +#  Benoit Canet <benoit.canet@irqsave.net>
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2.
> +# See the COPYING file in the top-level directory.

Why GPLv2-only?  New files should prefer GPLv2+ (you should add the "or
later" clause).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

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

end of thread, other threads:[~2014-08-05 12:51 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-01  5:26 [Qemu-devel] [PATCH v1 00/24] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
2014-08-01  5:26 ` [Qemu-devel] [PATCH v1 01/24] qmp: Extract system emulation related code from qmp.c into qmp-system.c Benoît Canet
2014-08-05 12:40   ` Eric Blake
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 02/24] monitor: Make some function public Benoît Canet
2014-08-05 12:41   ` Eric Blake
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 03/24] monitor: Extract monitor-system.h header Benoît Canet
2014-08-05 12:47   ` Eric Blake
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 04/24] monitor: Make monitor_fprintf public before extracting it Benoît Canet
2014-08-05 12:48   ` Eric Blake
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 05/24] monitor: Extract monitor_fprintf to monitor-system.c Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 06/24] monitor: Extract qmp_human_monitor_command into monitor-system.c Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 07/24] monitor: Make some function to extract public Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 08/24] monitor: Extract a couple of function to monitor-system.c Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 09/24] monitor: Make do_info_help public Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 10/24] monitor: Extract do_info_help in monitor-system.c Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 11/24] monitor: Make some monitor functions public before moving them " Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 12/24] monitor: Make do_loadvm public before moving it to monitor-system.c Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 13/24] monitor: Move do_loadvm from monitor.c " Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 14/24] monitor: Make commands public before moving them " Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 15/24] monitor: Move mon_cmd_t arrays and some function from monitor.c " Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 16/24] monitor: Move more functions " Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 17/24] monitor: Move two net " Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 18/24] monitor: Move qmp_rtc_reset_reinjection " Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 19/24] monitor-system: Switch back functions to static Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 20/24] monitor: Extract hardware dependent completion function from monitor.c to monitor-system.c Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 21/24] monitor: Cleanup monitor.c includes after extracting monitor-system.c Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 22/24] qemu-nbd: build QAPI block core into qemu-nbd Benoît Canet
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 23/24] qapi: Add a script to filter qmp-commands-old.h to generate a subset of it Benoît Canet
2014-08-05 12:51   ` Eric Blake
2014-08-01  5:27 ` [Qemu-devel] [PATCH v1 24/24] qemu-nbd: Add --qmp option to qemu-nbd Benoît Canet

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).