summaryrefslogtreecommitdiff
path: root/qtest.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-10-18 13:51:11 +0200
committerMichael S. Tsirkin <mst@redhat.com>2013-12-10 12:29:56 +0200
commitd4fce24f3a59eda081cdf2e38e7001591b95d173 (patch)
tree5a0fe8c36f8c50af45cfc438d9d84c1dbd4fab00 /qtest.c
parent83d08f2673504a299194dcac1657a13754b5932a (diff)
qtest: split configuration of qtest accelerator and chardev
qtest uses the icount infrastructure to implement a test-driven vm_clock. This however is not necessary when using -qtest as a "probe" together with a normal TCG-, KVM- or Xen-based virtual machine. Hence, split out the call to configure_icount into a new function that is called only for "-machine accel=qtest"; and disable those commands when running with an accelerator other than qtest. This also fixes an assertion failure with "qemu-system-x86_64 -machine accel=qtest" but no -qtest option. This is a valid case, albeit somewhat weird; nothing will happen in the VM but you'll still be able to interact with the monitor or the GUI. Now that qtest_init is not limited to an int(void) function, change global variables that are not used outside qtest_init to arguments. And finally, cleanup useless parts of include/sysemu/qtest.h. The file is not used at all for user-only emulation, and qtest is not available on Win32 due to its usage of sigwait. Reported-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'qtest.c')
-rw-r--r--qtest.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/qtest.c b/qtest.c
index 584c70762a..dcf1301229 100644
--- a/qtest.c
+++ b/qtest.c
@@ -22,8 +22,6 @@
#define MAX_IRQ 256
-const char *qtest_chrdev;
-const char *qtest_log;
bool qtest_allowed;
static DeviceState *irq_intercept_dev;
@@ -406,7 +404,7 @@ 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) {
+ } else if (qtest_enabled() && strcmp(words[0], "clock_step") == 0) {
int64_t ns;
if (words[1]) {
@@ -417,7 +415,7 @@ static void qtest_process_command(CharDriverState *chr, gchar **words)
qtest_clock_warp(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns);
qtest_send_prefix(chr);
qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
- } else if (strcmp(words[0], "clock_set") == 0) {
+ } else if (qtest_enabled() && strcmp(words[0], "clock_set") == 0) {
int64_t ns;
g_assert(words[1]);
@@ -502,13 +500,17 @@ static void qtest_event(void *opaque, int event)
}
}
-int qtest_init(void)
+int qtest_init_accel(void)
{
- CharDriverState *chr;
+ configure_icount("0");
- g_assert(qtest_chrdev != NULL);
+ return 0;
+}
+
+void qtest_init(const char *qtest_chrdev, const char *qtest_log)
+{
+ CharDriverState *chr;
- configure_icount("0");
chr = qemu_chr_new("qtest", qtest_chrdev, NULL);
qemu_chr_add_handlers(chr, qtest_can_read, qtest_read, qtest_event, chr);
@@ -525,6 +527,4 @@ int qtest_init(void)
}
qtest_chr = chr;
-
- return 0;
}