vm: Require --board to be specified on the cmd-line.

If you run `cros_vm --start` in a chrome checkout outside the Simple
Chrome shell and forget to pass in --board, it leads to some
unintuitive errors like:
 WARNING: Using system QEMU.
 ERROR: QEMU not found.

Which happens since the code needs to know the board to find the right
QEMU inside the Simple Chrome cache. Adding this check should ensure
folks don't forget to pass in --board.

BUG=chromium:937821
TEST=unittest

Change-Id: I4fc8c80ff20f2f901c4fc7ab945a8f3af15f5145
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2268282
Reviewed-by: Achuith Bhandarkar <achuith@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Tested-by: Ben Pastene <bpastene@chromium.org>
diff --git a/lib/vm.py b/lib/vm.py
index bcd3d41..7375f8d 100644
--- a/lib/vm.py
+++ b/lib/vm.py
@@ -322,8 +322,7 @@
   def _GetBuiltVMImagePath(self):
     """Get path of a locally built VM image."""
     vm_image_path = os.path.join(
-        constants.SOURCE_ROOT, 'src/build/images',
-        cros_build_lib.GetBoard(self.board, strict=True),
+        constants.SOURCE_ROOT, 'src/build/images', self.board,
         'latest', constants.VM_IMAGE_BIN)
     return vm_image_path if os.path.isfile(vm_image_path) else None
 
@@ -353,6 +352,13 @@
         raise VMError('VM image does not exist: %s' % self.image_path)
     logging.debug('VM image path: %s', self.image_path)
 
+  def _SetDefaultBoard(self):
+    """Sets a default board if none is specified."""
+    if self.board:
+      return
+    sdk_board_env = os.environ.get(cros_chrome_sdk.SDKFetcher.SDK_BOARD_ENV)
+    self.board = cros_build_lib.GetBoard(sdk_board_env, strict=True)
+
   def _WaitForSSHPort(self, sleep=5):
     """Wait for SSH port to become available."""
     class _SSHPortInUseError(Exception):
@@ -461,6 +467,7 @@
     """
     if not self.enable_kvm:
       logging.warning('KVM is not supported; Chrome VM will be slow')
+    self._SetDefaultBoard()
     self._SetQemuPath()
     self._SetVMImagePath()
     logging.info('Pid file: %s', self.pidfile)