diff mbox series

[v3,11/11] tests/qtest/migration-test: Only use available accelerators

Message ID 20230120082341.59913-12-philmd@linaro.org
State New
Headers show
Series tests/qtest: Allow running boot-serial / migration with TCG disabled | expand

Commit Message

Philippe Mathieu-Daudé Jan. 20, 2023, 8:23 a.m. UTC
For example, avoid when TCG is disabled:

  $ make check-qtest-aarch64
  ...
  20/20 qemu:qtest+qtest-aarch64 / qtest-aarch64/migration-test
  qemu-system-aarch64: -accel tcg: invalid accelerator tcg

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 tests/qtest/migration-test.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

Comments

Juan Quintela Jan. 30, 2023, 4:49 a.m. UTC | #1
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> For example, avoid when TCG is disabled:
>
>   $ make check-qtest-aarch64
>   ...
>   20/20 qemu:qtest+qtest-aarch64 / qtest-aarch64/migration-test
>   qemu-system-aarch64: -accel tcg: invalid accelerator tcg
>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Juan Quintela <quintela@redhat.com>
diff mbox series

Patch

diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index e7786bcbc5..b0eaddbf5a 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -45,6 +45,8 @@ 
 
 unsigned start_address;
 unsigned end_address;
+static bool has_tcg;
+static bool has_kvm;
 static bool uffd_feature_thread_id;
 
 /*
@@ -603,13 +605,16 @@  static int test_migrate_start(QTestState **from, QTestState **to,
     got_stop = false;
 
     cmd_common = g_string_new("");
-    /* KVM first */
-    if (args->use_dirty_ring) {
-        g_string_append(cmd_common, "-accel kvm,dirty-ring-size=4096 ");
-    } else {
-        g_string_append(cmd_common, "-accel kvm ");
+    if (has_kvm) { /* KVM first */
+        if (args->use_dirty_ring) {
+            g_string_append(cmd_common, "-accel kvm,dirty-ring-size=4096 ");
+        } else {
+            g_string_append(cmd_common, "-accel kvm ");
+        }
+    }
+    if (has_tcg) {
+        g_string_append(cmd_common, "-accel tcg ");
     }
-    g_string_append(cmd_common, "-accel tcg ");
 
     bootpath = g_strdup_printf("%s/bootsect", tmpfs);
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
@@ -2460,12 +2465,14 @@  static bool kvm_dirty_ring_supported(void)
 
 int main(int argc, char **argv)
 {
-    const bool has_kvm = qtest_has_accel("kvm");
     const bool has_uffd = ufd_version_check();
     const char *arch = qtest_get_arch();
     g_autoptr(GError) err = NULL;
     int ret;
 
+    has_tcg = qtest_has_accel("tcg");
+    has_kvm = qtest_has_accel("kvm");
+
     g_test_init(&argc, &argv, NULL);
 
     /*