aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2021-03-24 02:55:40 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-03-24 02:55:40 +0000
commit442dafa3c92a73aff4e70d1f1ce5e00105d7cc42 (patch)
tree925ca81c23f7a0034a7f0581162765c5db2c9896
parent960f8fb60aad6089eba31d1e4a14df18ca631794 (diff)
parentbfeedf17cf825597610818a5f51a184ff1e76c8a (diff)
downloadltp-442dafa3c92a73aff4e70d1f1ce5e00105d7cc42.tar.gz
Merge "Enhanced detection of KVM" am: 9fff91dc6c am: bfeedf17cf
Original change: https://android-review.googlesource.com/c/platform/external/ltp/+/1573412 Change-Id: Iac0cb326e2beb57419465047dece1c594c0231ef
-rw-r--r--lib/tst_virt.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/tst_virt.c b/lib/tst_virt.c
index c05da0a3c..d21f74c1c 100644
--- a/lib/tst_virt.c
+++ b/lib/tst_virt.c
@@ -23,9 +23,20 @@
*/
#include <unistd.h>
+#include <sys/stat.h>
#include "test.h"
#include "safe_macros.h"
+static int file_exist(const char *path)
+{
+ struct stat st;
+
+ if (!access(path, R_OK) && !stat(path, &st))
+ return 1;
+
+ return 0;
+}
+
static int is_kvm(void)
{
FILE *cpuinfo;
@@ -44,6 +55,10 @@ static int is_kvm(void)
}
SAFE_FCLOSE(NULL, cpuinfo);
+
+ if (file_exist("/dev/vda") || file_exist("/dev/block/vda"))
+ found = 1;
+
return found;
}