qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API
@ 2010-12-06 18:23 Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 01/25] QMP: Rename query handlers Luiz Capitulino
                   ` (24 more replies)
  0 siblings, 25 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

Today, when writing an info command that is used by QMP and HMP, the
programmer has to implement:

 1. The handler itself, that's the function that gathers data and
    returns it as QObjects
 2. A pretty printing function, which is called by the human monitor
    to print the returned QObjects in human readable form

However, we want to have a clean separation between QMP and the human
monitor. Actually, we want to turn QMP into an internal API and the
human monitor should be written on top of that.

So, this series does:

 1. Move all QMP calling code to the info handler using it, that's
    we change the pretty printing function to call QMP and turn it
    into an info handler
 2. Drop all QMP calling code from do_info()

Please, note that this is only done for info handlers. Command handlers
will take a bit more time to be converted.

 balloon.c   |   26 +-----
 balloon.h   |    2 +-
 block.c     |   16 ++-
 block.h     |    8 +-
 console.h   |    8 +-
 hw/pci.c    |    9 ++-
 hw/pci.h    |    4 +-
 input.c     |   11 ++-
 migration.c |   13 ++-
 migration.h |    4 +-
 monitor.c   |  341 +++++++++++++++++++++++++++--------------------------------
 qemu-char.c |   10 ++-
 qemu-char.h |    4 +-
 ui/vnc.c    |   11 ++-
 14 files changed, 227 insertions(+), 240 deletions(-)

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

* [Qemu-devel] [PATCH 01/25] QMP: Rename query handlers
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-07 12:28   ` Miguel Di Ciurcio Filho
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 02/25] QMP: Drop user_print usage from the qmp_query_cmds[] table Luiz Capitulino
                   ` (23 subsequent siblings)
  24 siblings, 1 reply; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

Query handlers still carry their human monitor name. This commit
renames all of them to a more QMP-like name.

For example, do_info_version() is renamed to qmp_query_version().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 balloon.c   |    4 +-
 balloon.h   |    2 +-
 block.c     |    4 +-
 block.h     |    4 +-
 console.h   |    4 +-
 hw/pci.c    |    2 +-
 hw/pci.h    |    2 +-
 input.c     |    2 +-
 migration.c |    2 +-
 migration.h |    2 +-
 monitor.c   |   74 +++++++++++++++++++++++++++++-----------------------------
 qemu-char.c |    2 +-
 qemu-char.h |    2 +-
 ui/vnc.c    |    2 +-
 14 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/balloon.c b/balloon.c
index 0021fef..dbc6f44 100644
--- a/balloon.c
+++ b/balloon.c
@@ -86,7 +86,7 @@ void monitor_print_balloon(Monitor *mon, const QObject *data)
 }
 
 /**
- * do_info_balloon(): Balloon information
+ * qmp_query_balloon(): Balloon information
  *
  * Make an asynchronous request for balloon info.  When the request completes
  * a QDict will be returned according to the following specification:
@@ -106,7 +106,7 @@ void monitor_print_balloon(Monitor *mon, const QObject *data)
  *   "major_page_faults": 142, "minor_page_faults": 239245,
  *   "free_mem": 1014185984, "total_mem": 1044668416 }
  */
-int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
+int qmp_query_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
 {
     int ret;
 
diff --git a/balloon.h b/balloon.h
index d478e28..3b5ec4a 100644
--- a/balloon.h
+++ b/balloon.h
@@ -26,7 +26,7 @@ int qemu_balloon(ram_addr_t target, MonitorCompletion cb, void *opaque);
 int qemu_balloon_status(MonitorCompletion cb, void *opaque);
 
 void monitor_print_balloon(Monitor *mon, const QObject *data);
-int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque);
+int qmp_query_balloon(Monitor *mon, MonitorCompletion cb, void *opaque);
 int do_balloon(Monitor *mon, const QDict *params,
                MonitorCompletion cb, void *opaque);
 
diff --git a/block.c b/block.c
index 63effd8..a5d865b 100644
--- a/block.c
+++ b/block.c
@@ -1596,7 +1596,7 @@ void bdrv_info_print(Monitor *mon, const QObject *data)
     qlist_iter(qobject_to_qlist(data), bdrv_print_dict, mon);
 }
 
-void bdrv_info(Monitor *mon, QObject **ret_data)
+void qmp_query_block(Monitor *mon, QObject **ret_data)
 {
     QList *bs_list;
     BlockDriverState *bs;
@@ -1702,7 +1702,7 @@ static QObject* bdrv_info_stats_bs(BlockDriverState *bs)
     return res;
 }
 
-void bdrv_info_stats(Monitor *mon, QObject **ret_data)
+void qmp_query_blockstats(Monitor *mon, QObject **ret_data)
 {
     QObject *obj;
     QList *devices;
diff --git a/block.h b/block.h
index 78ecfac..a979d5b 100644
--- a/block.h
+++ b/block.h
@@ -53,9 +53,9 @@ typedef enum {
 void bdrv_mon_event(const BlockDriverState *bdrv,
                     BlockMonEventAction action, int is_read);
 void bdrv_info_print(Monitor *mon, const QObject *data);
-void bdrv_info(Monitor *mon, QObject **ret_data);
+void qmp_query_block(Monitor *mon, QObject **ret_data);
 void bdrv_stats_print(Monitor *mon, const QObject *data);
-void bdrv_info_stats(Monitor *mon, QObject **ret_data);
+void qmp_query_blockstats(Monitor *mon, QObject **ret_data);
 
 void bdrv_init(void);
 void bdrv_init_with_whitelist(void);
diff --git a/console.h b/console.h
index aafb031..f613e4e 100644
--- a/console.h
+++ b/console.h
@@ -73,7 +73,7 @@ struct MouseTransformInfo {
 };
 
 void do_info_mice_print(Monitor *mon, const QObject *data);
-void do_info_mice(Monitor *mon, QObject **ret_data);
+void qmp_query_mice(Monitor *mon, QObject **ret_data);
 void do_mouse_set(Monitor *mon, const QDict *qdict);
 
 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
@@ -370,7 +370,7 @@ void vnc_display_close(DisplayState *ds);
 int vnc_display_open(DisplayState *ds, const char *display);
 int vnc_display_password(DisplayState *ds, const char *password);
 void do_info_vnc_print(Monitor *mon, const QObject *data);
-void do_info_vnc(Monitor *mon, QObject **ret_data);
+void qmp_query_vnc(Monitor *mon, QObject **ret_data);
 char *vnc_display_local_addr(DisplayState *ds);
 
 /* curses.c */
diff --git a/hw/pci.c b/hw/pci.c
index 0c15b13..08c36ec 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1438,7 +1438,7 @@ static QObject *pci_get_bus_dict(PCIBus *bus, int bus_num)
     return NULL;
 }
 
-void do_pci_info(Monitor *mon, QObject **ret_data)
+void qmp_query_pci(Monitor *mon, QObject **ret_data)
 {
     QList *bus_list;
     struct PCIHostBus *host;
diff --git a/hw/pci.h b/hw/pci.h
index 89f7b76..b87c6c0 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -254,7 +254,7 @@ int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
                      unsigned *slotp);
 
 void do_pci_info_print(Monitor *mon, const QObject *data);
-void do_pci_info(Monitor *mon, QObject **ret_data);
+void qmp_query_pci(Monitor *mon, QObject **ret_data);
 void pci_bridge_update_mappings(PCIBus *b);
 
 bool pci_msi_enabled(PCIDevice *dev);
diff --git a/input.c b/input.c
index ec05548..a3ea9c2 100644
--- a/input.c
+++ b/input.c
@@ -220,7 +220,7 @@ void do_info_mice_print(Monitor *mon, const QObject *data)
     qlist_iter(mice_list, info_mice_iter, mon);
 }
 
-void do_info_mice(Monitor *mon, QObject **ret_data)
+void qmp_query_mice(Monitor *mon, QObject **ret_data)
 {
     QEMUPutMouseEntry *cursor;
     QList *mice_list;
diff --git a/migration.c b/migration.c
index 622a9d2..923d20e 100644
--- a/migration.c
+++ b/migration.c
@@ -216,7 +216,7 @@ static void migrate_put_status(QDict *qdict, const char *name,
     qdict_put_obj(qdict, name, obj);
 }
 
-void do_info_migrate(Monitor *mon, QObject **ret_data)
+void qmp_query_migrate(Monitor *mon, QObject **ret_data)
 {
     QDict *qdict;
     MigrationState *s = current_migration;
diff --git a/migration.h b/migration.h
index d13ed4f..30ee679 100644
--- a/migration.h
+++ b/migration.h
@@ -67,7 +67,7 @@ int do_migrate_set_downtime(Monitor *mon, const QDict *qdict,
 
 void do_info_migrate_print(Monitor *mon, const QObject *data);
 
-void do_info_migrate(Monitor *mon, QObject **ret_data);
+void qmp_query_migrate(Monitor *mon, QObject **ret_data);
 
 int exec_start_incoming_migration(const char *host_port);
 
diff --git a/monitor.c b/monitor.c
index f1aebc1..0bf56e4 100644
--- a/monitor.c
+++ b/monitor.c
@@ -729,7 +729,7 @@ static void do_info_version_print(Monitor *mon, const QObject *data)
                   qdict_get_str(qdict, "package"));
 }
 
-static void do_info_version(Monitor *mon, QObject **ret_data)
+static void qmp_query_version(Monitor *mon, QObject **ret_data)
 {
     const char *version = QEMU_VERSION;
     int major = 0, minor = 0, micro = 0;
@@ -757,7 +757,7 @@ static void do_info_name_print(Monitor *mon, const QObject *data)
     monitor_printf(mon, "%s\n", qdict_get_str(qdict, "name"));
 }
 
-static void do_info_name(Monitor *mon, QObject **ret_data)
+static void qmp_query_name(Monitor *mon, QObject **ret_data)
 {
     *ret_data = qemu_name ? qobject_from_jsonf("{'name': %s }", qemu_name) :
                             qobject_from_jsonf("{}");
@@ -778,7 +778,7 @@ static QObject *get_cmd_dict(const char *name)
     return qobject_from_jsonf("{ 'name': %s }", p);
 }
 
-static void do_info_commands(Monitor *mon, QObject **ret_data)
+static void qmp_query_commands(Monitor *mon, QObject **ret_data)
 {
     QList *cmd_list;
     const mon_cmd_t *cmd;
@@ -803,7 +803,7 @@ static void do_info_uuid_print(Monitor *mon, const QObject *data)
     monitor_printf(mon, "%s\n", qdict_get_str(qobject_to_qdict(data), "UUID"));
 }
 
-static void do_info_uuid(Monitor *mon, QObject **ret_data)
+static void qmp_query_uuid(Monitor *mon, QObject **ret_data)
 {
     char uuid[64];
 
@@ -898,7 +898,7 @@ static void monitor_print_cpus(Monitor *mon, const QObject *data)
     qlist_iter(cpu_list, print_cpu_iter, mon);
 }
 
-static void do_info_cpus(Monitor *mon, QObject **ret_data)
+static void qmp_query_cpus(Monitor *mon, QObject **ret_data)
 {
     CPUState *env;
     QList *cpu_list;
@@ -2006,7 +2006,7 @@ static void do_info_kvm_print(Monitor *mon, const QObject *data)
     }
 }
 
-static void do_info_kvm(Monitor *mon, QObject **ret_data)
+static void qmp_query_kvm(Monitor *mon, QObject **ret_data)
 {
 #ifdef CONFIG_KVM
     *ret_data = qobject_from_jsonf("{ 'enabled': %i, 'present': true }",
@@ -2149,7 +2149,7 @@ static void do_info_status_print(Monitor *mon, const QObject *data)
     monitor_printf(mon, "\n");
 }
 
-static void do_info_status(Monitor *mon, QObject **ret_data)
+static void qmp_query_status(Monitor *mon, QObject **ret_data)
 {
     *ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i }",
                                     vm_running, singlestep);
@@ -2386,7 +2386,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show the version of QEMU",
         .user_print = do_info_version_print,
-        .mhandler.info_new = do_info_version,
+        .mhandler.info_new = qmp_query_version,
     },
     {
         .name       = "network",
@@ -2401,7 +2401,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show the character devices",
         .user_print = qemu_chr_info_print,
-        .mhandler.info_new = qemu_chr_info,
+        .mhandler.info_new = qmp_query_chardev,
     },
     {
         .name       = "block",
@@ -2409,7 +2409,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show the block devices",
         .user_print = bdrv_info_print,
-        .mhandler.info_new = bdrv_info,
+        .mhandler.info_new = qmp_query_block,
     },
     {
         .name       = "blockstats",
@@ -2417,7 +2417,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show block device statistics",
         .user_print = bdrv_stats_print,
-        .mhandler.info_new = bdrv_info_stats,
+        .mhandler.info_new = qmp_query_blockstats,
     },
     {
         .name       = "registers",
@@ -2432,7 +2432,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show infos for each CPU",
         .user_print = monitor_print_cpus,
-        .mhandler.info_new = do_info_cpus,
+        .mhandler.info_new = qmp_query_cpus,
     },
     {
         .name       = "history",
@@ -2461,7 +2461,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show PCI info",
         .user_print = do_pci_info_print,
-        .mhandler.info_new = do_pci_info,
+        .mhandler.info_new = qmp_query_pci,
     },
 #if defined(TARGET_I386) || defined(TARGET_SH4)
     {
@@ -2494,7 +2494,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show KVM information",
         .user_print = do_info_kvm_print,
-        .mhandler.info_new = do_info_kvm,
+        .mhandler.info_new = qmp_query_kvm,
     },
     {
         .name       = "numa",
@@ -2544,7 +2544,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show the current VM status (running|paused)",
         .user_print = do_info_status_print,
-        .mhandler.info_new = do_info_status,
+        .mhandler.info_new = qmp_query_status,
     },
     {
         .name       = "pcmcia",
@@ -2559,7 +2559,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show which guest mouse is receiving events",
         .user_print = do_info_mice_print,
-        .mhandler.info_new = do_info_mice,
+        .mhandler.info_new = qmp_query_mice,
     },
     {
         .name       = "vnc",
@@ -2567,7 +2567,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show the vnc server status",
         .user_print = do_info_vnc_print,
-        .mhandler.info_new = do_info_vnc,
+        .mhandler.info_new = qmp_query_vnc,
     },
     {
         .name       = "name",
@@ -2575,7 +2575,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show the current VM name",
         .user_print = do_info_name_print,
-        .mhandler.info_new = do_info_name,
+        .mhandler.info_new = qmp_query_name,
     },
     {
         .name       = "uuid",
@@ -2583,7 +2583,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show the current VM UUID",
         .user_print = do_info_uuid_print,
-        .mhandler.info_new = do_info_uuid,
+        .mhandler.info_new = qmp_query_uuid,
     },
 #if defined(TARGET_PPC)
     {
@@ -2609,7 +2609,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show migration status",
         .user_print = do_info_migrate_print,
-        .mhandler.info_new = do_info_migrate,
+        .mhandler.info_new = qmp_query_migrate,
     },
     {
         .name       = "balloon",
@@ -2617,7 +2617,7 @@ static const mon_cmd_t info_cmds[] = {
         .params     = "",
         .help       = "show balloon information",
         .user_print = monitor_print_balloon,
-        .mhandler.info_async = do_info_balloon,
+        .mhandler.info_async = qmp_query_balloon,
         .flags      = MONITOR_CMD_ASYNC,
     },
     {
@@ -2674,7 +2674,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show the version of QEMU",
         .user_print = do_info_version_print,
-        .mhandler.info_new = do_info_version,
+        .mhandler.info_new = qmp_query_version,
     },
     {
         .name       = "commands",
@@ -2682,7 +2682,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "list QMP available commands",
         .user_print = monitor_user_noop,
-        .mhandler.info_new = do_info_commands,
+        .mhandler.info_new = qmp_query_commands,
     },
     {
         .name       = "chardev",
@@ -2690,7 +2690,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show the character devices",
         .user_print = qemu_chr_info_print,
-        .mhandler.info_new = qemu_chr_info,
+        .mhandler.info_new = qmp_query_chardev,
     },
     {
         .name       = "block",
@@ -2698,7 +2698,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show the block devices",
         .user_print = bdrv_info_print,
-        .mhandler.info_new = bdrv_info,
+        .mhandler.info_new = qmp_query_block,
     },
     {
         .name       = "blockstats",
@@ -2706,7 +2706,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show block device statistics",
         .user_print = bdrv_stats_print,
-        .mhandler.info_new = bdrv_info_stats,
+        .mhandler.info_new = qmp_query_blockstats,
     },
     {
         .name       = "cpus",
@@ -2714,7 +2714,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show infos for each CPU",
         .user_print = monitor_print_cpus,
-        .mhandler.info_new = do_info_cpus,
+        .mhandler.info_new = qmp_query_cpus,
     },
     {
         .name       = "pci",
@@ -2722,7 +2722,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show PCI info",
         .user_print = do_pci_info_print,
-        .mhandler.info_new = do_pci_info,
+        .mhandler.info_new = qmp_query_pci,
     },
     {
         .name       = "kvm",
@@ -2730,7 +2730,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show KVM information",
         .user_print = do_info_kvm_print,
-        .mhandler.info_new = do_info_kvm,
+        .mhandler.info_new = qmp_query_kvm,
     },
     {
         .name       = "status",
@@ -2738,7 +2738,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show the current VM status (running|paused)",
         .user_print = do_info_status_print,
-        .mhandler.info_new = do_info_status,
+        .mhandler.info_new = qmp_query_status,
     },
     {
         .name       = "mice",
@@ -2746,7 +2746,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show which guest mouse is receiving events",
         .user_print = do_info_mice_print,
-        .mhandler.info_new = do_info_mice,
+        .mhandler.info_new = qmp_query_mice,
     },
     {
         .name       = "vnc",
@@ -2754,7 +2754,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show the vnc server status",
         .user_print = do_info_vnc_print,
-        .mhandler.info_new = do_info_vnc,
+        .mhandler.info_new = qmp_query_vnc,
     },
     {
         .name       = "name",
@@ -2762,7 +2762,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show the current VM name",
         .user_print = do_info_name_print,
-        .mhandler.info_new = do_info_name,
+        .mhandler.info_new = qmp_query_name,
     },
     {
         .name       = "uuid",
@@ -2770,7 +2770,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show the current VM UUID",
         .user_print = do_info_uuid_print,
-        .mhandler.info_new = do_info_uuid,
+        .mhandler.info_new = qmp_query_uuid,
     },
     {
         .name       = "migrate",
@@ -2778,7 +2778,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show migration status",
         .user_print = do_info_migrate_print,
-        .mhandler.info_new = do_info_migrate,
+        .mhandler.info_new = qmp_query_migrate,
     },
     {
         .name       = "balloon",
@@ -2786,7 +2786,7 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .params     = "",
         .help       = "show balloon information",
         .user_print = monitor_print_balloon,
-        .mhandler.info_async = do_info_balloon,
+        .mhandler.info_async = qmp_query_balloon,
         .flags      = MONITOR_CMD_ASYNC,
     },
     { /* NULL */ },
@@ -4615,7 +4615,7 @@ static QObject *get_qmp_greeting(void)
 {
     QObject *ver;
 
-    do_info_version(NULL, &ver);
+    qmp_query_version(NULL, &ver);
     return qobject_from_jsonf("{'QMP':{'version': %p,'capabilities': []}}",ver);
 }
 
diff --git a/qemu-char.c b/qemu-char.c
index edc9ad6..e8788e6 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2589,7 +2589,7 @@ void qemu_chr_info_print(Monitor *mon, const QObject *ret_data)
     qlist_iter(qobject_to_qlist(ret_data), qemu_chr_qlist_iter, mon);
 }
 
-void qemu_chr_info(Monitor *mon, QObject **ret_data)
+void qmp_query_chardev(Monitor *mon, QObject **ret_data)
 {
     QList *chr_list;
     CharDriverState *chr;
diff --git a/qemu-char.h b/qemu-char.h
index e6ee6c4..a456bb9 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -93,7 +93,7 @@ void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len);
 int qemu_chr_get_msgfd(CharDriverState *s);
 void qemu_chr_accept_input(CharDriverState *s);
 void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
-void qemu_chr_info(Monitor *mon, QObject **ret_data);
+void qmp_query_chardev(Monitor *mon, QObject **ret_data);
 CharDriverState *qemu_chr_find(const char *name);
 
 /* add an eventfd to the qemu devices that are polled */
diff --git a/ui/vnc.c b/ui/vnc.c
index 864342e..4674f5e 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -327,7 +327,7 @@ void do_info_vnc_print(Monitor *mon, const QObject *data)
     }
 }
 
-void do_info_vnc(Monitor *mon, QObject **ret_data)
+void qmp_query_vnc(Monitor *mon, QObject **ret_data)
 {
     if (vnc_display == NULL || vnc_display->display == NULL) {
         *ret_data = qobject_from_jsonf("{ 'enabled': false }");
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 02/25] QMP: Drop user_print usage from the qmp_query_cmds[] table
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 01/25] QMP: Rename query handlers Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 03/25] Monitor: Drop balloon handlers comments Luiz Capitulino
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

QMP doesn't use this field, it's only useful in the human monitor.

NOTE: Other unused fields are going to be dropped by future
      commits.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   15 ---------------
 1 files changed, 0 insertions(+), 15 deletions(-)

diff --git a/monitor.c b/monitor.c
index 0bf56e4..481eab2 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2673,7 +2673,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the version of QEMU",
-        .user_print = do_info_version_print,
         .mhandler.info_new = qmp_query_version,
     },
     {
@@ -2681,7 +2680,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "list QMP available commands",
-        .user_print = monitor_user_noop,
         .mhandler.info_new = qmp_query_commands,
     },
     {
@@ -2689,7 +2687,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the character devices",
-        .user_print = qemu_chr_info_print,
         .mhandler.info_new = qmp_query_chardev,
     },
     {
@@ -2697,7 +2694,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the block devices",
-        .user_print = bdrv_info_print,
         .mhandler.info_new = qmp_query_block,
     },
     {
@@ -2705,7 +2701,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show block device statistics",
-        .user_print = bdrv_stats_print,
         .mhandler.info_new = qmp_query_blockstats,
     },
     {
@@ -2713,7 +2708,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show infos for each CPU",
-        .user_print = monitor_print_cpus,
         .mhandler.info_new = qmp_query_cpus,
     },
     {
@@ -2721,7 +2715,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show PCI info",
-        .user_print = do_pci_info_print,
         .mhandler.info_new = qmp_query_pci,
     },
     {
@@ -2729,7 +2722,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show KVM information",
-        .user_print = do_info_kvm_print,
         .mhandler.info_new = qmp_query_kvm,
     },
     {
@@ -2737,7 +2729,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the current VM status (running|paused)",
-        .user_print = do_info_status_print,
         .mhandler.info_new = qmp_query_status,
     },
     {
@@ -2745,7 +2736,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show which guest mouse is receiving events",
-        .user_print = do_info_mice_print,
         .mhandler.info_new = qmp_query_mice,
     },
     {
@@ -2753,7 +2743,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the vnc server status",
-        .user_print = do_info_vnc_print,
         .mhandler.info_new = qmp_query_vnc,
     },
     {
@@ -2761,7 +2750,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the current VM name",
-        .user_print = do_info_name_print,
         .mhandler.info_new = qmp_query_name,
     },
     {
@@ -2769,7 +2757,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the current VM UUID",
-        .user_print = do_info_uuid_print,
         .mhandler.info_new = qmp_query_uuid,
     },
     {
@@ -2777,7 +2764,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show migration status",
-        .user_print = do_info_migrate_print,
         .mhandler.info_new = qmp_query_migrate,
     },
     {
@@ -2785,7 +2771,6 @@ static const mon_cmd_t qmp_query_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show balloon information",
-        .user_print = monitor_print_balloon,
         .mhandler.info_async = qmp_query_balloon,
         .flags      = MONITOR_CMD_ASYNC,
     },
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 03/25] Monitor: Drop balloon handlers comments
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 01/25] QMP: Rename query handlers Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 02/25] QMP: Drop user_print usage from the qmp_query_cmds[] table Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 04/25] Monitor: Move qmp_query_version() up in monitor.c Luiz Capitulino
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

Commit 637503d122eb7656d91a8489e254d9e880be7504 dropped (duplicated)
documentation from code, but it missed the balloon handlers.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 balloon.c |   24 ------------------------
 1 files changed, 0 insertions(+), 24 deletions(-)

diff --git a/balloon.c b/balloon.c
index dbc6f44..b3edc7a 100644
--- a/balloon.c
+++ b/balloon.c
@@ -85,27 +85,6 @@ void monitor_print_balloon(Monitor *mon, const QObject *data)
     monitor_printf(mon, "\n");
 }
 
-/**
- * qmp_query_balloon(): Balloon information
- *
- * Make an asynchronous request for balloon info.  When the request completes
- * a QDict will be returned according to the following specification:
- *
- * - "actual": current balloon value in bytes
- * The following fields may or may not be present:
- * - "mem_swapped_in": Amount of memory swapped in (bytes)
- * - "mem_swapped_out": Amount of memory swapped out (bytes)
- * - "major_page_faults": Number of major faults
- * - "minor_page_faults": Number of minor faults
- * - "free_mem": Total amount of free and unused memory (bytes)
- * - "total_mem": Total amount of available memory (bytes)
- *
- * Example:
- *
- * { "actual": 1073741824, "mem_swapped_in": 0, "mem_swapped_out": 0,
- *   "major_page_faults": 142, "minor_page_faults": 239245,
- *   "free_mem": 1014185984, "total_mem": 1044668416 }
- */
 int qmp_query_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
 {
     int ret;
@@ -124,9 +103,6 @@ int qmp_query_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
     return 0;
 }
 
-/**
- * do_balloon(): Request VM to change its memory allocation
- */
 int do_balloon(Monitor *mon, const QDict *params,
 	       MonitorCompletion cb, void *opaque)
 {
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 04/25] Monitor: Move qmp_query_version() up in monitor.c
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (2 preceding siblings ...)
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 03/25] Monitor: Drop balloon handlers comments Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 05/25] Monitor: Convert do_info_version_print() into do_info_version() Luiz Capitulino
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

So that next commit can change do_info_version_print() to call it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/monitor.c b/monitor.c
index 481eab2..6252b3f 100644
--- a/monitor.c
+++ b/monitor.c
@@ -714,21 +714,6 @@ help:
     help_cmd(mon, "info");
 }
 
-static void do_info_version_print(Monitor *mon, const QObject *data)
-{
-    QDict *qdict;
-    QDict *qemu;
-
-    qdict = qobject_to_qdict(data);
-    qemu = qdict_get_qdict(qdict, "qemu");
-
-    monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n",
-                  qdict_get_int(qemu, "major"),
-                  qdict_get_int(qemu, "minor"),
-                  qdict_get_int(qemu, "micro"),
-                  qdict_get_str(qdict, "package"));
-}
-
 static void qmp_query_version(Monitor *mon, QObject **ret_data)
 {
     const char *version = QEMU_VERSION;
@@ -745,6 +730,21 @@ static void qmp_query_version(Monitor *mon, QObject **ret_data)
         'micro': %d }, 'package': %s }", major, minor, micro, QEMU_PKGVERSION);
 }
 
+static void do_info_version_print(Monitor *mon, const QObject *data)
+{
+    QDict *qdict;
+    QDict *qemu;
+
+    qdict = qobject_to_qdict(data);
+    qemu = qdict_get_qdict(qdict, "qemu");
+
+    monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n",
+                  qdict_get_int(qemu, "major"),
+                  qdict_get_int(qemu, "minor"),
+                  qdict_get_int(qemu, "micro"),
+                  qdict_get_str(qdict, "package"));
+}
+
 static void do_info_name_print(Monitor *mon, const QObject *data)
 {
     QDict *qdict;
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 05/25] Monitor: Convert do_info_version_print() into do_info_version()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (3 preceding siblings ...)
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 04/25] Monitor: Move qmp_query_version() up in monitor.c Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 06/25] Monitor: Convert qemu_chr_info_print() into qemu_chr_info() Luiz Capitulino
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_version() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/monitor.c b/monitor.c
index 6252b3f..56575a6 100644
--- a/monitor.c
+++ b/monitor.c
@@ -730,11 +730,12 @@ static void qmp_query_version(Monitor *mon, QObject **ret_data)
         'micro': %d }, 'package': %s }", major, minor, micro, QEMU_PKGVERSION);
 }
 
-static void do_info_version_print(Monitor *mon, const QObject *data)
+static void do_info_version(Monitor *mon)
 {
-    QDict *qdict;
-    QDict *qemu;
+    QDict *qdict, *qemu;
+    QObject *data;
 
+    qmp_query_version(NULL, &data);
     qdict = qobject_to_qdict(data);
     qemu = qdict_get_qdict(qdict, "qemu");
 
@@ -743,6 +744,8 @@ static void do_info_version_print(Monitor *mon, const QObject *data)
                   qdict_get_int(qemu, "minor"),
                   qdict_get_int(qemu, "micro"),
                   qdict_get_str(qdict, "package"));
+
+    qobject_decref(data);
 }
 
 static void do_info_name_print(Monitor *mon, const QObject *data)
@@ -2385,8 +2388,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the version of QEMU",
-        .user_print = do_info_version_print,
-        .mhandler.info_new = qmp_query_version,
+        .mhandler.info = do_info_version,
     },
     {
         .name       = "network",
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 06/25] Monitor: Convert qemu_chr_info_print() into qemu_chr_info()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (4 preceding siblings ...)
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 05/25] Monitor: Convert do_info_version_print() into do_info_version() Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 07/25] Monitor: Convert bdrv_info_print() into bdrv_info() Luiz Capitulino
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_chardev() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c   |    3 +--
 qemu-char.c |    8 ++++++--
 qemu-char.h |    2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/monitor.c b/monitor.c
index 56575a6..d48c137 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2402,8 +2402,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the character devices",
-        .user_print = qemu_chr_info_print,
-        .mhandler.info_new = qmp_query_chardev,
+        .mhandler.info = qemu_chr_info,
     },
     {
         .name       = "block",
diff --git a/qemu-char.c b/qemu-char.c
index e8788e6..063943f 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2584,9 +2584,13 @@ static void qemu_chr_qlist_iter(QObject *obj, void *opaque)
                                          qdict_get_str(chr_dict, "filename"));
 }
 
-void qemu_chr_info_print(Monitor *mon, const QObject *ret_data)
+void qemu_chr_info(Monitor *mon)
 {
-    qlist_iter(qobject_to_qlist(ret_data), qemu_chr_qlist_iter, mon);
+    QObject *data;
+
+    qmp_query_chardev(NULL, &data);
+    qlist_iter(qobject_to_qlist(data), qemu_chr_qlist_iter, mon);
+    qobject_decref(data);
 }
 
 void qmp_query_chardev(Monitor *mon, QObject **ret_data)
diff --git a/qemu-char.h b/qemu-char.h
index a456bb9..09d3de3 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -92,7 +92,7 @@ int qemu_chr_can_read(CharDriverState *s);
 void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len);
 int qemu_chr_get_msgfd(CharDriverState *s);
 void qemu_chr_accept_input(CharDriverState *s);
-void qemu_chr_info_print(Monitor *mon, const QObject *ret_data);
+void qemu_chr_info(Monitor *mon);
 void qmp_query_chardev(Monitor *mon, QObject **ret_data);
 CharDriverState *qemu_chr_find(const char *name);
 
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 07/25] Monitor: Convert bdrv_info_print() into bdrv_info()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (5 preceding siblings ...)
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 06/25] Monitor: Convert qemu_chr_info_print() into qemu_chr_info() Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 08/25] Monitor: Convert bdrv_stats_print() into bdrv_stats() Luiz Capitulino
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_block() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 block.c   |    6 +++++-
 block.h   |    2 +-
 monitor.c |    3 +--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index a5d865b..2eadd70 100644
--- a/block.c
+++ b/block.c
@@ -1591,9 +1591,13 @@ static void bdrv_print_dict(QObject *obj, void *opaque)
     monitor_printf(mon, "\n");
 }
 
-void bdrv_info_print(Monitor *mon, const QObject *data)
+void bdrv_info(Monitor *mon)
 {
+    QObject *data;
+
+    qmp_query_block(NULL, &data);
     qlist_iter(qobject_to_qlist(data), bdrv_print_dict, mon);
+    qobject_decref(data);
 }
 
 void qmp_query_block(Monitor *mon, QObject **ret_data)
diff --git a/block.h b/block.h
index a979d5b..e71b6ad 100644
--- a/block.h
+++ b/block.h
@@ -52,8 +52,8 @@ typedef enum {
 
 void bdrv_mon_event(const BlockDriverState *bdrv,
                     BlockMonEventAction action, int is_read);
-void bdrv_info_print(Monitor *mon, const QObject *data);
 void qmp_query_block(Monitor *mon, QObject **ret_data);
+void bdrv_info(Monitor *mon);
 void bdrv_stats_print(Monitor *mon, const QObject *data);
 void qmp_query_blockstats(Monitor *mon, QObject **ret_data);
 
diff --git a/monitor.c b/monitor.c
index d48c137..2bdaf03 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2409,8 +2409,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the block devices",
-        .user_print = bdrv_info_print,
-        .mhandler.info_new = qmp_query_block,
+        .mhandler.info = bdrv_info,
     },
     {
         .name       = "blockstats",
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 08/25] Monitor: Convert bdrv_stats_print() into bdrv_stats()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (6 preceding siblings ...)
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 07/25] Monitor: Convert bdrv_info_print() into bdrv_info() Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 09/25] Monitor: Move qmp_query_cpus() up in monitor.c Luiz Capitulino
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_blockstats() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 block.c   |    6 +++++-
 block.h   |    2 +-
 monitor.c |    3 +--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/block.c b/block.c
index 2eadd70..5b89790 100644
--- a/block.c
+++ b/block.c
@@ -1671,9 +1671,13 @@ static void bdrv_stats_iter(QObject *data, void *opaque)
                         qdict_get_int(qdict, "wr_operations"));
 }
 
-void bdrv_stats_print(Monitor *mon, const QObject *data)
+void bdrv_stats(Monitor *mon)
 {
+    QObject *data;
+
+    qmp_query_blockstats(NULL, &data);
     qlist_iter(qobject_to_qlist(data), bdrv_stats_iter, mon);
+    qobject_decref(data);
 }
 
 static QObject* bdrv_info_stats_bs(BlockDriverState *bs)
diff --git a/block.h b/block.h
index e71b6ad..ff79f02 100644
--- a/block.h
+++ b/block.h
@@ -54,7 +54,7 @@ void bdrv_mon_event(const BlockDriverState *bdrv,
                     BlockMonEventAction action, int is_read);
 void qmp_query_block(Monitor *mon, QObject **ret_data);
 void bdrv_info(Monitor *mon);
-void bdrv_stats_print(Monitor *mon, const QObject *data);
+void bdrv_stats(Monitor *mon);
 void qmp_query_blockstats(Monitor *mon, QObject **ret_data);
 
 void bdrv_init(void);
diff --git a/monitor.c b/monitor.c
index 2bdaf03..3091a1a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2416,8 +2416,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show block device statistics",
-        .user_print = bdrv_stats_print,
-        .mhandler.info_new = qmp_query_blockstats,
+        .mhandler.info = bdrv_stats,
     },
     {
         .name       = "registers",
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 09/25] Monitor: Move qmp_query_cpus() up in monitor.c
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (7 preceding siblings ...)
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 08/25] Monitor: Convert bdrv_stats_print() into bdrv_stats() Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 10/25] Monitor: Convert monitor_print_cpus() into do_info_cpus() Luiz Capitulino
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

So that next commit can change monitor_print_cpus() to call it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   78 ++++++++++++++++++++++++++++++------------------------------
 1 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/monitor.c b/monitor.c
index 3091a1a..f067d07 100644
--- a/monitor.c
+++ b/monitor.c
@@ -854,6 +854,45 @@ static void do_info_registers(Monitor *mon)
 #endif
 }
 
+static void qmp_query_cpus(Monitor *mon, QObject **ret_data)
+{
+    CPUState *env;
+    QList *cpu_list;
+
+    cpu_list = qlist_new();
+
+    /* just to set the default cpu if not already done */
+    mon_get_cpu();
+
+    for(env = first_cpu; env != NULL; env = env->next_cpu) {
+        QDict *cpu;
+        QObject *obj;
+
+        cpu_synchronize_state(env);
+
+        obj = qobject_from_jsonf("{ 'CPU': %d, 'current': %i, 'halted': %i }",
+                                 env->cpu_index, env == mon->mon_cpu,
+                                 env->halted);
+
+        cpu = qobject_to_qdict(obj);
+
+#if defined(TARGET_I386)
+        qdict_put(cpu, "pc", qint_from_int(env->eip + env->segs[R_CS].base));
+#elif defined(TARGET_PPC)
+        qdict_put(cpu, "nip", qint_from_int(env->nip));
+#elif defined(TARGET_SPARC)
+        qdict_put(cpu, "pc", qint_from_int(env->pc));
+        qdict_put(cpu, "npc", qint_from_int(env->npc));
+#elif defined(TARGET_MIPS)
+        qdict_put(cpu, "PC", qint_from_int(env->active_tc.PC));
+#endif
+
+        qlist_append(cpu_list, cpu);
+    }
+
+    *ret_data = QOBJECT(cpu_list);
+}
+
 static void print_cpu_iter(QObject *obj, void *opaque)
 {
     QDict *cpu;
@@ -901,45 +940,6 @@ static void monitor_print_cpus(Monitor *mon, const QObject *data)
     qlist_iter(cpu_list, print_cpu_iter, mon);
 }
 
-static void qmp_query_cpus(Monitor *mon, QObject **ret_data)
-{
-    CPUState *env;
-    QList *cpu_list;
-
-    cpu_list = qlist_new();
-
-    /* just to set the default cpu if not already done */
-    mon_get_cpu();
-
-    for(env = first_cpu; env != NULL; env = env->next_cpu) {
-        QDict *cpu;
-        QObject *obj;
-
-        cpu_synchronize_state(env);
-
-        obj = qobject_from_jsonf("{ 'CPU': %d, 'current': %i, 'halted': %i }",
-                                 env->cpu_index, env == mon->mon_cpu,
-                                 env->halted);
-
-        cpu = qobject_to_qdict(obj);
-
-#if defined(TARGET_I386)
-        qdict_put(cpu, "pc", qint_from_int(env->eip + env->segs[R_CS].base));
-#elif defined(TARGET_PPC)
-        qdict_put(cpu, "nip", qint_from_int(env->nip));
-#elif defined(TARGET_SPARC)
-        qdict_put(cpu, "pc", qint_from_int(env->pc));
-        qdict_put(cpu, "npc", qint_from_int(env->npc));
-#elif defined(TARGET_MIPS)
-        qdict_put(cpu, "PC", qint_from_int(env->active_tc.PC));
-#endif
-
-        qlist_append(cpu_list, cpu);
-    }
-
-    *ret_data = QOBJECT(cpu_list);
-}
-
 static int do_cpu_set(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     int index = qdict_get_int(qdict, "index");
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 10/25] Monitor: Convert monitor_print_cpus() into do_info_cpus()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (8 preceding siblings ...)
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 09/25] Monitor: Move qmp_query_cpus() up in monitor.c Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 11/25] Monitor: Convert do_pci_info_print() into do_pci_info() Luiz Capitulino
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_cpus() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/monitor.c b/monitor.c
index f067d07..2164853 100644
--- a/monitor.c
+++ b/monitor.c
@@ -931,13 +931,13 @@ static void print_cpu_iter(QObject *obj, void *opaque)
     monitor_printf(mon, "\n");
 }
 
-static void monitor_print_cpus(Monitor *mon, const QObject *data)
+static void do_info_cpus(Monitor *mon)
 {
-    QList *cpu_list;
+    QObject *data;
 
-    assert(qobject_type(data) == QTYPE_QLIST);
-    cpu_list = qobject_to_qlist(data);
-    qlist_iter(cpu_list, print_cpu_iter, mon);
+    qmp_query_cpus(mon, &data);
+    qlist_iter(qobject_to_qlist(data), print_cpu_iter, mon);
+    qobject_decref(data);
 }
 
 static int do_cpu_set(Monitor *mon, const QDict *qdict, QObject **ret_data)
@@ -2430,8 +2430,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show infos for each CPU",
-        .user_print = monitor_print_cpus,
-        .mhandler.info_new = qmp_query_cpus,
+        .mhandler.info = do_info_cpus,
     },
     {
         .name       = "history",
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 11/25] Monitor: Convert do_pci_info_print() into do_pci_info()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (9 preceding siblings ...)
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 10/25] Monitor: Convert monitor_print_cpus() into do_info_cpus() Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 12/25] Monitor: Move qmp_query_kvm() up in monitor.c Luiz Capitulino
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_pci() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/pci.c  |    7 ++++++-
 hw/pci.h  |    2 +-
 monitor.c |    3 +--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 08c36ec..ba204bf 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1276,9 +1276,12 @@ static void pci_device_print(Monitor *mon, QDict *device)
     }
 }
 
-void do_pci_info_print(Monitor *mon, const QObject *data)
+void do_pci_info(Monitor *mon)
 {
     QListEntry *bus, *dev;
+    QObject *data;
+
+    qmp_query_pci(NULL, &data);
 
     QLIST_FOREACH_ENTRY(qobject_to_qlist(data), bus) {
         QDict *qdict = qobject_to_qdict(qlist_entry_obj(bus));
@@ -1286,6 +1289,8 @@ void do_pci_info_print(Monitor *mon, const QObject *data)
             pci_device_print(mon, qobject_to_qdict(qlist_entry_obj(dev)));
         }
     }
+
+    qobject_decref(data);
 }
 
 static QObject *pci_get_dev_class(const PCIDevice *dev)
diff --git a/hw/pci.h b/hw/pci.h
index b87c6c0..22509dc 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -253,7 +253,7 @@ int pci_parse_devaddr(const char *addr, int *domp, int *busp,
 int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
                      unsigned *slotp);
 
-void do_pci_info_print(Monitor *mon, const QObject *data);
+void do_pci_info(Monitor *mon);
 void qmp_query_pci(Monitor *mon, QObject **ret_data);
 void pci_bridge_update_mappings(PCIBus *b);
 
diff --git a/monitor.c b/monitor.c
index 2164853..1fbe78b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2458,8 +2458,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show PCI info",
-        .user_print = do_pci_info_print,
-        .mhandler.info_new = qmp_query_pci,
+        .mhandler.info = do_pci_info,
     },
 #if defined(TARGET_I386) || defined(TARGET_SH4)
     {
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 12/25] Monitor: Move qmp_query_kvm() up in monitor.c
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (10 preceding siblings ...)
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 11/25] Monitor: Convert do_pci_info_print() into do_pci_info() Luiz Capitulino
@ 2010-12-06 18:23 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 13/25] Monitor: Convert do_info_kvm_print() into do_info_kvm() Luiz Capitulino
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

So that next commit can change do_info_kvm_print() to call it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/monitor.c b/monitor.c
index 1fbe78b..e8f0562 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1994,6 +1994,16 @@ static void tlb_info(Monitor *mon)
 
 #endif
 
+static void qmp_query_kvm(Monitor *mon, QObject **ret_data)
+{
+#ifdef CONFIG_KVM
+    *ret_data = qobject_from_jsonf("{ 'enabled': %i, 'present': true }",
+                                   kvm_enabled());
+#else
+    *ret_data = qobject_from_jsonf("{ 'enabled': false, 'present': false }");
+#endif
+}
+
 static void do_info_kvm_print(Monitor *mon, const QObject *data)
 {
     QDict *qdict;
@@ -2009,16 +2019,6 @@ static void do_info_kvm_print(Monitor *mon, const QObject *data)
     }
 }
 
-static void qmp_query_kvm(Monitor *mon, QObject **ret_data)
-{
-#ifdef CONFIG_KVM
-    *ret_data = qobject_from_jsonf("{ 'enabled': %i, 'present': true }",
-                                   kvm_enabled());
-#else
-    *ret_data = qobject_from_jsonf("{ 'enabled': false, 'present': false }");
-#endif
-}
-
 static void do_info_numa(Monitor *mon)
 {
     int i;
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 13/25] Monitor: Convert do_info_kvm_print() into do_info_kvm()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (11 preceding siblings ...)
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 12/25] Monitor: Move qmp_query_kvm() up in monitor.c Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 14/25] Monitor: Move qmp_query_status() up in monitor.c Luiz Capitulino
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_kvm() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index e8f0562..4286375 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2004,10 +2004,12 @@ static void qmp_query_kvm(Monitor *mon, QObject **ret_data)
 #endif
 }
 
-static void do_info_kvm_print(Monitor *mon, const QObject *data)
+static void do_info_kvm(Monitor *mon)
 {
+    QObject *data;
     QDict *qdict;
 
+    qmp_query_kvm(NULL, &data);
     qdict = qobject_to_qdict(data);
 
     monitor_printf(mon, "kvm support: ");
@@ -2017,6 +2019,8 @@ static void do_info_kvm_print(Monitor *mon, const QObject *data)
     } else {
         monitor_printf(mon, "not compiled\n");
     }
+
+    qobject_decref(data);
 }
 
 static void do_info_numa(Monitor *mon)
@@ -2490,8 +2494,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show KVM information",
-        .user_print = do_info_kvm_print,
-        .mhandler.info_new = qmp_query_kvm,
+        .mhandler.info = do_info_kvm,
     },
     {
         .name       = "numa",
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 14/25] Monitor: Move qmp_query_status() up in monitor.c
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (12 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 13/25] Monitor: Convert do_info_kvm_print() into do_info_kvm() Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 15/25] Monitor: Convert do_info_status_print() into do_info_status() Luiz Capitulino
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

So that next commit can change do_info_status_print() to use it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/monitor.c b/monitor.c
index 4286375..731cb35 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2137,6 +2137,12 @@ static void do_inject_nmi(Monitor *mon, const QDict *qdict)
 }
 #endif
 
+static void qmp_query_status(Monitor *mon, QObject **ret_data)
+{
+    *ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i }",
+                                    vm_running, singlestep);
+}
+
 static void do_info_status_print(Monitor *mon, const QObject *data)
 {
     QDict *qdict;
@@ -2156,12 +2162,6 @@ static void do_info_status_print(Monitor *mon, const QObject *data)
     monitor_printf(mon, "\n");
 }
 
-static void qmp_query_status(Monitor *mon, QObject **ret_data)
-{
-    *ret_data = qobject_from_jsonf("{ 'running': %i, 'singlestep': %i }",
-                                    vm_running, singlestep);
-}
-
 static qemu_acl *find_acl(Monitor *mon, const char *name)
 {
     qemu_acl *acl = qemu_acl_find(name);
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 15/25] Monitor: Convert do_info_status_print() into do_info_status()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (13 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 14/25] Monitor: Move qmp_query_status() up in monitor.c Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 16/25] Monitor: Convert do_info_mice_print() into do_info_mice() Luiz Capitulino
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_status() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 731cb35..445c73a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2143,10 +2143,12 @@ static void qmp_query_status(Monitor *mon, QObject **ret_data)
                                     vm_running, singlestep);
 }
 
-static void do_info_status_print(Monitor *mon, const QObject *data)
+static void do_info_status(Monitor *mon)
 {
     QDict *qdict;
+    QObject *data;
 
+    qmp_query_status(NULL, &data);
     qdict = qobject_to_qdict(data);
 
     monitor_printf(mon, "VM status: ");
@@ -2160,6 +2162,7 @@ static void do_info_status_print(Monitor *mon, const QObject *data)
     }
 
     monitor_printf(mon, "\n");
+    qobject_decref(data);
 }
 
 static qemu_acl *find_acl(Monitor *mon, const char *name)
@@ -2543,8 +2546,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the current VM status (running|paused)",
-        .user_print = do_info_status_print,
-        .mhandler.info_new = qmp_query_status,
+        .mhandler.info = do_info_status,
     },
     {
         .name       = "pcmcia",
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 16/25] Monitor: Convert do_info_mice_print() into do_info_mice()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (14 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 15/25] Monitor: Convert do_info_status_print() into do_info_status() Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 17/25] Monitor: Convert do_info_vnc_print() into do_info_vnc() Luiz Capitulino
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_mice() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 console.h |    2 +-
 input.c   |    9 +++++++--
 monitor.c |    3 +--
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/console.h b/console.h
index f613e4e..232714b 100644
--- a/console.h
+++ b/console.h
@@ -72,7 +72,7 @@ struct MouseTransformInfo {
     int a[7];
 };
 
-void do_info_mice_print(Monitor *mon, const QObject *data);
+void do_info_mice(Monitor *mon);
 void qmp_query_mice(Monitor *mon, QObject **ret_data);
 void do_mouse_set(Monitor *mon, const QDict *qdict);
 
diff --git a/input.c b/input.c
index a3ea9c2..cbe0074 100644
--- a/input.c
+++ b/input.c
@@ -207,17 +207,22 @@ static void info_mice_iter(QObject *data, void *opaque)
                    qdict_get_bool(mouse, "absolute") ? " (absolute)" : "");
 }
 
-void do_info_mice_print(Monitor *mon, const QObject *data)
+void do_info_mice(Monitor *mon)
 {
     QList *mice_list;
+    QObject *data;
 
+    qmp_query_mice(NULL, &data);
     mice_list = qobject_to_qlist(data);
     if (qlist_empty(mice_list)) {
         monitor_printf(mon, "No mouse devices connected\n");
-        return;
+        goto out;
     }
 
     qlist_iter(mice_list, info_mice_iter, mon);
+
+out:
+    qobject_decref(data);
 }
 
 void qmp_query_mice(Monitor *mon, QObject **ret_data)
diff --git a/monitor.c b/monitor.c
index 445c73a..3b86076 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2560,8 +2560,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show which guest mouse is receiving events",
-        .user_print = do_info_mice_print,
-        .mhandler.info_new = qmp_query_mice,
+        .mhandler.info = do_info_mice,
     },
     {
         .name       = "vnc",
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 17/25] Monitor: Convert do_info_vnc_print() into do_info_vnc()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (15 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 16/25] Monitor: Convert do_info_mice_print() into do_info_mice() Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 18/25] Monitor: Move qmp_query_name() up in monitor.c Luiz Capitulino
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_vnc() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 console.h |    2 +-
 monitor.c |    3 +--
 ui/vnc.c  |    9 +++++++--
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/console.h b/console.h
index 232714b..c72f612 100644
--- a/console.h
+++ b/console.h
@@ -369,7 +369,7 @@ void vnc_display_init(DisplayState *ds);
 void vnc_display_close(DisplayState *ds);
 int vnc_display_open(DisplayState *ds, const char *display);
 int vnc_display_password(DisplayState *ds, const char *password);
-void do_info_vnc_print(Monitor *mon, const QObject *data);
+void do_info_vnc(Monitor *mon);
 void qmp_query_vnc(Monitor *mon, QObject **ret_data);
 char *vnc_display_local_addr(DisplayState *ds);
 
diff --git a/monitor.c b/monitor.c
index 3b86076..59b3866 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2567,8 +2567,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the vnc server status",
-        .user_print = do_info_vnc_print,
-        .mhandler.info_new = qmp_query_vnc,
+        .mhandler.info = do_info_vnc,
     },
     {
         .name       = "name",
diff --git a/ui/vnc.c b/ui/vnc.c
index 4674f5e..51f6db4 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -302,15 +302,17 @@ static void info_vnc_iter(QObject *obj, void *opaque)
 #endif
 }
 
-void do_info_vnc_print(Monitor *mon, const QObject *data)
+void do_info_vnc(Monitor *mon)
 {
     QDict *server;
     QList *clients;
+    QObject *data;
 
+    qmp_query_vnc(NULL, &data);
     server = qobject_to_qdict(data);
     if (qdict_get_bool(server, "enabled") == 0) {
         monitor_printf(mon, "Server: disabled\n");
-        return;
+        goto out;
     }
 
     monitor_printf(mon, "Server:\n");
@@ -325,6 +327,9 @@ void do_info_vnc_print(Monitor *mon, const QObject *data)
     } else {
         qlist_iter(clients, info_vnc_iter, mon);
     }
+
+out:
+    qobject_decref(data);
 }
 
 void qmp_query_vnc(Monitor *mon, QObject **ret_data)
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 18/25] Monitor: Move qmp_query_name() up in monitor.c
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (16 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 17/25] Monitor: Convert do_info_vnc_print() into do_info_vnc() Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 19/25] Monitor: Convert do_info_name_print() into do_info_name() Luiz Capitulino
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

So that next commit can change do_info_name_print() to call it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/monitor.c b/monitor.c
index 59b3866..89325d8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -748,6 +748,12 @@ static void do_info_version(Monitor *mon)
     qobject_decref(data);
 }
 
+static void qmp_query_name(Monitor *mon, QObject **ret_data)
+{
+    *ret_data = qemu_name ? qobject_from_jsonf("{'name': %s }", qemu_name) :
+                            qobject_from_jsonf("{}");
+}
+
 static void do_info_name_print(Monitor *mon, const QObject *data)
 {
     QDict *qdict;
@@ -760,12 +766,6 @@ static void do_info_name_print(Monitor *mon, const QObject *data)
     monitor_printf(mon, "%s\n", qdict_get_str(qdict, "name"));
 }
 
-static void qmp_query_name(Monitor *mon, QObject **ret_data)
-{
-    *ret_data = qemu_name ? qobject_from_jsonf("{'name': %s }", qemu_name) :
-                            qobject_from_jsonf("{}");
-}
-
 static QObject *get_cmd_dict(const char *name)
 {
     const char *p;
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 19/25] Monitor: Convert do_info_name_print() into do_info_name()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (17 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 18/25] Monitor: Move qmp_query_name() up in monitor.c Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 20/25] Monitor: Move qmp_query_uuid() up in monitor.c Luiz Capitulino
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_name() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/monitor.c b/monitor.c
index 89325d8..2d1f183 100644
--- a/monitor.c
+++ b/monitor.c
@@ -754,16 +754,21 @@ static void qmp_query_name(Monitor *mon, QObject **ret_data)
                             qobject_from_jsonf("{}");
 }
 
-static void do_info_name_print(Monitor *mon, const QObject *data)
+static void do_info_name(Monitor *mon)
 {
     QDict *qdict;
+    QObject *data;
 
+    qmp_query_name(NULL, &data);
     qdict = qobject_to_qdict(data);
     if (qdict_size(qdict) == 0) {
-        return;
+        goto out;
     }
 
     monitor_printf(mon, "%s\n", qdict_get_str(qdict, "name"));
+
+out:
+    qobject_decref(data);
 }
 
 static QObject *get_cmd_dict(const char *name)
@@ -2574,8 +2579,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the current VM name",
-        .user_print = do_info_name_print,
-        .mhandler.info_new = qmp_query_name,
+        .mhandler.info = do_info_name,
     },
     {
         .name       = "uuid",
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 20/25] Monitor: Move qmp_query_uuid() up in monitor.c
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (18 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 19/25] Monitor: Convert do_info_name_print() into do_info_name() Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 21/25] Monitor: Convert do_info_uuid_print() into do_info_uuid() Luiz Capitulino
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

So that next commit can change do_info_uuid_print() to call it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/monitor.c b/monitor.c
index 2d1f183..e9b07f3 100644
--- a/monitor.c
+++ b/monitor.c
@@ -806,11 +806,6 @@ static void qmp_query_commands(Monitor *mon, QObject **ret_data)
     *ret_data = QOBJECT(cmd_list);
 }
 
-static void do_info_uuid_print(Monitor *mon, const QObject *data)
-{
-    monitor_printf(mon, "%s\n", qdict_get_str(qobject_to_qdict(data), "UUID"));
-}
-
 static void qmp_query_uuid(Monitor *mon, QObject **ret_data)
 {
     char uuid[64];
@@ -823,6 +818,11 @@ static void qmp_query_uuid(Monitor *mon, QObject **ret_data)
     *ret_data = qobject_from_jsonf("{ 'UUID': %s }", uuid);
 }
 
+static void do_info_uuid_print(Monitor *mon, const QObject *data)
+{
+    monitor_printf(mon, "%s\n", qdict_get_str(qobject_to_qdict(data), "UUID"));
+}
+
 /* get the current CPU defined by the user */
 static int mon_set_cpu(int cpu_index)
 {
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 21/25] Monitor: Convert do_info_uuid_print() into do_info_uuid()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (19 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 20/25] Monitor: Move qmp_query_uuid() up in monitor.c Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 22/25] Monitor: qmp_query_migrate(): Return {} for empty MigrationState Luiz Capitulino
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_uuid() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index e9b07f3..3b6137e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -818,9 +818,13 @@ static void qmp_query_uuid(Monitor *mon, QObject **ret_data)
     *ret_data = qobject_from_jsonf("{ 'UUID': %s }", uuid);
 }
 
-static void do_info_uuid_print(Monitor *mon, const QObject *data)
+static void do_info_uuid(Monitor *mon)
 {
+    QObject *data;
+
+    qmp_query_uuid(NULL, &data);
     monitor_printf(mon, "%s\n", qdict_get_str(qobject_to_qdict(data), "UUID"));
+    qobject_decref(data);
 }
 
 /* get the current CPU defined by the user */
@@ -2586,8 +2590,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show the current VM UUID",
-        .user_print = do_info_uuid_print,
-        .mhandler.info_new = qmp_query_uuid,
+        .mhandler.info = do_info_uuid,
     },
 #if defined(TARGET_PPC)
     {
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 22/25] Monitor: qmp_query_migrate(): Return {} for empty MigrationState
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (20 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 21/25] Monitor: Convert do_info_uuid_print() into do_info_uuid() Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 23/25] Monitor: Convert do_info_migrate_print() into do_info_migrate() Luiz Capitulino
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

When no migration has been performed (ie. empty MigrationState),
qmp_query_migrate() returns nothing.

Let's do what other query handlers do: return an empty json-object.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 migration.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/migration.c b/migration.c
index 923d20e..ed253af 100644
--- a/migration.c
+++ b/migration.c
@@ -192,6 +192,9 @@ void do_info_migrate_print(Monitor *mon, const QObject *data)
     QDict *qdict;
 
     qdict = qobject_to_qdict(data);
+    if (qdict_size(qdict) == 0) {
+        return;
+    }
 
     monitor_printf(mon, "Migration status: %s\n",
                    qdict_get_str(qdict, "status"));
@@ -248,6 +251,8 @@ void qmp_query_migrate(Monitor *mon, QObject **ret_data)
             *ret_data = qobject_from_jsonf("{ 'status': 'cancelled' }");
             break;
         }
+    } else {
+        *ret_data = qobject_from_jsonf("{}");
     }
 }
 
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 23/25] Monitor: Convert do_info_migrate_print() into do_info_migrate()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (21 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 22/25] Monitor: qmp_query_migrate(): Return {} for empty MigrationState Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 24/25] Monitor: Introduce do_info_balloon() Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 25/25] Monitor: do_info(): Drop unused code Luiz Capitulino
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

The new handler directly calls qmp_query_migrate() to gather
data and then prints it. This change allows us to drop the
user_print callback.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 migration.c |    8 ++++++--
 migration.h |    2 +-
 monitor.c   |    3 +--
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/migration.c b/migration.c
index ed253af..df10354 100644
--- a/migration.c
+++ b/migration.c
@@ -187,13 +187,15 @@ static void migrate_print_status(Monitor *mon, const char *name,
                         qdict_get_int(qdict, "total") >> 10);
 }
 
-void do_info_migrate_print(Monitor *mon, const QObject *data)
+void do_info_migrate(Monitor *mon)
 {
     QDict *qdict;
+    QObject *data;
 
+    qmp_query_migrate(NULL, &data);
     qdict = qobject_to_qdict(data);
     if (qdict_size(qdict) == 0) {
-        return;
+        goto out;
     }
 
     monitor_printf(mon, "Migration status: %s\n",
@@ -206,6 +208,8 @@ void do_info_migrate_print(Monitor *mon, const QObject *data)
     if (qdict_haskey(qdict, "disk")) {
         migrate_print_status(mon, "disk", qdict);
     }
+out:
+    qobject_decref(data);
 }
 
 static void migrate_put_status(QDict *qdict, const char *name,
diff --git a/migration.h b/migration.h
index 30ee679..96d4eb3 100644
--- a/migration.h
+++ b/migration.h
@@ -65,7 +65,7 @@ uint64_t migrate_max_downtime(void);
 int do_migrate_set_downtime(Monitor *mon, const QDict *qdict,
                             QObject **ret_data);
 
-void do_info_migrate_print(Monitor *mon, const QObject *data);
+void do_info_migrate(Monitor *mon);
 
 void qmp_query_migrate(Monitor *mon, QObject **ret_data);
 
diff --git a/monitor.c b/monitor.c
index 3b6137e..97bab21 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2615,8 +2615,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show migration status",
-        .user_print = do_info_migrate_print,
-        .mhandler.info_new = qmp_query_migrate,
+        .mhandler.info = do_info_migrate,
     },
     {
         .name       = "balloon",
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 24/25] Monitor: Introduce do_info_balloon()
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (22 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 23/25] Monitor: Convert do_info_migrate_print() into do_info_migrate() Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 25/25] Monitor: do_info(): Drop unused code Luiz Capitulino
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

Today, the do_info() function takes care of handling asynchronous
calls. But what we really want is to move all the asynchronous
stuff behind the (future) QMP API.

The QMP API will be directly used by handlers, and won't be tied to
the human monitor common code (like do_info()) in any way.

This commit takes the first step towards this goal: it introduces
do_info_ballon(), which is a regular info handler, except that it
knows how to directly call an asynchronous QMP handler.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 97bab21..d07608e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -714,6 +714,22 @@ help:
     help_cmd(mon, "info");
 }
 
+static void do_info_balloon(Monitor *mon)
+{
+    int err;
+    MonitorCompletionData *cb_data;
+
+    cb_data = qemu_malloc(sizeof(*cb_data));
+    cb_data->mon = mon;
+    cb_data->user_print = monitor_print_balloon;
+    monitor_suspend(mon);
+    err = qmp_query_balloon(NULL, user_monitor_complete, cb_data);
+    if (err < 0) {
+        monitor_resume(mon);
+        qemu_free(cb_data);
+    }
+}
+
 static void qmp_query_version(Monitor *mon, QObject **ret_data)
 {
     const char *version = QEMU_VERSION;
@@ -2622,9 +2638,7 @@ static const mon_cmd_t info_cmds[] = {
         .args_type  = "",
         .params     = "",
         .help       = "show balloon information",
-        .user_print = monitor_print_balloon,
-        .mhandler.info_async = qmp_query_balloon,
-        .flags      = MONITOR_CMD_ASYNC,
+        .mhandler.info = do_info_balloon,
     },
     {
         .name       = "qtree",
-- 
1.7.3.3.398.g0b0cd

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

* [Qemu-devel] [PATCH 25/25] Monitor: do_info(): Drop unused code
  2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
                   ` (23 preceding siblings ...)
  2010-12-06 18:24 ` [Qemu-devel] [PATCH 24/25] Monitor: Introduce do_info_balloon() Luiz Capitulino
@ 2010-12-06 18:24 ` Luiz Capitulino
  24 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-06 18:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, armbru

Last commits moved QMP calling code to the info handlers themselves,
now do_info() does nothing with QMP anymore, just drop all QMP handling
code from it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   42 ++++++------------------------------------
 1 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/monitor.c b/monitor.c
index d07608e..8bfd755 100644
--- a/monitor.c
+++ b/monitor.c
@@ -661,28 +661,14 @@ static void user_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,
     }
 }
 
-static void user_async_info_handler(Monitor *mon, const mon_cmd_t *cmd)
-{
-    int ret;
-
-    MonitorCompletionData *cb_data = qemu_malloc(sizeof(*cb_data));
-    cb_data->mon = mon;
-    cb_data->user_print = cmd->user_print;
-    monitor_suspend(mon);
-    ret = cmd->mhandler.info_async(mon, user_monitor_complete, cb_data);
-    if (ret < 0) {
-        monitor_resume(mon);
-        qemu_free(cb_data);
-    }
-}
-
 static void do_info(Monitor *mon, const QDict *qdict)
 {
     const mon_cmd_t *cmd;
     const char *item = qdict_get_try_str(qdict, "item");
 
     if (!item) {
-        goto help;
+        help_cmd(mon, "info");
+        return;
     }
 
     for (cmd = info_cmds; cmd->name != NULL; cmd++) {
@@ -690,28 +676,12 @@ static void do_info(Monitor *mon, const QDict *qdict)
             break;
     }
 
-    if (cmd->name == NULL) {
-        goto help;
-    }
-
-    if (handler_is_async(cmd)) {
-        user_async_info_handler(mon, cmd);
-    } else if (handler_is_qobject(cmd)) {
-        QObject *info_data = NULL;
-
-        cmd->mhandler.info_new(mon, &info_data);
-        if (info_data) {
-            cmd->user_print(mon, info_data);
-            qobject_decref(info_data);
-        }
-    } else {
-        cmd->mhandler.info(mon);
+    if (!cmd->name) {
+        help_cmd(mon, "info");
+        return;
     }
 
-    return;
-
-help:
-    help_cmd(mon, "info");
+    cmd->mhandler.info(mon);
 }
 
 static void do_info_balloon(Monitor *mon)
-- 
1.7.3.3.398.g0b0cd

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

* Re: [Qemu-devel] [PATCH 01/25] QMP: Rename query handlers
  2010-12-06 18:23 ` [Qemu-devel] [PATCH 01/25] QMP: Rename query handlers Luiz Capitulino
@ 2010-12-07 12:28   ` Miguel Di Ciurcio Filho
  2010-12-07 13:15     ` Luiz Capitulino
  0 siblings, 1 reply; 28+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-12-07 12:28 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: aliguori, qemu-devel, armbru

On Mon, Dec 6, 2010 at 4:23 PM, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> Query handlers still carry their human monitor name. This commit
> renames all of them to a more QMP-like name.
>
> For example, do_info_version() is renamed to qmp_query_version().
> - * do_info_balloon(): Balloon information
> + * qmp_query_balloon(): Balloon information
>  *
>  * Make an asynchronous request for balloon info.  When the request completes
>  * a QDict will be returned according to the following specification:
> @@ -106,7 +106,7 @@ void monitor_print_balloon(Monitor *mon, const QObject *data)
>  *   "major_page_faults": 142, "minor_page_faults": 239245,
>  *   "free_mem": 1014185984, "total_mem": 1044668416 }
>  */
> -int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
> +int qmp_query_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
>  {

If the idea is to detach the human monitor from the QMP API, is there
any reason to keep passing `Monitor *mon` to qmp_* functions? In some
parts of the code NULL is being passed.

Regards,

Miguel

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

* Re: [Qemu-devel] [PATCH 01/25] QMP: Rename query handlers
  2010-12-07 12:28   ` Miguel Di Ciurcio Filho
@ 2010-12-07 13:15     ` Luiz Capitulino
  0 siblings, 0 replies; 28+ messages in thread
From: Luiz Capitulino @ 2010-12-07 13:15 UTC (permalink / raw)
  To: Miguel Di Ciurcio Filho; +Cc: aliguori, qemu-devel, armbru

On Tue, 7 Dec 2010 10:28:25 -0200
Miguel Di Ciurcio Filho <miguel.filho@gmail.com> wrote:

> On Mon, Dec 6, 2010 at 4:23 PM, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> > Query handlers still carry their human monitor name. This commit
> > renames all of them to a more QMP-like name.
> >
> > For example, do_info_version() is renamed to qmp_query_version().
> > - * do_info_balloon(): Balloon information
> > + * qmp_query_balloon(): Balloon information
> >  *
> >  * Make an asynchronous request for balloon info.  When the request completes
> >  * a QDict will be returned according to the following specification:
> > @@ -106,7 +106,7 @@ void monitor_print_balloon(Monitor *mon, const QObject *data)
> >  *   "major_page_faults": 142, "minor_page_faults": 239245,
> >  *   "free_mem": 1014185984, "total_mem": 1044668416 }
> >  */
> > -int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
> > +int qmp_query_balloon(Monitor *mon, MonitorCompletion cb, void *opaque)
> >  {
> 
> If the idea is to detach the human monitor from the QMP API, is there
> any reason to keep passing `Monitor *mon` to qmp_* functions?

No, I should drop it soon.

> In some parts of the code NULL is being passed.

Yes, this series is just a first step. We have lots of work to do and sometimes
I don't know what to do next, but the plan looks more or less like this:

1. Change info handlers to make directly QMP calls

   This series.
   
2. Move all qmp_query_* functions from the qmp_query_cmds[] table to the
   qmp-commands.hx one

   I have this almost ready, but I'm wondering if I should take the
   opportunity to drop the monitor object in this series...

3. Split all monitor commands into a human monitor part and a QMP part,
   the QMP part becomes the QMP API and the human monitor just calls it

   I have started doing this (maybe it's in an RFC state), but trust me,
   it's very difficult to split some handlers.

   One example is the do_change() one. Yes, a clearly human targeted
   command. So the question is: should we split such a handler or should
   we just add a good replacement?

   If we choose to add a replacement, then it's going to take a lot of
   time to have the QMP vs. HMP separation done. If we split the handler,
   then we'll have to live with complex, ugly code for a while.

4. Make handlers return an error object

   This is the new error infrastructure work, Markus will work on this.

5. Drop all Monitor object usage by QMP by introducing a QMP object

   We won't pass the QMP object to handlers, it's just our interface
   with the chardev layer that will change.

6. Add async command infrastructure

   Not necessary step 6, we'll probably be able to do it sooner.

7. Split the monitor code inti different files

   Possibly moving it to its own directory:

       - monitor/monitor.c: common code
       - monitor/hmp.c: human monitor
       - monitor/qmp.c: (guess what)

8. Make the QMP C API a real API

   Ie. do all cleanup needed to make it consumable, maybe even outside
   of QEMU

9. Conquer the world

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

end of thread, other threads:[~2010-12-07 13:20 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-06 18:23 [Qemu-devel] [PATCH v1 00/25]: Monitor: First step on an internal QMP API Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 01/25] QMP: Rename query handlers Luiz Capitulino
2010-12-07 12:28   ` Miguel Di Ciurcio Filho
2010-12-07 13:15     ` Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 02/25] QMP: Drop user_print usage from the qmp_query_cmds[] table Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 03/25] Monitor: Drop balloon handlers comments Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 04/25] Monitor: Move qmp_query_version() up in monitor.c Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 05/25] Monitor: Convert do_info_version_print() into do_info_version() Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 06/25] Monitor: Convert qemu_chr_info_print() into qemu_chr_info() Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 07/25] Monitor: Convert bdrv_info_print() into bdrv_info() Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 08/25] Monitor: Convert bdrv_stats_print() into bdrv_stats() Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 09/25] Monitor: Move qmp_query_cpus() up in monitor.c Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 10/25] Monitor: Convert monitor_print_cpus() into do_info_cpus() Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 11/25] Monitor: Convert do_pci_info_print() into do_pci_info() Luiz Capitulino
2010-12-06 18:23 ` [Qemu-devel] [PATCH 12/25] Monitor: Move qmp_query_kvm() up in monitor.c Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 13/25] Monitor: Convert do_info_kvm_print() into do_info_kvm() Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 14/25] Monitor: Move qmp_query_status() up in monitor.c Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 15/25] Monitor: Convert do_info_status_print() into do_info_status() Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 16/25] Monitor: Convert do_info_mice_print() into do_info_mice() Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 17/25] Monitor: Convert do_info_vnc_print() into do_info_vnc() Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 18/25] Monitor: Move qmp_query_name() up in monitor.c Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 19/25] Monitor: Convert do_info_name_print() into do_info_name() Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 20/25] Monitor: Move qmp_query_uuid() up in monitor.c Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 21/25] Monitor: Convert do_info_uuid_print() into do_info_uuid() Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 22/25] Monitor: qmp_query_migrate(): Return {} for empty MigrationState Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 23/25] Monitor: Convert do_info_migrate_print() into do_info_migrate() Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 24/25] Monitor: Introduce do_info_balloon() Luiz Capitulino
2010-12-06 18:24 ` [Qemu-devel] [PATCH 25/25] Monitor: do_info(): Drop unused code Luiz Capitulino

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