*/
#include <dirent.h>
#include "hw/hw.h"
+#include "hw/qdev.h"
#include "hw/usb.h"
#include "hw/pcmcia.h"
#include "hw/pc.h"
#include "hw/pci.h"
+#include "hw/watchdog.h"
#include "gdbstub.h"
#include "net.h"
#include "qemu-char.h"
static void do_info_version(Monitor *mon)
{
- monitor_printf(mon, "%s\n", QEMU_VERSION);
+ monitor_printf(mon, "%s\n", QEMU_VERSION QEMU_PKGVERSION);
}
static void do_info_name(Monitor *mon)
cpu_set_log(mask);
}
+static void do_singlestep(Monitor *mon, const char *option)
+{
+ if (!option || !strcmp(option, "on")) {
+ singlestep = 1;
+ } else if (!strcmp(option, "off")) {
+ singlestep = 0;
+ } else {
+ monitor_printf(mon, "unexpected option %s\n", option);
+ }
+}
+
static void do_stop(Monitor *mon)
{
vm_stop(EXCP_INTERRUPT);
}
}
-#ifdef CONFIG_GDBSTUB
-static void do_gdbserver(Monitor *mon, const char *port)
+static void do_gdbserver(Monitor *mon, const char *device)
{
- if (!port)
- port = DEFAULT_GDBSTUB_PORT;
- if (gdbserver_start(port) < 0) {
- monitor_printf(mon, "Could not open gdbserver socket on port '%s'\n",
- port);
- } else if (strcmp(port, "none") == 0) {
+ if (!device)
+ device = "tcp::" DEFAULT_GDBSTUB_PORT;
+ if (gdbserver_start(device) < 0) {
+ monitor_printf(mon, "Could not open gdbserver on device '%s'\n",
+ device);
+ } else if (strcmp(device, "none") == 0) {
monitor_printf(mon, "Disabled gdbserver\n");
} else {
- monitor_printf(mon, "Waiting gdb connection on port '%s'\n", port);
+ monitor_printf(mon, "Waiting for gdb connection on device '%s'\n",
+ device);
+ }
+}
+
+static void do_watchdog_action(Monitor *mon, const char *action)
+{
+ if (select_watchdog_action(action) == -1) {
+ monitor_printf(mon, "Unknown watchdog action '%s'\n", action);
}
}
-#endif
static void monitor_printc(Monitor *mon, int c)
{
static void do_info_kqemu(Monitor *mon)
{
-#ifdef USE_KQEMU
+#ifdef CONFIG_KQEMU
CPUState *env;
int val;
val = 0;
#endif
}
+static void do_info_numa(Monitor *mon)
+{
+ int i;
+ CPUState *env;
+
+ monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
+ for (i = 0; i < nb_numa_nodes; i++) {
+ monitor_printf(mon, "node %d cpus:", i);
+ for (env = first_cpu; env != NULL; env = env->next_cpu) {
+ if (env->numa_node == i) {
+ monitor_printf(mon, " %d", env->cpu_index);
+ }
+ }
+ monitor_printf(mon, "\n");
+ monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
+ node_mem[i] >> 20);
+ }
+}
+
#ifdef CONFIG_PROFILER
int64_t kqemu_time;
kqemu_ret_int_count = 0;
kqemu_ret_excp_count = 0;
kqemu_ret_intr_count = 0;
-#ifdef USE_KQEMU
+#ifdef CONFIG_KQEMU
kqemu_record_dump();
#endif
}
}
}
+#ifdef HAS_AUDIO
static void do_stop_capture(Monitor *mon, int n)
{
int i;
}
}
-#ifdef HAS_AUDIO
static void do_wav_capture(Monitor *mon, const char *path,
int has_freq, int freq,
int has_bits, int bits,
static void do_info_status(Monitor *mon)
{
- if (vm_running)
- monitor_printf(mon, "VM status: running\n");
- else
+ if (vm_running) {
+ if (singlestep) {
+ monitor_printf(mon, "VM status: running (single step mode)\n");
+ } else {
+ monitor_printf(mon, "VM status: running\n");
+ }
+ } else
monitor_printf(mon, "VM status: paused\n");
}
}
}
-/* Please update qemu-doc.texi when adding or changing commands */
static const mon_cmd_t mon_cmds[] = {
- { "help|?", "s?", help_cmd,
- "[cmd]", "show the help" },
- { "commit", "s", do_commit,
- "device|all", "commit changes to the disk images (if -snapshot is used) or backing files" },
- { "info", "s?", do_info,
- "subcommand", "show various information about the system state" },
- { "q|quit", "", do_quit,
- "", "quit the emulator" },
- { "eject", "-fB", do_eject,
- "[-f] device", "eject a removable medium (use -f to force it)" },
- { "change", "BFs?", do_change,
- "device filename [format]", "change a removable medium, optional format" },
- { "screendump", "F", do_screen_dump,
- "filename", "save screen into PPM image 'filename'" },
- { "logfile", "F", do_logfile,
- "filename", "output logs to 'filename'" },
- { "log", "s", do_log,
- "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" },
- { "savevm", "s?", do_savevm,
- "tag|id", "save a VM snapshot. If no tag or id are provided, a new snapshot is created" },
- { "loadvm", "s", do_loadvm,
- "tag|id", "restore a VM snapshot from its tag or id" },
- { "delvm", "s", do_delvm,
- "tag|id", "delete a VM snapshot from its tag or id" },
- { "stop", "", do_stop,
- "", "stop emulation", },
- { "c|cont", "", do_cont,
- "", "resume emulation", },
-#ifdef CONFIG_GDBSTUB
- { "gdbserver", "s?", do_gdbserver,
- "[port]", "start gdbserver session (default port=1234)", },
-#endif
- { "x", "/l", do_memory_dump,
- "/fmt addr", "virtual memory dump starting at 'addr'", },
- { "xp", "/l", do_physical_memory_dump,
- "/fmt addr", "physical memory dump starting at 'addr'", },
- { "p|print", "/l", do_print,
- "/fmt expr", "print expression value (use $reg for CPU register access)", },
- { "i", "/ii.", do_ioport_read,
- "/fmt addr", "I/O port read" },
-
- { "sendkey", "si?", do_sendkey,
- "keys [hold_ms]", "send keys to the VM (e.g. 'sendkey ctrl-alt-f1', default hold time=100 ms)" },
- { "system_reset", "", do_system_reset,
- "", "reset the system" },
- { "system_powerdown", "", do_system_powerdown,
- "", "send system power down event" },
- { "sum", "ii", do_sum,
- "addr size", "compute the checksum of a memory region" },
- { "usb_add", "s", do_usb_add,
- "device", "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')" },
- { "usb_del", "s", do_usb_del,
- "device", "remove USB device 'bus.addr'" },
- { "cpu", "i", do_cpu_set,
- "index", "set the default CPU" },
- { "mouse_move", "sss?", do_mouse_move,
- "dx dy [dz]", "send mouse move events" },
- { "mouse_button", "i", do_mouse_button,
- "state", "change mouse button state (1=L, 2=M, 4=R)" },
- { "mouse_set", "i", do_mouse_set,
- "index", "set which mouse device receives events" },
-#ifdef HAS_AUDIO
- { "wavcapture", "si?i?i?", do_wav_capture,
- "path [frequency bits channels]",
- "capture audio to a wave file (default frequency=44100 bits=16 channels=2)" },
-#endif
- { "stopcapture", "i", do_stop_capture,
- "capture index", "stop capture" },
- { "memsave", "lis", do_memory_save,
- "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", },
- { "pmemsave", "lis", do_physical_memory_save,
- "addr size file", "save to disk physical memory dump starting at 'addr' of size 'size'", },
- { "boot_set", "s", do_boot_set,
- "bootdevice", "define new values for the boot device list" },
-#if defined(TARGET_I386)
- { "nmi", "i", do_inject_nmi,
- "cpu", "inject an NMI on the given CPU", },
-#endif
- { "migrate", "-ds", do_migrate,
- "[-d] uri", "migrate to URI (using -d to not wait for completion)" },
- { "migrate_cancel", "", do_migrate_cancel,
- "", "cancel the current VM migration" },
- { "migrate_set_speed", "s", do_migrate_set_speed,
- "value", "set maximum speed (in bytes) for migrations" },
-#if defined(TARGET_I386)
- { "drive_add", "ss", drive_hot_add, "pci_addr=[[<domain>:]<bus>:]<slot>\n"
- "[file=file][,if=type][,bus=n]\n"
- "[,unit=m][,media=d][index=i]\n"
- "[,cyls=c,heads=h,secs=s[,trans=t]]\n"
- "[snapshot=on|off][,cache=on|off]",
- "add drive to PCI storage controller" },
- { "pci_add", "sss", pci_device_hot_add, "pci_addr=auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", "hot-add PCI device" },
- { "pci_del", "s", pci_device_hot_remove, "pci_addr=[[<domain>:]<bus>:]<slot>", "hot remove PCI device" },
- { "host_net_add", "ss", net_host_device_add,
- "[tap,user,socket,vde] options", "add host VLAN client" },
- { "host_net_remove", "is", net_host_device_remove,
- "vlan_id name", "remove host VLAN client" },
-#endif
- { "balloon", "i", do_balloon,
- "target", "request VM to change it's memory allocation (in MB)" },
- { "set_link", "ss", do_set_link,
- "name [up|down]", "change the link status of a network adapter" },
- { "acl", "sss?i?", do_acl, "<command> <aclname> [<match>] [<index>]\n",
- "acl show vnc.username\n"
- "acl policy vnc.username deny\n"
- "acl allow vnc.username fred\n"
- "acl deny vnc.username bob\n"
- "acl reset vnc.username\n" },
+#include "qemu-monitor.h"
{ NULL, NULL, },
};
-/* Please update qemu-doc.texi when adding or changing commands */
+/* Please update qemu-monitor.hx when adding or changing commands */
static const mon_cmd_t info_cmds[] = {
{ "version", "", do_info_version,
"", "show the version of QEMU" },
"", "show KQEMU information", },
{ "kvm", "", do_info_kvm,
"", "show KVM information", },
+ { "numa", "", do_info_numa,
+ "", "show NUMA information", },
{ "usb", "", usb_info,
"", "show guest USB devices", },
{ "usbhost", "", usb_host_info,
{ "migrate", "", do_info_migrate, "", "show migration status" },
{ "balloon", "", do_info_balloon,
"", "show balloon information" },
+ { "qtree", "", do_info_qtree,
+ "", "show device tree" },
{ NULL, NULL, },
};
return 0;
}
+/*
+ * Store the command-name in cmdname, and return a pointer to
+ * the remaining of the command string.
+ */
+static const char *get_command_name(const char *cmdline,
+ char *cmdname, size_t nlen)
+{
+ size_t len;
+ const char *p, *pstart;
+
+ p = cmdline;
+ while (qemu_isspace(*p))
+ p++;
+ if (*p == '\0')
+ return NULL;
+ pstart = p;
+ while (*p != '\0' && *p != '/' && !qemu_isspace(*p))
+ p++;
+ len = p - pstart;
+ if (len > nlen - 1)
+ len = nlen - 1;
+ memcpy(cmdname, pstart, len);
+ cmdname[len] = '\0';
+ return p;
+}
+
static int default_fmt_format = 'x';
static int default_fmt_size = 4;
static void monitor_handle_command(Monitor *mon, const char *cmdline)
{
- const char *p, *pstart, *typestr;
- char *q;
- int c, nb_args, len, i, has_arg;
+ const char *p, *typestr;
+ int c, nb_args, i, has_arg;
const mon_cmd_t *cmd;
char cmdname[256];
char buf[1024];
#endif
/* extract the command name */
- p = cmdline;
- q = cmdname;
- while (qemu_isspace(*p))
- p++;
- if (*p == '\0')
+ p = get_command_name(cmdline, cmdname, sizeof(cmdname));
+ if (!p)
return;
- pstart = p;
- while (*p != '\0' && *p != '/' && !qemu_isspace(*p))
- p++;
- len = p - pstart;
- if (len > sizeof(cmdname) - 1)
- len = sizeof(cmdname) - 1;
- memcpy(cmdname, pstart, len);
- cmdname[len] = '\0';
/* find the command */
for(cmd = mon_cmds; cmd->name != NULL; cmd++) {
if (compare_cmd(cmdname, cmd->name))
- goto found;
+ break;
+ }
+
+ if (cmd->name == NULL) {
+ monitor_printf(mon, "unknown command: '%s'\n", cmdname);
+ return;
}
- monitor_printf(mon, "unknown command: '%s'\n", cmdname);
- return;
- found:
for(i = 0; i < MAX_ARGS; i++)
str_allocated[i] = NULL;
fail:
for(i = 0; i < MAX_ARGS; i++)
qemu_free(str_allocated[i]);
- return;
}
static void cmd_completion(const char *name, const char *list)