From: Lennart Poettering Date: Fri, 19 Jan 2024 17:47:41 +0000 (+0100) Subject: vmspawn: ENODEV is not the only error the kernel returns if a device is not there X-Git-Tag: v256-rc1~1083^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fdc7d50ba40a92348d1ea31dfeda4ee4cc804046;p=thirdparty%2Fsystemd.git vmspawn: ENODEV is not the only error the kernel returns if a device is not there Let's use ERRNO_IS_DEVICE_ABSENT() to cover all cases. (And while we are at it also use ERRNO_IS_PRIVILEGE() where appropriate) --- diff --git a/src/vmspawn/vmspawn-util.c b/src/vmspawn/vmspawn-util.c index 16ece318097..c8e67597909 100644 --- a/src/vmspawn/vmspawn-util.c +++ b/src/vmspawn/vmspawn-util.c @@ -40,7 +40,7 @@ int qemu_check_kvm_support(void) { log_debug_errno(errno, "/dev/kvm not found. Not using KVM acceleration."); return false; } - if (errno == EPERM) { + if (ERRNO_IS_PRIVILEGE(errno)) { log_debug_errno(errno, "Permission denied to access /dev/kvm. Not using KVM acceleration."); return false; } @@ -62,11 +62,11 @@ int qemu_check_vsock_support(void) { fd = open("/dev/vhost-vsock", O_RDWR|O_CLOEXEC); if (fd >= 0) return true; - if (errno == ENODEV) { + if (ERRNO_IS_DEVICE_ABSENT(errno)) { log_debug_errno(errno, "/dev/vhost-vsock device doesn't exist. Not adding a vsock device to the virtual machine."); return false; } - if (errno == EPERM) { + if (ERRNO_IS_PRIVILEGE(errno)) { log_debug_errno(errno, "Permission denied to access /dev/vhost-vsock. Not adding a vsock device to the virtual machine."); return false; }