summaryrefslogtreecommitdiff
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
commit4d00796364ec4edab86b08abc38fd644d5e3c0ad (patch)
treeef35c4260437568add05037ee7a004fc2bc49162 /qtest.c
parent7a6a740d8dcc02f5693315d7935b5de9b963bb96 (diff)
qtest: add memset to qtest protocol
Previously, memset was just a frontend to write() and only stupidly sent the pattern many times across the wire. Let's not discuss who stupidly wrote it like that in the first place. (Hint: It was me.) Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1430864578-22072-4-git-send-email-jsnow@redhat.com
Diffstat (limited to 'qtest.c')
-rw-r--r--qtest.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/qtest.c b/qtest.c
index 73b7a0f9b8..04412ddde1 100644
--- a/qtest.c
+++ b/qtest.c
@@ -125,6 +125,9 @@ static bool qtest_opened;
* > b64write ADDR SIZE B64_DATA
* < OK
*
+ * > memset ADDR SIZE VALUE
+ * < OK
+ *
* ADDR, SIZE, VALUE are all integers parsed with strtoul() with a base of 0.
*
* DATA is an arbitrarily long hex number prefixed with '0x'. If it's smaller
@@ -473,6 +476,23 @@ static void qtest_process_command(CharDriverState *chr, gchar **words)
qtest_send_prefix(chr);
qtest_send(chr, "OK\n");
+ } else if (strcmp(words[0], "memset") == 0) {
+ uint64_t addr, len;
+ uint8_t *data;
+ uint8_t pattern;
+
+ g_assert(words[1] && words[2] && words[3]);
+ addr = strtoull(words[1], NULL, 0);
+ len = strtoull(words[2], NULL, 0);
+ pattern = strtoull(words[3], NULL, 0);
+
+ data = g_malloc(len);
+ memset(data, pattern, len);
+ cpu_physical_memory_write(addr, data, len);
+ g_free(data);
+
+ qtest_send_prefix(chr);
+ qtest_send(chr, "OK\n");
} else if (strcmp(words[0], "b64write") == 0) {
uint64_t addr, len;
uint8_t *data;