diff options
| author | Fabiano Rosas <farosas@suse.de> | 2024-11-27 15:28:51 -0300 |
|---|---|---|
| committer | Fabiano Rosas <farosas@suse.de> | 2024-12-12 10:25:40 -0300 |
| commit | 124a3c58b82ad8e3662711f4deca281d81d5d56a (patch) | |
| tree | 898e17b9ebfc6f3d38aa52225a6ec21a17990bd7 /tests/qtest/migration-test.c | |
| parent | b7d7f723a9853a68a648075a1f2ab96d410e929e (diff) | |
| download | focaccia-qemu-124a3c58b82ad8e3662711f4deca281d81d5d56a.tar.gz focaccia-qemu-124a3c58b82ad8e3662711f4deca281d81d5d56a.zip | |
tests/qtest/migration: Move ufd_version_check to utils
Move ufd_version_check() to migration-util.c file. This is a helper function that is used during tests definition so it should be available outside of migration-test.c Since the function is moving to another file, change it to stop accessing the global uffd_feature_thread_id and take it as argument instead. Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
Diffstat (limited to 'tests/qtest/migration-test.c')
| -rw-r--r-- | tests/qtest/migration-test.c | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index e295bd3081..f1c1ca309a 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -35,6 +35,7 @@ /* For dirty ring test; so far only x86_64 is supported */ #if defined(__linux__) && defined(HOST_X86_64) #include "linux/kvm.h" +#include <sys/ioctl.h> #endif unsigned start_address; @@ -88,50 +89,6 @@ typedef enum PostcopyRecoveryFailStage { #include <sys/vfs.h> #endif -#if defined(__linux__) && defined(__NR_userfaultfd) && defined(CONFIG_EVENTFD) -#include <sys/eventfd.h> -#include <sys/ioctl.h> -#include "qemu/userfaultfd.h" - -static bool ufd_version_check(void) -{ - struct uffdio_api api_struct; - uint64_t ioctl_mask; - - int ufd = uffd_open(O_CLOEXEC); - - if (ufd == -1) { - g_test_message("Skipping test: userfaultfd not available"); - return false; - } - - api_struct.api = UFFD_API; - api_struct.features = 0; - if (ioctl(ufd, UFFDIO_API, &api_struct)) { - g_test_message("Skipping test: UFFDIO_API failed"); - return false; - } - uffd_feature_thread_id = api_struct.features & UFFD_FEATURE_THREAD_ID; - - ioctl_mask = (1ULL << _UFFDIO_REGISTER | - 1ULL << _UFFDIO_UNREGISTER); - if ((api_struct.ioctls & ioctl_mask) != ioctl_mask) { - g_test_message("Skipping test: Missing userfault feature"); - return false; - } - - return true; -} - -#else -static bool ufd_version_check(void) -{ - g_test_message("Skipping test: Userfault not available (builtdtime)"); - return false; -} - -#endif - static char *tmpfs; static char *bootpath; @@ -3532,7 +3489,7 @@ int main(int argc, char **argv) return 0; } - has_uffd = ufd_version_check(); + has_uffd = ufd_version_check(&uffd_feature_thread_id); arch = qtest_get_arch(); is_x86 = !strcmp(arch, "i386") || !strcmp(arch, "x86_64"); |