diff options
| author | David S. Miller <davem@davemloft.net> | 2019-06-22 08:59:24 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2019-06-22 08:59:24 -0400 |
| commit | 92ad6325cb891bb455487bfe90cc47d18aa6ec37 (patch) | |
| tree | 433a7ef938fae69789216043f67eff9f9c6b0c68 /tools/testing/selftests/kvm/lib/kvm_util.c | |
| parent | e0effb5fbd56a8b2b8917611cbf4fcd9aba92b8f (diff) | |
| parent | c356dc4b540edd6c02b409dd8cf3208ba2804c38 (diff) | |
| download | talos-op-linux-92ad6325cb891bb455487bfe90cc47d18aa6ec37.tar.gz talos-op-linux-92ad6325cb891bb455487bfe90cc47d18aa6ec37.zip | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Minor SPDX change conflict.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/kvm_util.c')
| -rw-r--r-- | tools/testing/selftests/kvm/lib/kvm_util.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 633b22df46a4..ee864fa07d8e 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * tools/testing/selftests/kvm/lib/kvm_util.c * * Copyright (C) 2018, Google LLC. - * - * This work is licensed under the terms of the GNU GPL, version 2. */ #include "test_util.h" @@ -1583,3 +1582,39 @@ void *addr_gva2hva(struct kvm_vm *vm, vm_vaddr_t gva) { return addr_gpa2hva(vm, addr_gva2gpa(vm, gva)); } + +/* + * Is Unrestricted Guest + * + * Input Args: + * vm - Virtual Machine + * + * Output Args: None + * + * Return: True if the unrestricted guest is set to 'Y', otherwise return false. + * + * Check if the unrestricted guest flag is enabled. + */ +bool vm_is_unrestricted_guest(struct kvm_vm *vm) +{ + char val = 'N'; + size_t count; + FILE *f; + + if (vm == NULL) { + /* Ensure that the KVM vendor-specific module is loaded. */ + f = fopen(KVM_DEV_PATH, "r"); + TEST_ASSERT(f != NULL, "Error in opening KVM dev file: %d", + errno); + fclose(f); + } + + f = fopen("/sys/module/kvm_intel/parameters/unrestricted_guest", "r"); + if (f) { + count = fread(&val, sizeof(char), 1, f); + TEST_ASSERT(count == 1, "Unable to read from param file."); + fclose(f); + } + + return val == 'Y'; +} |

