Revision 10e4f606
b/monitor.c | ||
---|---|---|
137 | 137 |
CPUState *mon_cpu; |
138 | 138 |
BlockDriverCompletionFunc *password_completion_cb; |
139 | 139 |
void *password_opaque; |
140 |
#ifdef CONFIG_DEBUG_MONITOR |
|
141 |
int print_calls_nr; |
|
142 |
#endif |
|
140 | 143 |
QError *error; |
141 | 144 |
QLIST_HEAD(,mon_fd_t) fds; |
142 | 145 |
QLIST_ENTRY(Monitor) entry; |
... | ... | |
146 | 149 |
#define MON_DEBUG(fmt, ...) do { \ |
147 | 150 |
fprintf(stderr, "Monitor: "); \ |
148 | 151 |
fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) |
152 |
|
|
153 |
static inline void mon_print_count_inc(Monitor *mon) |
|
154 |
{ |
|
155 |
mon->print_calls_nr++; |
|
156 |
} |
|
157 |
|
|
158 |
static inline void mon_print_count_init(Monitor *mon) |
|
159 |
{ |
|
160 |
mon->print_calls_nr = 0; |
|
161 |
} |
|
162 |
|
|
163 |
static inline int mon_print_count_get(const Monitor *mon) |
|
164 |
{ |
|
165 |
return mon->print_calls_nr; |
|
166 |
} |
|
167 |
|
|
149 | 168 |
#else /* !CONFIG_DEBUG_MONITOR */ |
150 | 169 |
#define MON_DEBUG(fmt, ...) do { } while (0) |
170 |
static inline void mon_print_count_inc(Monitor *mon) { } |
|
171 |
static inline void mon_print_count_init(Monitor *mon) { } |
|
172 |
static inline int mon_print_count_get(const Monitor *mon) { return 0; } |
|
151 | 173 |
#endif /* CONFIG_DEBUG_MONITOR */ |
152 | 174 |
|
153 | 175 |
static QLIST_HEAD(mon_list, Monitor) mon_list; |
... | ... | |
230 | 252 |
if (!mon) |
231 | 253 |
return; |
232 | 254 |
|
255 |
mon_print_count_inc(mon); |
|
256 |
|
|
233 | 257 |
if (monitor_ctrl_mode(mon)) { |
234 |
qemu_error_new(QERR_UNDEFINED_ERROR); |
|
235 | 258 |
return; |
236 | 259 |
} |
237 | 260 |
|
... | ... | |
3873 | 3896 |
MON_DEBUG("command '%s' returned success but passed an error\n", |
3874 | 3897 |
cmd->name); |
3875 | 3898 |
} |
3899 |
|
|
3900 |
if (mon_print_count_get(mon) > 0 && strcmp(cmd->name, "info") != 0) { |
|
3901 |
/* |
|
3902 |
* Handlers should not call Monitor print functions. |
|
3903 |
* |
|
3904 |
* Action: Ignore them in QMP. |
|
3905 |
* |
|
3906 |
* (XXX: we don't check any 'info' or 'query' command here |
|
3907 |
* because the user print function _is_ called by do_info(), hence |
|
3908 |
* we will trigger this check. This problem will go away when we |
|
3909 |
* make 'query' commands real and kill do_info()) |
|
3910 |
*/ |
|
3911 |
MON_DEBUG("command '%s' called print functions %d time(s)\n", |
|
3912 |
cmd->name, mon_print_count_get(mon)); |
|
3913 |
} |
|
3876 | 3914 |
#endif |
3877 | 3915 |
} |
3878 | 3916 |
|
... | ... | |
3882 | 3920 |
int ret; |
3883 | 3921 |
QObject *data = NULL; |
3884 | 3922 |
|
3923 |
mon_print_count_init(mon); |
|
3924 |
|
|
3885 | 3925 |
ret = cmd->mhandler.cmd_new(mon, params, &data); |
3886 | 3926 |
handler_audit(mon, cmd, ret); |
3887 | 3927 |
|
Also available in: Unified diff