Commit f832485d authored by Andrew Jones's avatar Andrew Jones Committed by Paolo Bonzini

KVM: selftests: Rename vm_guest_mode_params

We're going to want this name in the library code, so use a shorter
name in the tests.
Signed-off-by: default avatarAndrew Jones <drjones@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 12c0d0f6
...@@ -386,15 +386,14 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations, ...@@ -386,15 +386,14 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations,
kvm_vm_free(vm); kvm_vm_free(vm);
} }
struct vm_guest_mode_params { struct guest_mode {
bool supported; bool supported;
bool enabled; bool enabled;
}; };
struct vm_guest_mode_params vm_guest_mode_params[NUM_VM_MODES]; static struct guest_mode guest_modes[NUM_VM_MODES];
#define vm_guest_mode_params_init(mode, supported, enabled) \ #define guest_mode_init(mode, supported, enabled) ({ \
({ \ guest_modes[mode] = (struct guest_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)
...@@ -417,7 +416,7 @@ static void help(char *name) ...@@ -417,7 +416,7 @@ static void help(char *name)
" 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", i, vm_guest_mode_string(i), printf(" %d: %s%s\n", i, vm_guest_mode_string(i),
vm_guest_mode_params[i].supported ? " (supported)" : ""); guest_modes[i].supported ? " (supported)" : "");
} }
puts(""); puts("");
exit(0); exit(0);
...@@ -440,24 +439,25 @@ int main(int argc, char *argv[]) ...@@ -440,24 +439,25 @@ int main(int argc, char *argv[])
#endif #endif
#ifdef __x86_64__ #ifdef __x86_64__
vm_guest_mode_params_init(VM_MODE_PXXV48_4K, true, true); guest_mode_init(VM_MODE_PXXV48_4K, true, true);
#endif #endif
#ifdef __aarch64__ #ifdef __aarch64__
vm_guest_mode_params_init(VM_MODE_P40V48_4K, true, true); guest_mode_init(VM_MODE_P40V48_4K, true, true);
vm_guest_mode_params_init(VM_MODE_P40V48_64K, true, true); guest_mode_init(VM_MODE_P40V48_64K, true, true);
{ {
unsigned int limit = kvm_check_cap(KVM_CAP_ARM_VM_IPA_SIZE); unsigned int limit = kvm_check_cap(KVM_CAP_ARM_VM_IPA_SIZE);
if (limit >= 52) if (limit >= 52)
vm_guest_mode_params_init(VM_MODE_P52V48_64K, true, true); guest_mode_init(VM_MODE_P52V48_64K, true, true);
if (limit >= 48) { if (limit >= 48) {
vm_guest_mode_params_init(VM_MODE_P48V48_4K, true, true); guest_mode_init(VM_MODE_P48V48_4K, true, true);
vm_guest_mode_params_init(VM_MODE_P48V48_64K, true, true); guest_mode_init(VM_MODE_P48V48_64K, true, true);
} }
} }
#endif #endif
#ifdef __s390x__ #ifdef __s390x__
vm_guest_mode_params_init(VM_MODE_P40V48_4K, true, true); guest_mode_init(VM_MODE_P40V48_4K, true, true);
#endif #endif
while ((opt = getopt(argc, argv, "hi:I:p:m:")) != -1) { while ((opt = getopt(argc, argv, "hi:I:p:m:")) != -1) {
...@@ -474,13 +474,13 @@ int main(int argc, char *argv[]) ...@@ -474,13 +474,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_mode_params[i].enabled = false; guest_modes[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_mode_params[mode].enabled = true; guest_modes[mode].enabled = true;
break; break;
case 'h': case 'h':
default: default:
...@@ -498,9 +498,9 @@ int main(int argc, char *argv[]) ...@@ -498,9 +498,9 @@ 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_mode_params[i].enabled) if (!guest_modes[i].enabled)
continue; continue;
TEST_ASSERT(vm_guest_mode_params[i].supported, TEST_ASSERT(guest_modes[i].supported,
"Guest mode ID %d (%s) not supported.", "Guest mode ID %d (%s) not supported.",
i, vm_guest_mode_string(i)); i, vm_guest_mode_string(i));
run_test(i, iterations, interval, phys_offset); run_test(i, iterations, interval, phys_offset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment