From 204febd17f9ebb9e94b1980b42c7f2c2307851c1 Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Wed, 11 Jan 2017 09:49:32 +0100 Subject: libqtest: handle zero length memwrite/memread Some recently added tests pass a zero length to qtest_memwrite(). Unfortunately, the qtest protocol doesn't implement an on-the-wire syntax for zero-length writes and the current code happily sends garbage to QEMU. This causes intermittent failures. It isn't worth the pain to enhance the protocol, so this patch simply fixes the issue by "just return, doing nothing". The same fix is applied to qtest_memread() since the issue also exists in the QEMU part of the "memread" command. Suggested-by: Peter Maydell Signed-off-by: Greg Kurz Reviewed-by: Eric Blake Reviewed-by: John Snow Message-id: 148412457273.22750.983275587432075569.stgit@bahia Signed-off-by: Peter Maydell --- qtest.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qtest.c') diff --git a/qtest.c b/qtest.c index 46b99aed52..bd9d417812 100644 --- a/qtest.c +++ b/qtest.c @@ -430,6 +430,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words) g_assert(words[1] && words[2]); g_assert(qemu_strtoull(words[1], NULL, 0, &addr) == 0); g_assert(qemu_strtoull(words[2], NULL, 0, &len) == 0); + /* We'd send garbage to libqtest if len is 0 */ + g_assert(len); data = g_malloc(len); cpu_physical_memory_read(addr, data, len); -- cgit v1.2.3