Extract qmp.c and monitor.c core and wire QMP into qemu-nbd
Subsystems (2)
v2 cover Extract qmp.c and monitor.c core and wire QMP into qemu-nbd
In v2:
Applied Eric's suggestions
Applied Eric's Rev By
changed my personal email into my company email
Benoît Canet (26):
qmp: Extract system emulation related code from qmp.c into
qmp-system.c
monitor: Make some function public
monitor: Convert Monitor reset_seen field too boolean
monitor: Convert mon_cmd_t to MonitorCommand
monitor: Extract monitor-system.h header
monitor: Make monitor_fprintf public before extracting it
monitor: Extract monitor_fprintf to monitor-system.c
monitor: Extract qmp_human_monitor_command into monitor-system.c
monitor: Make some function to extract public
monitor: Extract a couple of function to monitor-system.c
monitor: Make do_info_help public
monitor: Extract do_info_help in monitor-system.c
monitor: Make some monitor functions public before moving them in
monitor-system.c
monitor: Make do_loadvm public before moving it to monitor-system.c
monitor: Move do_loadvm from monitor.c to monitor-system.c
monitor: Make commands public before moving them to monitor-system.c
monitor: Move MonitorCommand arrays and some function from monitor.c
to monitor-system.c
monitor: Move more functions from monitor.c to monitor-system.c
monitor: Move two net functions from monitor.c to monitor-system.c
monitor: Move qmp_rtc_reset_reinjection from monitor.c to
monitor-system.c
monitor-system: Switch back functions to static
monitor: Extract hardware dependent completion function from monitor.c
to monitor-system.c
monitor: Cleanup monitor.c includes after extracting monitor-system.c
qemu-nbd: build QAPI block core into qemu-nbd
qapi: Add a script to filter qmp-commands-old.h to generate a subset
of it.
qemu-nbd: Add --qmp option to qemu-nbd.
Makefile | 40 +- Makefile.objs | 15 +- Makefile.target | 1 + block/Makefile.objs | 11 +- include/monitor/monitor-init.h | 34 + include/monitor/monitor-system.h | 99 + include/monitor/monitor.h | 10 + monitor-init.c | 121 + monitor-system.c | 2807 +++++++++++++++++++++ monitor.c | 3525 +++------------------------ qapi/Makefile.objs | 2 + qemu-nbd.c | 33 +- qmp-system.c | 376 +++ qmp.c | 361 +-- qobject/Makefile.objs | 2 + qom/Makefile.objs | 8 +- scripts/filter_qmp_commands_old.py | 93 + stubs/Makefile.objs | 15 + stubs/arch-type.c | 3 + stubs/autostart.c | 1 + stubs/cpus-list.c | 3 + stubs/get-double.c | 8 + stubs/get-expr.c | 8 + stubs/kvm-allowed.c | 3 + stubs/kvm-cpu-synchronize-post-init.c | 5 + stubs/kvm-cpu-synchronize-state.c | 5 + stubs/qemu-add-machine-init-done-notifier.c | 5 + stubs/qemu-chr-open-msmouse.c | 7 + stubs/runstate-is-running.c | 6 + stubs/serial-hds.c | 3 + stubs/vmstate-info-buffer.c | 8 + stubs/vmstate-info-uint32.c | 8 + util/Makefile.objs | 2 + vl.c | 88 +- 34 files changed, 4088 insertions(+), 3628 deletions(-) create mode 100644 include/monitor/monitor-init.h create mode 100644 include/monitor/monitor-system.h create mode 100644 monitor-init.c create mode 100644 monitor-system.c create mode 100644 qmp-system.c create mode 100755 scripts/filter_qmp_commands_old.py create mode 100644 stubs/arch-type.c create mode 100644 stubs/autostart.c create mode 100644 stubs/cpus-list.c create mode 100644 stubs/get-double.c create mode 100644 stubs/get-expr.c create mode 100644 stubs/kvm-allowed.c create mode 100644 stubs/kvm-cpu-synchronize-post-init.c create mode 100644 stubs/kvm-cpu-synchronize-state.c create mode 100644 stubs/qemu-add-machine-init-done-notifier.c create mode 100644 stubs/qemu-chr-open-msmouse.c create mode 100644 stubs/runstate-is-running.c create mode 100644 stubs/serial-hds.c create mode 100644 stubs/vmstate-info-buffer.c create mode 100644 stubs/vmstate-info-uint32.c
Signature · 1 line
2.1.0.rc1
PATCH v2 1/26 qmp: Extract system emulation related code from qmp.c into qmp-system.c
This patch will allow linking qmp.o with utility binaries without dragging in too many unrelated object files and external dependencies.
--- Makefile.objs | 2 +- qmp-system.c | 376 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ qmp.c | 361 +------------------------------------------------------ 3 files changed, 379 insertions(+), 360 deletions(-) create mode 100644 qmp-system.c
Makefile.objs +1 -1
@@ -85,7 +85,7 @@ common-obj-$(CONFIG_SMARTCARD_NSS) += $(libcacard-y) # qapi common-obj-y += qmp-marshal.o -common-obj-y += qmp.o hmp.o +common-obj-y += qmp.o qmp-system.o hmp.o endif ######################################################################
qmp-system.c new file +376 -0
376 lines not on this page · raw message
qmp.c +2 -359
400 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 2/26 monitor: Make some function public
In reply to Benoît CanetNext commits will split monitor.c to monitor.c and monitor-system.c.
Change some functions from static to public in order to prepare for this.
--- include/monitor/monitor.h | 10 ++++++++++ monitor.c | 24 ++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-)
include/monitor/monitor.h +10 -0
@@ -66,5 +66,15 @@ int monitor_fdset_get_fd(int64_t fdset_id, int flags);int monitor_fdset_dup_fd_add (int64_t fdset_id,int dup_fd);int monitor_fdset_dup_fd_remove (int dup_fd);int monitor_fdset_dup_fd_find (int dup_fd); +int monitor_ctrl_mode (const Monitor *mon); +void monitor_data_init (Monitor *mon); +int compare_cmd (const char *name,const char *list); +int parse_cmdline (const char *cmdline,int *pnb_args,char **args); +void free_cmdline_args (char **args,int nb_args); +void handle_user_command (Monitor *mon,const char *cmdline); +void add_completion_option (ReadLineState *rs,const char *str, +const char *option); +void monitor_user_noop (Monitor *mon,const QObject *data); +int do_qmp_capabilities (Monitor *mon,const QDict *params,QObject **ret_data);#endif /* !MONITOR_H */
monitor.c +10 -14
@@ -241,7 +241,7 @@ static inline int qmp_cmd_mode(const Monitor *mon) }/* Return true if in control mode, false otherwise */ -static inline int monitor_ctrl_mode (const Monitor *mon) +inline int monitor_ctrl_mode (const Monitor *mon) {return (mon->flags &MONITOR_USE_CONTROL ); }
@@ -389,7 +389,7 @@ static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,return 0 ; } -static void monitor_user_noop (Monitor *mon,const QObject *data) { } +void monitor_user_noop (Monitor *mon,const QObject *data) { }static inline int handler_is_qobject (const mon_cmd_t *cmd) {
@@ -593,8 +593,7 @@ static void monitor_qapi_event_init(void)qmp_event_set_func_emit (monitor_qapi_event_queue); } -static int do_qmp_capabilities (Monitor *mon,const QDict *params, -QObject **ret_data) +int do_qmp_capabilities (Monitor *mon,const QDict *params,QObject **ret_data) {/* Will setup QMP capabilities in the future */ if (monitor_ctrl_mode (mon)) {
@@ -604,9 +603,7 @@ static int do_qmp_capabilities(Monitor *mon, const QDict *params,return 0 ; } -static void handle_user_command (Monitor *mon,const char *cmdline); - -static void monitor_data_init (Monitor *mon) +void monitor_data_init (Monitor *mon) {memset (mon,0 ,sizeof (Monitor));qemu_mutex_init (&mon->out_lock);
@@ -659,7 +656,7 @@ out:return output; } -static int compare_cmd (const char *name,const char *list) +int compare_cmd (const char *name,const char *list) {const char *p, *pstart;int len;
@@ -747,7 +744,7 @@ static int get_str(char *buf, int buf_size, const char **pp)#define MAX_ARGS 16 -static void free_cmdline_args (char **args,int nb_args) +void free_cmdline_args (char **args,int nb_args) {int i;
@@ -772,8 +769,7 @@ static void free_cmdline_args(char **args, int nb_args)* of args have a limit of MAX_ARGS. If cmdline contains more, it will * return with failure. */ -static int parse_cmdline (const char *cmdline, -int *pnb_args,char **args) +int parse_cmdline (const char *cmdline,int *pnb_args,char **args) {const char *p;int nb_args, ret;
@@ -4093,7 +4089,7 @@ static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret) } } -static void handle_user_command (Monitor *mon,const char *cmdline) +void handle_user_command (Monitor *mon,const char *cmdline) {QDict *qdict;const mon_cmd_t *cmd;
@@ -4230,8 +4226,8 @@ static const char *next_arg_type(const char *typestr)return (p !=NULL ? ++p : typestr); } -static void add_completion_option (ReadLineState *rs,const char *str, -const char *option) +void add_completion_option (ReadLineState *rs,const char *str, +const char *option) {if (!str || !option) {return ;
Signature · 1 line
2.1.0.rc1
PATCH v2 3/26 monitor: Convert Monitor reset_seen field too boolean
In reply to Benoît Canet--- monitor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
monitor.c +3 -2
@@ -191,7 +191,7 @@ typedef struct MonitorQAPIEventState {struct Monitor {CharDriverState *chr; -int reset_seen; +bool reset_seen;int flags;int suspend_cnt;bool skip_flush;
@@ -606,6 +606,7 @@ int do_qmp_capabilities(Monitor *mon, const QDict *params, QObject **ret_data)void monitor_data_init (Monitor *mon) {memset (mon,0 ,sizeof (Monitor)); + mon->reset_seen = false;qemu_mutex_init (&mon->out_lock); mon->outbuf =qstring_new ();/* Use *mon_cmds by default. */
@@ -5242,7 +5243,7 @@ static void monitor_event(void *opaque, int event)if (!mon->mux_out) {readline_show_prompt (mon->rs); } - mon->reset_seen =1 ; + mon->reset_seen = true; mon_refcount++;break ;
Signature · 1 line
2.1.0.rc1
PATCH v2 4/26 monitor: Convert mon_cmd_t to MonitorCommand
In reply to Benoît Canet--- monitor.c | 68 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 34 deletions(-)
monitor.c +34 -34
@@ -123,7 +123,7 @@ struct MonitorCompletionData {void (*user_print)(Monitor *mon,const QObject *data); }; -typedef struct mon_cmd_t { +typedef struct MonitorCommand { const char *name; const char *args_type; const char *params;
@@ -140,9 +140,9 @@ typedef struct mon_cmd_t {* mhandler should be used. If it exist, sub_table[?].mhandler should be * used, and mhandler of 1st level plays the role of help function. */ -struct mon_cmd_t *sub_table; +struct MonitorCommand *sub_table;void (*command_completion)(ReadLineState *rs,int nb_args,const char *str); -} mon_cmd_t; +} MonitorCommand;/* file descriptors passed via SCM_RIGHTS */ typedef struct mon_fd_t mon_fd_t ;
@@ -208,7 +208,7 @@ struct Monitor {CPUState *mon_cpu;BlockDriverCompletionFunc *password_completion_cb;void *password_opaque; -mon_cmd_t *cmd_table; +MonitorCommand *cmd_table;QError *error; QLIST_HEAD(,mon_fd_t) fds;QLIST_ENTRY (Monitor) entry;
@@ -224,10 +224,10 @@ static QLIST_HEAD(mon_list, Monitor) mon_list; static QLIST_HEAD(mon_fdsets, MonFdset) mon_fdsets;static int mon_refcount; -static mon_cmd_t mon_cmds[]; -static mon_cmd_t info_cmds[]; +static MonitorCommand mon_cmds[]; +static MonitorCommand info_cmds[]; -static const mon_cmd_t qmp_cmds[]; +static const MonitorCommand qmp_cmds[];Monitor *cur_mon;Monitor *default_mon;
@@ -391,12 +391,12 @@ static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,void monitor_user_noop (Monitor *mon,const QObject *data) { } -static inline int handler_is_qobject (const mon_cmd_t *cmd) +static inline int handler_is_qobject (const MonitorCommand *cmd) {return cmd->user_print !=NULL ; } -static inline bool handler_is_async (const mon_cmd_t *cmd) +static inline bool handler_is_async (const MonitorCommand *cmd) {return cmd->flags &MONITOR_CMD_ASYNC ; }
@@ -804,7 +804,7 @@ int parse_cmdline(const char *cmdline, int *pnb_args, char **args) }static void help_cmd_dump_one (Monitor *mon, -const mon_cmd_t *cmd, +const MonitorCommand *cmd,char **prefix_args,int prefix_args_nb) {
@@ -817,10 +817,10 @@ static void help_cmd_dump_one(Monitor *mon, }/* @args[@arg_index] is the valid command need to find in @cmds */ -static void help_cmd_dump (Monitor *mon,const mon_cmd_t *cmds, +static void help_cmd_dump (Monitor *mon,const MonitorCommand *cmds,char **args,int nb_args,int arg_index) { -const mon_cmd_t *cmd; +const MonitorCommand *cmd;/* No valid arg need to compare with, dump all in *cmds */ if (arg_index >= nb_args) {
@@ -940,13 +940,13 @@ static void qmp_monitor_complete(void *opaque, QObject *ret_data)monitor_protocol_emitter (opaque, ret_data); } -static int qmp_async_cmd_handler (Monitor *mon,const mon_cmd_t *cmd, +static int qmp_async_cmd_handler (Monitor *mon,const MonitorCommand *cmd,const QDict *params) {return cmd->mhandler.cmd_async (mon, params, qmp_monitor_complete, mon); } -static void user_async_cmd_handler (Monitor *mon,const mon_cmd_t *cmd, +static void user_async_cmd_handler (Monitor *mon,const MonitorCommand *cmd,const QDict *params) {int ret;
@@ -971,7 +971,7 @@ static void do_info_help(Monitor *mon, const QDict *qdict)CommandInfoList *qmp_query_commands (Error **errp) {CommandInfoList *info, *cmd_list =NULL ; -const mon_cmd_t *cmd; +const MonitorCommand *cmd;for (cmd = qmp_cmds; cmd->name !=NULL ; cmd++) { info =g_malloc0 (sizeof (*info));
@@ -2595,7 +2595,7 @@ int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp) }/* Please update hmp-commands.hx when adding or changing commands */ -static mon_cmd_t info_cmds[] = { +static MonitorCommand info_cmds[] = { { .name ="version" , .args_type ="" ,
@@ -2921,12 +2921,12 @@ static mon_cmd_t info_cmds[] = { };/* mon_cmds and info_cmds would be sorted at runtime */ -static mon_cmd_t mon_cmds[] = { +static MonitorCommand mon_cmds[] = { #include "hmp-commands.h" {NULL ,NULL , }, }; -static const mon_cmd_t qmp_cmds[] = { +static const MonitorCommand qmp_cmds[] = { #include "qmp-commands-old.h" {/* NULL */ }, };
@@ -3643,10 +3643,10 @@ static int is_valid_option(const char *c, const char *typestr)return (typestr !=NULL ); } -static const mon_cmd_t *search_dispatch_table (const mon_cmd_t *disp_table, +static const MonitorCommand *search_dispatch_table (const MonitorCommand *disp_table,const char *cmdname) { -const mon_cmd_t *cmd; +const MonitorCommand *cmd;for (cmd = disp_table; cmd->name !=NULL ; cmd++) {if (compare_cmd (cmdname, cmd->name)) {
@@ -3657,7 +3657,7 @@ static const mon_cmd_t *search_dispatch_table(const mon_cmd_t *disp_table,return NULL ; } -static const mon_cmd_t *qmp_find_cmd (const char *cmdname) +static const MonitorCommand *qmp_find_cmd (const char *cmdname) {return search_dispatch_table (qmp_cmds, cmdname); }
@@ -3674,15 +3674,15 @@ static const mon_cmd_t *qmp_find_cmd(const char *cmdname)* Do not assume the returned command points into @table! It doesn't * when the command is a sub-command. */ -static const mon_cmd_t *monitor_parse_command (Monitor *mon, +static const MonitorCommand *monitor_parse_command (Monitor *mon,const char *cmdline,int start, -mon_cmd_t *table, +MonitorCommand *table,QDict *qdict) {const char *p, *typestr;int c; -const mon_cmd_t *cmd; +const MonitorCommand *cmd;char cmdname[256 ];char buf[1024 ];char *key;
@@ -4078,7 +4078,7 @@ void monitor_set_error(Monitor *mon, QError *qerror) } } -static void handler_audit (Monitor *mon,const mon_cmd_t *cmd,int ret) +static void handler_audit (Monitor *mon,const MonitorCommand *cmd,int ret) {if (ret && !monitor_has_error (mon)) {/*
@@ -4093,7 +4093,7 @@ static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)void handle_user_command (Monitor *mon,const char *cmdline) {QDict *qdict; -const mon_cmd_t *cmd; +const MonitorCommand *cmd; qdict =qdict_new ();
@@ -4653,14 +4653,14 @@ void loadvm_completion(ReadLineState *rs, int nb_args, const char *str) }static void monitor_find_completion_by_table (Monitor *mon, -const mon_cmd_t *cmd_table, +const MonitorCommand *cmd_table,char **args,int nb_args) {const char *cmdname;int i;const char *ptype, *str; -const mon_cmd_t *cmd; +const MonitorCommand *cmd;MonitorBlockComplete mbs;if (nb_args <=1 ) {
@@ -4951,7 +4951,7 @@ out:* 3. Each argument provided by the client must have the type expected * by the command */ -static int qmp_check_client_args (const mon_cmd_t *cmd,QDict *client_args) +static int qmp_check_client_args (const MonitorCommand *cmd,QDict *client_args) {int flags, err;QDict *cmd_args;
@@ -5027,7 +5027,7 @@ static QDict *qmp_check_input_obj(QObject *input_obj)return input_dict; } -static void qmp_call_cmd (Monitor *mon,const mon_cmd_t *cmd, +static void qmp_call_cmd (Monitor *mon,const MonitorCommand *cmd,const QDict *params) {int ret;
@@ -5044,7 +5044,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)int err;QObject *obj;QDict *input, *args; -const mon_cmd_t *cmd; +const MonitorCommand *cmd;const char *cmd_name;Monitor *mon = cur_mon;
@@ -5257,14 +5257,14 @@ static void monitor_event(void *opaque, int event)static int compare_mon_cmd (const void *a,const void *b) { -return strcmp (((const mon_cmd_t *)a)->name, - ((const mon_cmd_t *)b)->name); +return strcmp (((const MonitorCommand *)a)->name, + ((const MonitorCommand *)b)->name); }static void sortcmdlist (void ) {int array_num; -int elem_size =sizeof (mon_cmd_t); +int elem_size =sizeof (MonitorCommand); array_num =sizeof (mon_cmds)/elem_size-1 ;qsort ((void *)mon_cmds, array_num, elem_size, compare_mon_cmd);
Signature · 1 line
2.1.0.rc1
PATCH v2 5/26 monitor: Extract monitor-system.h header
In reply to Benoît CanetThis header will allow allow splitting the monitor into two parts.
--- include/monitor/monitor-system.h | 99 ++++++++++++++++++++++++++++++++++++++++ monitor.c | 57 ++--------------------- 2 files changed, 102 insertions(+), 54 deletions(-) create mode 100644 include/monitor/monitor-system.h
include/monitor/monitor-system.h new file +99 -0
@@ -0,0 +1,99 @@ +/* +* QEMU monitor +* +* Copyright (c) 2003-2004 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#ifndef MONITOR_COMMANDS_H +#define MONITOR_COMMANDS_H + +#include "monitor/monitor.h" +#include "qapi/error.h" +#include "qapi/qmp/qlist.h" +#include "qapi/qmp/qstring.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/json-streamer.h" +#include "qapi/qmp/json-parser.h" +#include <qom/object_interfaces.h> +#include "hw/pci/pci.h" + +#include <stdint.h> + +#define MAX_ARGS 16 + +struct MonitorCommand ; + +typedef struct MonitorControl { +QObject *id; +JSONMessageParser parser; +int command_mode; +}MonitorControl ; + +struct Monitor { +CharDriverState *chr; +bool reset_seen; +int flags; +int suspend_cnt; +bool skip_flush; + +QemuMutex out_lock; +QString *outbuf; +guint out_watch; + +/* Read under either BQL or out_lock, written with BQL+out_lock. */ +int mux_out; + +ReadLineState *rs; +MonitorControl *mc; +CPUState *mon_cpu; +BlockDriverCompletionFunc *password_completion_cb; +void *password_opaque; +struct MonitorCommand *cmd_table; +QError *error; + QLIST_HEAD(,mon_fd_t) fds; +QLIST_ENTRY (Monitor) entry; +}; + +typedef struct MonitorCommand { +const char *name; +const char *args_type; +const char *params; +const char *help; +void (*user_print)(Monitor *mon,const QObject *data); +union { +void (*cmd)(Monitor *mon,const QDict *qdict); +int (*cmd_new)(Monitor *mon,const QDict *params,QObject **ret_data); +int (*cmd_async)(Monitor *mon,const QDict *params, +MonitorCompletion *cb,void *opaque); + } mhandler; +int flags; +/* @sub_table is a list of 2nd level of commands. If it do not exist, +* mhandler should be used. If it exist, sub_table[?].mhandler should be +* used, and mhandler of 1st level plays the role of help function. +*/ +struct MonitorCommand *sub_table; +void (*command_completion)(ReadLineState *rs,int nb_args,const char *str); +}MonitorCommand ; + +int get_expr (Monitor *mon,int64_t *pval,const char **pp); +int get_double (Monitor *mon,double *pval,const char **pp); + +#endif
monitor.c +3 -54
93 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 6/26 monitor: Make monitor_fprintf public before extracting it
In reply to Benoît Canet--- disas.c | 10 ---------- include/monitor/monitor.h | 2 ++ monitor.c | 4 ++-- 3 files changed, 4 insertions(+), 12 deletions(-)
disas.c +0 -10
@@ -435,16 +435,6 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,return 0 ; } -static int GCC_FMT_ATTR(2, 3) -monitor_fprintf(FILE *stream, const char *fmt, ...) -{ -va_list ap; -va_start (ap, fmt); -monitor_vprintf ((Monitor *)stream, fmt, ap); -va_end (ap); -return 0 ; -} -/* Disassembler for the monitor. See target_disas for a description of flags. */ void monitor_disas(Monitor *mon, CPUArchState *env,
include/monitor/monitor.h +2 -0
@@ -77,4 +77,6 @@ void add_completion_option(ReadLineState *rs, const char *str,void monitor_user_noop (Monitor *mon,const QObject *data);int do_qmp_capabilities (Monitor *mon,const QDict *params,QObject **ret_data); +int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, const char *fmt, ...); +#endif /* !MONITOR_H */
monitor.c +2 -2
@@ -328,8 +328,8 @@ void monitor_printf(Monitor *mon, const char *fmt, ...)va_end (ap); } -static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, - const char *fmt, ...) +int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, + const char *fmt, ...) {va_list ap;va_start (ap, fmt);
Signature · 1 line
2.1.0.rc1
PATCH v2 7/26 monitor: Extract monitor_fprintf to monitor-system.c
In reply to Benoît Canet--- Makefile.target | 1 + disas.c | 10 ++++++ include/monitor/monitor-system.h | 3 ++ include/monitor/monitor.h | 2 -- monitor-system.c | 69 ++++++++++++++++++++++++++++++++++++++++ monitor.c | 10 ------ 6 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 monitor-system.c
Makefile.target +1 -0
@@ -120,6 +120,7 @@ endif #CONFIG_BSD_USER # System emulator target ifdef CONFIG_SOFTMMU obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o +obj-y += monitor-system.o obj-y += qtest.o obj-y += hw/ obj-$(CONFIG_FDT) += device_tree.o
disas.c +10 -0
@@ -435,6 +435,16 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,return 0 ; } +static int GCC_FMT_ATTR(2, 3) +monitor_fprintf(FILE *stream, const char *fmt, ...) +{ +va_list ap; +va_start (ap, fmt); +monitor_vprintf ((Monitor *)stream, fmt, ap); +va_end (ap); +return 0 ; +} +/* Disassembler for the monitor. See target_disas for a description of flags. */ void monitor_disas(Monitor *mon, CPUArchState *env,
include/monitor/monitor-system.h +3 -0
@@ -96,4 +96,7 @@ typedef struct MonitorCommand {int get_expr (Monitor *mon,int64_t *pval,const char **pp);int get_double (Monitor *mon,double *pval,const char **pp); +int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, + const char *fmt, ...); +#endif
include/monitor/monitor.h +0 -2
@@ -77,6 +77,4 @@ void add_completion_option(ReadLineState *rs, const char *str,void monitor_user_noop (Monitor *mon,const QObject *data);int do_qmp_capabilities (Monitor *mon,const QDict *params,QObject **ret_data); -int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, const char *fmt, ...); -#endif /* !MONITOR_H */
monitor-system.c new file +69 -0
69 lines not on this page · raw message
monitor.c +0 -10
@@ -328,16 +328,6 @@ void monitor_printf(Monitor *mon, const char *fmt, ...)va_end (ap); } -int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, - const char *fmt, ...) -{ -va_list ap; -va_start (ap, fmt); -monitor_vprintf ((Monitor *)stream, fmt, ap); -va_end (ap); -return 0 ; -} -void monitor_user_noop (Monitor *mon,const QObject *data) { }static inline int handler_is_qobject (const MonitorCommand *cmd)
Signature · 1 line
2.1.0.rc1
PATCH v2 8/26 monitor: Extract qmp_human_monitor_command into monitor-system.c
In reply to Benoît Canet--- monitor-system.c | 43 +++++++++++++++++++++++++++++++++++++++++++ monitor.c | 44 -------------------------------------------- 2 files changed, 43 insertions(+), 44 deletions(-)
monitor-system.c +43 -0
@@ -67,3 +67,46 @@ int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,return 0 ; } +static void monitor_data_destroy (Monitor *mon) +{ +QDECREF (mon->outbuf); +qemu_mutex_destroy (&mon->out_lock); +} + +char *qmp_human_monitor_command (const char *command_line,bool has_cpu_index, +int64_t cpu_index,Error **errp) +{ +char *output =NULL ; +Monitor *old_mon, hmp; + +monitor_data_init (&hmp); + hmp.skip_flush = true; + + old_mon = cur_mon; + cur_mon = &hmp; + +if (has_cpu_index) { +int ret =monitor_set_cpu (cpu_index); +if (ret <0 ) { + cur_mon = old_mon; +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"cpu-index" , +"a CPU number" ); + goto out; + } + } + +handle_user_command (&hmp, command_line); + cur_mon = old_mon; + +qemu_mutex_lock (&hmp.out_lock); +if (qstring_get_length (hmp.outbuf) >0 ) { + output =g_strdup (qstring_get_str (hmp.outbuf)); + }else { + output =g_strdup ("" ); + } +qemu_mutex_unlock (&hmp.out_lock); + +out: +monitor_data_destroy (&hmp); +return output; +}
monitor.c +0 -44
50 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 9/26 monitor: Make some function to extract public
In reply to Benoît CanetThe functions made public are: help_cmd, do_help_cmd, do_trace_event_set_state and do_trace_file.
Put the header declaration in monitor/monitor-system.h directly to avoid a type conflict.
--- include/monitor/monitor-system.h | 4 ++++ monitor.c | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-)
include/monitor/monitor-system.h +4 -0
@@ -98,5 +98,9 @@ int get_double(Monitor *mon, double *pval, const char **pp); int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, const char *fmt, ...); +void help_cmd(Monitor *mon, const char *name); +void do_help_cmd(Monitor *mon, const QDict *qdict); +void do_trace_event_set_state(Monitor *mon, const QDict *qdict); +void do_trace_file(Monitor *mon, const QDict *qdict);#endif
monitor.c +4 -4
@@ -740,7 +740,7 @@ static void help_cmd_dump(Monitor *mon, const MonitorCommand *cmds, } } -static void help_cmd (Monitor *mon,const char *name) +void help_cmd (Monitor *mon,const char *name) {char *args[MAX_ARGS ];int nb_args =0 ;
@@ -769,12 +769,12 @@ static void help_cmd(Monitor *mon, const char *name)free_cmdline_args (args, nb_args); } -static void do_help_cmd (Monitor *mon,const QDict *qdict) +void do_help_cmd (Monitor *mon,const QDict *qdict) {help_cmd (mon,qdict_get_try_str (qdict,"name" )); } -static void do_trace_event_set_state (Monitor *mon,const QDict *qdict) +void do_trace_event_set_state (Monitor *mon,const QDict *qdict) {const char *tp_name =qdict_get_str (qdict,"name" );bool new_state =qdict_get_bool (qdict,"option" );
@@ -795,7 +795,7 @@ static void do_trace_event_set_state(Monitor *mon, const QDict *qdict) }#ifdef CONFIG_TRACE_SIMPLE -static void do_trace_file (Monitor *mon,const QDict *qdict) +void do_trace_file (Monitor *mon,const QDict *qdict) {const char *op =qdict_get_try_str (qdict,"op" );const char *arg =qdict_get_try_str (qdict,"arg" );
Signature · 1 line
2.1.0.rc1
PATCH v2 10/26 monitor: Extract a couple of function to monitor-system.c
In reply to Benoît CanetThe extracted function are help_cmd, do_help_cmd, do_trace_event_set_state, and do_trace_file.
--- monitor-system.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 121 ------------------------------------------------------- 2 files changed, 121 insertions(+), 121 deletions(-)
monitor-system.c +121 -0
@@ -110,3 +110,124 @@ out:monitor_data_destroy (&hmp);return output; } + +static void help_cmd_dump_one (Monitor *mon, +const MonitorCommand *cmd, +char **prefix_args, +int prefix_args_nb) +{ +int i; + +for (i =0 ; i < prefix_args_nb; i++) { +monitor_printf (mon,"%s " , prefix_args[i]); + } +monitor_printf (mon,"%s %s -- %s\n" , cmd->name, cmd->params, cmd->help); +} + +/* @args[@arg_index] is the valid command need to find in @cmds */ +static void help_cmd_dump (Monitor *mon,const MonitorCommand *cmds, +char **args,int nb_args,int arg_index) +{ +const MonitorCommand *cmd; + +/* No valid arg need to compare with, dump all in *cmds */ +if (arg_index >= nb_args) { +for (cmd = cmds; cmd->name !=NULL ; cmd++) { +help_cmd_dump_one (mon, cmd, args, arg_index); + } +return ; + } + +/* Find one entry to dump */ +for (cmd = cmds; cmd->name !=NULL ; cmd++) { +if (compare_cmd (args[arg_index], cmd->name)) { +if (cmd->sub_table) { +/* continue with next arg */ +help_cmd_dump (mon, cmd->sub_table, + args, nb_args, arg_index +1 ); + }else { +help_cmd_dump_one (mon, cmd, args, arg_index); + } +break ; + } + } +} + +void help_cmd (Monitor *mon,const char *name) +{ +char *args[MAX_ARGS ]; +int nb_args =0 ; + +/* 1. parse user input */ +if (name) { +/* special case for log, directly dump and return */ +if (!strcmp (name,"log" )) { +const QEMULogItem *item; +monitor_printf (mon,"Log items (comma separated):\n" ); +monitor_printf (mon,"%-10s %s\n" ,"none" ,"remove all logs" ); +for (item = qemu_log_items; item->mask !=0 ; item++) { +monitor_printf (mon,"%-10s %s\n" , item->name, item->help); + } +return ; + } + +if (parse_cmdline (name, &nb_args, args) <0 ) { +return ; + } + } + +/* 2. dump the contents according to parsed args */ +help_cmd_dump (mon, mon->cmd_table, args, nb_args,0 ); + +free_cmdline_args (args, nb_args); +} + +void do_help_cmd (Monitor *mon,const QDict *qdict) +{ +help_cmd (mon,qdict_get_try_str (qdict,"name" )); +} + +void do_trace_event_set_state (Monitor *mon,const QDict *qdict) +{ +const char *tp_name =qdict_get_str (qdict,"name" ); +bool new_state =qdict_get_bool (qdict,"option" ); + +bool found = false; +TraceEvent *ev =NULL ; +while ((ev =trace_event_pattern (tp_name, ev)) !=NULL ) { + found = true; +if (!trace_event_get_state_static (ev)) { +monitor_printf (mon,"event \"%s\" is not traceable\n" , tp_name); + }else { +trace_event_set_state_dynamic (ev, new_state); + } + } +if (!trace_event_is_pattern (tp_name) && !found) { +monitor_printf (mon,"unknown event name \"%s\"\n" , tp_name); + } +} + +#ifdef CONFIG_TRACE_SIMPLE +void do_trace_file (Monitor *mon,const QDict *qdict) +{ +const char *op =qdict_get_try_str (qdict,"op" ); +const char *arg =qdict_get_try_str (qdict,"arg" ); + +if (!op) { +st_print_trace_file_status ((FILE *)mon, &monitor_fprintf); + }else if (!strcmp (op,"on" )) { +st_set_trace_file_enabled (true); + }else if (!strcmp (op,"off" )) { +st_set_trace_file_enabled (false); + }else if (!strcmp (op,"flush" )) { +st_flush_trace_buffer (); + }else if (!strcmp (op,"set" )) { +if (arg) { +st_set_trace_file (arg); + } + }else { +monitor_printf (mon,"unexpected argument \"%s\"\n" , op); +help_cmd (mon,"trace-file" ); + } +} +#endif
monitor.c +0 -121
127 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 11/26 monitor: Make do_info_help public
In reply to Benoît Canet--- include/monitor/monitor-system.h | 1 + monitor.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
include/monitor/monitor-system.h +1 -0
@@ -102,5 +102,6 @@ void help_cmd(Monitor *mon, const char *name);void do_help_cmd (Monitor *mon,const QDict *qdict);void do_trace_event_set_state (Monitor *mon,const QDict *qdict);void do_trace_file (Monitor *mon,const QDict *qdict); +void do_info_help (Monitor *mon,const QDict *qdict);#endif
monitor.c +1 -1
@@ -737,7 +737,7 @@ static void user_async_cmd_handler(Monitor *mon, const MonitorCommand *cmd, } } -static void do_info_help (Monitor *mon,const QDict *qdict) +void do_info_help (Monitor *mon,const QDict *qdict) {help_cmd (mon,"info" ); }
Signature · 1 line
2.1.0.rc1
PATCH v2 12/26 monitor: Extract do_info_help in monitor-system.c
In reply to Benoît Canet--- monitor-system.c | 5 +++++ monitor.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-)
monitor-system.c +5 -0
@@ -231,3 +231,8 @@ void do_trace_file(Monitor *mon, const QDict *qdict) } }#endif + +void do_info_help (Monitor *mon,const QDict *qdict) +{ +help_cmd (mon,"info" ); +}
monitor.c +0 -5
@@ -737,11 +737,6 @@ static void user_async_cmd_handler(Monitor *mon, const MonitorCommand *cmd, } } -void do_info_help (Monitor *mon,const QDict *qdict) -{ -help_cmd (mon,"info" ); -} -CommandInfoList *qmp_query_commands (Error **errp) {CommandInfoList *info, *cmd_list =NULL ;
Signature · 1 line
2.1.0.rc1
PATCH v2 13/26 monitor: Make some monitor functions public before moving them in monitor-system.c
In reply to Benoît CanetThis will allow monitor.c to access these functions once they are moved in monitor-system.c
--- include/monitor/monitor-system.h | 37 ++ monitor-system.c | 1164 ++++++++++++++++++++++++++++++++++++++ monitor.c | 1163 ------------------------------------- 3 files changed, 1201 insertions(+), 1163 deletions(-)
include/monitor/monitor-system.h +37 -0
@@ -104,4 +104,41 @@ void do_trace_event_set_state(Monitor *mon, const QDict *qdict);void do_trace_file (Monitor *mon,const QDict *qdict);void do_info_help (Monitor *mon,const QDict *qdict); +void do_info_registers (Monitor *mon,const QDict *qdict); +void do_info_jit (Monitor *mon,const QDict *qdict); +void do_info_history (Monitor *mon,const QDict *qdict); +void tlb_info (Monitor *mon,const QDict *qdict); +void mem_info (Monitor *mon,const QDict *qdict); +void do_info_mtree (Monitor *mon,const QDict *qdict); +void do_info_numa (Monitor *mon,const QDict *qdict); +void do_info_profile (Monitor *mon,const QDict *qdict); +void do_info_capture (Monitor *mon,const QDict *qdict); +void do_info_cpu_stats (Monitor *mon,const QDict *qdict); +void do_trace_print_events (Monitor *mon,const QDict *qdict); +void do_logfile (Monitor *mon,const QDict *qdict); +void do_log (Monitor *mon,const QDict *qdict); +void do_singlestep (Monitor *mon,const QDict *qdict); +void do_gdbserver (Monitor *mon,const QDict *qdict); +void do_memory_dump (Monitor *mon,const QDict *qdict); +void do_physical_memory_dump (Monitor *mon,const QDict *qdict); +void do_print (Monitor *mon,const QDict *qdict); +void do_ioport_read (Monitor *mon,const QDict *qdict); +void do_ioport_write (Monitor *mon,const QDict *qdict); +void do_sum (Monitor *mon,const QDict *qdict); +void do_mouse_move (Monitor *mon,const QDict *qdict); +void do_mouse_button (Monitor *mon,const QDict *qdict); +void do_wav_capture (Monitor *mon,const QDict *qdict); +void do_stop_capture (Monitor *mon,const QDict *qdict); +void do_boot_set (Monitor *mon,const QDict *qdict); +int client_migrate_info (Monitor *mon,const QDict *qdict, +MonitorCompletion cb,void *opaque); +void do_watchdog_action (Monitor *mon,const QDict *qdict); +void do_acl_show (Monitor *mon,const QDict *qdict); +void do_acl_policy (Monitor *mon,const QDict *qdict); +void do_acl_add (Monitor *mon,const QDict *qdict); +void do_acl_remove (Monitor *mon,const QDict *qdict); +void do_acl_reset (Monitor *mon,const QDict *qdict); +void do_inject_mce (Monitor *mon,const QDict *qdict); +CPUArchState *mon_get_cpu (void ); +#endif
monitor-system.c +1164 -0
1,173 lines not on this page · raw message
monitor.c +0 -1163
1,169 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 14/26 monitor: Make do_loadvm public before moving it to monitor-system.c
In reply to Benoît Canet--- include/monitor/monitor-system.h | 1 + monitor.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
include/monitor/monitor-system.h +1 -0
@@ -140,5 +140,6 @@ void do_acl_remove(Monitor *mon, const QDict *qdict);void do_acl_reset (Monitor *mon,const QDict *qdict);void do_inject_mce (Monitor *mon,const QDict *qdict);CPUArchState *mon_get_cpu (void ); +void do_loadvm (Monitor *mon,const QDict *qdict);#endif
monitor.c +1 -1
@@ -827,7 +827,7 @@ void qmp_closefd(const char *fdname, Error **errp)error_set (errp,QERR_FD_NOT_FOUND , fdname); } -static void do_loadvm (Monitor *mon,const QDict *qdict) +void do_loadvm (Monitor *mon,const QDict *qdict) {int saved_vm_running =runstate_is_running ();const char *name =qdict_get_str (qdict,"name" );
Signature · 1 line
2.1.0.rc1
PATCH v2 15/26 monitor: Move do_loadvm from monitor.c to monitor-system.c
In reply to Benoît Canet--- monitor-system.c | 12 ++++++++++++ monitor.c | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-)
monitor-system.c +12 -0
@@ -1400,3 +1400,15 @@ void do_inject_mce(Monitor *mon, const QDict *qdict) } }#endif + +void do_loadvm (Monitor *mon,const QDict *qdict) +{ +int saved_vm_running =runstate_is_running (); +const char *name =qdict_get_str (qdict,"name" ); + +vm_stop (RUN_STATE_RESTORE_VM ); + +if (load_vmstate (name) ==0 && saved_vm_running) { +vm_start (); + } +}
monitor.c +0 -12
@@ -827,18 +827,6 @@ void qmp_closefd(const char *fdname, Error **errp)error_set (errp,QERR_FD_NOT_FOUND , fdname); } -void do_loadvm (Monitor *mon,const QDict *qdict) -{ -int saved_vm_running =runstate_is_running (); -const char *name =qdict_get_str (qdict,"name" ); - -vm_stop (RUN_STATE_RESTORE_VM ); - -if (load_vmstate (name) ==0 && saved_vm_running) { -vm_start (); - } -} -int monitor_get_fd (Monitor *mon,const char *fdname,Error **errp) {mon_fd_t *monfd;
Signature · 1 line
2.1.0.rc1
PATCH v2 16/26 monitor: Make commands public before moving them to monitor-system.c
In reply to Benoît Canet--- monitor.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
monitor.c +6 -6
@@ -173,10 +173,10 @@ static QLIST_HEAD(mon_list, Monitor) mon_list; static QLIST_HEAD(mon_fdsets, MonFdset) mon_fdsets;static int mon_refcount; -static MonitorCommand mon_cmds[]; -static MonitorCommand info_cmds[]; +MonitorCommand mon_cmds[]; +MonitorCommand info_cmds[]; -static const MonitorCommand qmp_cmds[]; +const MonitorCommand qmp_cmds[];Monitor *cur_mon;Monitor *default_mon;
@@ -1189,7 +1189,7 @@ int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp) }/* Please update hmp-commands.hx when adding or changing commands */ -static MonitorCommand info_cmds[] = { +MonitorCommand info_cmds[] = { { .name ="version" , .args_type ="" ,
@@ -1515,12 +1515,12 @@ static MonitorCommand info_cmds[] = { };/* mon_cmds and info_cmds would be sorted at runtime */ -static MonitorCommand mon_cmds[] = { +MonitorCommand mon_cmds[] = { #include "hmp-commands.h" {NULL ,NULL , }, }; -static const MonitorCommand qmp_cmds[] = { +const MonitorCommand qmp_cmds[] = { #include "qmp-commands-old.h" {/* NULL */ }, };
Signature · 1 line
2.1.0.rc1
PATCH v2 17/26 monitor: Move MonitorCommand arrays and some function from monitor.c to monitor-system.c
In reply to Benoît CanetAlso add sizeof variables for MonitorCommand arrays for cross modules usage.
--- monitor-system.c | 984 ++++++++++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 1010 ++---------------------------------------------------- 2 files changed, 1007 insertions(+), 987 deletions(-)
monitor-system.c +984 -0
@@ -1412,3 +1412,987 @@ void do_loadvm(Monitor *mon, const QDict *qdict)vm_start (); } } + +/* Please update hmp-commands.hx when adding or changing commands */ +MonitorCommand info_cmds[] = { + { + .name ="version" , + .args_type ="" , + .params ="" , + .help ="show the version of QEMU" , + .mhandler.cmd = hmp_info_version, + }, + { + .name ="network" , + .args_type ="" , + .params ="" , + .help ="show the network state" , + .mhandler.cmd = do_info_network, + }, + { + .name ="chardev" , + .args_type ="" , + .params ="" , + .help ="show the character devices" , + .mhandler.cmd = hmp_info_chardev, + }, + { + .name ="block" , + .args_type ="verbose:-v,device:B?" , + .params ="[-v] [device]" , + .help ="show info of one block device or all block devices " +"(and details of images with -v option)" , + .mhandler.cmd = hmp_info_block, + }, + { + .name ="blockstats" , + .args_type ="" , + .params ="" , + .help ="show block device statistics" , + .mhandler.cmd = hmp_info_blockstats, + }, + { + .name ="block-jobs" , + .args_type ="" , + .params ="" , + .help ="show progress of ongoing block device operations" , + .mhandler.cmd = hmp_info_block_jobs, + }, + { + .name ="registers" , + .args_type ="" , + .params ="" , + .help ="show the cpu registers" , + .mhandler.cmd = do_info_registers, + }, + { + .name ="cpus" , + .args_type ="" , + .params ="" , + .help ="show infos for each CPU" , + .mhandler.cmd = hmp_info_cpus, + }, + { + .name ="history" , + .args_type ="" , + .params ="" , + .help ="show the command line history" , + .mhandler.cmd = do_info_history, + }, +#if defined(TARGET_I386) || defined(TARGET_PPC) || defined(TARGET_MIPS) || \ + defined(TARGET_LM32) || (defined(TARGET_SPARC) && !defined(TARGET_SPARC64)) + { + .name ="irq" , + .args_type ="" , + .params ="" , + .help ="show the interrupts statistics (if available)" , +#ifdef TARGET_SPARC + .mhandler.cmd = sun4m_irq_info, +#elif defined(TARGET_LM32) + .mhandler.cmd = lm32_irq_info, +#else + .mhandler.cmd = irq_info, +#endif + }, + { + .name ="pic" , + .args_type ="" , + .params ="" , + .help ="show i8259 (PIC) state" , +#ifdef TARGET_SPARC + .mhandler.cmd = sun4m_pic_info, +#elif defined(TARGET_LM32) + .mhandler.cmd = lm32_do_pic_info, +#else + .mhandler.cmd = pic_info, +#endif + }, +#endif + { + .name ="pci" , + .args_type ="" , + .params ="" , + .help ="show PCI info" , + .mhandler.cmd = hmp_info_pci, + }, +#if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \ + defined(TARGET_PPC) || defined(TARGET_XTENSA) + { + .name ="tlb" , + .args_type ="" , + .params ="" , + .help ="show virtual to physical memory mappings" , + .mhandler.cmd = tlb_info, + }, +#endif +#if defined(TARGET_I386) + { + .name ="mem" , + .args_type ="" , + .params ="" , + .help ="show the active virtual memory mappings" , + .mhandler.cmd = mem_info, + }, +#endif + { + .name ="mtree" , + .args_type ="" , + .params ="" , + .help ="show memory tree" , + .mhandler.cmd = do_info_mtree, + }, + { + .name ="jit" , + .args_type ="" , + .params ="" , + .help ="show dynamic compiler info" , + .mhandler.cmd = do_info_jit, + }, + { + .name ="kvm" , + .args_type ="" , + .params ="" , + .help ="show KVM information" , + .mhandler.cmd = hmp_info_kvm, + }, + { + .name ="numa" , + .args_type ="" , + .params ="" , + .help ="show NUMA information" , + .mhandler.cmd = do_info_numa, + }, + { + .name ="usb" , + .args_type ="" , + .params ="" , + .help ="show guest USB devices" , + .mhandler.cmd = usb_info, + }, + { + .name ="usbhost" , + .args_type ="" , + .params ="" , + .help ="show host USB devices" , + .mhandler.cmd = usb_host_info, + }, + { + .name ="profile" , + .args_type ="" , + .params ="" , + .help ="show profiling information" , + .mhandler.cmd = do_info_profile, + }, + { + .name ="capture" , + .args_type ="" , + .params ="" , + .help ="show capture information" , + .mhandler.cmd = do_info_capture, + }, + { + .name ="snapshots" , + .args_type ="" , + .params ="" , + .help ="show the currently saved VM snapshots" , + .mhandler.cmd = do_info_snapshots, + }, + { + .name ="status" , + .args_type ="" , + .params ="" , + .help ="show the current VM status (running|paused)" , + .mhandler.cmd = hmp_info_status, + }, + { + .name ="pcmcia" , + .args_type ="" , + .params ="" , + .help ="show guest PCMCIA status" , + .mhandler.cmd = pcmcia_info, + }, + { + .name ="mice" , + .args_type ="" , + .params ="" , + .help ="show which guest mouse is receiving events" , + .mhandler.cmd = hmp_info_mice, + }, + { + .name ="vnc" , + .args_type ="" , + .params ="" , + .help ="show the vnc server status" , + .mhandler.cmd = hmp_info_vnc, + }, +#if defined(CONFIG_SPICE) + { + .name ="spice" , + .args_type ="" , + .params ="" , + .help ="show the spice server status" , + .mhandler.cmd = hmp_info_spice, + }, +#endif + { + .name ="name" , + .args_type ="" , + .params ="" , + .help ="show the current VM name" , + .mhandler.cmd = hmp_info_name, + }, + { + .name ="uuid" , + .args_type ="" , + .params ="" , + .help ="show the current VM UUID" , + .mhandler.cmd = hmp_info_uuid, + }, + { + .name ="cpustats" , + .args_type ="" , + .params ="" , + .help ="show CPU statistics" , + .mhandler.cmd = do_info_cpu_stats, + }, +#if defined(CONFIG_SLIRP) + { + .name ="usernet" , + .args_type ="" , + .params ="" , + .help ="show user network stack connection states" , + .mhandler.cmd = do_info_usernet, + }, +#endif + { + .name ="migrate" , + .args_type ="" , + .params ="" , + .help ="show migration status" , + .mhandler.cmd = hmp_info_migrate, + }, + { + .name ="migrate_capabilities" , + .args_type ="" , + .params ="" , + .help ="show current migration capabilities" , + .mhandler.cmd = hmp_info_migrate_capabilities, + }, + { + .name ="migrate_cache_size" , + .args_type ="" , + .params ="" , + .help ="show current migration xbzrle cache size" , + .mhandler.cmd = hmp_info_migrate_cache_size, + }, + { + .name ="balloon" , + .args_type ="" , + .params ="" , + .help ="show balloon information" , + .mhandler.cmd = hmp_info_balloon, + }, + { + .name ="qtree" , + .args_type ="" , + .params ="" , + .help ="show device tree" , + .mhandler.cmd = do_info_qtree, + }, + { + .name ="qdm" , + .args_type ="" , + .params ="" , + .help ="show qdev device model list" , + .mhandler.cmd = do_info_qdm, + }, + { + .name ="roms" , + .args_type ="" , + .params ="" , + .help ="show roms" , + .mhandler.cmd = do_info_roms, + }, + { + .name ="trace-events" , + .args_type ="" , + .params ="" , + .help ="show available trace-events & their state" , + .mhandler.cmd = do_trace_print_events, + }, + { + .name ="tpm" , + .args_type ="" , + .params ="" , + .help ="show the TPM device" , + .mhandler.cmd = hmp_info_tpm, + }, + { + .name ="memdev" , + .args_type ="" , + .params ="" , + .help ="show memory backends" , + .mhandler.cmd = hmp_info_memdev, + }, + { + .name =NULL , + }, +}; + +/* mon_cmds and info_cmds would be sorted at runtime */ +MonitorCommand mon_cmds[] = { +#include "hmp-commands.h" + {NULL ,NULL , }, +}; + +const MonitorCommand qmp_cmds[] = { +#include "qmp-commands-old.h" + {/* NULL */ }, +}; + +/*******************************************************************/ + +static const char *pch; +static sigjmp_buf expr_env; + +#define MD_TLONG 0 +#define MD_I32 1 + +typedef struct MonitorDef { +const char *name; +int offset; +target_long (*get_value)(const struct MonitorDef *md,int val); +int type; +}MonitorDef ; + +#if defined(TARGET_I386 ) +static target_long monitor_get_pc (const struct MonitorDef *md,int val) +{ +CPUArchState *env =mon_get_cpu (); +return env->eip + env->segs[R_CS ].base; +} +#endif + +#if defined(TARGET_PPC ) +static target_long monitor_get_ccr (const struct MonitorDef *md,int val) +{ +CPUArchState *env =mon_get_cpu (); +unsigned int u; +int i; + + u =0 ; +for (i =0 ; i <8 ; i++) + u |= env->crf[i] << (32 - (4 * i)); + +return u; +} + +static target_long monitor_get_msr (const struct MonitorDef *md,int val) +{ +CPUArchState *env =mon_get_cpu (); +return env->msr; +} + +static target_long monitor_get_xer (const struct MonitorDef *md,int val) +{ +CPUArchState *env =mon_get_cpu (); +return env->xer; +} + +static target_long monitor_get_decr (const struct MonitorDef *md,int val) +{ +CPUArchState *env =mon_get_cpu (); +return cpu_ppc_load_decr (env); +} + +static target_long monitor_get_tbu (const struct MonitorDef *md,int val) +{ +CPUArchState *env =mon_get_cpu (); +return cpu_ppc_load_tbu (env); +} + +static target_long monitor_get_tbl (const struct MonitorDef *md,int val) +{ +CPUArchState *env =mon_get_cpu (); +return cpu_ppc_load_tbl (env); +} +#endif + +#if defined(TARGET_SPARC ) +#ifndef TARGET_SPARC64 +static target_long monitor_get_psr (const struct MonitorDef *md,int val) +{ +CPUArchState *env =mon_get_cpu (); + +return cpu_get_psr (env); +} +#endif + +static target_long monitor_get_reg (const struct MonitorDef *md,int val) +{ +CPUArchState *env =mon_get_cpu (); +return env->regwptr[val]; +} +#endif + +static const MonitorDef monitor_defs[] = { +#ifdef TARGET_I386 + +#define SEG(name, seg) \ + { name, offsetof(CPUX86State, segs[seg].selector), NULL, MD_I32 },\ + { name ".base", offsetof(CPUX86State, segs[seg].base) },\ + { name ".limit", offsetof(CPUX86State, segs[seg].limit), NULL, MD_I32 }, + + { "eax", offsetof(CPUX86State, regs[0]) }, + { "ecx", offsetof(CPUX86State, regs[1]) }, + { "edx", offsetof(CPUX86State, regs[2]) }, + { "ebx", offsetof(CPUX86State, regs[3]) }, + { "esp|sp", offsetof(CPUX86State, regs[4]) }, + { "ebp|fp", offsetof(CPUX86State, regs[5]) }, + { "esi", offsetof(CPUX86State, regs[6]) }, + { "edi", offsetof(CPUX86State, regs[7]) }, +#ifdef TARGET_X86_64 + { "r8", offsetof(CPUX86State, regs[8]) }, + { "r9", offsetof(CPUX86State, regs[9]) }, + { "r10", offsetof(CPUX86State, regs[10]) }, + { "r11", offsetof(CPUX86State, regs[11]) }, + { "r12", offsetof(CPUX86State, regs[12]) }, + { "r13", offsetof(CPUX86State, regs[13]) }, + { "r14", offsetof(CPUX86State, regs[14]) }, + { "r15", offsetof(CPUX86State, regs[15]) }, +#endif + {"eflags" , offsetof(CPUX86State , eflags) }, + {"eip" , offsetof(CPUX86State , eip) }, + SEG("cs", R_CS) + SEG("ds", R_DS) + SEG("es", R_ES) + SEG("ss", R_SS) + SEG("fs", R_FS) + SEG("gs", R_GS) + {"pc" ,0 , monitor_get_pc, }, +#elif defined(TARGET_PPC) +/* General purpose registers */ + { "r0", offsetof(CPUPPCState, gpr[0]) }, + { "r1", offsetof(CPUPPCState, gpr[1]) }, + { "r2", offsetof(CPUPPCState, gpr[2]) }, + { "r3", offsetof(CPUPPCState, gpr[3]) }, + { "r4", offsetof(CPUPPCState, gpr[4]) }, + { "r5", offsetof(CPUPPCState, gpr[5]) }, + { "r6", offsetof(CPUPPCState, gpr[6]) }, + { "r7", offsetof(CPUPPCState, gpr[7]) }, + { "r8", offsetof(CPUPPCState, gpr[8]) }, + { "r9", offsetof(CPUPPCState, gpr[9]) }, + { "r10", offsetof(CPUPPCState, gpr[10]) }, + { "r11", offsetof(CPUPPCState, gpr[11]) }, + { "r12", offsetof(CPUPPCState, gpr[12]) }, + { "r13", offsetof(CPUPPCState, gpr[13]) }, + { "r14", offsetof(CPUPPCState, gpr[14]) }, + { "r15", offsetof(CPUPPCState, gpr[15]) }, + { "r16", offsetof(CPUPPCState, gpr[16]) }, + { "r17", offsetof(CPUPPCState, gpr[17]) }, + { "r18", offsetof(CPUPPCState, gpr[18]) }, + { "r19", offsetof(CPUPPCState, gpr[19]) }, + { "r20", offsetof(CPUPPCState, gpr[20]) }, + { "r21", offsetof(CPUPPCState, gpr[21]) }, + { "r22", offsetof(CPUPPCState, gpr[22]) }, + { "r23", offsetof(CPUPPCState, gpr[23]) }, + { "r24", offsetof(CPUPPCState, gpr[24]) }, + { "r25", offsetof(CPUPPCState, gpr[25]) }, + { "r26", offsetof(CPUPPCState, gpr[26]) }, + { "r27", offsetof(CPUPPCState, gpr[27]) }, + { "r28", offsetof(CPUPPCState, gpr[28]) }, + { "r29", offsetof(CPUPPCState, gpr[29]) }, + { "r30", offsetof(CPUPPCState, gpr[30]) }, + { "r31", offsetof(CPUPPCState, gpr[31]) }, +/* Floating point registers */ + { "f0", offsetof(CPUPPCState, fpr[0]) }, + { "f1", offsetof(CPUPPCState, fpr[1]) }, + { "f2", offsetof(CPUPPCState, fpr[2]) }, + { "f3", offsetof(CPUPPCState, fpr[3]) }, + { "f4", offsetof(CPUPPCState, fpr[4]) }, + { "f5", offsetof(CPUPPCState, fpr[5]) }, + { "f6", offsetof(CPUPPCState, fpr[6]) }, + { "f7", offsetof(CPUPPCState, fpr[7]) }, + { "f8", offsetof(CPUPPCState, fpr[8]) }, + { "f9", offsetof(CPUPPCState, fpr[9]) }, + { "f10", offsetof(CPUPPCState, fpr[10]) }, + { "f11", offsetof(CPUPPCState, fpr[11]) }, + { "f12", offsetof(CPUPPCState, fpr[12]) }, + { "f13", offsetof(CPUPPCState, fpr[13]) }, + { "f14", offsetof(CPUPPCState, fpr[14]) }, + { "f15", offsetof(CPUPPCState, fpr[15]) }, + { "f16", offsetof(CPUPPCState, fpr[16]) }, + { "f17", offsetof(CPUPPCState, fpr[17]) }, + { "f18", offsetof(CPUPPCState, fpr[18]) }, + { "f19", offsetof(CPUPPCState, fpr[19]) }, + { "f20", offsetof(CPUPPCState, fpr[20]) }, + { "f21", offsetof(CPUPPCState, fpr[21]) }, + { "f22", offsetof(CPUPPCState, fpr[22]) }, + { "f23", offsetof(CPUPPCState, fpr[23]) }, + { "f24", offsetof(CPUPPCState, fpr[24]) }, + { "f25", offsetof(CPUPPCState, fpr[25]) }, + { "f26", offsetof(CPUPPCState, fpr[26]) }, + { "f27", offsetof(CPUPPCState, fpr[27]) }, + { "f28", offsetof(CPUPPCState, fpr[28]) }, + { "f29", offsetof(CPUPPCState, fpr[29]) }, + { "f30", offsetof(CPUPPCState, fpr[30]) }, + { "f31", offsetof(CPUPPCState, fpr[31]) }, + {"fpscr" , offsetof(CPUPPCState , fpscr) }, +/* Next instruction pointer */ + {"nip|pc" , offsetof(CPUPPCState , nip) }, + {"lr" , offsetof(CPUPPCState , lr) }, + {"ctr" , offsetof(CPUPPCState , ctr) }, + {"decr" ,0 , &monitor_get_decr, }, + {"ccr" ,0 , &monitor_get_ccr, }, +/* Machine state register */ + {"msr" ,0 , &monitor_get_msr, }, + {"xer" ,0 , &monitor_get_xer, }, + {"tbu" ,0 , &monitor_get_tbu, }, + {"tbl" ,0 , &monitor_get_tbl, }, +/* Segment registers */ + { "sdr1", offsetof(CPUPPCState, spr[SPR_SDR1]) }, + { "sr0", offsetof(CPUPPCState, sr[0]) }, + { "sr1", offsetof(CPUPPCState, sr[1]) }, + { "sr2", offsetof(CPUPPCState, sr[2]) }, + { "sr3", offsetof(CPUPPCState, sr[3]) }, + { "sr4", offsetof(CPUPPCState, sr[4]) }, + { "sr5", offsetof(CPUPPCState, sr[5]) }, + { "sr6", offsetof(CPUPPCState, sr[6]) }, + { "sr7", offsetof(CPUPPCState, sr[7]) }, + { "sr8", offsetof(CPUPPCState, sr[8]) }, + { "sr9", offsetof(CPUPPCState, sr[9]) }, + { "sr10", offsetof(CPUPPCState, sr[10]) }, + { "sr11", offsetof(CPUPPCState, sr[11]) }, + { "sr12", offsetof(CPUPPCState, sr[12]) }, + { "sr13", offsetof(CPUPPCState, sr[13]) }, + { "sr14", offsetof(CPUPPCState, sr[14]) }, + { "sr15", offsetof(CPUPPCState, sr[15]) }, +/* Too lazy to put BATs... */ + { "pvr", offsetof(CPUPPCState, spr[SPR_PVR]) }, + + { "srr0", offsetof(CPUPPCState, spr[SPR_SRR0]) }, + { "srr1", offsetof(CPUPPCState, spr[SPR_SRR1]) }, + { "dar", offsetof(CPUPPCState, spr[SPR_DAR]) }, + { "dsisr", offsetof(CPUPPCState, spr[SPR_DSISR]) }, + { "cfar", offsetof(CPUPPCState, spr[SPR_CFAR]) }, + { "sprg0", offsetof(CPUPPCState, spr[SPR_SPRG0]) }, + { "sprg1", offsetof(CPUPPCState, spr[SPR_SPRG1]) }, + { "sprg2", offsetof(CPUPPCState, spr[SPR_SPRG2]) }, + { "sprg3", offsetof(CPUPPCState, spr[SPR_SPRG3]) }, + { "sprg4", offsetof(CPUPPCState, spr[SPR_SPRG4]) }, + { "sprg5", offsetof(CPUPPCState, spr[SPR_SPRG5]) }, + { "sprg6", offsetof(CPUPPCState, spr[SPR_SPRG6]) }, + { "sprg7", offsetof(CPUPPCState, spr[SPR_SPRG7]) }, + { "pid", offsetof(CPUPPCState, spr[SPR_BOOKE_PID]) }, + { "csrr0", offsetof(CPUPPCState, spr[SPR_BOOKE_CSRR0]) }, + { "csrr1", offsetof(CPUPPCState, spr[SPR_BOOKE_CSRR1]) }, + { "esr", offsetof(CPUPPCState, spr[SPR_BOOKE_ESR]) }, + { "dear", offsetof(CPUPPCState, spr[SPR_BOOKE_DEAR]) }, + { "mcsr", offsetof(CPUPPCState, spr[SPR_BOOKE_MCSR]) }, + { "tsr", offsetof(CPUPPCState, spr[SPR_BOOKE_TSR]) }, + { "tcr", offsetof(CPUPPCState, spr[SPR_BOOKE_TCR]) }, + { "vrsave", offsetof(CPUPPCState, spr[SPR_VRSAVE]) }, + { "pir", offsetof(CPUPPCState, spr[SPR_BOOKE_PIR]) }, + { "mcsrr0", offsetof(CPUPPCState, spr[SPR_BOOKE_MCSRR0]) }, + { "mcsrr1", offsetof(CPUPPCState, spr[SPR_BOOKE_MCSRR1]) }, + { "decar", offsetof(CPUPPCState, spr[SPR_BOOKE_DECAR]) }, + { "ivpr", offsetof(CPUPPCState, spr[SPR_BOOKE_IVPR]) }, + { "epcr", offsetof(CPUPPCState, spr[SPR_BOOKE_EPCR]) }, + { "sprg8", offsetof(CPUPPCState, spr[SPR_BOOKE_SPRG8]) }, + { "ivor0", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR0]) }, + { "ivor1", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR1]) }, + { "ivor2", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR2]) }, + { "ivor3", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR3]) }, + { "ivor4", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR4]) }, + { "ivor5", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR5]) }, + { "ivor6", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR6]) }, + { "ivor7", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR7]) }, + { "ivor8", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR8]) }, + { "ivor9", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR9]) }, + { "ivor10", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR10]) }, + { "ivor11", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR11]) }, + { "ivor12", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR12]) }, + { "ivor13", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR13]) }, + { "ivor14", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR14]) }, + { "ivor15", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR15]) }, + { "ivor32", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR32]) }, + { "ivor33", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR33]) }, + { "ivor34", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR34]) }, + { "ivor35", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR35]) }, + { "ivor36", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR36]) }, + { "ivor37", offsetof(CPUPPCState, spr[SPR_BOOKE_IVOR37]) }, + { "mas0", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS0]) }, + { "mas1", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS1]) }, + { "mas2", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS2]) }, + { "mas3", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS3]) }, + { "mas4", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS4]) }, + { "mas6", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS6]) }, + { "mas7", offsetof(CPUPPCState, spr[SPR_BOOKE_MAS7]) }, + { "mmucfg", offsetof(CPUPPCState, spr[SPR_MMUCFG]) }, + { "tlb0cfg", offsetof(CPUPPCState, spr[SPR_BOOKE_TLB0CFG]) }, + { "tlb1cfg", offsetof(CPUPPCState, spr[SPR_BOOKE_TLB1CFG]) }, + { "epr", offsetof(CPUPPCState, spr[SPR_BOOKE_EPR]) }, + { "eplc", offsetof(CPUPPCState, spr[SPR_BOOKE_EPLC]) }, + { "epsc", offsetof(CPUPPCState, spr[SPR_BOOKE_EPSC]) }, + { "svr", offsetof(CPUPPCState, spr[SPR_E500_SVR]) }, + { "mcar", offsetof(CPUPPCState, spr[SPR_Exxx_MCAR]) }, + { "pid1", offsetof(CPUPPCState, spr[SPR_BOOKE_PID1]) }, + { "pid2", offsetof(CPUPPCState, spr[SPR_BOOKE_PID2]) }, + { "hid0", offsetof(CPUPPCState, spr[SPR_HID0]) }, + +#elif defined(TARGET_SPARC) + { "g0", offsetof(CPUSPARCState, gregs[0]) }, + { "g1", offsetof(CPUSPARCState, gregs[1]) }, + { "g2", offsetof(CPUSPARCState, gregs[2]) }, + { "g3", offsetof(CPUSPARCState, gregs[3]) }, + { "g4", offsetof(CPUSPARCState, gregs[4]) }, + { "g5", offsetof(CPUSPARCState, gregs[5]) }, + { "g6", offsetof(CPUSPARCState, gregs[6]) }, + { "g7", offsetof(CPUSPARCState, gregs[7]) }, + {"o0" ,0 , monitor_get_reg }, + {"o1" ,1 , monitor_get_reg }, + {"o2" ,2 , monitor_get_reg }, + {"o3" ,3 , monitor_get_reg }, + {"o4" ,4 , monitor_get_reg }, + {"o5" ,5 , monitor_get_reg }, + {"o6" ,6 , monitor_get_reg }, + {"o7" ,7 , monitor_get_reg }, + {"l0" ,8 , monitor_get_reg }, + {"l1" ,9 , monitor_get_reg }, + {"l2" ,10 , monitor_get_reg }, + {"l3" ,11 , monitor_get_reg }, + {"l4" ,12 , monitor_get_reg }, + {"l5" ,13 , monitor_get_reg }, + {"l6" ,14 , monitor_get_reg }, + {"l7" ,15 , monitor_get_reg }, + {"i0" ,16 , monitor_get_reg }, + {"i1" ,17 , monitor_get_reg }, + {"i2" ,18 , monitor_get_reg }, + {"i3" ,19 , monitor_get_reg }, + {"i4" ,20 , monitor_get_reg }, + {"i5" ,21 , monitor_get_reg }, + {"i6" ,22 , monitor_get_reg }, + {"i7" ,23 , monitor_get_reg }, + {"pc" , offsetof(CPUSPARCState , pc) }, + {"npc" , offsetof(CPUSPARCState , npc) }, + {"y" , offsetof(CPUSPARCState , y) }, +#ifndef TARGET_SPARC64 + {"psr" ,0 , &monitor_get_psr, }, + {"wim" , offsetof(CPUSPARCState , wim) }, +#endif + {"tbr" , offsetof(CPUSPARCState , tbr) }, + {"fsr" , offsetof(CPUSPARCState , fsr) }, + { "f0", offsetof(CPUSPARCState, fpr[0].l.upper) }, + { "f1", offsetof(CPUSPARCState, fpr[0].l.lower) }, + { "f2", offsetof(CPUSPARCState, fpr[1].l.upper) }, + { "f3", offsetof(CPUSPARCState, fpr[1].l.lower) }, + { "f4", offsetof(CPUSPARCState, fpr[2].l.upper) }, + { "f5", offsetof(CPUSPARCState, fpr[2].l.lower) }, + { "f6", offsetof(CPUSPARCState, fpr[3].l.upper) }, + { "f7", offsetof(CPUSPARCState, fpr[3].l.lower) }, + { "f8", offsetof(CPUSPARCState, fpr[4].l.upper) }, + { "f9", offsetof(CPUSPARCState, fpr[4].l.lower) }, + { "f10", offsetof(CPUSPARCState, fpr[5].l.upper) }, + { "f11", offsetof(CPUSPARCState, fpr[5].l.lower) }, + { "f12", offsetof(CPUSPARCState, fpr[6].l.upper) }, + { "f13", offsetof(CPUSPARCState, fpr[6].l.lower) }, + { "f14", offsetof(CPUSPARCState, fpr[7].l.upper) }, + { "f15", offsetof(CPUSPARCState, fpr[7].l.lower) }, + { "f16", offsetof(CPUSPARCState, fpr[8].l.upper) }, + { "f17", offsetof(CPUSPARCState, fpr[8].l.lower) }, + { "f18", offsetof(CPUSPARCState, fpr[9].l.upper) }, + { "f19", offsetof(CPUSPARCState, fpr[9].l.lower) }, + { "f20", offsetof(CPUSPARCState, fpr[10].l.upper) }, + { "f21", offsetof(CPUSPARCState, fpr[10].l.lower) }, + { "f22", offsetof(CPUSPARCState, fpr[11].l.upper) }, + { "f23", offsetof(CPUSPARCState, fpr[11].l.lower) }, + { "f24", offsetof(CPUSPARCState, fpr[12].l.upper) }, + { "f25", offsetof(CPUSPARCState, fpr[12].l.lower) }, + { "f26", offsetof(CPUSPARCState, fpr[13].l.upper) }, + { "f27", offsetof(CPUSPARCState, fpr[13].l.lower) }, + { "f28", offsetof(CPUSPARCState, fpr[14].l.upper) }, + { "f29", offsetof(CPUSPARCState, fpr[14].l.lower) }, + { "f30", offsetof(CPUSPARCState, fpr[15].l.upper) }, + { "f31", offsetof(CPUSPARCState, fpr[15].l.lower) }, +#ifdef TARGET_SPARC64 + { "f32", offsetof(CPUSPARCState, fpr[16]) }, + { "f34", offsetof(CPUSPARCState, fpr[17]) }, + { "f36", offsetof(CPUSPARCState, fpr[18]) }, + { "f38", offsetof(CPUSPARCState, fpr[19]) }, + { "f40", offsetof(CPUSPARCState, fpr[20]) }, + { "f42", offsetof(CPUSPARCState, fpr[21]) }, + { "f44", offsetof(CPUSPARCState, fpr[22]) }, + { "f46", offsetof(CPUSPARCState, fpr[23]) }, + { "f48", offsetof(CPUSPARCState, fpr[24]) }, + { "f50", offsetof(CPUSPARCState, fpr[25]) }, + { "f52", offsetof(CPUSPARCState, fpr[26]) }, + { "f54", offsetof(CPUSPARCState, fpr[27]) }, + { "f56", offsetof(CPUSPARCState, fpr[28]) }, + { "f58", offsetof(CPUSPARCState, fpr[29]) }, + { "f60", offsetof(CPUSPARCState, fpr[30]) }, + { "f62", offsetof(CPUSPARCState, fpr[31]) }, + {"asi" , offsetof(CPUSPARCState , asi) }, + {"pstate" , offsetof(CPUSPARCState , pstate) }, + {"cansave" , offsetof(CPUSPARCState , cansave) }, + {"canrestore" , offsetof(CPUSPARCState , canrestore) }, + {"otherwin" , offsetof(CPUSPARCState , otherwin) }, + {"wstate" , offsetof(CPUSPARCState , wstate) }, + {"cleanwin" , offsetof(CPUSPARCState , cleanwin) }, + {"fprs" , offsetof(CPUSPARCState , fprs) }, +#endif +#endif + {NULL }, +}; + +static void GCC_FMT_ATTR(2, 3) QEMU_NORETURN +expr_error(Monitor *mon, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); +monitor_vprintf (mon, fmt, ap); + monitor_printf(mon, "\n"); + va_end(ap); + siglongjmp(expr_env, 1); +} + +/* return 0 if OK, -1 if not found */ +static int get_monitor_def(target_long *pval, const char *name) +{ +const MonitorDef *md; +void *ptr; + +for (md = monitor_defs; md->name !=NULL ; md++) { +if (compare_cmd (name, md->name)) { +if (md->get_value) { + *pval = md->get_value (md, md->offset); + }else { +CPUArchState *env =mon_get_cpu (); + ptr = (uint8_t *)env + md->offset; +switch (md->type) { +case MD_I32 : + *pval = *(int32_t *)ptr; +break ; +case MD_TLONG : + *pval = *(target_long *)ptr; +break ; +default : + *pval =0 ; +break ; + } + } +return 0 ; + } + } +return -1 ; +} + +static void next(void) +{ + if (*pch != '\0') { + pch++; + while (qemu_isspace(*pch)) + pch++; + } +} + +static int64_t expr_sum(Monitor *mon); + +static int64_t expr_unary(Monitor *mon) +{ +int64_t n; +char *p; +int ret; + +switch (*pch) { +case '+' : +next (); + n =expr_unary (mon); +break ; +case '-' : +next (); + n = -expr_unary (mon); +break ; +case '~' : +next (); + n = ~expr_unary (mon); +break ; +case '(' : +next (); + n =expr_sum (mon); +if (*pch !=')' ) { +expr_error (mon,"')' expected" ); + } +next (); +break ; +case '\'' : + pch++; +if (*pch =='\0' ) +expr_error (mon,"character constant expected" ); + n = *pch; + pch++; +if (*pch !='\'' ) +expr_error (mon,"missing terminating \' character" ); +next (); +break ; +case '$' : + { +char buf[128 ], *q; +target_long reg=0 ; + + pch++; + q = buf; +while ((*pch >='a' && *pch <='z' ) || + (*pch >='A' && *pch <='Z' ) || + (*pch >='0' && *pch <='9' ) || + *pch =='_' || *pch =='.' ) { +if ((q - buf) <sizeof (buf) -1 ) + *q++ = *pch; + pch++; + } +while (qemu_isspace (*pch)) + pch++; + *q =0 ; + ret =get_monitor_def (®, buf); +if (ret <0 ) +expr_error (mon,"unknown register" ); + n = reg; + } +break ; +case '\0' : +expr_error (mon,"unexpected end of expression" ); + n =0 ; +break ; +default : + errno =0 ; + n =strtoull (pch, &p,0 ); +if (errno ==ERANGE ) { +expr_error (mon,"number too large" ); + } +if (pch == p) { +expr_error (mon,"invalid char '%c' in expression" , *p); + } + pch = p; +while (qemu_isspace (*pch)) + pch++; +break ; + } +return n; +} + + +static int64_t expr_prod (Monitor *mon) +{ +int64_t val, val2; +int op; + + val =expr_unary (mon); +for (;;) { + op = *pch; +if (op !='*' && op !='/' && op !='%' ) +break ; +next (); + val2 =expr_unary (mon); +switch (op) { +default : +case '*' : + val *= val2; +break ; +case '/' : +case '%' : +if (val2 ==0 ) +expr_error (mon,"division by zero" ); +if (op =='/' ) + val /= val2; +else + val %= val2; +break ; + } + } +return val; +} + +static int64_t expr_logic (Monitor *mon) +{ +int64_t val, val2; +int op; + + val =expr_prod (mon); +for (;;) { + op = *pch; +if (op !='&' && op !='|' && op !='^' ) +break ; +next (); + val2 =expr_prod (mon); +switch (op) { +default : +case '&' : + val &= val2; +break ; +case '|' : + val |= val2; +break ; +case '^' : + val ^= val2; +break ; + } + } +return val; +} + +static int64_t expr_sum (Monitor *mon) +{ +int64_t val, val2; +int op; + + val =expr_logic (mon); +for (;;) { + op = *pch; +if (op !='+' && op !='-' ) +break ; +next (); + val2 =expr_logic (mon); +if (op =='+' ) + val += val2; +else + val -= val2; + } +return val; +} + +int get_expr (Monitor *mon,int64_t *pval,const char **pp) +{ + pch = *pp; +if (sigsetjmp (expr_env,0 )) { + *pp = pch; +return -1 ; + } +while (qemu_isspace (*pch)) + pch++; + *pval =expr_sum (mon); + *pp = pch; +return 0 ; +} + +int get_double (Monitor *mon,double *pval,const char **pp) +{ +const char *p = *pp; +char *tailp; +double d; + + d =strtod (p, &tailp); +if (tailp == p) { +monitor_printf (mon,"Number expected\n" ); +return -1 ; + } +if (d != d || d - d !=0 ) { +/* NaN or infinity */ +monitor_printf (mon,"Bad number\n" ); +return -1 ; + } + *pval = d; + *pp = tailp; +return 0 ; +} + +size_t sizeof_mon_cmds =sizeof (mon_cmds); +size_t sizeof_info_cmds =sizeof (info_cmds);
monitor.c +23 -987
1,030 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 18/26 monitor: Move more functions from monitor.c to monitor-system.c
In reply to Benoît Canet--- monitor-system.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 69 -------------------------------------------------------- 2 files changed, 69 insertions(+), 69 deletions(-)
monitor-system.c +69 -0
@@ -2396,3 +2396,72 @@ int get_double(Monitor *mon, double *pval, const char **pp)size_t sizeof_mon_cmds =sizeof (mon_cmds);size_t sizeof_info_cmds =sizeof (info_cmds); + +static void bdrv_password_cb (void *opaque,const char *password, +void *readline_opaque) +{ +Monitor *mon = opaque; +BlockDriverState *bs = readline_opaque; +int ret =0 ; + +if (bdrv_set_key (bs, password) !=0 ) { +monitor_printf (mon,"invalid password\n" ); + ret = -EPERM ; + } +if (mon->password_completion_cb) + mon->password_completion_cb (mon->password_opaque, ret); + +monitor_read_command (mon,1 ); +} + +ReadLineState *monitor_get_rs (Monitor *mon) +{ +return mon->rs; +} + +int monitor_read_bdrv_key_start (Monitor *mon,BlockDriverState *bs, +BlockDriverCompletionFunc *completion_cb, +void *opaque) +{ +int err; + +if (!bdrv_key_required (bs)) { +if (completion_cb) +completion_cb (opaque,0 ); +return 0 ; + } + +if (monitor_ctrl_mode (mon)) { +qerror_report (QERR_DEVICE_ENCRYPTED ,bdrv_get_device_name (bs), +bdrv_get_encrypted_filename (bs)); +return -1 ; + } + +monitor_printf (mon,"%s (%s) is encrypted.\n" ,bdrv_get_device_name (bs), +bdrv_get_encrypted_filename (bs)); + + mon->password_completion_cb = completion_cb; + mon->password_opaque = opaque; + + err =monitor_read_password (mon, bdrv_password_cb, bs); + +if (err && completion_cb) +completion_cb (opaque, err); + +return err; +} + +int monitor_read_block_device_key (Monitor *mon,const char *device, +BlockDriverCompletionFunc *completion_cb, +void *opaque) +{ +BlockDriverState *bs; + + bs =bdrv_find (device); +if (!bs) { +monitor_printf (mon,"Device not found %s\n" , device); +return -1 ; + } + +return monitor_read_bdrv_key_start (mon, bs, completion_cb, opaque); +}
monitor.c +0 -69
75 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 19/26 monitor: Move two net functions from monitor.c to monitor-system.c
In reply to Benoît CanetWith this move the monitor.c/monitor-system.c split is complete.
--- monitor-system.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 49 ------------------------------------------------- 2 files changed, 49 insertions(+), 49 deletions(-)
monitor-system.c +49 -0
@@ -2465,3 +2465,52 @@ int monitor_read_block_device_key(Monitor *mon, const char *device,return monitor_read_bdrv_key_start (mon, bs, completion_cb, opaque); } + +void set_link_completion (ReadLineState *rs,int nb_args,const char *str) +{ +size_t len; + + len =strlen (str); +readline_set_completion_index (rs, len); +if (nb_args ==2 ) { +NetClientState *ncs[255 ]; +int count, i; + count =qemu_find_net_clients_except (NULL , ncs, +NET_CLIENT_OPTIONS_KIND_NONE ,255 ); +for (i =0 ; i < count; i++) { +const char *name = ncs[i]->name; +if (!strncmp (str, name, len)) { +readline_add_completion (rs, name); + } + } + }else if (nb_args ==3 ) { +add_completion_option (rs, str,"on" ); +add_completion_option (rs, str,"off" ); + } +} + +void netdev_del_completion (ReadLineState *rs,int nb_args,const char *str) +{ +int len, count, i; +NetClientState *ncs[255 ]; + +if (nb_args !=2 ) { +return ; + } + + len =strlen (str); +readline_set_completion_index (rs, len); + count =qemu_find_net_clients_except (NULL , ncs,NET_CLIENT_OPTIONS_KIND_NIC , +255 ); +for (i =0 ; i < count; i++) { +QemuOpts *opts; +const char *name = ncs[i]->name; +if (strncmp (str, name, len)) { +continue ; + } + opts =qemu_opts_find (qemu_find_opts_err ("netdev" ,NULL ), name); +if (opts) { +readline_add_completion (rs, name); + } + } +}
monitor.c +0 -49
55 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 20/26 monitor: Move qmp_rtc_reset_reinjection from monitor.c to monitor-system.c
In reply to Benoît Canet--- monitor-system.c | 7 +++++++ monitor.c | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-)
monitor-system.c +7 -0
@@ -2514,3 +2514,10 @@ void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str) } } } + +#ifndef TARGET_I386 +void qmp_rtc_reset_reinjection (Error **errp) +{ +error_set (errp,QERR_FEATURE_DISABLED ,"rtc-reset-reinjection" ); +} +#endif
monitor.c +0 -7
@@ -2951,10 +2951,3 @@ QemuOptsList qemu_mon_opts = { {/* end of list */ } }, }; - -#ifndef TARGET_I386 -void qmp_rtc_reset_reinjection (Error **errp) -{ -error_set (errp,QERR_FEATURE_DISABLED ,"rtc-reset-reinjection" ); -} -#endif
Signature · 1 line
2.1.0.rc1
PATCH v2 21/26 monitor-system: Switch back functions to static
In reply to Benoît CanetThe move from monitor.c to monitor-system.c is done these functions no longer needs to be public.
--- include/monitor/monitor-system.h | 46 -------------------- monitor-system.c | 93 ++++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 92 deletions(-)
include/monitor/monitor-system.h +0 -46
@@ -96,50 +96,4 @@ typedef struct MonitorCommand {int get_expr (Monitor *mon,int64_t *pval,const char **pp);int get_double (Monitor *mon,double *pval,const char **pp); -int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream, - const char *fmt, ...); -void help_cmd(Monitor *mon, const char *name); -void do_help_cmd(Monitor *mon, const QDict *qdict); -void do_trace_event_set_state(Monitor *mon, const QDict *qdict); -void do_trace_file(Monitor *mon, const QDict *qdict); -void do_info_help(Monitor *mon, const QDict *qdict); - -void do_info_registers(Monitor *mon, const QDict *qdict); -void do_info_jit(Monitor *mon, const QDict *qdict); -void do_info_history(Monitor *mon, const QDict *qdict); -void tlb_info(Monitor *mon, const QDict *qdict); -void mem_info(Monitor *mon, const QDict *qdict); -void do_info_mtree(Monitor *mon, const QDict *qdict); -void do_info_numa(Monitor *mon, const QDict *qdict); -void do_info_profile(Monitor *mon, const QDict *qdict); -void do_info_capture(Monitor *mon, const QDict *qdict); -void do_info_cpu_stats(Monitor *mon, const QDict *qdict); -void do_trace_print_events(Monitor *mon, const QDict *qdict); -void do_logfile(Monitor *mon, const QDict *qdict); -void do_log(Monitor *mon, const QDict *qdict); -void do_singlestep(Monitor *mon, const QDict *qdict); -void do_gdbserver(Monitor *mon, const QDict *qdict); -void do_memory_dump(Monitor *mon, const QDict *qdict); -void do_physical_memory_dump(Monitor *mon, const QDict *qdict); -void do_print(Monitor *mon, const QDict *qdict); -void do_ioport_read(Monitor *mon, const QDict *qdict); -void do_ioport_write(Monitor *mon, const QDict *qdict); -void do_sum(Monitor *mon, const QDict *qdict); -void do_mouse_move(Monitor *mon, const QDict *qdict); -void do_mouse_button(Monitor *mon, const QDict *qdict); -void do_wav_capture(Monitor *mon, const QDict *qdict); -void do_stop_capture(Monitor *mon, const QDict *qdict); -void do_boot_set(Monitor *mon, const QDict *qdict); -int client_migrate_info(Monitor *mon, const QDict *qdict, - MonitorCompletion cb, void *opaque); -void do_watchdog_action(Monitor *mon, const QDict *qdict); -void do_acl_show(Monitor *mon, const QDict *qdict); -void do_acl_policy(Monitor *mon, const QDict *qdict); -void do_acl_add(Monitor *mon, const QDict *qdict); -void do_acl_remove(Monitor *mon, const QDict *qdict); -void do_acl_reset(Monitor *mon, const QDict *qdict); -void do_inject_mce(Monitor *mon, const QDict *qdict); -CPUArchState *mon_get_cpu(void); -void do_loadvm(Monitor *mon, const QDict *qdict); -#endif
monitor-system.c +47 -46
355 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 22/26 monitor: Extract hardware dependent completion function from monitor.c to monitor-system.c
In reply to Benoît Canet--- monitor-system.c | 283 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 281 ------------------------------------------------------ 2 files changed, 283 insertions(+), 281 deletions(-)
monitor-system.c +283 -0
@@ -49,6 +49,8 @@#include "net/slirp.h" #include "sysemu/blockdev.h" #include "qemu/config-file.h" +#include "block/snapshot.h" +#include "block/qapi.h" /* for pic/irq_info */ #if defined(TARGET_SPARC )
@@ -2522,3 +2524,284 @@ void qmp_rtc_reset_reinjection(Error **errp)error_set (errp,QERR_FEATURE_DISABLED ,"rtc-reset-reinjection" ); }#endif + +void netdev_add_completion (ReadLineState *rs,int nb_args,const char *str) +{ +size_t len; +int i; + +if (nb_args !=2 ) { +return ; + } + len =strlen (str); +readline_set_completion_index (rs, len); +for (i =0 ; NetClientOptionsKind_lookup[i]; i++) { +add_completion_option (rs, str, NetClientOptionsKind_lookup[i]); + } +} + +void device_add_completion (ReadLineState *rs,int nb_args,const char *str) +{ +GSList *list, *elt; +size_t len; + +if (nb_args !=2 ) { +return ; + } + + len =strlen (str); +readline_set_completion_index (rs, len); + list = elt =object_class_get_list (TYPE_DEVICE , false); +while (elt) { +const char *name; +DeviceClass *dc =OBJECT_CLASS_CHECK (DeviceClass, elt->data, +TYPE_DEVICE ); + name =object_class_get_name (OBJECT_CLASS (dc)); + +if (!dc->cannot_instantiate_with_device_add_yet + && !strncmp (name, str, len)) { +readline_add_completion (rs, name); + } + elt = elt->next; + } +g_slist_free (list); +} + +void object_add_completion (ReadLineState *rs,int nb_args,const char *str) +{ +GSList *list, *elt; +size_t len; + +if (nb_args !=2 ) { +return ; + } + + len =strlen (str); +readline_set_completion_index (rs, len); + list = elt =object_class_get_list (TYPE_USER_CREATABLE , false); +while (elt) { +const char *name; + + name =object_class_get_name (OBJECT_CLASS (elt->data)); +if (!strncmp (name, str, len) &&strcmp (name,TYPE_USER_CREATABLE )) { +readline_add_completion (rs, name); + } + elt = elt->next; + } +g_slist_free (list); +} + +static void device_del_bus_completion (ReadLineState *rs,BusState *bus, +const char *str,size_t len) +{ +BusChild *kid; + + QTAILQ_FOREACH(kid, &bus->children, sibling) { +DeviceState *dev = kid->child; +BusState *dev_child; + +if (dev->id && !strncmp (str, dev->id, len)) { +readline_add_completion (rs, dev->id); + } + + QLIST_FOREACH(dev_child, &dev->child_bus, sibling) { +device_del_bus_completion (rs, dev_child, str, len); + } + } +} + +void device_del_completion (ReadLineState *rs,int nb_args,const char *str) +{ +size_t len; + +if (nb_args !=2 ) { +return ; + } + + len =strlen (str); +readline_set_completion_index (rs, len); +device_del_bus_completion (rs,sysbus_get_default (), str, len); +} + +void object_del_completion (ReadLineState *rs,int nb_args,const char *str) +{ +ObjectPropertyInfoList *list, *start; +size_t len; + +if (nb_args !=2 ) { +return ; + } + len =strlen (str); +readline_set_completion_index (rs, len); + + start = list =qmp_qom_list ("/objects" ,NULL ); +while (list) { +ObjectPropertyInfo *info = list->value; + +if (!strncmp (info->type,"child<" ,5 ) + && !strncmp (info->name, str, len)) { +readline_add_completion (rs, info->name); + } + list = list->next; + } +qapi_free_ObjectPropertyInfoList (start); +} + +void sendkey_completion (ReadLineState *rs,int nb_args,const char *str) +{ +int i; +char *sep; +size_t len; + +if (nb_args !=2 ) { +return ; + } + sep =strrchr (str,'-' ); +if (sep) { + str = sep +1 ; + } + len =strlen (str); +readline_set_completion_index (rs, len); +for (i =0 ; i <Q_KEY_CODE_MAX ; i++) { +if (!strncmp (str, QKeyCode_lookup[i], len)) { +readline_add_completion (rs, QKeyCode_lookup[i]); + } + } +} + +void watchdog_action_completion (ReadLineState *rs,int nb_args,const char *str) +{ +if (nb_args !=2 ) { +return ; + } +readline_set_completion_index (rs,strlen (str)); +add_completion_option (rs, str,"reset" ); +add_completion_option (rs, str,"shutdown" ); +add_completion_option (rs, str,"poweroff" ); +add_completion_option (rs, str,"pause" ); +add_completion_option (rs, str,"debug" ); +add_completion_option (rs, str,"none" ); +} + +void migrate_set_capability_completion (ReadLineState *rs,int nb_args, +const char *str) +{ +size_t len; + + len =strlen (str); +readline_set_completion_index (rs, len); +if (nb_args ==2 ) { +int i; +for (i =0 ; i <MIGRATION_CAPABILITY_MAX ; i++) { +const char *name = MigrationCapability_lookup[i]; +if (!strncmp (str, name, len)) { +readline_add_completion (rs, name); + } + } + }else if (nb_args ==3 ) { +add_completion_option (rs, str,"on" ); +add_completion_option (rs, str,"off" ); + } +} + +void host_net_add_completion (ReadLineState *rs,int nb_args,const char *str) +{ +int i; +size_t len; +if (nb_args !=2 ) { +return ; + } + len =strlen (str); +readline_set_completion_index (rs, len); +for (i =0 ; host_net_devices[i]; i++) { +if (!strncmp (host_net_devices[i], str, len)) { +readline_add_completion (rs, host_net_devices[i]); + } + } +} + +void host_net_remove_completion (ReadLineState *rs,int nb_args,const char *str) +{ +NetClientState *ncs[255 ]; +int count, i, len; + + len =strlen (str); +readline_set_completion_index (rs, len); +if (nb_args ==2 ) { + count =qemu_find_net_clients_except (NULL , ncs, +NET_CLIENT_OPTIONS_KIND_NONE ,255 ); +for (i =0 ; i < count; i++) { +int id; +char name[16 ]; + +if (net_hub_id_for_client (ncs[i], &id)) { +continue ; + } +snprintf (name,sizeof (name),"%d" , id); +if (!strncmp (str, name, len)) { +readline_add_completion (rs, name); + } + } +return ; + }else if (nb_args ==3 ) { + count =qemu_find_net_clients_except (NULL , ncs, +NET_CLIENT_OPTIONS_KIND_NIC ,255 ); +for (i =0 ; i < count; i++) { +const char *name; + + name = ncs[i]->name; +if (!strncmp (str, name, len)) { +readline_add_completion (rs, name); + } + } +return ; + } +} + +static void vm_completion (ReadLineState *rs,const char *str) +{ +size_t len; +BlockDriverState *bs =NULL ; + + len =strlen (str); +readline_set_completion_index (rs, len); +while ((bs =bdrv_next (bs))) { +SnapshotInfoList *snapshots, *snapshot; + +if (!bdrv_can_snapshot (bs)) { +continue ; + } +if (bdrv_query_snapshot_info_list (bs, &snapshots,NULL )) { +continue ; + } + snapshot = snapshots; +while (snapshot) { +char *completion = snapshot->value->name; +if (!strncmp (str, completion, len)) { +readline_add_completion (rs, completion); + } + completion = snapshot->value->id; +if (!strncmp (str, completion, len)) { +readline_add_completion (rs, completion); + } + snapshot = snapshot->next; + } +qapi_free_SnapshotInfoList (snapshots); + } + +} + +void delvm_completion (ReadLineState *rs,int nb_args,const char *str) +{ +if (nb_args ==2 ) { +vm_completion (rs, str); + } +} + +void loadvm_completion (ReadLineState *rs,int nb_args,const char *str) +{ +if (nb_args ==2 ) { +vm_completion (rs, str); + } +} +
monitor.c +0 -281
299 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 23/26 monitor: Cleanup monitor.c includes after extracting monitor-system.c
In reply to Benoît Canet--- monitor.c | 35 ----------------------------------- 1 file changed, 35 deletions(-)
monitor.c +0 -35
@@ -22,64 +22,29 @@* THE SOFTWARE. */ #include <dirent.h> -#include "hw/hw.h" -#include "monitor/qdev.h" -#include "hw/usb.h" -#include "hw/pcmcia.h" -#include "hw/i386/pc.h" #include "hw/pci/pci.h" -#include "sysemu/watchdog.h" -#include "hw/loader.h" -#include "exec/gdbstub.h" #include "net/net.h" -#include "net/slirp.h" #include "sysemu/char.h" -#include "ui/qemu-spice.h" #include "sysemu/sysemu.h" #include "monitor/monitor.h" #include "monitor/monitor-system.h" #include "qemu/readline.h" #include "ui/console.h" #include "ui/input.h" -#include "sysemu/blockdev.h" -#include "audio/audio.h" -#include "disas/disas.h" -#include "sysemu/balloon.h" -#include "qemu/timer.h" -#include "migration/migration.h" -#include "sysemu/kvm.h" -#include "qemu/acl.h" -#include "sysemu/tpm.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qfloat.h" -#include "qapi/qmp/qlist.h" #include "qapi/qmp/qbool.h" -#include "qapi/qmp/qstring.h" -#include "qapi/qmp/qjson.h" -#include "qapi/qmp/json-streamer.h" -#include "qapi/qmp/json-parser.h" -#include <qom/object_interfaces.h> -#include "qemu/osdep.h" -#include "cpu.h" #include "trace.h" #include "trace/control.h" #ifdef CONFIG_TRACE_SIMPLE #include "trace/simple.h" #endif -#include "exec/memory.h" -#include "exec/cpu_ldst.h" #include "qmp-commands.h" #include "hmp.h" #include "qemu/thread.h" #include "qapi/qmp-event.h" #include "qapi-event.h" -/* for pic/irq_info */ -#if defined(TARGET_SPARC ) -#include "hw/sparc/sun4m.h" -#endif -#include "hw/lm32/lm32_pic.h" -//#define DEBUG //#define DEBUG_COMPLETION
Signature · 1 line
2.1.0.rc1
PATCH v2 24/26 qemu-nbd: build QAPI block core into qemu-nbd
In reply to Benoît CanetCompile and link QAPI block core code into qemu-nbd.
This patch circle around unwanted dependecies by stubing some functions in the stubs directory.
--- Makefile | 33 +++++++++++++++++++++++++++-- Makefile.objs | 10 +++++++++ block/Makefile.objs | 11 ++++++---- qapi/Makefile.objs | 2 ++ qobject/Makefile.objs | 2 ++ qom/Makefile.objs | 8 ++++--- stubs/Makefile.objs | 15 +++++++++++++ stubs/arch-type.c | 3 +++ stubs/autostart.c | 1 + stubs/cpus-list.c | 3 +++ stubs/get-double.c | 8 +++++++ stubs/get-expr.c | 8 +++++++ stubs/kvm-allowed.c | 3 +++ stubs/kvm-cpu-synchronize-post-init.c | 5 +++++ stubs/kvm-cpu-synchronize-state.c | 5 +++++ stubs/qemu-add-machine-init-done-notifier.c | 5 +++++ stubs/qemu-chr-open-msmouse.c | 7 ++++++ stubs/runstate-is-running.c | 6 ++++++ stubs/serial-hds.c | 3 +++ stubs/vmstate-info-buffer.c | 8 +++++++ stubs/vmstate-info-uint32.c | 8 +++++++ util/Makefile.objs | 2 ++ 22 files changed, 147 insertions(+), 9 deletions(-) create mode 100644 stubs/arch-type.c create mode 100644 stubs/autostart.c create mode 100644 stubs/cpus-list.c create mode 100644 stubs/get-double.c create mode 100644 stubs/get-expr.c create mode 100644 stubs/kvm-allowed.c create mode 100644 stubs/kvm-cpu-synchronize-post-init.c create mode 100644 stubs/kvm-cpu-synchronize-state.c create mode 100644 stubs/qemu-add-machine-init-done-notifier.c create mode 100644 stubs/qemu-chr-open-msmouse.c create mode 100644 stubs/runstate-is-running.c create mode 100644 stubs/serial-hds.c create mode 100644 stubs/vmstate-info-buffer.c create mode 100644 stubs/vmstate-info-uint32.c
Makefile +31 -2
@@ -44,6 +44,13 @@ ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail)) endif endif +GENERATED_BLOCK_HEADERS = block/qapi-generated/qmp-commands.h +GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-types.h +GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-visit.h +GENERATED_BLOCK_SOURCES = block/qapi-generated/qmp-marshal.c +GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-types.c +GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-visit.c + GENERATED_HEADERS = config-host.h qemu-options.def GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
@@ -136,6 +143,7 @@ dummy := $(call unnest-vars,, \ qga-vss-dll-obj-y \ block-obj-y \ block-obj-m \ + qapi-block-obj-y \ common-obj-y \ common-obj-m)
@@ -212,7 +220,8 @@ util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)' qemu-img.o: qemu-img-cmds.h qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a -qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a +qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) $(qapi-block-obj-y) libqemustub.a +qemu-nbd$(EXESUF): QEMU_CFLAGS += -DBLOCK_COMMAND_MONITOR qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
@@ -271,6 +280,22 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(gen-out-type) -o "." -m -i $<, \ " GEN $@") +block/qapi-generated/qapi-types.c block/qapi-generated/qapi-types.h :\ +$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ + $(gen-out-type) -o block/qapi-generated -b -i $<, \ + " GEN $@") +block/qapi-generated/qapi-visit.c block/qapi-generated/qapi-visit.h :\ +$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ + $(gen-out-type) -o block/qapi-generated -b -i $<, \ + " GEN $@") +block/qapi-generated/qmp-commands.h block/qapi-generated/qmp-marshal.c :\ +$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ + $(gen-out-type) -o block/qapi-generated -m -i $<, \ + " GEN $@") + QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
@@ -291,8 +316,11 @@ clean: rm -f trace/generated-tracers-dtrace.h* rm -f $(foreach f,$(GENERATED_HEADERS),$(f) $(f)-timestamp) rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp) + rm -f $(foreach f,$(GENERATED_BLOCK_HEADERS),$(f) $(f)-timestamp) + rm -f $(foreach f,$(GENERATED_BLOCK_SOURCES),$(f) $(f)-timestamp) rm -rf qapi-generated rm -rf qga/qapi-generated + rm -rf block/qapi-generated for d in $(ALL_SUBDIRS); do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \
@@ -550,7 +578,8 @@ endif # CONFIG_WIN # Add a dependency on the generated files, so that they are always # rebuilt before other object files ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail)) -Makefile: $(GENERATED_HEADERS) +Makefile: $(GENERATED_HEADERS) $(GENERATED_BLOCK_HEADERS)\ + $(GENERATED_BLOCK_SOURCES) endif # Include automatically generated dependency files
Makefile.objs +10 -0
@@ -21,6 +21,16 @@ block-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o block-obj-m = block/ +qapi-block-obj-y = block/qapi-generated/qmp-marshal.o blockdev.o qmp.o +qapi-block-obj-y += monitor.o +qapi-block-obj-y += qemu-char.o +qapi-block-obj-y += qemu-log.o +qapi-block-obj-y += qom/ +qapi-block-obj-y += util/ +qapi-block-obj-y += qobject/ +qapi-block-obj-y += block/ +qapi-block-obj-y += qapi/ +qapi-block-obj-y += stubs/ ###################################################################### # smartcard
block/Makefile.objs +7 -4
@@ -20,10 +20,13 @@ block-obj-$(CONFIG_GLUSTERFS) += gluster.o block-obj-$(CONFIG_LIBSSH2) += ssh.o endif -common-obj-y += stream.o -common-obj-y += commit.o -common-obj-y += mirror.o -common-obj-y += backup.o +block-job-obj-y = stream.o +block-job-obj-y += commit.o +block-job-obj-y += mirror.o +block-job-obj-y += backup.o + +common-obj-y += $(block-job-obj-y) +qapi-block-obj-y += $(block-job-obj-y) iscsi.o-cflags := $(LIBISCSI_CFLAGS) iscsi.o-libs := $(LIBISCSI_LIBS)
qapi/Makefile.objs +2 -0
@@ -4,3 +4,5 @@ util-obj-y += string-input-visitor.o string-output-visitor.o util-obj-y += opts-visitor.o util-obj-y += qmp-event.o + +qapi-block-obj-y += $(util-obj-y)
qobject/Makefile.objs +2 -0
@@ -1,3 +1,5 @@ util-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o util-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o util-obj-y += qerror.o + +qapi-block-obj-y += $(util-obj-y)
qom/Makefile.objs +5 -3
@@ -1,3 +1,5 @@ -common-obj-y = object.o container.o qom-qobject.o -common-obj-y += cpu.o -common-obj-y += object_interfaces.o +qom-obj-y = object.o container.o qom-qobject.o +qom-obj-y += object_interfaces.o + +common-obj-y += $(qom-obj-y) cpu.o +qapi-block-obj-y += $(qom-obj-y)
stubs/Makefile.objs +15 -0
@@ -40,3 +40,18 @@ stub-obj-$(CONFIG_WIN32) += fd-register.o stub-obj-y += cpus.o stub-obj-y += kvm.o stub-obj-y += qmp_pc_dimm_device_list.o + +qapi-block-obj-y += arch-type.o +qapi-block-obj-y += autostart.o +qapi-block-obj-y += kvm-allowed.o +qapi-block-obj-y += cpus-list.o +qapi-block-obj-y += serial-hds.o +qapi-block-obj-y += qemu-chr-open-msmouse.o +qapi-block-obj-y += runstate-is-running.o +qapi-block-obj-y += kvm-cpu-synchronize-state.o +qapi-block-obj-y += kvm-cpu-synchronize-post-init.o +qapi-block-obj-y += qemu-add-machine-init-done-notifier.o +qapi-block-obj-y += get-double.o +qapi-block-obj-y += get-expr.o +qapi-block-obj-y += vmstate-info-buffer.o +qapi-block-obj-y += vmstate-info-uint32.o
stubs/arch-type.c new file +3 -0
@@ -0,0 +1,3 @@ +#include <stdint.h> + +const uint32_t arch_type =-1 ;
stubs/autostart.c new file +1 -0
@@ -0,0 +1 @@ +int autostart;
stubs/cpus-list.c new file +3 -0
@@ -0,0 +1,3 @@ +#include "sysemu/kvm.h" + +struct CPUTailQ cpus =QTAILQ_HEAD_INITIALIZER (cpus);
stubs/get-double.c new file +8 -0
@@ -0,0 +1,8 @@ +#include <stdint.h> +#include "monitor/monitor-system.h" + +int get_double (Monitor *mon,double *pval,const char **pp) +{ + *pval =0 ; +return 0 ; +}
stubs/get-expr.c new file +8 -0
@@ -0,0 +1,8 @@ +#include <stdint.h> +#include "monitor/monitor-system.h" + +int get_expr (Monitor *mon,int64_t *pval,const char **pp) +{ + *pval =0 ; +return 0 ; +}
stubs/kvm-allowed.c new file +3 -0
@@ -0,0 +1,3 @@ +#include <stdbool.h> + +bool kvm_allowed;
stubs/kvm-cpu-synchronize-post-init.c new file +5 -0
@@ -0,0 +1,5 @@ +#include "sysemu/kvm.h" + +void kvm_cpu_synchronize_post_init (CPUState *cpu) +{ +}
stubs/kvm-cpu-synchronize-state.c new file +5 -0
@@ -0,0 +1,5 @@ +#include "sysemu/kvm.h" + +void kvm_cpu_synchronize_state (CPUState *cpu) +{ +}
stubs/qemu-add-machine-init-done-notifier.c new file +5 -0
@@ -0,0 +1,5 @@ +#include "sysemu/sysemu.h" + +void qemu_add_machine_init_done_notifier (Notifier *notify) +{ +}
stubs/qemu-chr-open-msmouse.c new file +7 -0
@@ -0,0 +1,7 @@ +#include "sysemu/char.h" +#include "ui/console.h" + +CharDriverState *qemu_chr_open_msmouse (void ) +{ +return NULL ; +}
stubs/runstate-is-running.c new file +6 -0
@@ -0,0 +1,6 @@ +#include "sysemu/sysemu.h" + +int runstate_is_running (void ) +{ +return 1 ; +}
stubs/serial-hds.c new file +3 -0
@@ -0,0 +1,3 @@ +#include "sysemu/sysemu.h" + +CharDriverState *serial_hds[MAX_SERIAL_PORTS ];
stubs/vmstate-info-buffer.c new file +8 -0
@@ -0,0 +1,8 @@ +#include <qemu-common.h> +#include "migration/vmstate.h" + +const VMStateInfo vmstate_info_buffer = { + .name ="buffer" , + .get =NULL , + .put =NULL , +};
stubs/vmstate-info-uint32.c new file +8 -0
@@ -0,0 +1,8 @@ +#include <qemu-common.h> +#include "migration/vmstate.h" + +const VMStateInfo vmstate_info_uint32 = { + .name ="uint32" , + .get =NULL , + .put =NULL , +};
util/Makefile.objs +2 -0
@@ -15,3 +15,5 @@ util-obj-y += throttle.o util-obj-y += getauxval.o util-obj-y += readline.o util-obj-y += rfifolock.o + +qapi-block-obj-y += $(util-obj-y)
Signature · 1 line
2.1.0.rc1
PATCH v2 25/26 qapi: Add a script to filter qmp-commands-old.h to generate a subset of it.
In reply to Benoît CanetSince qmp-command-olds.h is generated from qmp-commands.hx we will sometime want to include only a subset of it. For example when linking qapi block commands with qemu-nbd.
--- Makefile | 7 +++ scripts/filter_qmp_commands_old.py | 93 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100755 scripts/filter_qmp_commands_old.py
Makefile +7 -0
@@ -47,6 +47,7 @@ endif GENERATED_BLOCK_HEADERS = block/qapi-generated/qmp-commands.h GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-types.h GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-visit.h +GENERATED_BLOCK_HEADERS += block/qapi-generated/qmp-commands-old.h GENERATED_BLOCK_SOURCES = block/qapi-generated/qmp-marshal.c GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-types.c GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-visit.c
@@ -296,6 +297,12 @@ $(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(gen-out-type) -o block/qapi-generated -m -i $<, \ " GEN $@") +block/qapi-generated/qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx \ +block/qapi-generated/qmp-commands.h + $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< |\ +./scripts/filter_qmp_commands_old.py \ +$(SRC_PATH)/block/qapi-generated/qmp-commands.h > $@," GEN $@") + QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
scripts/filter_qmp_commands_old.py new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1
PATCH v2 26/26 qemu-nbd: Add --qmp option to qemu-nbd.
In reply to Benoît CanetThis patch add a -qmp parameter to the qemu-nbd command line in order to be able to manipulate the qemu-nbd block devices via qmp.
This could be used with containers to easily migrate from qemu to a container.
--- Makefile.objs | 3 +- include/monitor/monitor-init.h | 34 ++++++++++++ monitor-init.c | 121 +++++++++++++++++++++++++++++++++++++++++ monitor.c | 1 + qemu-nbd.c | 33 ++++++++++- vl.c | 88 +----------------------------- 6 files changed, 190 insertions(+), 90 deletions(-) create mode 100644 include/monitor/monitor-init.h create mode 100644 monitor-init.c
Makefile.objs +2 -1
@@ -23,6 +23,7 @@ block-obj-m = block/ qapi-block-obj-y = block/qapi-generated/qmp-marshal.o blockdev.o qmp.o qapi-block-obj-y += monitor.o +qapi-block-obj-y += monitor-init.o qapi-block-obj-y += qemu-char.o qapi-block-obj-y += qemu-log.o qapi-block-obj-y += qom/
@@ -79,7 +80,7 @@ common-obj-y += bt-host.o bt-vhci.o bt-host.o-cflags := $(BLUEZ_CFLAGS) common-obj-y += dma-helpers.o -common-obj-y += vl.o +common-obj-y += vl.o monitor-init.o vl.o-cflags := $(GPROF_CFLAGS) $(SDL_CFLAGS) common-obj-y += tpm.o
include/monitor/monitor-init.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* QEMU System Emulator +* +* Copyright (c) 2003-2008 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#ifndef MONITOR_INIT_H +#define MONITOR_INIT_H + +#include "qemu/option.h" + +int chardev_init_func (QemuOpts *opts,void *opaque); +int mon_init_func (QemuOpts *opts,void *opaque); +void monitor_parse (const char *optarg,const char *mode); + +#endif
monitor-init.c new file +121 -0
121 lines not on this page · raw message
monitor.c +1 -0
@@ -149,6 +149,7 @@ static MonitorCommand info_cmds[] = { };size_t sizeof_info_cmds =sizeof (info_cmds);static const MonitorCommand qmp_cmds[] = { +#include "block/qapi-generated/qmp-commands-old.h" {/* NULL */ }, };#else
qemu-nbd.c +30 -3
@@ -16,13 +16,16 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#include "monitor/monitor-init.h" #include "qemu-common.h" #include "block/block.h" #include "block/nbd.h" +#include "qemu/config-file.h" #include "qemu/main-loop.h" #include "qemu/sockets.h" #include "qemu/error-report.h" #include "block/snapshot.h" +#include "sysemu/sysemu.h" #include <stdarg.h> #include <stdio.h>
@@ -97,6 +100,9 @@ static void usage(const char *name)" --aio=MODE set AIO mode (native or threads)\n" #endif"\n" +"Management options:\n" +" -q, --qmp=DEV machine monitor listen on DEV\n" +"\n" "Report bugs to <[email protected]>\n" , name, NBD_DEFAULT_PORT, "DEVICE"); }
@@ -390,7 +396,7 @@ int main(int argc, char **argv)off_t fd_size;QemuOpts *sn_opts =NULL ;const char *sn_id_or_name =NULL ; -const char *sopt ="hVb:o:p:rsnP:c:dvk:e:f:tl:" ; +const char *sopt ="hVb:o:p:rsnP:c:dvk:e:f:tl:q:" ;struct option lopt[] = { {"help" ,0 ,NULL ,'h' }, {"version" ,0 ,NULL ,'V' },
@@ -412,6 +418,7 @@ int main(int argc, char **argv) { "discard", 1, NULL, QEMU_NBD_OPT_DISCARD }, { "shared", 1, NULL, 'e' }, { "format", 1, NULL, 'f' }, + { "qmp", 1, NULL, 'q' }, { "persistent", 0, NULL, 't' }, { "verbose", 0, NULL, 'v' }, { NULL, 0, NULL, 0 }
@@ -432,6 +439,11 @@ int main(int argc, char **argv)pthread_t client_thread;const char *fmt =NULL ;Error *local_err =NULL ; +bool has_qmp = false; + +module_call_init (MODULE_INIT_QOM ); +qemu_add_opts (&qemu_mon_opts); +qemu_add_opts (&qemu_chardev_opts);/* The client thread uses SIGTERM to interrupt the server. A signal * handler ensures that "qemu-nbd -v -c" exits with a nice status code.
@@ -553,6 +565,10 @@ int main(int argc, char **argv)case 't' : persistent =1 ;break ; +case 'q' : +monitor_parse (optarg,"control" ); + has_qmp = true; +break ;case 'v' : verbose =1 ;break ;
@@ -576,6 +592,15 @@ int main(int argc, char **argv) argv[0]); } +if (qemu_opts_foreach (qemu_find_opts ("chardev" ), chardev_init_func, +NULL ,1 ) !=0 ) { +exit (1 ); + } + +if (qemu_opts_foreach (qemu_find_opts ("mon" ), mon_init_func,NULL ,1 ) !=0 ) { +exit (1 ); + } +if (disconnect) { fd =open (argv[optind],O_RDWR );if (fd <0 ) {
@@ -725,8 +750,10 @@ int main(int argc, char **argv) (void *)(uintptr_t)fd);/* now when the initialization is (almost) complete, chdir("/") -* to free any busy filesystems */ -if (chdir ("/" ) <0 ) { +* to free any busy filesystems. We don't do this when QMP is used to avoid +* disturbing snapshot taking. +*/ +if (!has_qmp &&chdir ("/" ) <0 ) {err (EXIT_FAILURE ,"Could not chdir to root directory" ); }
vl.c +2 -86
106 lines not on this page · raw message
Signature · 1 line
2.1.0.rc1