From: Lennart Poettering Date: Tue, 18 Apr 2023 08:48:54 +0000 (+0200) Subject: kmod-setup: bypass heavy virtio-rng check if we are not running in a VM anyway X-Git-Tag: v254-rc1~688^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F27320%2Fhead;p=thirdparty%2Fsystemd.git kmod-setup: bypass heavy virtio-rng check if we are not running in a VM anyway detect_vm() is cheap, because cached, let's hence do that early before we get out the big guns and sweep through sysfs. --- diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c index 949b1a5854a..adf817800f4 100644 --- a/src/core/kmod-setup.c +++ b/src/core/kmod-setup.c @@ -67,6 +67,10 @@ static int has_virtio_rng_recurse_dir_cb( static bool has_virtio_rng(void) { int r; + /* Directory traversal might be slow, hence let's do a cheap check first if it's even worth it */ + if (detect_vm() == VIRTUALIZATION_NONE) + return false; + r = recurse_dir_at( AT_FDCWD, "/sys/devices/pci0000:00",