Re: [PATCH 2/5] KVM: selftests: Initialise default mode in each test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 16, 2021 at 12:31:32PM +0000, Marc Zyngier wrote:
> As we are going to add support for a variable default mode on arm64,
> let's make sure it is setup first by sprinkling a number of calls
> to get_modes_append_default() when the test starts.
> 
> Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
> ---
>  tools/testing/selftests/kvm/aarch64/arch_timer.c       | 3 +++
>  tools/testing/selftests/kvm/aarch64/debug-exceptions.c | 3 +++
>  tools/testing/selftests/kvm/aarch64/get-reg-list.c     | 3 +++
>  tools/testing/selftests/kvm/aarch64/psci_cpu_on_test.c | 3 +++
>  tools/testing/selftests/kvm/aarch64/vgic_init.c        | 3 +++
>  tools/testing/selftests/kvm/kvm_binary_stats_test.c    | 3 +++
>  tools/testing/selftests/kvm/kvm_create_max_vcpus.c     | 3 +++
>  tools/testing/selftests/kvm/memslot_perf_test.c        | 4 ++++
>  tools/testing/selftests/kvm/rseq_test.c                | 3 +++
>  tools/testing/selftests/kvm/set_memory_region_test.c   | 4 ++++
>  tools/testing/selftests/kvm/steal_time.c               | 3 +++

I wish there was a better way to set the defaults for each test
without requiring a function call to be put at the beginning of
each test. Maybe we should create a constructor function? I.e.

diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
index f307c9f61981..603e09be12ae 100644
--- a/tools/testing/selftests/kvm/Makefile
+++ b/tools/testing/selftests/kvm/Makefile
@@ -148,7 +148,7 @@ LDFLAGS += -pthread $(no-pie-option) $(pgste-option)
 # $(TEST_GEN_PROGS) starts with $(OUTPUT)/
 include ../lib.mk
 
-STATIC_LIBS := $(OUTPUT)/libkvm.a
+STATIC_LIBS := lib/init.o $(OUTPUT)/libkvm.a
 LIBKVM_C := $(filter %.c,$(LIBKVM))
 LIBKVM_S := $(filter %.S,$(LIBKVM))
 LIBKVM_C_OBJ := $(patsubst %.c, $(OUTPUT)/%.o, $(LIBKVM_C))
diff --git a/tools/testing/selftests/kvm/lib/init.c b/tools/testing/selftests/kvm/lib/init.c
new file mode 100644
index 000000000000..6f92a85aa263
--- /dev/null
+++ b/tools/testing/selftests/kvm/lib/init.c
@@ -0,0 +1,6 @@
+#include "guest_modes.h"
+
+void __attribute__((constructor)) main_init(void)
+{
+#ifdef __aarch64__
+       guest_modes_set_default();
+#endif
+}


Thanks,
drew

_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux