diff options
author | Markus Armbruster <armbru@redhat.com> | 2013-02-06 21:27:26 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-02-06 16:35:20 -0600 |
commit | 543f34126b7bfc85b05d0e371e3ce0695444f433 (patch) | |
tree | a1daca7381d4f1843e7858eba8fafed8f4774ad3 /hmp.c | |
parent | de1cc36e1039faf65b1739d28bef9f2a4e230eb6 (diff) | |
download | qemu-543f34126b7bfc85b05d0e371e3ce0695444f433.tar.gz qemu-543f34126b7bfc85b05d0e371e3ce0695444f433.tar.bz2 qemu-543f34126b7bfc85b05d0e371e3ce0695444f433.zip |
hmp: make memchar-read escape ASCII control chars except \n and \t
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hmp.c')
-rw-r--r-- | hmp.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -679,6 +679,7 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict) const char *chardev = qdict_get_str(qdict, "device"); char *data; Error *errp = NULL; + int i; data = qmp_ringbuf_read(chardev, size, false, 0, &errp); if (errp) { @@ -687,7 +688,19 @@ void hmp_ringbuf_read(Monitor *mon, const QDict *qdict) return; } - monitor_printf(mon, "%s\n", data); + for (i = 0; data[i]; i++) { + unsigned char ch = data[i]; + + if (ch == '\\') { + monitor_printf(mon, "\\\\"); + } else if ((ch < 0x20 && ch != '\n' && ch != '\t') || ch == 0x7F) { + monitor_printf(mon, "\\u%04X", ch); + } else { + monitor_printf(mon, "%c", ch); + } + + } + monitor_printf(mon, "\n"); g_free(data); } |