Re: [PATCH 5/7] kvm: selftests: dirty_log_test: improve mode param management

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

 



2018-11-06 14:57+0100, Andrew Jones:
> Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
> ---
> diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
> @@ -353,23 +353,16 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations,
>  	kvm_vm_free(vm);
>  }
>  
> -static struct vm_guest_modes {
> -	enum vm_guest_mode mode;
> +struct vm_guest_mode_params {
>  	bool supported;
>  	bool enabled;
> -} vm_guest_modes[NUM_VM_MODES] = {
> -#if defined(__x86_64__)
> -	{ VM_MODE_P52V48_4K,	1, 1, },
> -	{ VM_MODE_P52V48_64K,	0, 0, },
> -	{ VM_MODE_P40V48_4K,	0, 0, },
> -	{ VM_MODE_P40V48_64K,	0, 0, },
> -#elif defined(__aarch64__)
> -	{ VM_MODE_P52V48_4K,	0, 0, },
> -	{ VM_MODE_P52V48_64K,	0, 0, },
> -	{ VM_MODE_P40V48_4K,	1, 1, },
> -	{ VM_MODE_P40V48_64K,	1, 1, },
> -#endif
>  };
> +struct vm_guest_mode_params vm_guest_mode_params[NUM_VM_MODES];
> +
> +#define vm_guest_mode_params_init(mode, supported, enabled)					\
> +({												\
> +	vm_guest_mode_params[mode] = (struct vm_guest_mode_params){ supported, enabled };	\
> +})

Backing the modes with a constant array is even uglier now that we don't
hard code it in one place.  The compiler should still protest if we
forget to change the bounds, so I've applied the whole series as the
mode_init interface is simple to improve upon,

thanks.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux