: QMP queue
PATCH 2/19 qapi: Convert query-mice
In reply to Luiz Capitulino--- hmp.c | 20 ++++++++++++++++ hmp.h | 1 + input.c | 64 +++++++++++++---------------------------------------- monitor.c | 11 +-------- qapi-schema.json | 30 +++++++++++++++++++++++++ qmp-commands.hx | 6 +++++ 6 files changed, 74 insertions(+), 58 deletions(-)
hmp.c +20 -0
@@ -94,6 +94,26 @@ void hmp_info_chardev(Monitor *mon)qapi_free_ChardevInfoList (char_info); } +void hmp_info_mice (Monitor *mon) +{ +MouseInfoList *mice_list, *mouse; + + mice_list =qmp_query_mice (NULL ); +if (!mice_list) { +monitor_printf (mon,"No mouse devices connected\n" ); +return ; + } + +for (mouse = mice_list; mouse; mouse = mouse->next) { +monitor_printf (mon,"%c Mouse #%" PRId64": %s%s\n" , + mouse->value->current ?'*' :' ' , + mouse->value->index, mouse->value->name, + mouse->value->absolute ?" (absolute)" :"" ); + } + +qapi_free_MouseInfoList (mice_list); +} +void hmp_quit (Monitor *mon,const QDict *qdict) {monitor_suspend (mon);
hmp.h +1 -0
@@ -23,6 +23,7 @@ void hmp_info_kvm(Monitor *mon);void hmp_info_status (Monitor *mon);void hmp_info_uuid (Monitor *mon);void hmp_info_chardev (Monitor *mon); +void hmp_info_mice (Monitor *mon);void hmp_quit (Monitor *mon,const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict);
input.c +16 -48
83 lines not on this page · raw message
monitor.c +1 -10
@@ -2942,8 +2942,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 = do_info_mice, + .mhandler.info = hmp_info_mice, }, { .name = "vnc",
@@ -3093,14 +3092,6 @@ static const mon_cmd_t qmp_query_cmds[] = { .mhandler.info_new = do_pci_info, }, { - .name = "mice", - .args_type = "", - .params = "", - .help = "show which guest mouse is receiving events", - .user_print = do_info_mice_print, - .mhandler.info_new = do_info_mice, - }, - { .name = "vnc", .args_type = "", .params = "",
qapi-schema.json +30 -0
@@ -226,6 +226,36 @@ { 'command': 'query-commands', 'returns': ['CommandInfo'] } ## +# @MouseInfo: +# +# Information about a mouse device. +# +# @name: the name of the mouse device +# +# @index: the index of the mouse device +# +# @current: true if this device is currently receiving mouse events +# +# @absolute: true if this device supports absolute coordinates as input +# +# Since: 0.14.0 +## +{ 'type': 'MouseInfo', + 'data': {'name': 'str', 'index': 'int', 'current': 'bool', + 'absolute': 'bool'} } + +## +# @query-mice: +# +# Returns information about each active mouse device +# +# Returns: a list of @MouseInfo for each device +# +# Since: 0.14.0 +## +{ 'command': 'query-mice', 'returns': ['MouseInfo'] } + +## # @quit: # # This command will cause the QEMU process to exit gracefully. While every
qmp-commands.hx +6 -0
@@ -1663,6 +1663,12 @@ Example: EQMP + { + .name = "query-mice", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_mice, + }, + SQMP query-vnc ---------
Signature · 1 line
1.7.7.1.475.g997a1
Anthony,
This pull request contains only my "QAPI conversions round 2" series (which got no review comments... last chance!).
The changes (since 9f60639b848944200c3d33a89233d808de0b5a43) are available in the following repository:
git://repo.or.cz/qemu/qmp-unstable.git queue/qmp
Luiz Capitulino (19):
qapi-commands.py: Don't call the output marshal on error
qapi: Convert query-mice
qapi: Convert query-migrate
Monitor: Make mon_set_cpu() public
Monitor: Introduce monitor_get_cpu_index()
qapi: Convert the cpu command
qapi: Convert query-cpus
block: iostatus: Drop BDRV_IOS_INVAL
block: Rename the BlockIOStatus enum values
qapi: Convert query-block
qapi: Convert query-blockstats
qerror: Add a user string for QERR_FEATURE_DISABLED
qapi: Convert query-vnc
qapi: Convert query-spice
qapi: Convert query-balloon
qapi: Convert query-pci
QMP: Drop the query commands dispatch table
Monitor: do_info(): Drop QMP command handling code Drop qemu-objects.h from modules that don't require it
balloon.c | 72 +----- balloon.h | 6 +- block.c | 234 ++++++------------ block.h | 5 - block_int.h | 4 +- console.h | 9 - cpus.c | 45 ++++ error.c | 3 +- hmp-commands.hx | 3 +- hmp.c | 407 ++++++++++++++++++++++++++++++ hmp.h | 10 + hw/pci-stub.c | 15 +- hw/pci.c | 322 +++++++++--------------- hw/pci.h | 4 - hw/virtio-balloon.c | 78 +----- input.c | 64 ++---- migration.c | 82 ++----- monitor.c | 313 ++---------------------- monitor.h | 2 + qapi-schema.json | 616 ++++++++++++++++++++++++++++++++++++++++++++++ qerror.c | 4 + qmp-commands.hx | 60 +++++- qmp.c | 27 ++ scripts/qapi-commands.py | 4 +- ui/spice-core.c | 139 +++++------ ui/vnc.c | 135 +++++++---- vl.c | 2 +- 27 files changed, 1611 insertions(+), 1054 deletions(-)
PATCH 6/19 qapi: Convert the cpu command
--- hmp-commands.hx | 3 +-- hmp.c | 12 ++++++++++++ hmp.h | 1 + monitor.c | 11 ----------- qapi-schema.json | 11 +++++++++++ qmp-commands.hx | 5 +---- qmp.c | 5 +++++ 7 files changed, 31 insertions(+), 17 deletions(-)
hmp-commands.hx +1 -2
@@ -587,8 +587,7 @@ ETEXI .args_type = "index:i", .params = "index", .help = "set the default CPU", - .user_print = monitor_user_noop, - .mhandler.cmd_new = do_cpu_set, + .mhandler.cmd = hmp_cpu, }, STEXI
hmp.c +12 -0
@@ -165,3 +165,15 @@ void hmp_system_powerdown(Monitor *mon, const QDict *qdict) {qmp_system_powerdown (NULL ); } + +void hmp_cpu (Monitor *mon,const QDict *qdict) +{ +int64_t cpu_index; + +/* XXX: drop the monitor_set_cpu() usage when all HMP commands that +use it are converted to the QAPI */ + cpu_index =qdict_get_int (qdict,"index" ); +if (monitor_set_cpu (cpu_index) <0 ) { +monitor_printf (mon,"invalid CPU index\n" ); + } +}
hmp.h +1 -0
@@ -29,5 +29,6 @@ void hmp_quit(Monitor *mon, const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict);void hmp_system_powerdown (Monitor *mon,const QDict *qdict); +void hmp_cpu (Monitor *mon,const QDict *qdict);#endif
monitor.c +0 -11
@@ -902,17 +902,6 @@ static void do_info_cpus(Monitor *mon, QObject **ret_data) *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" ); -if (monitor_set_cpu (index) <0 ) { -qerror_report (QERR_INVALID_PARAMETER_VALUE ,"index" , -"a CPU number" ); -return -1 ; - } -return 0 ; -} -static void do_info_jit (Monitor *mon) {dump_exec_info ((FILE *)mon, monitor_fprintf);
qapi-schema.json +11 -0
@@ -351,3 +351,14 @@ # prompting the user in some way. ## { 'command': 'system_powerdown' } + +## +# @cpu: +# +# This command is a nop that is only provided for the purposes of compatibility. +# +# Since: 0.14.0 +# +# Notes: Do not use this command. +## +{ 'command': 'cpu', 'data': {'index': 'int'} }
qmp-commands.hx +1 -4
@@ -331,10 +331,7 @@ EQMP { .name = "cpu", .args_type = "index:i", - .params = "index", - .help = "set the default CPU", - .user_print = monitor_user_noop, - .mhandler.cmd_new = do_cpu_set, + .mhandler.cmd_new = qmp_marshal_input_cpu, }, SQMP
qmp.c +5 -0
@@ -90,3 +90,8 @@ void qmp_system_powerdown(Error **erp) {qemu_system_powerdown_request (); } + +void qmp_cpu (int64_t index,Error **errp) +{ +/* Just do nothing */ +}
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 13/19 qapi: Convert query-vnc
In reply to Luiz CapitulinoThere are three important remarks in relation to the non-qapi command:
1. This commit also fixes the behavior of the 'query-vnc' and 'info vnc' commands to return an error when qemu is built without VNC support (ie. --disable-vnc). The non-qapi command would return the OK response in QMP and no response in HMP
2. The qapi version explicitly marks the fields 'host', 'family', 'service' and 'auth' as optional. Their are not documented as optional in the non-qapi command doc, but they would not be returned if vnc support is disabled. The qapi version maintains the same semantics, but documents those fields correctly
3. The 'clients' field, which is a list, is marked as optional but is always returned. If there are no clients connected an empty list is returned. This is not the Right Way to this in the qapi but it's how the non-qapi command used to work
--- console.h | 9 ---- hmp.c | 46 ++++++++++++++++++ hmp.h | 1 + monitor.c | 11 +---- qapi-schema.json | 81 ++++++++++++++++++++++++++++++++ qmp-commands.hx | 6 ++ qmp.c | 10 ++++ ui/vnc.c | 135 +++++++++++++++++++++++++++++++++--------------------- 8 files changed, 228 insertions(+), 71 deletions(-)
console.h +0 -9
@@ -383,8 +383,6 @@ char *vnc_display_local_addr(DisplayState *ds);#ifdef CONFIG_VNC int vnc_display_password (DisplayState *ds,const char *password);int vnc_display_pw_expire (DisplayState *ds,time_t expires); -void do_info_vnc_print (Monitor *mon,const QObject *data); -void do_info_vnc (Monitor *mon,QObject **ret_data);#else static inline int vnc_display_password (DisplayState *ds,const char *password) {
@@ -396,13 +394,6 @@ static inline int vnc_display_pw_expire(DisplayState *ds, time_t expires)qerror_report (QERR_FEATURE_DISABLED ,"vnc" ); return -ENODEV; }; -static inline void do_info_vnc (Monitor *mon,QObject **ret_data) -{ -}; -static inline void do_info_vnc_print (Monitor *mon,const QObject *data) -{ -monitor_printf (mon,"VNC support disabled\n" ); -};#endif /* curses.c */
hmp.c +46 -0
52 lines not on this page · raw message
hmp.h +1 -0
@@ -28,6 +28,7 @@ void hmp_info_migrate(Monitor *mon);void hmp_info_cpus (Monitor *mon);void hmp_info_block (Monitor *mon);void hmp_info_blockstats (Monitor *mon); +void hmp_info_vnc (Monitor *mon);void hmp_quit (Monitor *mon,const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict);
monitor.c +1 -10
@@ -2849,8 +2849,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 = do_info_vnc, + .mhandler.info = hmp_info_vnc, },#if defined(CONFIG_SPICE ) {
@@ -2966,14 +2965,6 @@ static const mon_cmd_t qmp_query_cmds[] = { .user_print = do_pci_info_print, .mhandler.info_new = do_pci_info, }, - { - .name = "vnc", - .args_type = "", - .params = "", - .help = "show the vnc server status", - .user_print = do_info_vnc_print, - .mhandler.info_new = do_info_vnc, - },#if defined(CONFIG_SPICE ) { .name = "spice",
qapi-schema.json +81 -0
87 lines not on this page · raw message
qmp-commands.hx +6 -0
@@ -1741,6 +1741,12 @@ Example: EQMP + { + .name = "query-vnc", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_vnc, + }, + SQMP query-spice -----------
qmp.c +10 -0
@@ -95,3 +95,13 @@ void qmp_cpu(int64_t index, Error **errp) {/* Just do nothing */ } + +#ifndef CONFIG_VNC +/* If VNC support is enabled, the "true" query-vnc command is +defined in the VNC subsystem */ +VncInfo *qmp_query_vnc (Error **errp) +{ +error_set (errp,QERR_FEATURE_DISABLED ,"vnc" ); +return NULL ; +}; +#endif
ui/vnc.c +83 -52
169 lines not on this page · raw message
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 15/19 qapi: Convert query-balloon
In reply to Luiz CapitulinoPlease, note that some of the code supporting memory statistics is still around (eg. virtio_balloon_receive_stats() and reset_stats()).
Also, the qmp_query_balloon() function is synchronous and thus doesn't make any use of the (not fully working) monitor's asynchronous command support (the old non-qapi implementation did).
--- balloon.c | 72 +++++++++-------------------------------------- balloon.h | 6 +-- hmp.c | 39 +++++++++++++++++++++++++ hmp.h | 1 + hw/virtio-balloon.c | 78 +++++++++----------------------------------------- monitor.c | 13 +-------- qapi-schema.json | 44 ++++++++++++++++++++++++++++ qmp-commands.hx | 5 +++ 8 files changed, 120 insertions(+), 138 deletions(-)
balloon.c +14 -58
@@ -25,12 +25,11 @@*/ #include "monitor.h" -#include "qjson.h" -#include "qint.h" #include "cpu-common.h" #include "kvm.h" #include "balloon.h" #include "trace.h" +#include "qmp-commands.h" static QEMUBalloonEvent *balloon_event_fn;static QEMUBalloonStatus *balloon_stat_fn;
@@ -72,76 +71,33 @@ static int qemu_balloon(ram_addr_t target)return 1 ; } -static int qemu_balloon_status (MonitorCompletion cb,void *opaque) +static int qemu_balloon_status (BalloonInfo *info) {if (!balloon_stat_fn) {return 0 ; } -balloon_stat_fn (balloon_opaque, cb, opaque); +balloon_stat_fn (balloon_opaque, info);return 1 ; } -static void print_balloon_stat (const char *key,QObject *obj,void *opaque) +BalloonInfo *qmp_query_balloon (Error **errp) { -Monitor *mon = opaque; - -if (strcmp (key,"actual" )) { -monitor_printf (mon,",%s=%" PRId64, key, -qint_get_int (qobject_to_qint (obj))); - } -} - -void monitor_print_balloon (Monitor *mon,const QObject *data) -{ -QDict *qdict; - - qdict =qobject_to_qdict (data); -if (!qdict_haskey (qdict,"actual" )) { -return ; - } -monitor_printf (mon,"balloon: actual=%" PRId64, -qdict_get_int (qdict,"actual" ) >>20 ); -qdict_iter (qdict, print_balloon_stat, mon); -monitor_printf (mon,"\n" ); -} - -/** -* do_info_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 do_info_balloon (Monitor *mon,MonitorCompletion cb,void *opaque) -{ -int ret; +BalloonInfo *info;if (kvm_enabled () && !kvm_has_sync_mmu ()) { -qerror_report (QERR_KVM_MISSING_CAP ,"synchronous MMU" ,"balloon" ); -return -1 ; +error_set (errp,QERR_KVM_MISSING_CAP ,"synchronous MMU" ,"balloon" ); +return NULL ; } - ret =qemu_balloon_status (cb, opaque); -if (!ret) { -qerror_report (QERR_DEVICE_NOT_ACTIVE ,"balloon" ); -return -1 ; + info =g_malloc0 (sizeof (*info)); + +if (qemu_balloon_status (info) ==0 ) { +error_set (errp,QERR_DEVICE_NOT_ACTIVE ,"balloon" ); +qapi_free_BalloonInfo (info); +return NULL ; } -return 0 ; +return info; }/**
balloon.h +2 -4
@@ -15,17 +15,15 @@#define _QEMU_BALLOON_H#include "monitor.h" +#include "qapi-types.h" typedef void (QEMUBalloonEvent )(void *opaque,ram_addr_t target); -typedef void (QEMUBalloonStatus )(void *opaque,MonitorCompletion cb, -void *cb_data); +typedef void (QEMUBalloonStatus )(void *opaque,BalloonInfo *info);int qemu_add_balloon_handler (QEMUBalloonEvent *event_func,QEMUBalloonStatus *stat_func,void *opaque);void qemu_remove_balloon_handler (void *opaque); -void monitor_print_balloon (Monitor *mon,const QObject *data); -int do_info_balloon (Monitor *mon,MonitorCompletion cb,void *opaque);int do_balloon (Monitor *mon,const QDict *params,MonitorCompletion cb,void *opaque);
hmp.c +39 -0
@@ -349,6 +349,45 @@ out:qapi_free_SpiceInfo (info); } +void hmp_info_balloon (Monitor *mon) +{ +BalloonInfo *info; +Error *err =NULL ; + + info =qmp_query_balloon (&err); +if (err) { +monitor_printf (mon,"%s\n" ,error_get_pretty (err)); +error_free (err); +return ; + } + +monitor_printf (mon,"balloon: actual=%" PRId64, info->actual >>20 ); +if (info->has_mem_swapped_in) { +monitor_printf (mon," mem_swapped_in=%" PRId64, info->mem_swapped_in); + } +if (info->has_mem_swapped_out) { +monitor_printf (mon," mem_swapped_out=%" PRId64, info->mem_swapped_out); + } +if (info->has_major_page_faults) { +monitor_printf (mon," major_page_faults=%" PRId64, + info->major_page_faults); + } +if (info->has_minor_page_faults) { +monitor_printf (mon," minor_page_faults=%" PRId64, + info->minor_page_faults); + } +if (info->has_free_mem) { +monitor_printf (mon," free_mem=%" PRId64, info->free_mem); + } +if (info->has_total_mem) { +monitor_printf (mon," total_mem=%" PRId64, info->total_mem); + } + +monitor_printf (mon,"\n" ); + +qapi_free_BalloonInfo (info); +} +void hmp_quit (Monitor *mon,const QDict *qdict) {monitor_suspend (mon);
hmp.h +1 -0
@@ -30,6 +30,7 @@ void hmp_info_block(Monitor *mon);void hmp_info_blockstats (Monitor *mon);void hmp_info_vnc (Monitor *mon);void hmp_info_spice (Monitor *mon); +void hmp_info_balloon (Monitor *mon);void hmp_quit (Monitor *mon,const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict);
hw/virtio-balloon.c +14 -64
135 lines not on this page · raw message
monitor.c +1 -12
@@ -2904,9 +2904,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show balloon information", - .user_print = monitor_print_balloon, - .mhandler.info_async = do_info_balloon, - .flags = MONITOR_CMD_ASYNC, + .mhandler.info = hmp_info_balloon, }, { .name = "qtree",
@@ -2964,15 +2962,6 @@ static const mon_cmd_t qmp_query_cmds[] = { .user_print = do_pci_info_print, .mhandler.info_new = do_pci_info, }, - { - .name = "balloon", - .args_type = "", - .params = "", - .help = "show balloon information", - .user_print = monitor_print_balloon, - .mhandler.info_async = do_info_balloon, - .flags = MONITOR_CMD_ASYNC, - }, { /* NULL */ }, };
qapi-schema.json +44 -0
50 lines not on this page · raw message
qmp-commands.hx +5 -0
@@ -1989,3 +1989,8 @@ Example: EQMP + { + .name = "query-balloon", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_balloon, + },
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 7/19 qapi: Convert query-cpus
In reply to Luiz Capitulino--- cpus.c | 45 ++++++++++++++++++++++++ hmp.c | 39 +++++++++++++++++++++ hmp.h | 1 + monitor.c | 101 +----------------------------------------------------- qapi-schema.json | 46 ++++++++++++++++++++++++ qmp-commands.hx | 6 +++ 6 files changed, 138 insertions(+), 100 deletions(-)
cpus.c +45 -0
@@ -30,6 +30,7 @@#include "gdbstub.h" #include "dma.h" #include "kvm.h" +#include "qmp-commands.h" #include "qemu-thread.h" #include "cpus.h"
@@ -1094,3 +1095,47 @@ void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg)cpu_list (f, cpu_fprintf);/* deprecated */ #endif } + +CpuInfoList *qmp_query_cpus (Error **errp) +{ +CpuInfoList *head =NULL , *cur_item =NULL ; +CPUState *env; + +for (env = first_cpu; env !=NULL ; env = env->next_cpu) { +CpuInfoList *info; + +cpu_synchronize_state (env); + + info =g_malloc0 (sizeof (*info)); + info->value =g_malloc0 (sizeof (*info->value)); + info->value->CPU = env->cpu_index; + info->value->current = (env == first_cpu); + info->value->halted = env->halted; + info->value->thread_id = env->thread_id; +#if defined(TARGET_I386 ) + info->value->has_pc = true; + info->value->pc = env->eip + env->segs[R_CS ].base; +#elif defined(TARGET_PPC ) + info->value->has_nip = true; + info->value->nip = env->nip; +#elif defined(TARGET_SPARC ) + info->value->has_pc = true; + info->value->pc = env->pc; + info->value->has_npc = true; + info->value->npc = env->npc; +#elif defined(TARGET_MIPS ) + info->value->has_PC = true; + info->value->PC = env->active_tc.PC; +#endif + +/* XXX: waiting for the qapi to support GSList */ +if (!cur_item) { + head = cur_item = info; + }else { + cur_item->next = info; + cur_item = info; + } + } + +return head; +}
hmp.c +39 -0
@@ -145,6 +145,45 @@ void hmp_info_migrate(Monitor *mon)qapi_free_MigrationInfo (info); } +void hmp_info_cpus (Monitor *mon) +{ +CpuInfoList *cpu_list, *cpu; + + cpu_list =qmp_query_cpus (NULL ); + +for (cpu = cpu_list; cpu; cpu = cpu->next) { +int active =' ' ; + +if (cpu->value->CPU ==monitor_get_cpu_index ()) { + active ='*' ; + } + +monitor_printf (mon,"%c CPU #%" PRId64": " , active, cpu->value->CPU); + +if (cpu->value->has_pc) { +monitor_printf (mon,"pc=0x%016" PRIx64, cpu->value->pc); + } +if (cpu->value->has_nip) { +monitor_printf (mon,"nip=0x%016" PRIx64, cpu->value->nip); + } +if (cpu->value->has_npc) { +monitor_printf (mon,"pc=0x%016" PRIx64, cpu->value->pc); +monitor_printf (mon,"npc=0x%016" PRIx64, cpu->value->npc); + } +if (cpu->value->has_PC) { +monitor_printf (mon,"PC=0x%016" PRIx64, cpu->value->PC); + } + +if (cpu->value->halted) { +monitor_printf (mon," (halted)" ); + } + +monitor_printf (mon," thread_id=%" PRId64"\n" , cpu->value->thread_id); + } + +qapi_free_CpuInfoList (cpu_list); +} +void hmp_quit (Monitor *mon,const QDict *qdict) {monitor_suspend (mon);
hmp.h +1 -0
@@ -25,6 +25,7 @@ void hmp_info_uuid(Monitor *mon);void hmp_info_chardev (Monitor *mon);void hmp_info_mice (Monitor *mon);void hmp_info_migrate (Monitor *mon); +void hmp_info_cpus (Monitor *mon);void hmp_quit (Monitor *mon,const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict);
monitor.c +1 -100
119 lines not on this page · raw message
qapi-schema.json +46 -0
52 lines not on this page · raw message
qmp-commands.hx +6 -0
@@ -1347,6 +1347,12 @@ Example: EQMP + { + .name = "query-cpus", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_cpus, + }, + SQMP query-pci ---------
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 1/19 qapi-commands.py: Don't call the output marshal on error
In reply to Luiz CapitulinoToday we generate something like this:
int qmp_marshal_input_query_foo(...)
...
retval = qmp_query_foo(errp);
qmp_marshal_output_query_foo(retval, ret, errp);
...However, if qmp_query_foo() fails 'retval' will probably be NULL, which can cause a segfault as not all visitors check if 'retval' is valid.
This commit fixes that by changing the code generator to only call the output marshal if qmp_query_foo() succeeds, like this:
retval = qmp_query_foo(errp);
if (!error_is_set(errp)) {
qmp_marshal_output_query_foo(retval, ret, errp);
}--- scripts/qapi-commands.py | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
scripts/qapi-commands.py +3 -1
@@ -62,7 +62,9 @@ def gen_sync_call(name, args, ret_type, indent=0): name=c_var(name), args=arglist, retval=retval).rstrip() if ret_type: ret += "\n" + mcgen('''' -%(marshal_output_call)s +if (!error_is_set(errp)) { + %(marshal_output_call)s +} ''', marshal_output_call=gen_marshal_output_call(name, ret_type)).rstrip() pop_indent(indent)
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 5/19 Monitor: Introduce monitor_get_cpu_index()
In reply to Luiz CapitulinoReturns 'cur_mons's CPU index. A future commit will use it.
--- monitor.c | 5 +++++ monitor.h | 1 + 2 files changed, 6 insertions(+), 0 deletions(-)
monitor.c +5 -0
@@ -794,6 +794,11 @@ static CPUState *mon_get_cpu(void)return cur_mon->mon_cpu; } +int monitor_get_cpu_index (void ) +{ +return mon_get_cpu ()->cpu_index; +} +static void do_info_registers (Monitor *mon) {CPUState *env;
monitor.h +1 -0
@@ -58,6 +58,7 @@ void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void monitor_print_filename (Monitor *mon,const char *filename);void monitor_flush (Monitor *mon);int monitor_set_cpu (int cpu_index); +int monitor_get_cpu_index (void );typedef void (MonitorCompletion )(void *opaque,QObject *ret_data);
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 4/19 Monitor: Make mon_set_cpu() public
In reply to Luiz CapitulinoAlso rename it to monitor_set_cpu().
--- monitor.c | 11 +++++------ monitor.h | 1 + 2 files changed, 6 insertions(+), 6 deletions(-)
monitor.c +5 -6
@@ -514,7 +514,6 @@ static int do_qmp_capabilities(Monitor *mon, const QDict *params,return 0 ; } -static int mon_set_cpu (int cpu_index);static void handle_user_command (Monitor *mon,const char *cmdline); static int do_hmp_passthrough(Monitor *mon, const QDict *params,
@@ -532,7 +531,7 @@ static int do_hmp_passthrough(Monitor *mon, const QDict *params, cur_mon = &hmp;if (qdict_haskey (params,"cpu-index" )) { - ret =mon_set_cpu (qdict_get_int (params,"cpu-index" )); + ret =monitor_set_cpu (qdict_get_int (params,"cpu-index" ));if (ret <0 ) { cur_mon = old_mon;qerror_report (QERR_INVALID_PARAMETER_VALUE ,"cpu-index" ,"a CPU number" );
@@ -772,8 +771,8 @@ CommandInfoList *qmp_query_commands(Error **errp)return cmd_list; } -/* get the current CPU defined by the user */ -static int mon_set_cpu (int cpu_index) +/* set the current CPU defined by the user */ +int monitor_set_cpu (int cpu_index) {CPUState *env;
@@ -789,7 +788,7 @@ static int mon_set_cpu(int cpu_index)static CPUState *mon_get_cpu (void ) {if (!cur_mon->mon_cpu) { -mon_set_cpu (0 ); +monitor_set_cpu (0 ); }cpu_synchronize_state (cur_mon->mon_cpu);return cur_mon->mon_cpu;
@@ -901,7 +900,7 @@ static void do_info_cpus(Monitor *mon, QObject **ret_data)static int do_cpu_set (Monitor *mon,const QDict *qdict,QObject **ret_data) {int index =qdict_get_int (qdict,"index" ); -if (mon_set_cpu (index) <0 ) { +if (monitor_set_cpu (index) <0 ) {qerror_report (QERR_INVALID_PARAMETER_VALUE ,"index" ,"a CPU number" );return -1 ;
monitor.h +1 -0
@@ -57,6 +57,7 @@ void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);void monitor_print_filename (Monitor *mon,const char *filename);void monitor_flush (Monitor *mon); +int monitor_set_cpu (int cpu_index);typedef void (MonitorCompletion )(void *opaque,QObject *ret_data);
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 8/19 block: iostatus: Drop BDRV_IOS_INVAL
In reply to Luiz CapitulinoA future commit will convert bdrv_info() to the QAPI and it won't provide IOS_INVAL.
Luckily all we have to do is to add a new 'iostatus_enabled' member to BlockDriverState and use it instead.
--- block.c | 5 +++-- block.h | 3 +-- block_int.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-)
block.c +3 -2
@@ -3139,6 +3139,7 @@ int bdrv_in_use(BlockDriverState *bs)void bdrv_iostatus_enable (BlockDriverState *bs) { + bs->iostatus_enabled = true; bs->iostatus =BDRV_IOS_OK ; }
@@ -3146,7 +3147,7 @@ void bdrv_iostatus_enable(BlockDriverState *bs)* enables it _and_ the VM is configured to stop on errors */ bool bdrv_iostatus_is_enabled (const BlockDriverState *bs) { -return (bs->iostatus !=BDRV_IOS_INVAL && +return (bs->iostatus_enabled && (bs->on_write_error ==BLOCK_ERR_STOP_ENOSPC || bs->on_write_error ==BLOCK_ERR_STOP_ANY || bs->on_read_error ==BLOCK_ERR_STOP_ANY ));
@@ -3154,7 +3155,7 @@ bool bdrv_iostatus_is_enabled(const BlockDriverState *bs)void bdrv_iostatus_disable (BlockDriverState *bs) { - bs->iostatus =BDRV_IOS_INVAL ; + bs->iostatus_enabled = false; }void bdrv_iostatus_reset (BlockDriverState *bs)
block.h +1 -2
@@ -78,8 +78,7 @@ typedef enum { } BlockMonEventAction;typedef enum { -BDRV_IOS_INVAL ,BDRV_IOS_OK ,BDRV_IOS_FAILED ,BDRV_IOS_ENOSPC , -BDRV_IOS_MAX +BDRV_IOS_OK ,BDRV_IOS_FAILED ,BDRV_IOS_ENOSPC ,BDRV_IOS_MAX }BlockIOStatus ;void bdrv_iostatus_enable (BlockDriverState *bs);
block_int.h +1 -0
@@ -202,6 +202,7 @@ struct BlockDriverState {drivers. They are not used by the block driver */ int cyls, heads, secs, translation;BlockErrorAction on_read_error, on_write_error; +bool iostatus_enabled;BlockIOStatus iostatus;char device_name[32 ];unsigned long *dirty_bitmap;
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 12/19 qerror: Add a user string for QERR_FEATURE_DISABLED
In reply to Luiz CapitulinoMissing from commit 821601ea5b.
--- qerror.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
qerror.c +4 -0
@@ -117,6 +117,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "No file descriptor supplied via SCM_RIGHTS", }, { + .error_fmt = QERR_FEATURE_DISABLED, + .desc = "The feature '%(name)' is not enabled", + }, + { .error_fmt = QERR_INVALID_BLOCK_FORMAT, .desc = "Invalid block format '%(name)'", },
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 14/19 qapi: Convert query-spice
In reply to Luiz Capitulino--- hmp.c | 43 +++++++++++++++++ hmp.h | 1 + monitor.c | 13 +----- qapi-schema.json | 74 +++++++++++++++++++++++++++++ qmp-commands.hx | 8 +++ qmp.c | 12 +++++ ui/spice-core.c | 139 ++++++++++++++++++++++------------------------------- 7 files changed, 197 insertions(+), 93 deletions(-)
hmp.c +43 -0
@@ -306,6 +306,49 @@ out:qapi_free_VncInfo (info); } +void hmp_info_spice (Monitor *mon) +{ +SpiceChannelList *chan; +SpiceInfo *info; + + info =qmp_query_spice (NULL ); + +if (!info->enabled) { +monitor_printf (mon,"Server: disabled\n" ); + goto out; + } + +monitor_printf (mon,"Server:\n" ); +if (info->has_port) { +monitor_printf (mon," address: %s:%" PRId64"\n" , + info->host, info->port); + } +if (info->has_tls_port) { +monitor_printf (mon," address: %s:%" PRId64" [tls]\n" , + info->host, info->tls_port); + } +monitor_printf (mon," auth: %s\n" , info->auth); +monitor_printf (mon," compiled: %s\n" , info->compiled_version); + +if (!info->has_channels || info->channels ==NULL ) { +monitor_printf (mon,"Channels: none\n" ); + }else { +for (chan = info->channels; chan; chan = chan->next) { +monitor_printf (mon,"Channel:\n" ); +monitor_printf (mon," address: %s:%s%s\n" , + chan->value->host, chan->value->port, + chan->value->tls ?" [tls]" :"" ); +monitor_printf (mon," session: %" PRId64"\n" , + chan->value->connection_id); +monitor_printf (mon," channel: %" PRId64":%" PRId64"\n" , + chan->value->channel_type, chan->value->channel_id); + } + } + +out: +qapi_free_SpiceInfo (info); +} +void hmp_quit (Monitor *mon,const QDict *qdict) {monitor_suspend (mon);
hmp.h +1 -0
@@ -29,6 +29,7 @@ void hmp_info_cpus(Monitor *mon);void hmp_info_block (Monitor *mon);void hmp_info_blockstats (Monitor *mon);void hmp_info_vnc (Monitor *mon); +void hmp_info_spice (Monitor *mon);void hmp_quit (Monitor *mon,const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict);
monitor.c +1 -12
@@ -2857,8 +2857,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the spice server status", - .user_print = do_info_spice_print, - .mhandler.info_new = do_info_spice, + .mhandler.info = hmp_info_spice, },#endif {
@@ -2965,16 +2964,6 @@ static const mon_cmd_t qmp_query_cmds[] = { .user_print = do_pci_info_print, .mhandler.info_new = do_pci_info, }, -#if defined(CONFIG_SPICE) - { - .name = "spice", - .args_type = "", - .params = "", - .help = "show the spice server status", - .user_print = do_info_spice_print, - .mhandler.info_new = do_info_spice, - }, -#endif { .name = "balloon", .args_type = "",
qapi-schema.json +74 -0
80 lines not on this page · raw message
qmp-commands.hx +8 -0
@@ -1817,6 +1817,14 @@ Example: EQMP +#if defined(CONFIG_SPICE) + { + .name = "query-spice", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_spice, + }, +#endif + SQMP query-name ----------
qmp.c +12 -0
@@ -105,3 +105,15 @@ VncInfo *qmp_query_vnc(Error **errp) return NULL; };#endif + +#ifndef CONFIG_SPICE +/* If SPICE support is enabled, the "true" query-spice command is +defined in the SPICE subsystem. Also note that we use a small +trick to maintain query-spice's original behavior, which is not +to be available in the namespace if SPICE is not compiled in */ +SpiceInfo *qmp_query_spice (Error **errp) +{ +error_set (errp,QERR_COMMAND_NOT_FOUND ,"query-spice" ); +return NULL ; +}; +#endif
ui/spice-core.c +58 -81
184 lines not on this page · raw message
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 19/19 Drop qemu-objects.h from modules that don't require it
In reply to Luiz CapitulinoPrevious commits dropped most qobjects usage from qemu modules (now they are a low level interface used by the QAPI). However, some modules still include the qemu-objects.h header file.
This commit drops qemu-objects.h from some of those modules and includes qjson.h instead, which is what they actually need.
--- block.c | 2 +- error.c | 3 ++- vl.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
block.c +1 -1
@@ -27,7 +27,7 @@#include "monitor.h" #include "block_int.h" #include "module.h" -#include "qemu-objects.h" +#include "qjson.h" #include "qemu-coroutine.h" #include "qmp-commands.h"
error.c +2 -1
@@ -12,8 +12,9 @@#include "qemu-common.h" #include "error.h" +#include "qjson.h" +#include "qdict.h" #include "error_int.h" -#include "qemu-objects.h" #include "qerror.h" struct Error
vl.c +1 -1
@@ -143,9 +143,9 @@ int main(int argc, char **argv)#include "audio/audio.h" #include "migration.h" #include "kvm.h" +#include "qjson.h" #include "qemu-option.h" #include "qemu-config.h" -#include "qemu-objects.h" #include "qemu-options.h" #include "qmp-commands.h" #include "main-loop.h"
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 11/19 qapi: Convert query-blockstats
In reply to Luiz Capitulino--- block.c | 111 ++++++++++++++++++------------------------------------ hmp.c | 34 ++++++++++++++++ hmp.h | 1 + monitor.c | 11 +----- qapi-schema.json | 67 ++++++++++++++++++++++++++++++++ qmp-commands.hx | 6 +++ 6 files changed, 146 insertions(+), 84 deletions(-)
block.c +37 -74
@@ -1874,93 +1874,56 @@ BlockInfoList *qmp_query_block(Error **errp)return head; } -static void bdrv_stats_iter (QObject *data,void *opaque) -{ -QDict *qdict; -Monitor *mon = opaque; - - qdict =qobject_to_qdict (data); -monitor_printf (mon,"%s:" ,qdict_get_str (qdict,"device" )); - - qdict =qobject_to_qdict (qdict_get (qdict,"stats" )); -monitor_printf (mon," rd_bytes=%" PRId64 -" wr_bytes=%" PRId64 -" rd_operations=%" PRId64 -" wr_operations=%" PRId64 -" flush_operations=%" PRId64 -" wr_total_time_ns=%" PRId64 -" rd_total_time_ns=%" PRId64 -" flush_total_time_ns=%" PRId64 -"\n" , -qdict_get_int (qdict,"rd_bytes" ), -qdict_get_int (qdict,"wr_bytes" ), -qdict_get_int (qdict,"rd_operations" ), -qdict_get_int (qdict,"wr_operations" ), -qdict_get_int (qdict,"flush_operations" ), -qdict_get_int (qdict,"wr_total_time_ns" ), -qdict_get_int (qdict,"rd_total_time_ns" ), -qdict_get_int (qdict,"flush_total_time_ns" )); -} - -void bdrv_stats_print (Monitor *mon,const QObject *data) -{ -qlist_iter (qobject_to_qlist (data), bdrv_stats_iter, mon); -} - -static QObject *bdrv_info_stats_bs (BlockDriverState *bs) -{ -QObject *res; -QDict *dict; - - res =qobject_from_jsonf ("{ 'stats': {" -"'rd_bytes': %" PRId64"," -"'wr_bytes': %" PRId64"," -"'rd_operations': %" PRId64"," -"'wr_operations': %" PRId64"," -"'wr_highest_offset': %" PRId64"," -"'flush_operations': %" PRId64"," -"'wr_total_time_ns': %" PRId64"," -"'rd_total_time_ns': %" PRId64"," -"'flush_total_time_ns': %" PRId64 -"} }" , - bs->nr_bytes[BDRV_ACCT_READ ], - bs->nr_bytes[BDRV_ACCT_WRITE ], - bs->nr_ops[BDRV_ACCT_READ ], - bs->nr_ops[BDRV_ACCT_WRITE ], - bs->wr_highest_sector * - (uint64_t )BDRV_SECTOR_SIZE , - bs->nr_ops[BDRV_ACCT_FLUSH ], - bs->total_time_ns[BDRV_ACCT_WRITE ], - bs->total_time_ns[BDRV_ACCT_READ ], - bs->total_time_ns[BDRV_ACCT_FLUSH ]); - dict =qobject_to_qdict (res); - -if (*bs->device_name) { -qdict_put (dict,"device" ,qstring_from_str (bs->device_name)); +/* Consider exposing this as a full fledged QMP command */ +static BlockStats *qmp_query_blockstat (const BlockDriverState *bs,Error **errp) +{ +BlockStats *s; + + s =g_malloc0 (sizeof (*s)); + +if (bs->device_name[0 ]) { + s->has_device = true; + s->device =g_strdup (bs->device_name); } + s->stats =g_malloc0 (sizeof (*s->stats)); + s->stats->rd_bytes = bs->nr_bytes[BDRV_ACCT_READ ]; + s->stats->wr_bytes = bs->nr_bytes[BDRV_ACCT_WRITE ]; + s->stats->rd_operations = bs->nr_ops[BDRV_ACCT_READ ]; + s->stats->wr_operations = bs->nr_ops[BDRV_ACCT_WRITE ]; + s->stats->wr_highest_offset = bs->wr_highest_sector *BDRV_SECTOR_SIZE ; + s->stats->flush_operations = bs->nr_ops[BDRV_ACCT_FLUSH ]; + s->stats->wr_total_time_ns = bs->total_time_ns[BDRV_ACCT_WRITE ]; + s->stats->rd_total_time_ns = bs->total_time_ns[BDRV_ACCT_READ ]; + s->stats->flush_total_time_ns = bs->total_time_ns[BDRV_ACCT_FLUSH ]; +if (bs->file) { -QObject *parent =bdrv_info_stats_bs (bs->file); -qdict_put_obj (dict,"parent" , parent); + s->has_parent = true; + s->parent =qmp_query_blockstat (bs->file,NULL ); } -return res; +return s; } -void bdrv_info_stats (Monitor *mon,QObject **ret_data) +BlockStatsList *qmp_query_blockstats (Error **errp) { -QObject *obj; -QList *devices; +BlockStatsList *head =NULL , *cur_item =NULL ;BlockDriverState *bs; - devices =qlist_new (); - QTAILQ_FOREACH(bs, &bdrv_states, list) { - obj =bdrv_info_stats_bs (bs); -qlist_append_obj (devices, obj); +BlockStatsList *info =g_malloc0 (sizeof (*info)); + info->value =qmp_query_blockstat (bs,NULL ); + +/* XXX: waiting for the qapi to support GSList */ +if (!cur_item) { + head = cur_item = info; + }else { + cur_item->next = info; + cur_item = info; + } } - *ret_data =QOBJECT (devices); +return head; }const char *bdrv_get_encrypted_filename (BlockDriverState *bs)
hmp.c +34 -0
@@ -226,6 +226,40 @@ void hmp_info_block(Monitor *mon)qapi_free_BlockInfoList (block_list); } +void hmp_info_blockstats (Monitor *mon) +{ +BlockStatsList *stats_list, *stats; + + stats_list =qmp_query_blockstats (NULL ); + +for (stats = stats_list; stats; stats = stats->next) { +if (!stats->value->has_device) { +continue ; + } + +monitor_printf (mon,"%s:" , stats->value->device); +monitor_printf (mon," rd_bytes=%" PRId64 +" wr_bytes=%" PRId64 +" rd_operations=%" PRId64 +" wr_operations=%" PRId64 +" flush_operations=%" PRId64 +" wr_total_time_ns=%" PRId64 +" rd_total_time_ns=%" PRId64 +" flush_total_time_ns=%" PRId64 +"\n" , + stats->value->stats->rd_bytes, + stats->value->stats->wr_bytes, + stats->value->stats->rd_operations, + stats->value->stats->wr_operations, + stats->value->stats->flush_operations, + stats->value->stats->wr_total_time_ns, + stats->value->stats->rd_total_time_ns, + stats->value->stats->flush_total_time_ns); + } + +qapi_free_BlockStatsList (stats_list); +} +void hmp_quit (Monitor *mon,const QDict *qdict) {monitor_suspend (mon);
hmp.h +1 -0
@@ -27,6 +27,7 @@ void hmp_info_mice(Monitor *mon);void hmp_info_migrate (Monitor *mon);void hmp_info_cpus (Monitor *mon);void hmp_info_block (Monitor *mon); +void hmp_info_blockstats (Monitor *mon);void hmp_quit (Monitor *mon,const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict);
monitor.c +1 -10
@@ -2681,8 +2681,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show block device statistics", - .user_print = bdrv_stats_print, - .mhandler.info_new = bdrv_info_stats, + .mhandler.info = hmp_info_blockstats, }, { .name = "registers",
@@ -2960,14 +2959,6 @@ static const mon_cmd_t qmp_cmds[] = {static const mon_cmd_t qmp_query_cmds[] = { { - .name ="blockstats" , - .args_type ="" , - .params ="" , - .help ="show block device statistics" , - .user_print = bdrv_stats_print, - .mhandler.info_new = bdrv_info_stats, - }, - { .name ="pci" , .args_type ="" , .params ="" ,
qapi-schema.json +67 -0
73 lines not on this page · raw message
qmp-commands.hx +6 -0
@@ -1311,6 +1311,12 @@ Example: EQMP + { + .name = "query-blockstats", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_blockstats, + }, + SQMP query-cpus ----------
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 10/19 qapi: Convert query-block
In reply to Luiz Capitulino--- block.c | 112 ++++++++++++++--------------------------------------- block.h | 5 -- block_int.h | 3 +- hmp.c | 42 ++++++++++++++++++++ hmp.h | 1 + monitor.c | 11 +----- qapi-schema.json | 85 +++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 6 +++ 8 files changed, 167 insertions(+), 98 deletions(-)
block.c +30 -82
@@ -29,6 +29,7 @@#include "module.h" #include "qemu-objects.h" #include "qemu-coroutine.h" +#include "qmp-commands.h" #ifdef CONFIG_BSD #include <sys/types.h>
@@ -1824,106 +1825,53 @@ void bdrv_mon_event(const BlockDriverState *bdrv,qobject_decref (data); } -static void bdrv_print_dict (QObject *obj,void *opaque) +BlockInfoList *qmp_query_block (Error **errp) { -QDict *bs_dict; -Monitor *mon = opaque; - - bs_dict =qobject_to_qdict (obj); - -monitor_printf (mon,"%s: removable=%d" , -qdict_get_str (bs_dict,"device" ), -qdict_get_bool (bs_dict,"removable" )); - -if (qdict_get_bool (bs_dict,"removable" )) { -monitor_printf (mon," locked=%d" ,qdict_get_bool (bs_dict,"locked" )); -monitor_printf (mon," tray-open=%d" , -qdict_get_bool (bs_dict,"tray-open" )); - } - -if (qdict_haskey (bs_dict,"io-status" )) { -monitor_printf (mon," io-status=%s" ,qdict_get_str (bs_dict,"io-status" )); - } - -if (qdict_haskey (bs_dict,"inserted" )) { -QDict *qdict =qobject_to_qdict (qdict_get (bs_dict,"inserted" )); - -monitor_printf (mon," file=" ); -monitor_print_filename (mon,qdict_get_str (qdict,"file" )); -if (qdict_haskey (qdict,"backing_file" )) { -monitor_printf (mon," backing_file=" ); -monitor_print_filename (mon,qdict_get_str (qdict,"backing_file" )); - } -monitor_printf (mon," ro=%d drv=%s encrypted=%d" , -qdict_get_bool (qdict,"ro" ), -qdict_get_str (qdict,"drv" ), -qdict_get_bool (qdict,"encrypted" )); - }else { -monitor_printf (mon," [not inserted]" ); - } - -monitor_printf (mon,"\n" ); -} - -void bdrv_info_print (Monitor *mon,const QObject *data) -{ -qlist_iter (qobject_to_qlist (data), bdrv_print_dict, mon); -} - -static const char *const io_status_name[BLOCK_DEVICE_IO_STATUS_MAX ] = { - [BLOCK_DEVICE_IO_STATUS_OK ] ="ok" , - [BLOCK_DEVICE_IO_STATUS_FAILED ] ="failed" , - [BLOCK_DEVICE_IO_STATUS_NOSPACE ] ="nospace" , -}; - -void bdrv_info (Monitor *mon,QObject **ret_data) -{ -QList *bs_list; +BlockInfoList *head =NULL , *cur_item =NULL ;BlockDriverState *bs; - bs_list =qlist_new (); - QTAILQ_FOREACH(bs, &bdrv_states, list) { -QObject *bs_obj; -QDict *bs_dict; +BlockInfoList *info =g_malloc0 (sizeof (*info)); - bs_obj =qobject_from_jsonf ("{ 'device': %s, 'type': 'unknown', " -"'removable': %i, 'locked': %i }" , - bs->device_name, -bdrv_dev_has_removable_media (bs), -bdrv_dev_is_medium_locked (bs)); - bs_dict =qobject_to_qdict (bs_obj); + info->value =g_malloc0 (sizeof (*info->value)); + info->value->device =g_strdup (bs->device_name); + info->value->type =g_strdup ("unknown" ); + info->value->locked =bdrv_dev_is_medium_locked (bs); + info->value->removable =bdrv_dev_has_removable_media (bs);if (bdrv_dev_has_removable_media (bs)) { -qdict_put (bs_dict,"tray-open" , -qbool_from_int (bdrv_dev_is_tray_open (bs))); + info->value->has_tray_open = true; + info->value->tray_open =bdrv_dev_is_tray_open (bs); }if (bdrv_iostatus_is_enabled (bs)) { -qdict_put (bs_dict,"io-status" , -qstring_from_str (io_status_name[bs->iostatus])); + info->value->has_io_status = true; + info->value->io_status = bs->iostatus; }if (bs->drv) { -QObject *obj; - - obj =qobject_from_jsonf ("{ 'file': %s, 'ro': %i, 'drv': %s, " -"'encrypted': %i }" , - bs->filename, bs->read_only, - bs->drv->format_name, -bdrv_is_encrypted (bs)); -if (bs->backing_file[0 ] !='\0' ) { -QDict *qdict =qobject_to_qdict (obj); -qdict_put (qdict,"backing_file" , -qstring_from_str (bs->backing_file)); + info->value->has_inserted = true; + info->value->inserted =g_malloc0 (sizeof (*info->value->inserted)); + info->value->inserted->file =g_strdup (bs->filename); + info->value->inserted->ro = bs->read_only; + info->value->inserted->drv =g_strdup (bs->drv->format_name); + info->value->inserted->encrypted = bs->encrypted; +if (bs->backing_file[0 ]) { + info->value->inserted->has_backing_file = true; + info->value->inserted->backing_file =g_strdup (bs->backing_file); } + } -qdict_put_obj (bs_dict,"inserted" , obj); +/* XXX: waiting for the qapi to support GSList */ +if (!cur_item) { + head = cur_item = info; + }else { + cur_item->next = info; + cur_item = info; } -qlist_append_obj (bs_list, bs_obj); } - *ret_data =QOBJECT (bs_list); +return head; }static void bdrv_stats_iter (QObject *data,void *opaque)
block.h +0 -5
@@ -77,11 +77,6 @@ typedef enum { BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP } BlockMonEventAction; -typedef enum { -BLOCK_DEVICE_IO_STATUS_OK ,BLOCK_DEVICE_IO_STATUS_FAILED , -BLOCK_DEVICE_IO_STATUS_NOSPACE ,BLOCK_DEVICE_IO_STATUS_MAX -}BlockIOStatus ; -void bdrv_iostatus_enable (BlockDriverState *bs);void bdrv_iostatus_reset (BlockDriverState *bs);void bdrv_iostatus_disable (BlockDriverState *bs);
block_int.h +2 -1
@@ -29,6 +29,7 @@#include "qemu-queue.h" #include "qemu-coroutine.h" #include "qemu-timer.h" +#include "qapi-types.h" #define BLOCK_FLAG_ENCRYPT 1#define BLOCK_FLAG_COMPAT6 4
@@ -203,7 +204,7 @@ struct BlockDriverState {int cyls, heads, secs, translation;BlockErrorAction on_read_error, on_write_error;bool iostatus_enabled; -BlockIOStatus iostatus; +BlockDeviceIoStatus iostatus;char device_name[32 ];unsigned long *dirty_bitmap;int64_t dirty_count;
hmp.c +42 -0
48 lines not on this page · raw message
hmp.h +1 -0
@@ -26,6 +26,7 @@ void hmp_info_chardev(Monitor *mon);void hmp_info_mice (Monitor *mon);void hmp_info_migrate (Monitor *mon);void hmp_info_cpus (Monitor *mon); +void hmp_info_block (Monitor *mon);void hmp_quit (Monitor *mon,const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict);
monitor.c +1 -10
@@ -2674,8 +2674,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show the block devices", - .user_print = bdrv_info_print, - .mhandler.info_new = bdrv_info, + .mhandler.info = hmp_info_block, }, { .name = "blockstats",
@@ -2961,14 +2960,6 @@ static const mon_cmd_t qmp_cmds[] = {static const mon_cmd_t qmp_query_cmds[] = { { - .name ="block" , - .args_type ="" , - .params ="" , - .help ="show the block devices" , - .user_print = bdrv_info_print, - .mhandler.info_new = bdrv_info, - }, - { .name ="blockstats" , .args_type ="" , .params ="" ,
qapi-schema.json +85 -0
91 lines not on this page · raw message
qmp-commands.hx +6 -0
@@ -1198,6 +1198,12 @@ Example: EQMP + { + .name = "query-block", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_block, + }, + SQMP query-blockstats ----------------
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 18/19 Monitor: do_info(): Drop QMP command handling code
In reply to Luiz CapitulinoPrevious commits converted all existing QMP commands to the QAPI, now each info command does its own QMP call.
Let's then drop all QMP command handling code from do_info().
--- monitor.c | 32 +------------------------------- 1 files changed, 1 insertions(+), 31 deletions(-)
monitor.c +1 -31
@@ -123,8 +123,6 @@ typedef struct mon_cmd_t {void (*user_print)(Monitor *mon,const QObject *data);union {void (*info)(Monitor *mon); -void (*info_new)(Monitor *mon,QObject **ret_data); -int (*info_async)(Monitor *mon,MonitorCompletion *cb,void *opaque);void (*cmd)(Monitor *mon,const QDict *qdict);int (*cmd_new)(Monitor *mon,const QDict *params,QObject **ret_data); int (*cmd_async)(Monitor *mon, const QDict *params,
@@ -679,21 +677,6 @@ 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 =g_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); -g_free (cb_data); - } -} -static void do_info (Monitor *mon,const QDict *qdict) {const mon_cmd_t *cmd;
@@ -712,20 +695,7 @@ static void do_info(Monitor *mon, const QDict *qdict) 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); - } - + cmd->mhandler.info (mon);return ; help:
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 9/19 block: Rename the BlockIOStatus enum values
In reply to Luiz CapitulinoThe biggest change is to rename its prefix from BDRV_IOS to BLOCK_DEVICE_IO_STATUS.
Next commit will convert the query-block command to the QAPI and that's how the enumeration is going to be generated.
--- block.c | 18 ++++++++++-------- block.h | 3 ++- 2 files changed, 12 insertions(+), 9 deletions(-)
block.c +10 -8
@@ -1870,10 +1870,10 @@ void bdrv_info_print(Monitor *mon, const QObject *data)qlist_iter (qobject_to_qlist (data), bdrv_print_dict, mon); } -static const char *const io_status_name[BDRV_IOS_MAX ] = { - [BDRV_IOS_OK ] ="ok" , - [BDRV_IOS_FAILED ] ="failed" , - [BDRV_IOS_ENOSPC ] ="nospace" , +static const char *const io_status_name[BLOCK_DEVICE_IO_STATUS_MAX ] = { + [BLOCK_DEVICE_IO_STATUS_OK ] ="ok" , + [BLOCK_DEVICE_IO_STATUS_FAILED ] ="failed" , + [BLOCK_DEVICE_IO_STATUS_NOSPACE ] ="nospace" , };void bdrv_info (Monitor *mon,QObject **ret_data)
@@ -3140,7 +3140,7 @@ int bdrv_in_use(BlockDriverState *bs)void bdrv_iostatus_enable (BlockDriverState *bs) { bs->iostatus_enabled = true; - bs->iostatus =BDRV_IOS_OK ; + bs->iostatus =BLOCK_DEVICE_IO_STATUS_OK ; }/* The I/O status is only enabled if the drive explicitly
@@ -3161,7 +3161,7 @@ void bdrv_iostatus_disable(BlockDriverState *bs)void bdrv_iostatus_reset (BlockDriverState *bs) {if (bdrv_iostatus_is_enabled (bs)) { - bs->iostatus =BDRV_IOS_OK ; + bs->iostatus =BLOCK_DEVICE_IO_STATUS_OK ; } }
@@ -3170,9 +3170,11 @@ void bdrv_iostatus_reset(BlockDriverState *bs)possible to implement this without device models being involved */ void bdrv_iostatus_set_err (BlockDriverState *bs,int error) { -if (bdrv_iostatus_is_enabled (bs) && bs->iostatus ==BDRV_IOS_OK ) { +if (bdrv_iostatus_is_enabled (bs) && + bs->iostatus ==BLOCK_DEVICE_IO_STATUS_OK ) {assert (error >=0 ); - bs->iostatus = error ==ENOSPC ?BDRV_IOS_ENOSPC :BDRV_IOS_FAILED ; + bs->iostatus = error ==ENOSPC ?BLOCK_DEVICE_IO_STATUS_NOSPACE : +BLOCK_DEVICE_IO_STATUS_FAILED ; } }
block.h +2 -1
@@ -78,7 +78,8 @@ typedef enum { } BlockMonEventAction;typedef enum { -BDRV_IOS_OK ,BDRV_IOS_FAILED ,BDRV_IOS_ENOSPC ,BDRV_IOS_MAX +BLOCK_DEVICE_IO_STATUS_OK ,BLOCK_DEVICE_IO_STATUS_FAILED , +BLOCK_DEVICE_IO_STATUS_NOSPACE ,BLOCK_DEVICE_IO_STATUS_MAX }BlockIOStatus ;void bdrv_iostatus_enable (BlockDriverState *bs);
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 17/19 QMP: Drop the query commands dispatch table
In reply to Luiz CapitulinoBecause QMP development originated in the monitor, it has inherited the monitor's distinction between query- and non-query commands.
However, previous commits unified both commands and the distinction is gone. This commit drops the query commands dispatch table and does some simplifications along the way.
--- monitor.c | 63 ++++-------------------------------------------------------- 1 files changed, 5 insertions(+), 58 deletions(-)
monitor.c +5 -58
@@ -205,7 +205,6 @@ static const mon_cmd_t mon_cmds[];static const mon_cmd_t info_cmds[];static const mon_cmd_t qmp_cmds[]; -static const mon_cmd_t qmp_query_cmds[];Monitor *cur_mon;Monitor *default_mon;
@@ -663,11 +662,6 @@ static int qmp_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd,return cmd->mhandler.cmd_async (mon, params, qmp_monitor_complete, mon); } -static void qmp_async_info_handler (Monitor *mon,const mon_cmd_t *cmd) -{ - cmd->mhandler.info_async (mon, qmp_monitor_complete, mon); -} -static void user_async_cmd_handler (Monitor *mon,const mon_cmd_t *cmd,const QDict *params) {
@@ -738,32 +732,16 @@ help:help_cmd (mon,"info" ); } -static CommandInfoList *alloc_cmd_entry (const char *cmd_name) -{ -CommandInfoList *info; - - info =g_malloc0 (sizeof (*info)); - info->value =g_malloc0 (sizeof (*info->value)); - info->value->name =g_strdup (cmd_name); - -return info; -} -CommandInfoList *qmp_query_commands (Error **errp) {CommandInfoList *info, *cmd_list =NULL ;const mon_cmd_t *cmd;for (cmd = qmp_cmds; cmd->name !=NULL ; cmd++) { - info =alloc_cmd_entry (cmd->name); - info->next = cmd_list; - cmd_list = info; - } + info =g_malloc0 (sizeof (*info)); + info->value =g_malloc0 (sizeof (*info->value)); + info->value->name =g_strdup (cmd->name); -for (cmd = qmp_query_cmds; cmd->name !=NULL ; cmd++) { -char buf[128 ]; -snprintf (buf,sizeof (buf),"query-%s" , cmd->name); - info =alloc_cmd_entry (buf); info->next = cmd_list; cmd_list = info; }
@@ -2952,10 +2930,6 @@ static const mon_cmd_t qmp_cmds[] = { { /* NULL */ }, }; -static const mon_cmd_t qmp_query_cmds[] = { - {/* NULL */ }, -}; -/*******************************************************************/ static const char *pch;
@@ -3750,11 +3724,6 @@ static const mon_cmd_t *monitor_find_command(const char *cmdname)return search_dispatch_table (mon_cmds, cmdname); } -static const mon_cmd_t *qmp_find_query_cmd (const char *info_item) -{ -return search_dispatch_table (qmp_query_cmds, info_item); -} -static const mon_cmd_t *qmp_find_cmd (const char *cmdname) {return search_dispatch_table (qmp_cmds, cmdname);
@@ -4678,22 +4647,6 @@ static QDict *qmp_check_input_obj(QObject *input_obj)return input_dict; } -static void qmp_call_query_cmd (Monitor *mon,const mon_cmd_t *cmd) -{ -QObject *ret_data =NULL ; - -if (handler_is_async (cmd)) { -qmp_async_info_handler (mon, cmd); -if (monitor_has_error (mon)) { -monitor_protocol_emitter (mon,NULL ); - } - }else { - cmd->mhandler.info_new (mon, &ret_data); -monitor_protocol_emitter (mon, ret_data); -qobject_decref (ret_data); - } -} -static void qmp_call_cmd (Monitor *mon,const mon_cmd_t *cmd,const QDict *params) {
@@ -4714,10 +4667,9 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)QObject *obj;QDict *input, *args;const mon_cmd_t *cmd; +const char *cmd_name;Monitor *mon = cur_mon; -const char *cmd_name, *query_cmd; - query_cmd =NULL ; args = input =NULL ; obj =json_parser_parse (tokens,NULL );
@@ -4744,9 +4696,6 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) } cmd =qmp_find_cmd (cmd_name); -if (!cmd &&strstart (cmd_name,"query-" , &query_cmd)) { - cmd =qmp_find_query_cmd (query_cmd); - }if (!cmd) {qerror_report (QERR_COMMAND_NOT_FOUND , cmd_name); goto err_out;
@@ -4765,9 +4714,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) goto err_out; } -if (query_cmd) { -qmp_call_query_cmd (mon, cmd); - }else if (handler_is_async (cmd)) { +if (handler_is_async (cmd)) { err =qmp_async_cmd_handler (mon, cmd, args);if (err) {/* emit the error response */
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 16/19 qapi: Convert query-pci
In reply to Luiz CapitulinoThis also fixes a bug with the old version: QMP would invert device id and vendor id. This would look ok on HMP because it was printing "device:vendor" instead of "vendor:device".
--- hmp.c | 101 +++++++++++++++++ hmp.h | 1 + hw/pci-stub.c | 15 +-- hw/pci.c | 322 ++++++++++++++++++++---------------------------------- hw/pci.h | 4 - monitor.c | 11 +-- qapi-schema.json | 128 +++++++++++++++++++++ qmp-commands.hx | 6 + 8 files changed, 363 insertions(+), 225 deletions(-)
hmp.c +101 -0
@@ -388,6 +388,107 @@ void hmp_info_balloon(Monitor *mon)qapi_free_BalloonInfo (info); } +static void hmp_info_pci_device (Monitor *mon,const PciDeviceInfo *dev) +{ +PciMemoryRegionList *region; + +monitor_printf (mon," Bus %2" PRId64", " , dev->bus); +monitor_printf (mon,"device %3" PRId64", function %" PRId64":\n" , + dev->slot, dev->function); +monitor_printf (mon," " ); + +if (dev->class_info.has_desc) { +monitor_printf (mon,"%s" , dev->class_info.desc); + }else { +monitor_printf (mon,"Class %04" PRId64, dev->class_info.class); + } + +monitor_printf (mon,": PCI device %04" PRIx64":%04" PRIx64"\n" , + dev->id.vendor, dev->id.device); + +if (dev->has_irq) { +monitor_printf (mon," IRQ %" PRId64".\n" , dev->irq); + } + +if (dev->has_pci_bridge) { +monitor_printf (mon," BUS %" PRId64".\n" , + dev->pci_bridge->bus.number); +monitor_printf (mon," secondary bus %" PRId64".\n" , + dev->pci_bridge->bus.secondary); +monitor_printf (mon," subordinate bus %" PRId64".\n" , + dev->pci_bridge->bus.subordinate); + +monitor_printf (mon," IO range [0x%04" PRIx64", 0x%04" PRIx64"]\n" , + dev->pci_bridge->bus.io_range->base, + dev->pci_bridge->bus.io_range->limit); + +monitor_printf (mon, +" memory range [0x%08" PRIx64", 0x%08" PRIx64"]\n" , + dev->pci_bridge->bus.memory_range->base, + dev->pci_bridge->bus.memory_range->limit); + +monitor_printf (mon," prefetchable memory range " +"[0x%08" PRIx64", 0x%08" PRIx64"]\n" , + dev->pci_bridge->bus.prefetchable_range->base, + dev->pci_bridge->bus.prefetchable_range->limit); + } + +for (region = dev->regions; region; region = region->next) { +uint64_t addr, size; + + addr = region->value->address; + size = region->value->size; + +monitor_printf (mon," BAR%" PRId64": " , region->value->bar); + +if (!strcmp (region->value->type,"io" )) { +monitor_printf (mon,"I/O at 0x%04" PRIx64 +" [0x%04" PRIx64"].\n" , + addr, addr + size -1 ); + }else { +monitor_printf (mon,"%d bit%s memory at 0x%08" PRIx64 +" [0x%08" PRIx64"].\n" , + region->value->mem_type_64 ?64 :32 , + region->value->prefetch ?" prefetchable" :"" , + addr, addr + size -1 ); + } + } + +monitor_printf (mon," id \"%s\"\n" , dev->qdev_id); + +if (dev->has_pci_bridge) { +if (dev->pci_bridge->has_devices) { +PciDeviceInfoList *cdev; +for (cdev = dev->pci_bridge->devices; cdev; cdev = cdev->next) { +hmp_info_pci_device (mon, cdev->value); + } + } + } +} + +void hmp_info_pci (Monitor *mon) +{ +PciInfoList *info; +Error *err =NULL ; + + info =qmp_query_pci (&err); +if (err) { +monitor_printf (mon,"PCI devices not supported\n" ); +error_free (err); +return ; + } + +for (; info; info = info->next) { +PciDeviceInfoList *dev; + +for (dev = info->value->devices; dev; dev = dev->next) { +hmp_info_pci_device (mon, dev->value); + } + } + +qapi_free_PciInfoList (info); +} +void hmp_quit (Monitor *mon,const QDict *qdict) {monitor_suspend (mon);
hmp.h +1 -0
@@ -31,6 +31,7 @@ void hmp_info_blockstats(Monitor *mon);void hmp_info_vnc (Monitor *mon);void hmp_info_spice (Monitor *mon);void hmp_info_balloon (Monitor *mon); +void hmp_info_pci (Monitor *mon);void hmp_quit (Monitor *mon,const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict);
hw/pci-stub.c +6 -9
@@ -21,20 +21,17 @@#include "sysemu.h" #include "monitor.h" #include "pci.h" +#include "qmp-commands.h" -static void pci_error_message (Monitor *mon) +PciInfoList *qmp_query_pci (Error **errp) { -monitor_printf (mon,"PCI devices not supported\n" ); +error_set (errp,QERR_UNSUPPORTED ); +return NULL ; } -void do_pci_info (Monitor *mon,QObject **ret_data) -{ -pci_error_message (mon); -} - -void do_pci_info_print (Monitor *mon,const QObject *data) +static void pci_error_message (Monitor *mon) { -pci_error_message (mon); +monitor_printf (mon,"PCI devices not supported\n" ); } int do_pcie_aer_inejct_error(Monitor *mon,
hw/pci.c +120 -202
404 lines not on this page · raw message
hw/pci.h +0 -4
@@ -2,7 +2,6 @@#define QEMU_PCI_H #include "qemu-common.h" -#include "qobject.h" #include "qdev.h" #include "memory.h"
@@ -271,9 +270,6 @@ 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,QObject **ret_data); -void pci_device_deassert_intx (PCIDevice *dev); static inline void
monitor.c +1 -10
@@ -2738,8 +2738,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show PCI info", - .user_print = do_pci_info_print, - .mhandler.info_new = do_pci_info, + .mhandler.info = hmp_info_pci, },#if defined(TARGET_I386 ) || defined(TARGET_SH4 ) || defined(TARGET_SPARC ) || \ defined(TARGET_PPC )
@@ -2954,14 +2953,6 @@ static const mon_cmd_t qmp_cmds[] = { };static const mon_cmd_t qmp_query_cmds[] = { - { - .name ="pci" , - .args_type ="" , - .params ="" , - .help ="show PCI info" , - .user_print = do_pci_info_print, - .mhandler.info_new = do_pci_info, - }, {/* NULL */ }, };
qapi-schema.json +128 -0
134 lines not on this page · raw message
qmp-commands.hx +6 -0
@@ -1576,6 +1576,12 @@ Note: This example has been shortened as the real response is too long. EQMP + { + .name = "query-pci", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_pci, + }, + SQMP query-kvm ---------
Signature · 1 line
1.7.7.1.475.g997a1
PATCH 3/19 qapi: Convert query-migrate
In reply to Luiz Capitulino--- hmp.c | 31 ++++++++++++++++++++ hmp.h | 1 + migration.c | 82 +++++++++++++++-------------------------------------- monitor.c | 11 +------ qapi-schema.json | 50 +++++++++++++++++++++++++++++++++ qmp-commands.hx | 6 ++++ 6 files changed, 112 insertions(+), 69 deletions(-)
hmp.c +31 -0
@@ -114,6 +114,37 @@ void hmp_info_mice(Monitor *mon)qapi_free_MouseInfoList (mice_list); } +void hmp_info_migrate (Monitor *mon) +{ +MigrationInfo *info; + + info =qmp_query_migrate (NULL ); + +if (info->has_status) { +monitor_printf (mon,"Migration status: %s\n" , info->status); + } + +if (info->has_ram) { +monitor_printf (mon,"transferred ram: %" PRIu64" kbytes\n" , + info->ram->transferred >>10 ); +monitor_printf (mon,"remaining ram: %" PRIu64" kbytes\n" , + info->ram->remaining >>10 ); +monitor_printf (mon,"total ram: %" PRIu64" kbytes\n" , + info->ram->total >>10 ); + } + +if (info->has_disk) { +monitor_printf (mon,"transferred disk: %" PRIu64" kbytes\n" , + info->disk->transferred >>10 ); +monitor_printf (mon,"remaining disk: %" PRIu64" kbytes\n" , + info->disk->remaining >>10 ); +monitor_printf (mon,"total disk: %" PRIu64" kbytes\n" , + info->disk->total >>10 ); + } + +qapi_free_MigrationInfo (info); +} +void hmp_quit (Monitor *mon,const QDict *qdict) {monitor_suspend (mon);
hmp.h +1 -0
@@ -24,6 +24,7 @@ void hmp_info_status(Monitor *mon);void hmp_info_uuid (Monitor *mon);void hmp_info_chardev (Monitor *mon);void hmp_info_mice (Monitor *mon); +void hmp_info_migrate (Monitor *mon);void hmp_quit (Monitor *mon,const QDict *qdict);void hmp_stop (Monitor *mon,const QDict *qdict);void hmp_system_reset (Monitor *mon,const QDict *qdict);
migration.c +23 -59
113 lines not on this page · raw message
monitor.c +1 -10
@@ -2999,8 +2999,7 @@ static const mon_cmd_t info_cmds[] = { .args_type = "", .params = "", .help = "show migration status", - .user_print = do_info_migrate_print, - .mhandler.info_new = do_info_migrate, + .mhandler.info = hmp_info_migrate, }, { .name = "balloon",
@@ -3110,14 +3109,6 @@ static const mon_cmd_t qmp_query_cmds[] = { },#endif { - .name = "migrate", - .args_type = "", - .params = "", - .help = "show migration status", - .user_print = do_info_migrate_print, - .mhandler.info_new = do_info_migrate, - }, - { .name = "balloon", .args_type = "", .params = "",
qapi-schema.json +50 -0
56 lines not on this page · raw message
qmp-commands.hx +6 -0
@@ -1919,6 +1919,12 @@ Examples: EQMP + { + .name = "query-migrate", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_migrate, + }, + SQMP query-balloon -------------
Signature · 1 line
1.7.7.1.475.g997a1
Quoted 9 lines · Luiz Capitulino
Anthony,
This pull request contains only my "QAPI conversions round 2" series (which got no review comments... last chance!).
The changes (since
9f60639b848944200c3d33a89233d808de0b5a43) are available in the following repository:
git://repo.or.cz/qemu/qmp-unstable.gitqueue/qmp
Pulled. Thanks.
Regards,
Anthony Liguori
Quoted 53 lines
Luiz Capitulino (19):
qapi-commands.py: Don't call the output marshal on error
qapi: Convert query-mice
qapi: Convert query-migrate
Monitor: Makemon_set_cpu()public
Monitor: Introducemonitor_get_cpu_index()
qapi: Convert the cpu command
qapi: Convert query-cpus
block: iostatus: DropBDRV_IOS_INVAL
block: Rename the BlockIOStatus enum values
qapi: Convert query-block
qapi: Convert query-blockstats
qerror: Add a user string forQERR_FEATURE_DISABLED
qapi: Convert query-vnc
qapi: Convert query-spice
qapi: Convert query-balloon
qapi: Convert query-pci
QMP: Drop the query commands dispatch table
Monitor:do_info(): Drop QMP command handling code Dropqemu-objects.hfrom modules that don't require itballoon.c | 72 +----- balloon.h | 6 +- block.c | 234 ++++++------------ block.h | 5 - block_int.h | 4 +- console.h | 9 - cpus.c | 45 ++++ error.c | 3 +- hmp-commands.hx | 3 +- hmp.c | 407 ++++++++++++++++++++++++++++++ hmp.h | 10 + hw/pci-stub.c | 15 +- hw/pci.c | 322 +++++++++--------------- hw/pci.h | 4 - hw/virtio-balloon.c | 78 +----- input.c | 64 ++---- migration.c | 82 ++----- monitor.c | 313 ++---------------------- monitor.h | 2 + qapi-schema.json | 616 ++++++++++++++++++++++++++++++++++++++++++++++ qerror.c | 4 + qmp-commands.hx | 60 +++++- qmp.c | 27 ++ scripts/qapi-commands.py | 4 +- ui/spice-core.c | 139 +++++------ ui/vnc.c | 135 +++++++---- vl.c | 2 +- 27 files changed, 1611 insertions(+), 1054 deletions(-)