[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 12/14] qtest: add memset to qtest protocol
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL v2 12/14] qtest: add memset to qtest protocol |
Date: |
Tue, 12 May 2015 14:46:24 -0400 |
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 <address@hidden>
Message-id: address@hidden
---
qtest.c | 20 ++++++++++++++++++++
tests/libqtest.c | 8 +-------
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/qtest.c b/qtest.c
index 73b7a0f..04412dd 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;
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 5f57005..055aad6 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -741,13 +741,7 @@ void qtest_memwrite(QTestState *s, uint64_t addr, const
void *data, size_t size)
void qtest_memset(QTestState *s, uint64_t addr, uint8_t pattern, size_t size)
{
- size_t i;
-
- qtest_sendf(s, "write 0x%" PRIx64 " 0x%zx 0x", addr, size);
- for (i = 0; i < size; i++) {
- qtest_sendf(s, "%02x", pattern);
- }
- qtest_sendf(s, "\n");
+ qtest_sendf(s, "memset 0x%" PRIx64 " 0x%zx 0x%02x\n", addr, size, pattern);
qtest_rsp(s, 0);
}
--
2.1.0
- [Qemu-devel] [PULL v2 00/14] Ide patches, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 08/14] qtest/ahci: add halted dma test, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 01/14] libqos/ahci: Add halted command helpers, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 02/14] libqos/ahci: Fix sector set method, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 04/14] ich9/ahci: Enable Migration, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 07/14] qtest/ahci: add flush migrate test, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 06/14] qtest/ahci: add migrate dma test, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 12/14] qtest: add memset to qtest protocol,
John Snow <=
- [Qemu-devel] [PULL v2 05/14] qtest/ahci: Add migration test, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 03/14] libqos: Add migration helpers, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 14/14] qtest: pre-buffer hex nibs, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 09/14] qtest/ahci: add migrate halted dma test, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 13/14] libqos/ahci: Swap memread/write with bufread/write, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 10/14] qtest: allow arbitrarily long sends, John Snow, 2015/05/12
- [Qemu-devel] [PULL v2 11/14] qtest: Add base64 encoded read/write, John Snow, 2015/05/12
- Re: [Qemu-devel] [PULL v2 00/14] Ide patches, Peter Maydell, 2015/05/12