Lines Matching full:mon
105 static void do_inject_mce(Monitor *mon,
131 static void monitor_command_cb(Monitor *mon, const char *cmdline,
134 static inline int qmp_cmd_mode(const Monitor *mon)
136 //return (mon->mc ? mon->mc->command_mode : 0);
141 static inline int monitor_ctrl_mode(const Monitor *mon)
143 return (mon->flags & MONITOR_USE_CONTROL);
152 static void monitor_read_command(Monitor *mon, int show_prompt)
154 readline_start(mon->rs, "(qemu) ", 0, monitor_command_cb, NULL);
156 readline_show_prompt(mon->rs);
159 static int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
162 if (mon->rs) {
163 readline_start(mon->rs, "Password: ", 1, readline_func, opaque);
167 monitor_printf(mon, "terminal does not support password prompting\n");
173 void monitor_flush(Monitor *mon)
175 if (mon && mon->outbuf_index != 0 && !mon->mux_out) {
176 qemu_chr_write(mon->chr, mon->outbuf, mon->outbuf_index);
177 mon->outbuf_index = 0;
183 static void monitor_puts(Monitor *mon, const char *str)
187 if (!mon)
195 mon->outbuf[mon->outbuf_index++] = '\r';
196 mon->outbuf[mon->outbuf_index++] = c;
197 if (mon->outbuf_index >= (sizeof(mon->outbuf) - 1)
199 monitor_flush(mon);
203 void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
207 monitor_puts(mon, buf);
210 void monitor_printf(Monitor *mon, const char *fmt, ...)
214 monitor_vprintf(mon, fmt, ap);
218 void monitor_print_filename(Monitor *mon, const char *filename)
227 monitor_printf(mon, "\\%c", filename[i]);
230 monitor_printf(mon, "\\t");
233 monitor_printf(mon, "\\r");
236 monitor_printf(mon, "\\n");
239 monitor_printf(mon, "%c", filename[i]);
280 static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
287 monitor_printf(mon, "%s%s %s -- %s\n", prefix, cmd->name,
292 static void help_cmd(Monitor *mon, const char *name)
295 help_cmd_dump(mon, info_cmds, "info ", NULL);
297 help_cmd_dump(mon, mon_cmds, "", name);
300 monitor_printf(mon, "Log items (comma separated):\n");
301 monitor_printf(mon, "%-10s %s\n", "none", "remove all logs");
303 monitor_printf(mon, "%-10s %s\n", item->name, item->help);
309 static void do_info(Monitor *mon, const char *item)
321 help_cmd(mon, "info");
325 handler(mon);
328 static void do_info_version(Monitor *mon)
330 monitor_printf(mon, "%s\n", QEMU_VERSION QEMU_PKGVERSION);
333 static void do_info_name(Monitor *mon)
336 monitor_printf(mon, "%s\n", qemu_name);
340 static void do_info_hpet(Monitor *mon)
342 monitor_printf(mon, "HPET is %s by QEMU\n",
347 static void do_info_uuid(Monitor *mon)
349 monitor_printf(mon, UUID_FMT "\n", qemu_uuid[0], qemu_uuid[1],
379 static void do_info_registers(Monitor *mon)
386 cpu_dump_state(env, (FILE *)mon, monitor_fprintf,
389 cpu_dump_state(env, (FILE *)mon, monitor_fprintf,
394 static void do_info_cpus(Monitor *mon)
403 monitor_printf(mon, "%c CPU #%d:",
404 (env == mon->mon_cpu) ? '*' : ' ',
407 monitor_printf(mon, " pc=0x" TARGET_FMT_lx,
410 monitor_printf(mon, " nip=0x" TARGET_FMT_lx, env->nip);
412 monitor_printf(mon, " pc=0x" TARGET_FMT_lx " npc=0x" TARGET_FMT_lx,
415 monitor_printf(mon, " PC=0x" TARGET_FMT_lx, env->active_tc.PC);
418 monitor_printf(mon, " (halted)");
419 monitor_printf(mon, "\n");
423 static void do_cpu_set(Monitor *mon, int index)
426 monitor_printf(mon, "Invalid CPU index\n");
429 static void do_info_jit(Monitor *mon)
431 dump_exec_info((FILE *)mon, monitor_fprintf);
434 static void do_info_history(Monitor *mon)
439 if (!mon->rs)
443 str = readline_get_history(mon->rs, i);
446 monitor_printf(mon, "%d: '%s'\n", i, str);
453 static void do_info_cpu_stats(Monitor *mon)
458 cpu_dump_statistics(env, (FILE *)mon, &monitor_fprintf, 0);
462 static void do_quit(Monitor *mon)
464 if ((mon->flags & MONITOR_QUIT_DOESNT_EXIT) == 0) {
468 mon->has_quit = 1;
471 static void change_vnc_password_cb(Monitor *mon, const char *password,
475 monitor_printf(mon, "could not set VNC server password\n");
477 monitor_read_command(mon, 1);
480 static void do_change_vnc(Monitor *mon, const char *target, const char *arg)
488 change_vnc_password_cb(mon, password, NULL);
490 monitor_read_password(mon, change_vnc_password_cb, NULL);
494 monitor_printf(mon, "could not start VNC server on %s\n", target);
498 static void do_change(Monitor *mon, const char *device, const char *target,
502 do_change_vnc(mon, target, arg);
504 do_change_block(mon, device, target, arg);
508 static void do_screen_dump(Monitor *mon, const char *filename)
513 static void do_logfile(Monitor *mon, const char *filename)
518 static void do_log(Monitor *mon, const char *items)
527 help_cmd(mon, "log");
534 static void do_singlestep(Monitor *mon, const char *option)
541 monitor_printf(mon, "unexpected option %s\n", option);
545 static void do_stop(Monitor *mon)
553 Monitor *mon;
557 static void do_cont(Monitor *mon)
559 struct bdrv_iterate_context context = { mon, 0 };
569 Monitor *mon = opaque;
573 do_cont(mon);
582 monitor_read_bdrv_key_start(context->mon, bs, bdrv_key_cb,
583 context->mon);
587 static void do_gdbserver(Monitor *mon, const char *device)
592 monitor_printf(mon, "Could not open gdbserver on device '%s'\n",
595 monitor_printf(mon, "Disabled gdbserver\n");
597 monitor_printf(mon, "Waiting for gdb connection on device '%s'\n",
602 static void do_watchdog_action(Monitor *mon, const char *action)
605 monitor_printf(mon, "Unknown watchdog action '%s'\n", action);
609 static void monitor_printc(Monitor *mon, int c)
611 monitor_printf(mon, "'");
614 monitor_printf(mon, "\\'");
617 monitor_printf(mon, "\\\\");
620 monitor_printf(mon, "\\n");
623 monitor_printf(mon, "\\r");
627 monitor_printf(mon, "%c", c);
629 mon, "\\x%02x", c);
633 monitor_printf(mon, "'");
636 static void memory_dump(Monitor *mon, int count, int format, int wsize,
670 monitor_disas(mon, env, addr, count, is_physical, flags);
701 monitor_printf(mon, TARGET_FMT_plx ":", addr);
703 monitor_printf(mon, TARGET_FMT_lx ":", (target_ulong)addr);
714 monitor_printf(mon, " Cannot access memory\n");
735 monitor_printf(mon, " ");
738 monitor_printf(mon, "%#*" PRIo64, max_digits, v);
741 monitor_printf(mon, "0x%0*" PRIx64, max_digits, v);
744 monitor_printf(mon, "%*" PRIu64, max_digits, v);
747 monitor_printf(mon, "%*" PRId64, max_digits, v);
750 monitor_printc(mon, v);
755 monitor_printf(mon, "\n");
767 static void do_memory_dump(Monitor *mon, int count, int format, int size,
771 memory_dump(mon, count, format, size, addr, 0);
780 static void do_physical_memory_dump(Monitor *mon, int count, int format,
785 memory_dump(mon, count, format, size, addr, 1);
788 static void do_print(Monitor *mon, int count, int format, int size,
795 monitor_printf(mon, "%#o", val);
798 monitor_printf(mon, "%#x", val);
801 monitor_printf(mon, "%u", val);
805 monitor_printf(mon, "%d", val);
808 monitor_printc(mon, val);
814 monitor_printf(mon, "%#" PRIo64, val);
817 monitor_printf(mon, "%#" PRIx64, val);
820 monitor_printf(mon, "%" PRIu64, val);
824 monitor_printf(mon, "%" PRId64, val);
827 monitor_printc(mon, val);
831 monitor_printf(mon, "\n");
834 static void do_memory_save(Monitor *mon, unsigned int valh, unsigned int vall,
849 monitor_printf(mon, "could not open '%s'\n", filename);
864 static void do_physical_memory_save(Monitor *mon, unsigned int valh,
875 monitor_printf(mon, "could not open '%s'\n", filename);
891 static void do_sum(Monitor *mon, uint32_t start, uint32_t size)
904 monitor_printf(mon, "%05d\n", sum);
1087 static void do_sendkey(Monitor *mon, const char *string, int has_hold_time,
1107 monitor_printf(mon, "invalid key: '%s...'\n", keyname_buf);
1111 monitor_printf(mon, "too many keys\n");
1117 monitor_printf(mon, "unknown key: '%s'\n", keyname_buf);
1140 static void do_mouse_move(Monitor *mon, const char *dx_str, const char *dy_str,
1152 static void do_mouse_button(Monitor *mon, int button_state)
1158 static void do_ioport_read(Monitor *mon, int count, int format, int size,
1185 monitor_printf(mon, "port%c[0x%04x] = %#0*x\n",
1199 static void do_boot_set(Monitor *mon, const char *bootdevice)
1206 monitor_printf(mon, "boot device list now set to %s\n",
1209 monitor_printf(mon, "setting boot device list failed with "
1212 monitor_printf(mon, "no function defined to set boot device list for "
1217 static void do_system_reset(Monitor *mon)
1222 static void do_system_powerdown(Monitor *mon)
1228 static void print_pte(Monitor *mon, uint32_t addr, uint32_t pte, uint32_t mask)
1230 monitor_printf(mon, "%08x: %08x %c%c%c%c%c%c%c%c\n",
1243 static void tlb_info(Monitor *mon)
1254 monitor_printf(mon, "PG disabled\n");
1263 print_pte(mon, (l1 << 22), pde, ~((1 << 20) - 1));
1270 print_pte(mon, (l1 << 22) + (l2 << 12),
1280 static void mem_print(Monitor *mon, uint32_t *pstart, int *plast_prot,
1287 monitor_printf(mon, "%08x-%08x %08x %c%c%c\n",
1301 static void mem_info(Monitor *mon)
1312 monitor_printf(mon, "PG disabled\n");
1325 mem_print(mon, &start, &last_prot, end, prot);
1337 mem_print(mon, &start, &last_prot, end, prot);
1342 mem_print(mon, &start, &last_prot, end, prot);
1350 static void print_tlb(Monitor *mon, int idx, tlb_t *tlb)
1352 monitor_printf(mon, " tlb%i:\t"
1362 static void tlb_info(Monitor *mon)
1367 monitor_printf (mon, "ITLB:\n");
1369 print_tlb (mon, i, &env->itlb[i]);
1370 monitor_printf (mon, "UTLB:\n");
1372 print_tlb (mon, i, &env->utlb[i]);
1377 static void do_info_kqemu(Monitor *mon)
1385 monitor_printf(mon, "No cpu initialized yet");
1389 monitor_printf(mon, "kqemu support: ");
1393 monitor_printf(mon, "disabled\n");
1396 monitor_printf(mon, "enabled for user code\n");
1399 monitor_printf(mon, "enabled for user and kernel code\n");
1403 monitor_printf(mon, "kqemu support: not compiled\n");
1407 static void do_info_kvm(Monitor *mon)
1410 monitor_printf(mon, "kvm support: ");
1412 monitor_printf(mon, "enabled\n");
1414 monitor_printf(mon, "disabled\n");
1416 monitor_printf(mon, "kvm support: not compiled\n");
1420 static void do_info_numa(Monitor *mon)
1425 monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
1427 monitor_printf(mon, "node %d cpus:", i);
1430 monitor_printf(mon, " %d", env->cpu_index);
1433 monitor_printf(mon, "\n");
1434 monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
1449 static void do_info_profile(Monitor *mon)
1455 monitor_printf(mon, "async time %" PRId64 " (%0.3f)\n",
1457 monitor_printf(mon, "qemu time %" PRId64 " (%0.3f)\n",
1459 monitor_printf(mon, "kqemu time %" PRId64 " (%0.3f %0.1f%%) count=%"
1480 static void do_info_profile(Monitor *mon)
1482 monitor_printf(mon, "Internal profiler not compiled\n");
1489 static void do_info_capture(Monitor *mon)
1495 monitor_printf(mon, "[%d]: ", i);
1501 static void do_stop_capture(Monitor *mon, int n)
1516 static void do_wav_capture(Monitor *mon, const char *path,
1530 monitor_printf(mon, "Faied to add wave capture\n");
1538 static void do_inject_nmi(Monitor *mon, int cpu_index)
1550 static void do_info_status(Monitor *mon)
1554 monitor_printf(mon, "VM status: running (single step mode)\n");
1556 monitor_printf(mon, "VM status: running\n");
1559 monitor_printf(mon, "VM status: paused\n");
1563 static void do_balloon(Monitor *mon, int value)
1569 static void do_info_balloon(Monitor *mon)
1575 monitor_printf(mon, "Using KVM without synchronous MMU, "
1578 monitor_printf(mon, "Ballooning not activated in VM\n");
1580 monitor_printf(mon, "balloon: actual=%d\n", (int)(actual >> 20));
1583 static void do_acl(Monitor *mon,
1594 monitor_printf(mon, "acl: unknown list '%s'\n", aclname);
1601 monitor_printf(mon, "policy: %s\n",
1605 monitor_printf(mon, "%d: %s %s\n", i,
1611 monitor_printf(mon, "acl: removed all rules\n");
1614 monitor_printf(mon, "acl: missing policy parameter\n");
1620 monitor_printf(mon, "acl: policy set to 'allow'\n");
1623 monitor_printf(mon, "acl: policy set to 'deny'\n");
1625 monitor_printf(mon, "acl: unknown policy '%s', expected 'deny' or 'allow'\n", match);
1633 monitor_printf(mon, "acl: missing match parameter\n");
1642 monitor_printf(mon, "acl: unable to add acl entry\n");
1644 monitor_printf(mon, "acl: added rule at position %d\n", ret);
1649 monitor_printf(mon, "acl: missing match parameter\n");
1655 monitor_printf(mon, "acl: no matching acl entry\n");
1657 monitor_printf(mon, "acl: removed rule at position %d\n", ret);
1659 monitor_printf(mon, "acl: unknown command '%s'\n", command);
2094 static void expr_error(Monitor *mon, const char *msg)
2096 monitor_printf(mon, "%s\n", msg);
2142 static int64_t expr_sum(Monitor *mon);
2144 static int64_t expr_unary(Monitor *mon)
2153 n = expr_unary(mon);
2157 n = -expr_unary(mon);
2161 n = ~expr_unary(mon);
2165 n = expr_sum(mon);
2167 expr_error(mon, "')' expected");
2174 expr_error(mon, "character constant expected");
2178 expr_error(mon, "missing terminating \' character");
2201 expr_error(mon, "unknown register");
2203 expr_error(mon, "no cpu defined");
2208 expr_error(mon, "unexpected end of expression");
2218 expr_error(mon, "invalid char in expression");
2229 static int64_t expr_prod(Monitor *mon)
2234 val = expr_unary(mon);
2240 val2 = expr_unary(mon);
2249 expr_error(mon, "division by zero");
2260 static int64_t expr_logic(Monitor *mon)
2265 val = expr_prod(mon);
2271 val2 = expr_prod(mon);
2288 static int64_t expr_sum(Monitor *mon)
2293 val = expr_logic(mon);
2299 val2 = expr_logic(mon);
2308 static int get_expr(Monitor *mon, int64_t *pval, const char **pp)
2317 *pval = expr_sum(mon);
2418 static void monitor_handle_command(Monitor *mon, const char *cmdline)
2427 void (*handler_0)(Monitor *mon);
2428 void (*handler_1)(Monitor *mon, void *arg0);
2429 mon, void *arg0, void *arg1);
2430 void (*handler_3)(Monitor *mon, void *arg0, void *arg1, void *arg2);
2431 void (*handler_4)(Monitor *mon, void *arg0, void *arg1, void *arg2,
2433 void (*handler_5)(Monitor *mon, void *arg0, void *arg1, void *arg2,
2435 void (*handler_6)(Monitor *mon, void *arg0, void *arg1, void *arg2,
2437 void (*handler_7)(Monitor *mon, void *arg0, void *arg1, void *arg2,
2439 void (*handler_8)(Monitor *mon, void *arg0, void *arg1, void *arg2,
2442 void (*handler_9)(Monitor *mon, void *arg0, void *arg1, void *arg2,
2445 void (*handler_10)(Monitor *mon, void *arg0, void *arg1, void *arg2,
2449 monitor_printf(mon, "command='%s'\n", cmdline);
2464 monitor_printf(mon, "unknown command: '%s'\n", cmdname);
2501 monitor_printf(mon, "%s: filename expected\n",
2505 monitor_printf(mon, "%s: block device name expected\n",
2509 monitor_printf(mon, "%s: string expected\n", cmdname);
2520 monitor_printf(mon, "%s: too many arguments\n", cmdname);
2578 monitor_printf(mon, "invalid char in format: '%c'\n",
2641 if (get_expr(mon, &val, &p))
2674 monitor_printf(mon, "%s: unsupported option -%c\n",
2688 monitor_printf(mon, "%s: unknown type '%c'\n", cmdname, c);
2696 monitor_printf(mon, "%s: extraneous characters at the end of line\n",
2704 handler_0(mon);
2708 handler_1(mon, args[0]);
2712 handler_2(mon, args[0], args[1]);
2716 handler_3(mon, args[0], args[1], args[2]);
2720 handler_4(mon, args[0], args[1], args[2], args[3]);
2724 handler_5(mon, args[0], args[1], args[2], args[3], args[4]);
2728 handler_6(mon, args[0], args[1], args[2], args[3], args[4], args[5]);
2732 handler_7(mon, args[0], args[1], args[2], args[3], args[4], args[5],
2737 handler_8(mon, args[0], args[1], args[2], args[3], args[4], args[5],
2742 handler_9(mon, args[0], args[1], args[2], args[3], args[4], args[5],
2747 handler_10(mon, args[0], args[1], args[2], args[3], args[4], args[5],
2751 monitor_printf(mon, "unsupported number of arguments: %d\n", nb_args);
2759 void monitor_set_error(Monitor *mon, QError *qerror)
2765 if (!mon->error) {
2766 mon->error = qerror;
2978 Monitor *mon = opaque;
2980 return (mon->suspend_cnt == 0) ? 128 : 0;
2983 static void monitor_done(Monitor *mon); // forward
3008 static void monitor_command_cb(Monitor *mon, const char *cmdline, void *opaque)
3010 monitor_suspend(mon);
3011 monitor_handle_command(mon, cmdline);
3012 monitor_resume(mon);
3015 int monitor_suspend(Monitor *mon)
3017 if (!mon->rs)
3019 mon->suspend_cnt++;
3023 void monitor_resume(Monitor *mon)
3025 if (!mon->rs)
3027 if (--mon->suspend_cnt == 0)
3028 readline_show_prompt(mon->rs);
3033 Monitor *mon = opaque;
3037 mon->mux_out = 0;
3038 if (mon->reset_seen) {
3039 readline_restart(mon->rs);
3040 monitor_resume(mon);
3041 monitor_flush(mon);
3043 mon->suspend_cnt = 0;
3048 if (mon->reset_seen) {
3049 if (mon->suspend_cnt == 0) {
3050 monitor_printf(mon, "\n");
3052 monitor_flush(mon);
3053 monitor_suspend(mon);
3055 mon->suspend_cnt++;
3057 mon->mux_out = 1;
3061 monitor_printf(mon, "QEMU %s monitor - type 'help' for more "
3063 if (!mon->mux_out) {
3064 readline_show_prompt(mon->rs);
3066 mon->reset_seen = 1;
3083 Monitor *mon;
3090 mon = qemu_mallocz(sizeof(*mon));
3092 mon->chr = chr;
3093 mon->flags = flags;
3095 mon->rs = readline_init(mon, monitor_find_completion);
3096 monitor_read_command(mon, 0);
3100 mon);
3102 QLIST_INSERT_HEAD(&mon_list, mon, entry);
3104 cur_mon = mon;
3107 static void monitor_done(Monitor *mon)
3109 if (cur_mon == mon)
3112 QLIST_REMOVE(mon, entry);
3114 readline_free(mon->rs);
3115 qemu_chr_close(mon->chr);
3117 qemu_free(mon);
3120 static void bdrv_password_cb(Monitor *mon, const char *password, void *opaque)
3126 monitor_printf(mon, "invalid password\n");
3129 if (mon->password_completion_cb)
3130 mon->password_completion_cb(mon->password_opaque, ret);
3132 monitor_read_command(mon, 1);
3135 int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
3147 if (monitor_ctrl_mode(mon)) {
3152 monitor_printf(mon, "%s (%s) is encrypted.\n", bdrv_get_device_name(bs),
3155 mon->password_completion_cb = completion_cb;
3156 mon->password_opaque = opaque;
3158 err = monitor_read_password(mon, bdrv_password_cb, bs);