mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
Merge tag 'kvm-x86-selftests-6.17' of https://github.com/kvm-x86/linux into HEAD
KVM selftests changes for 6.17 - Fix a comment typo. - Verify KVM is loaded when getting any KVM module param so that attempting to run a selftest without kvm.ko loaded results in a SKIP message about KVM not being loaded/enabled, versus some random parameter not existing. - SKIP tests that hit EACCES when attempting to access a file, with a "Root required?" help message. In most cases, the test just needs to be run with elevated permissions.
This commit is contained in:
@@ -26,15 +26,27 @@ static uint32_t last_guest_seed;
|
||||
|
||||
static int vcpu_mmap_sz(void);
|
||||
|
||||
int open_path_or_exit(const char *path, int flags)
|
||||
int __open_path_or_exit(const char *path, int flags, const char *enoent_help)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open(path, flags);
|
||||
__TEST_REQUIRE(fd >= 0 || errno != ENOENT, "Cannot open %s: %s", path, strerror(errno));
|
||||
TEST_ASSERT(fd >= 0, "Failed to open '%s'", path);
|
||||
if (fd < 0)
|
||||
goto error;
|
||||
|
||||
return fd;
|
||||
|
||||
error:
|
||||
if (errno == EACCES || errno == ENOENT)
|
||||
ksft_exit_skip("- Cannot open '%s': %s. %s\n",
|
||||
path, strerror(errno),
|
||||
errno == EACCES ? "Root required?" : enoent_help);
|
||||
TEST_FAIL("Failed to open '%s'", path);
|
||||
}
|
||||
|
||||
int open_path_or_exit(const char *path, int flags)
|
||||
{
|
||||
return __open_path_or_exit(path, flags, "");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -48,7 +60,7 @@ int open_path_or_exit(const char *path, int flags)
|
||||
*/
|
||||
static int _open_kvm_dev_path_or_exit(int flags)
|
||||
{
|
||||
return open_path_or_exit(KVM_DEV_PATH, flags);
|
||||
return __open_path_or_exit(KVM_DEV_PATH, flags, "Is KVM loaded and enabled?");
|
||||
}
|
||||
|
||||
int open_kvm_dev_path_or_exit(void)
|
||||
@@ -64,6 +76,9 @@ static ssize_t get_module_param(const char *module_name, const char *param,
|
||||
ssize_t bytes_read;
|
||||
int fd, r;
|
||||
|
||||
/* Verify KVM is loaded, to provide a more helpful SKIP message. */
|
||||
close(open_kvm_dev_path_or_exit());
|
||||
|
||||
r = snprintf(path, path_size, "/sys/module/%s/parameters/%s",
|
||||
module_name, param);
|
||||
TEST_ASSERT(r < path_size,
|
||||
|
||||
Reference in New Issue
Block a user