[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/28] qtest: Adding qtest_memset and qmemset.
From: |
John Snow |
Subject: |
[Qemu-devel] [PATCH 19/28] qtest: Adding qtest_memset and qmemset. |
Date: |
Mon, 7 Jul 2014 14:18:00 -0400 |
Currently, libqtest allows for memread and memwrite, but
does not offer a simple way to zero out regions of memory.
This patch adds a simple function to do so.
Signed-off-by: John Snow <address@hidden>
---
tests/libqtest.c | 12 ++++++++++++
tests/libqtest.h | 24 ++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 4a75cd3..e525e6f 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -659,6 +659,18 @@ void qtest_memwrite(QTestState *s, uint64_t addr, const
void *data, size_t size)
qtest_rsp(s, 0);
}
+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_rsp(s, 0);
+}
+
QDict *qmp(const char *fmt, ...)
{
va_list ap;
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 8f323c7..1be0934 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -283,6 +283,17 @@ void qtest_memread(QTestState *s, uint64_t addr, void
*data, size_t size);
void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t
size);
/**
+ * qtest_memset:
+ * @s: #QTestState instance to operate on.
+ * @addr: Guest address to write to.
+ * @patt: Byte pattern to fill the guest memory region with.
+ * @size: Number of bytes to write.
+ *
+ * Write a pattern to guest memory.
+ */
+void qtest_memset(QTestState *s, uint64_t addr, uint8_t patt, size_t size);
+
+/**
* qtest_clock_step_next:
* @s: #QTestState instance to operate on.
*
@@ -621,6 +632,19 @@ static inline void memwrite(uint64_t addr, const void
*data, size_t size)
}
/**
+ * qmemset:
+ * @addr: Guest address to write to.
+ * @patt: Byte pattern to fill the guest memory region with.
+ * @size: Number of bytes to write.
+ *
+ * Write a pattern to guest memory.
+ */
+static inline void qmemset(uint64_t addr, uint8_t patt, size_t size)
+{
+ qtest_memset(global_qtest, addr, patt, size);
+}
+
+/**
* clock_step_next:
*
* Advance the QEMU_CLOCK_VIRTUAL to the next deadline.
--
1.9.3
- [Qemu-devel] [PATCH 18/28] q35: Enable the ioapic device to be seen by qtest., (continued)
- [Qemu-devel] [PATCH 18/28] q35: Enable the ioapic device to be seen by qtest., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 21/28] libqtest: Correct small memory leak., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 27/28] ahci: Add test_hba_enable to ahci-test., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 22/28] libqos: Fixes a small memory leak., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 20/28] libqos: Correct memory leak, John Snow, 2014/07/07
- [Qemu-devel] [PATCH 19/28] qtest: Adding qtest_memset and qmemset.,
John Snow <=
- [Qemu-devel] [PATCH 23/28] ahci: Adding basic functionality qtest., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 28/28] ahci: Add test_identify case to ahci-test., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 24/28] ahci: Add test_pci_spec to ahci-test., John Snow, 2014/07/07
- [Qemu-devel] [PATCH 25/28] ahci: add test_pci_enable to ahci-test., John Snow, 2014/07/07