[autotest] Bug fix in _is_virtual_machine API.
BUG=b:124082140
TEST=Tested on local Moblab setup.
Change-Id: I62baef3cf0ad7b33a4c1446e4d141f8915617aa5
Reviewed-on: https://chromium-review.googlesource.com/1460415
Commit-Ready: Roopesha Sheshappa Rai <roopeshr@google.com>
Tested-by: Roopesha Sheshappa Rai <roopeshr@google.com>
Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Laurence Goodby <lgoodby@chromium.org>
(cherry picked from commit 06974b058522787e6ba88ac0d03b59758446bd31)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1628589
Reviewed-by: Keith Haddow <haddowk@chromium.org>
Commit-Queue: Keith Haddow <haddowk@chromium.org>
Tested-by: Keith Haddow <haddowk@chromium.org>
diff --git a/server/hosts/cros_repair.py b/server/hosts/cros_repair.py
index d6763c8..db39fe7 100644
--- a/server/hosts/cros_repair.py
+++ b/server/hosts/cros_repair.py
@@ -814,8 +814,10 @@
@param host: a hosts.Host object.
@returns True if the host is a virtual machine, False otherwise.
"""
- output = host.run('cat /proc/cpuinfo | grep "model name"')
- return output.stdout and 'qemu' in output.stdout.lower()
+ output = host.run('cat /proc/cpuinfo | grep "model name"',
+ ignore_status=True)
+ return (output.exit_status == 0 and output.stdout and
+ 'qemu' in output.stdout.lower())
class CryptohomeStatus(dict):