#include "qemu-timer.h"
#include "qmp-commands.h"
#include "monitor.h"
+#include "console.h"
static void hmp_handle_error(Monitor *mon, Error **errp)
{
if (info->has_status) {
monitor_printf(mon, "Migration status: %s\n", info->status);
+ monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
+ info->total_time);
}
if (info->has_ram) {
info->ram->remaining >> 10);
monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n",
info->ram->total >> 10);
- monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n",
- info->ram->total_time);
monitor_printf(mon, "duplicate: %" PRIu64 " pages\n",
info->ram->duplicate);
monitor_printf(mon, "normal: %" PRIu64 " pages\n",
qmp_closefd(fdname, &errp);
hmp_handle_error(mon, &errp);
}
+
+void hmp_send_key(Monitor *mon, const QDict *qdict)
+{
+ const char *keys = qdict_get_str(qdict, "keys");
+ QKeyCodeList *keylist, *head = NULL, *tmp = NULL;
+ int has_hold_time = qdict_haskey(qdict, "hold-time");
+ int hold_time = qdict_get_try_int(qdict, "hold-time", -1);
+ Error *err = NULL;
+ char keyname_buf[16];
+ char *separator;
+ int keyname_len, idx;
+
+ while (1) {
+ separator = strchr(keys, '-');
+ keyname_len = separator ? separator - keys : strlen(keys);
+ pstrcpy(keyname_buf, sizeof(keyname_buf), keys);
+
+ /* Be compatible with old interface, convert user inputted "<" */
+ if (!strncmp(keyname_buf, "<", 1) && keyname_len == 1) {
+ pstrcpy(keyname_buf, sizeof(keyname_buf), "less");
+ keyname_len = 4;
+ }
+ keyname_buf[keyname_len] = 0;
+
+ idx = index_from_key(keyname_buf);
+ if (idx == Q_KEY_CODE_MAX) {
+ monitor_printf(mon, "invalid parameter: %s\n", keyname_buf);
+ break;
+ }
+
+ keylist = g_malloc0(sizeof(*keylist));
+ keylist->value = idx;
+ keylist->next = NULL;
+
+ if (!head) {
+ head = keylist;
+ }
+ if (tmp) {
+ tmp->next = keylist;
+ }
+ tmp = keylist;
+
+ if (!separator) {
+ break;
+ }
+ keys = separator + 1;
+ }
+
+ if (idx != Q_KEY_CODE_MAX) {
+ qmp_send_key(head, has_hold_time, hold_time, &err);
+ }
+ hmp_handle_error(mon, &err);
+ qapi_free_QKeyCodeList(head);
+}