]> git.proxmox.com Git - mirror_qemu.git/commitdiff
tests/qtest/migration: Introduce find_common_machine_version
authorFabiano Rosas <farosas@suse.de>
Wed, 18 Oct 2023 19:27:35 +0000 (16:27 -0300)
committerJuan Quintela <quintela@redhat.com>
Fri, 20 Oct 2023 06:51:41 +0000 (08:51 +0200)
When using two different QEMU binaries for migration testing, we'll
need to find what is the machine version that will work with both
binaries. Add a helper for that.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231018192741.25885-7-farosas@suse.de>

tests/qtest/migration-helpers.c
tests/qtest/migration-helpers.h

index 0c185db450fead06e44c0ad84e8e1fe0ef6eece3..13449c1fe1aec462c17845d4ce383658d8b4f76a 100644 (file)
@@ -240,3 +240,29 @@ void wait_for_migration_fail(QTestState *from, bool allow_active)
     g_assert(qdict_get_bool(rsp_return, "running"));
     qobject_unref(rsp_return);
 }
+
+char *find_common_machine_version(const char *mtype, const char *var1,
+                                  const char *var2)
+{
+    g_autofree char *type1 = qtest_resolve_machine_alias(var1, mtype);
+    g_autofree char *type2 = qtest_resolve_machine_alias(var2, mtype);
+
+    g_assert(type1 && type2);
+
+    if (g_str_equal(type1, type2)) {
+        /* either can be used */
+        return g_strdup(type1);
+    }
+
+    if (qtest_has_machine_with_env(var2, type1)) {
+        return g_strdup(type1);
+    }
+
+    if (qtest_has_machine_with_env(var1, type2)) {
+        return g_strdup(type2);
+    }
+
+    g_test_message("No common machine version for machine type '%s' between "
+                   "binaries %s and %s", mtype, getenv(var1), getenv(var2));
+    g_assert_not_reached();
+}
index 4f51d0f8bc5ca25c16210fa1802a8ea4856906e7..d1c2351d334d431a422cd32947e4eae32fe8216d 100644 (file)
@@ -43,4 +43,6 @@ void wait_for_migration_complete(QTestState *who);
 
 void wait_for_migration_fail(QTestState *from, bool allow_active);
 
+char *find_common_machine_version(const char *mtype, const char *var1,
+                                  const char *var2);
 #endif /* MIGRATION_HELPERS_H */