kvm: selftests: dirty_log_test: improve mode param management
Signed-off-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
This commit is contained in:
parent
fd3f6f8139
commit
696ade770f
|
@ -365,23 +365,16 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations,
|
||||||
kvm_vm_free(vm);
|
kvm_vm_free(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct vm_guest_modes {
|
struct vm_guest_mode_params {
|
||||||
enum vm_guest_mode mode;
|
|
||||||
bool supported;
|
bool supported;
|
||||||
bool enabled;
|
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 }; \
|
||||||
|
})
|
||||||
|
|
||||||
static void help(char *name)
|
static void help(char *name)
|
||||||
{
|
{
|
||||||
|
@ -402,10 +395,8 @@ static void help(char *name)
|
||||||
" This option may be used multiple times.\n"
|
" This option may be used multiple times.\n"
|
||||||
" Guest mode IDs:\n");
|
" Guest mode IDs:\n");
|
||||||
for (i = 0; i < NUM_VM_MODES; ++i) {
|
for (i = 0; i < NUM_VM_MODES; ++i) {
|
||||||
printf(" %d: %s%s\n",
|
printf(" %d: %s%s\n", i, vm_guest_mode_string(i),
|
||||||
vm_guest_modes[i].mode,
|
vm_guest_mode_params[i].supported ? " (supported)" : "");
|
||||||
vm_guest_mode_string(vm_guest_modes[i].mode),
|
|
||||||
vm_guest_modes[i].supported ? " (supported)" : "");
|
|
||||||
}
|
}
|
||||||
puts("");
|
puts("");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -427,6 +418,14 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
|
vm_guest_mode_params_init(VM_MODE_P52V48_4K, true, true);
|
||||||
|
#endif
|
||||||
|
#ifdef __aarch64__
|
||||||
|
vm_guest_mode_params_init(VM_MODE_P40V48_4K, true, true);
|
||||||
|
vm_guest_mode_params_init(VM_MODE_P40V48_64K, true, true);
|
||||||
|
#endif
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "hi:I:p:m:")) != -1) {
|
while ((opt = getopt(argc, argv, "hi:I:p:m:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'i':
|
case 'i':
|
||||||
|
@ -441,13 +440,13 @@ int main(int argc, char *argv[])
|
||||||
case 'm':
|
case 'm':
|
||||||
if (!mode_selected) {
|
if (!mode_selected) {
|
||||||
for (i = 0; i < NUM_VM_MODES; ++i)
|
for (i = 0; i < NUM_VM_MODES; ++i)
|
||||||
vm_guest_modes[i].enabled = 0;
|
vm_guest_mode_params[i].enabled = false;
|
||||||
mode_selected = true;
|
mode_selected = true;
|
||||||
}
|
}
|
||||||
mode = strtoul(optarg, NULL, 10);
|
mode = strtoul(optarg, NULL, 10);
|
||||||
TEST_ASSERT(mode < NUM_VM_MODES,
|
TEST_ASSERT(mode < NUM_VM_MODES,
|
||||||
"Guest mode ID %d too big", mode);
|
"Guest mode ID %d too big", mode);
|
||||||
vm_guest_modes[mode].enabled = 1;
|
vm_guest_mode_params[mode].enabled = true;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
default:
|
default:
|
||||||
|
@ -465,13 +464,12 @@ int main(int argc, char *argv[])
|
||||||
srandom(time(0));
|
srandom(time(0));
|
||||||
|
|
||||||
for (i = 0; i < NUM_VM_MODES; ++i) {
|
for (i = 0; i < NUM_VM_MODES; ++i) {
|
||||||
if (!vm_guest_modes[i].enabled)
|
if (!vm_guest_mode_params[i].enabled)
|
||||||
continue;
|
continue;
|
||||||
TEST_ASSERT(vm_guest_modes[i].supported,
|
TEST_ASSERT(vm_guest_mode_params[i].supported,
|
||||||
"Guest mode ID %d (%s) not supported.",
|
"Guest mode ID %d (%s) not supported.",
|
||||||
vm_guest_modes[i].mode,
|
i, vm_guest_mode_string(i));
|
||||||
vm_guest_mode_string(vm_guest_modes[i].mode));
|
run_test(i, iterations, interval, phys_offset);
|
||||||
run_test(vm_guest_modes[i].mode, iterations, interval, phys_offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue