diff options
author | Nicolas Norvez <norvez@chromium.org> | 2016-08-12 12:32:42 +0100 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-08-15 09:25:29 -0700 |
commit | 8e917140b7ffafebb82d32998e9f56ad215a53c6 (patch) | |
tree | b552c49ed0cfb2cc85fff3672cdb6e4d522ffebb /host/lib | |
parent | 969ce32e407f32671ab79444238b9ddf98c7d960 (diff) | |
download | vboot-8e917140b7ffafebb82d32998e9f56ad215a53c6.tar.gz |
crossystem: refactor VM detection to share across architectures
If there is no HWID and mainfw_type is "nonchrome", report that the
host is a VM. If HWID is present, it's not a VM. Make the detection
architecture-independent.
BUG=chromium:632303
TEST=emerge-cyan vboot_reference and test binary on QEMU and HW
TEST=emerge-veyron_minnie vboot_reference and test binary on HW
BRANCH=none
Change-Id: I076eb9838a3b724ded0cfded9fb8d8a5392631c8
Reviewed-on: https://chromium-review.googlesource.com/368650
Commit-Ready: Nicolas Norvez <norvez@chromium.org>
Tested-by: Nicolas Norvez <norvez@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/crossystem.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c index 7c51927e..87c74169 100644 --- a/host/lib/crossystem.c +++ b/host/lib/crossystem.c @@ -553,6 +553,21 @@ int VbGetSystemPropertyInt(const char* name) { value = VbGetNvStorage(VBNV_TRY_RO_SYNC); } else if (!strcasecmp(name, "battery_cutoff_request")) { value = VbGetNvStorage(VBNV_BATTERY_CUTOFF_REQUEST); + } else if (!strcasecmp(name, "inside_vm")) { + /* Detect if the host is a VM. If there is no HWID and the firmware type + * is "nonchrome", then assume it is a VM. If HWID is present, it is a + * baremetal Chrome OS machine. Other cases are errors. */ + char hwid[VB_MAX_STRING_PROPERTY]; + if (!VbGetSystemPropertyString("hwid", hwid, sizeof(hwid))) { + char fwtype_buf[VB_MAX_STRING_PROPERTY]; + const char *fwtype = VbGetSystemPropertyString("mainfw_type", fwtype_buf, + sizeof(fwtype_buf)); + if (fwtype && !strcasecmp(fwtype, "nonchrome")) { + value = 1; + } + } else { + value = 0; + } } return value; |