diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-03-28 15:42:04 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-03-30 08:14:11 -0500 |
commit | 8156be561019bd0fc17729e9a528f6c81eea9186 (patch) | |
tree | 60af2c66cf7494076505deeeaff3387c42b78b8e /qtest.c | |
parent | 2028834574e75de9d34995fbaf09a8b35cb9daa0 (diff) | |
download | qemu-8156be561019bd0fc17729e9a528f6c81eea9186.tar.gz qemu-8156be561019bd0fc17729e9a528f6c81eea9186.tar.bz2 qemu-8156be561019bd0fc17729e9a528f6c81eea9186.zip |
qtest: add clock management
This patch combines qtest and -icount together to turn the vm_clock
into a source that can be fully managed by the client. To this end new
commands clock_step and clock_set are added. Hooking them with libqtest
is left as an exercise to the reader.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qtest.c')
-rw-r--r-- | qtest.c | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -18,6 +18,7 @@ #include "memory.h" #include "hw/irq.h" #include "sysemu.h" +#include "cpus.h" #define MAX_IRQ 256 @@ -44,6 +45,30 @@ static bool qtest_opened; * * Valid requests * + * Clock management: + * + * The qtest client is completely in charge of the vm_clock. qtest commands + * let you adjust the value of the clock (monotonically). All the commands + * return the current value of the clock in nanoseconds. + * + * > clock_step + * < OK VALUE + * + * Advance the clock to the next deadline. Useful when waiting for + * asynchronous events. + * + * > clock_step NS + * < OK VALUE + * + * Advance the clock by NS nanoseconds. + * + * > clock_set NS + * < OK VALUE + * + * Advance the clock to NS nanoseconds (do nothing if it's already past). + * + * PIO and memory access: + * * > outb ADDR VALUE * < OK * @@ -299,6 +324,25 @@ static void qtest_process_command(CharDriverState *chr, gchar **words) qtest_send_prefix(chr); qtest_send(chr, "OK\n"); + } else if (strcmp(words[0], "clock_step") == 0) { + int64_t ns; + + if (words[1]) { + ns = strtoll(words[1], NULL, 0); + } else { + ns = qemu_clock_deadline(vm_clock); + } + qtest_clock_warp(qemu_get_clock_ns(vm_clock) + ns); + qtest_send_prefix(chr); + qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_get_clock_ns(vm_clock)); + } else if (strcmp(words[0], "clock_set") == 0) { + int64_t ns; + + g_assert(words[1]); + ns = strtoll(words[1], NULL, 0); + qtest_clock_warp(ns); + qtest_send_prefix(chr); + qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_get_clock_ns(vm_clock)); } else { qtest_send_prefix(chr); qtest_send(chr, "FAIL Unknown command `%s'\n", words[0]); @@ -377,6 +421,7 @@ int qtest_init(void) g_assert(qtest_chrdev != NULL); + configure_icount("0"); chr = qemu_chr_new("qtest", qtest_chrdev, NULL); qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr); |