int suffix;
if (has_index) {
- cpu_outb(NULL, addr & 0xffff, index & 0xff);
+ cpu_outb(NULL, addr & IOPORTS_MASK, index & 0xff);
addr++;
}
addr &= 0xffff;
suffix, addr, size * 2, val);
}
-/* boot_set handler */
-static QEMUBootSetHandler *qemu_boot_set_handler = NULL;
-static void *boot_opaque;
-
-void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque)
-{
- qemu_boot_set_handler = func;
- boot_opaque = opaque;
-}
-
static void do_boot_set(Monitor *mon, const char *bootdevice)
{
int res;
- if (qemu_boot_set_handler) {
- res = qemu_boot_set_handler(boot_opaque, bootdevice);
- if (res == 0)
- monitor_printf(mon, "boot device list now set to %s\n",
- bootdevice);
- else
- monitor_printf(mon, "setting boot device list failed with "
- "error %i\n", res);
+ res = qemu_boot_set(bootdevice);
+ if (res == 0) {
+ monitor_printf(mon, "boot device list now set to %s\n", bootdevice);
+ } else if (res > 0) {
+ monitor_printf(mon, "setting boot device list failed\n");
} else {
monitor_printf(mon, "no function defined to set boot device list for "
"this architecture\n");
monitor_printf(mon, "balloon: actual=%d\n", (int)(actual >> 20));
}
-static void do_acl(Monitor *mon,
- const char *command,
- const char *aclname,
- const char *match,
- int has_index,
- int index)
+static qemu_acl *find_acl(Monitor *mon, const char *name)
{
- qemu_acl *acl;
+ qemu_acl *acl = qemu_acl_find(name);
- acl = qemu_acl_find(aclname);
if (!acl) {
- monitor_printf(mon, "acl: unknown list '%s'\n", aclname);
- return;
+ monitor_printf(mon, "acl: unknown list '%s'\n", name);
}
+ return acl;
+}
- if (strcmp(command, "show") == 0) {
- int i = 0;
- qemu_acl_entry *entry;
+static void do_acl_show(Monitor *mon, const char *aclname)
+{
+ qemu_acl *acl = find_acl(mon, aclname);
+ qemu_acl_entry *entry;
+ int i = 0;
+
+ if (acl) {
monitor_printf(mon, "policy: %s\n",
acl->defaultDeny ? "deny" : "allow");
TAILQ_FOREACH(entry, &acl->entries, next) {
i++;
monitor_printf(mon, "%d: %s %s\n", i,
- entry->deny ? "deny" : "allow",
- entry->match);
+ entry->deny ? "deny" : "allow", entry->match);
}
- } else if (strcmp(command, "reset") == 0) {
+ }
+}
+
+static void do_acl_reset(Monitor *mon, const char *aclname)
+{
+ qemu_acl *acl = find_acl(mon, aclname);
+
+ if (acl) {
qemu_acl_reset(acl);
monitor_printf(mon, "acl: removed all rules\n");
- } else if (strcmp(command, "policy") == 0) {
- if (!match) {
- monitor_printf(mon, "acl: missing policy parameter\n");
- return;
- }
+ }
+}
- if (strcmp(match, "allow") == 0) {
+static void do_acl_policy(Monitor *mon, const char *aclname,
+ const char *policy)
+{
+ qemu_acl *acl = find_acl(mon, aclname);
+
+ if (acl) {
+ if (strcmp(policy, "allow") == 0) {
acl->defaultDeny = 0;
monitor_printf(mon, "acl: policy set to 'allow'\n");
- } else if (strcmp(match, "deny") == 0) {
+ } else if (strcmp(policy, "deny") == 0) {
acl->defaultDeny = 1;
monitor_printf(mon, "acl: policy set to 'deny'\n");
} else {
- monitor_printf(mon, "acl: unknown policy '%s', expected 'deny' or 'allow'\n", match);
+ monitor_printf(mon, "acl: unknown policy '%s', "
+ "expected 'deny' or 'allow'\n", policy);
}
- } else if ((strcmp(command, "allow") == 0) ||
- (strcmp(command, "deny") == 0)) {
- int deny = strcmp(command, "deny") == 0 ? 1 : 0;
- int ret;
+ }
+}
+
+static void do_acl_add(Monitor *mon, const char *aclname,
+ const char *match, const char *policy,
+ int has_index, int index)
+{
+ qemu_acl *acl = find_acl(mon, aclname);
+ int deny, ret;
- if (!match) {
- monitor_printf(mon, "acl: missing match parameter\n");
+ if (acl) {
+ if (strcmp(policy, "allow") == 0) {
+ deny = 0;
+ } else if (strcmp(policy, "deny") == 0) {
+ deny = 1;
+ } else {
+ monitor_printf(mon, "acl: unknown policy '%s', "
+ "expected 'deny' or 'allow'\n", policy);
return;
}
-
if (has_index)
ret = qemu_acl_insert(acl, deny, match, index);
else
monitor_printf(mon, "acl: unable to add acl entry\n");
else
monitor_printf(mon, "acl: added rule at position %d\n", ret);
- } else if (strcmp(command, "remove") == 0) {
- int ret;
+ }
+}
- if (!match) {
- monitor_printf(mon, "acl: missing match parameter\n");
- return;
- }
+static void do_acl_remove(Monitor *mon, const char *aclname, const char *match)
+{
+ qemu_acl *acl = find_acl(mon, aclname);
+ int ret;
+ if (acl) {
ret = qemu_acl_remove(acl, match);
if (ret < 0)
monitor_printf(mon, "acl: no matching acl entry\n");
else
monitor_printf(mon, "acl: removed rule at position %d\n", ret);
- } else {
- monitor_printf(mon, "acl: unknown command '%s'\n", command);
}
}
+#if defined(TARGET_I386)
+static void do_inject_mce(Monitor *mon,
+ int cpu_index, int bank,
+ unsigned status_hi, unsigned status_lo,
+ unsigned mcg_status_hi, unsigned mcg_status_lo,
+ unsigned addr_hi, unsigned addr_lo,
+ unsigned misc_hi, unsigned misc_lo)
+{
+ CPUState *cenv;
+ uint64_t status = ((uint64_t)status_hi << 32) | status_lo;
+ uint64_t mcg_status = ((uint64_t)mcg_status_hi << 32) | mcg_status_lo;
+ uint64_t addr = ((uint64_t)addr_hi << 32) | addr_lo;
+ uint64_t misc = ((uint64_t)misc_hi << 32) | misc_lo;
+
+ for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu)
+ if (cenv->cpu_index == cpu_index && cenv->mcg_cap) {
+ cpu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc);
+ break;
+ }
+}
+#endif
+
static const mon_cmd_t mon_cmds[] = {
#include "qemu-monitor.h"
{ NULL, NULL, },
"", "show CPU statistics", },
#endif
#if defined(CONFIG_SLIRP)
- { "slirp", "", do_info_slirp,
- "", "show SLIRP statistics", },
+ { "usernet", "", do_info_usernet,
+ "", "show user network stack connection states", },
#endif
{ "migrate", "", do_info_migrate, "", "show migration status" },
{ "balloon", "", do_info_balloon,
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];
void *arg3, void *arg4, void *arg5);
void (*handler_7)(Monitor *mon, void *arg0, void *arg1, void *arg2,
void *arg3, void *arg4, void *arg5, void *arg6);
+ void (*handler_8)(Monitor *mon, void *arg0, void *arg1, void *arg2,
+ void *arg3, void *arg4, void *arg5, void *arg6,
+ void *arg7);
+ void (*handler_9)(Monitor *mon, void *arg0, void *arg1, void *arg2,
+ void *arg3, void *arg4, void *arg5, void *arg6,
+ void *arg7, void *arg8);
+ void (*handler_10)(Monitor *mon, void *arg0, void *arg1, void *arg2,
+ void *arg3, void *arg4, void *arg5, void *arg6,
+ void *arg7, void *arg8, void *arg9);
#ifdef DEBUG
monitor_printf(mon, "command='%s'\n", cmdline);
#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++) {
handler_7(mon, args[0], args[1], args[2], args[3], args[4], args[5],
args[6]);
break;
+ case 8:
+ handler_8 = cmd->handler;
+ handler_8(mon, args[0], args[1], args[2], args[3], args[4], args[5],
+ args[6], args[7]);
+ break;
+ case 9:
+ handler_9 = cmd->handler;
+ handler_9(mon, args[0], args[1], args[2], args[3], args[4], args[5],
+ args[6], args[7], args[8]);
+ break;
+ case 10:
+ handler_10 = cmd->handler;
+ handler_10(mon, args[0], args[1], args[2], args[3], args[4], args[5],
+ args[6], args[7], args[8], args[9]);
+ break;
default:
monitor_printf(mon, "unsupported number of arguments: %d\n", nb_args);
goto fail;
fail:
for(i = 0; i < MAX_ARGS; i++)
qemu_free(str_allocated[i]);
- return;
}
static void cmd_completion(const char *name, const char *list)
for(key = key_defs; key->name != NULL; key++) {
cmd_completion(str, key->name);
}
+ } else if (!strcmp(cmd->name, "help|?")) {
+ readline_set_completion_index(cur_mon->rs, strlen(str));
+ for (cmd = mon_cmds; cmd->name != NULL; cmd++) {
+ cmd_completion(str, cmd->name);
+ }
}
break;
default: