diff options
author | John Snow <jsnow@redhat.com> | 2015-05-22 14:13:44 -0400 |
---|---|---|
committer | John Snow <jsnow@redhat.com> | 2015-05-22 15:58:22 -0400 |
commit | 7a6a740d8dcc02f5693315d7935b5de9b963bb96 (patch) | |
tree | a2e267889145f6cff4d1af159684568d19bd16a8 /tests/libqtest.h | |
parent | 332cc7e9b39ddb2feacb4c71dcd18c3e5b0c3147 (diff) | |
download | qemu-7a6a740d8dcc02f5693315d7935b5de9b963bb96.tar.gz qemu-7a6a740d8dcc02f5693315d7935b5de9b963bb96.tar.bz2 qemu-7a6a740d8dcc02f5693315d7935b5de9b963bb96.zip |
qtest: Add base64 encoded read/write
For larger pieces of data that won't need to be debugged and
viewing the hex nibbles is unlikely to be useful, we can encode
data using base64 instead of encoding each byte as %02x, which
leads to some space savings and faster reads/writes.
For now, the default is left as hex nibbles in memwrite() and memread().
For the purposes of making qtest io easier to read and debug, some
callers may want to specify using the old encoding format for small
patches of data where the savings from base64 wouldn't be that profound.
memwrite/memread use a data encoding that takes 2x the size of the original
buffer, but base64 uses "only" (4/3)x, so for larger buffers we can save a
decent amount of time and space.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1430864578-22072-3-git-send-email-jsnow@redhat.com
Diffstat (limited to 'tests/libqtest.h')
-rw-r--r-- | tests/libqtest.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/libqtest.h b/tests/libqtest.h index 4b54b5da9e..ec42031523 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -301,6 +301,17 @@ uint64_t qtest_readq(QTestState *s, uint64_t addr); void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size); /** + * qtest_bufread: + * @s: #QTestState instance to operate on. + * @addr: Guest address to read from. + * @data: Pointer to where memory contents will be stored. + * @size: Number of bytes to read. + * + * Read guest memory into a buffer and receive using a base64 encoding. + */ +void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size); + +/** * qtest_memwrite: * @s: #QTestState instance to operate on. * @addr: Guest address to write to. @@ -312,6 +323,18 @@ 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_bufwrite: + * @s: #QTestState instance to operate on. + * @addr: Guest address to write to. + * @data: Pointer to the bytes that will be written to guest memory. + * @size: Number of bytes to write. + * + * Write a buffer to guest memory and transmit using a base64 encoding. + */ +void qtest_bufwrite(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. @@ -699,6 +722,19 @@ static inline void memread(uint64_t addr, void *data, size_t size) } /** + * bufread: + * @addr: Guest address to read from. + * @data: Pointer to where memory contents will be stored. + * @size: Number of bytes to read. + * + * Read guest memory into a buffer, receive using a base64 encoding. + */ +static inline void bufread(uint64_t addr, void *data, size_t size) +{ + qtest_bufread(global_qtest, addr, data, size); +} + +/** * memwrite: * @addr: Guest address to write to. * @data: Pointer to the bytes that will be written to guest memory. @@ -712,6 +748,19 @@ static inline void memwrite(uint64_t addr, const void *data, size_t size) } /** + * bufwrite: + * @addr: Guest address to write to. + * @data: Pointer to the bytes that will be written to guest memory. + * @size: Number of bytes to write. + * + * Write a buffer to guest memory, transmit using a base64 encoding. + */ +static inline void bufwrite(uint64_t addr, const void *data, size_t size) +{ + qtest_bufwrite(global_qtest, addr, data, size); +} + +/** * qmemset: * @addr: Guest address to write to. * @patt: Byte pattern to fill the guest memory region with. |