Re: [Qemu-devel] [PATCH 01/25] QMP: Rename query handlers

2010-12-07 Thread Miguel Di Ciurcio Filho
On Mon, Dec 6, 2010 at 4:23 PM, Luiz Capitulino lcapitul...@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



Re: [Qemu-devel] [PATCH 01/25] QMP: Rename query handlers

2010-12-07 Thread Luiz Capitulino
On Tue, 7 Dec 2010 10:28:25 -0200
Miguel Di Ciurcio Filho miguel.fi...@gmail.com wrote:

 On Mon, Dec 6, 2010 at 4:23 PM, Luiz Capitulino lcapitul...@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



[Qemu-devel] [PATCH 01/25] QMP: Rename query handlers

2010-12-06 Thread Luiz Capitulino
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 lcapitul...@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);