summaryrefslogtreecommitdiffstats
path: root/qtest.c
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2015-05-22 14:13:44 -0400
committerJohn Snow <jsnow@redhat.com>2015-05-22 15:58:22 -0400
commit5560b85a31e6f15a8841b66620d9497943094ee4 (patch)
tree267c1f98fab3800dcdc936ebc66f565c9d4d8445 /qtest.c
parent91d0374a7ffbd6a9cd0ba159c9160d9f26220cf5 (diff)
downloadhqemu-5560b85a31e6f15a8841b66620d9497943094ee4.zip
hqemu-5560b85a31e6f15a8841b66620d9497943094ee4.tar.gz
qtest: pre-buffer hex nibs
Instead of converting each byte one-at-a-time and then sending each byte over the wire, use sprintf() to pre-compute all of the hex nibs into a single buffer, then send the entire buffer all at once. This gives a moderate speed boost to memread() and memwrite() functions. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 1431021095-7558-2-git-send-email-jsnow@redhat.com
Diffstat (limited to 'qtest.c')
-rw-r--r--qtest.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/qtest.c b/qtest.c
index 04412dd..05cefd2 100644
--- a/qtest.c
+++ b/qtest.c
@@ -414,6 +414,7 @@ static void qtest_process_command(CharDriverState *chr, gchar **words)
} else if (strcmp(words[0], "read") == 0) {
uint64_t addr, len, i;
uint8_t *data;
+ char *enc;
g_assert(words[1] && words[2]);
addr = strtoull(words[1], NULL, 0);
@@ -422,14 +423,16 @@ static void qtest_process_command(CharDriverState *chr, gchar **words)
data = g_malloc(len);
cpu_physical_memory_read(addr, data, len);
- qtest_send_prefix(chr);
- qtest_send(chr, "OK 0x");
+ enc = g_malloc(2 * len + 1);
for (i = 0; i < len; i++) {
- qtest_sendf(chr, "%02x", data[i]);
+ sprintf(&enc[i * 2], "%02x", data[i]);
}
- qtest_send(chr, "\n");
+
+ qtest_send_prefix(chr);
+ qtest_sendf(chr, "OK 0x%s\n", enc);
g_free(data);
+ g_free(enc);
} else if (strcmp(words[0], "b64read") == 0) {
uint64_t addr, len;
uint8_t *data;
OpenPOWER on IntegriCloud