cros_vm: Fixes for VM.WaitForBoot() on non-KVM.

* remote_access throws SSHConnectionError instead of 255 error code.
* the OS crashes if we try to run vm_sanity.py before chrome has
launched, which can happen on non-hw accelerated runs.
* wait for 5 chrome processes to be launched before starting tests.
* wait for chrome restart after deploy_chrome.
* make process timeout configurable in deploy_chrome.py
* use retry_util.RetryException for retries.

BUG=chromium:655280
TEST=manual

Change-Id: I2f2dc09e1abc8a987a3da9aaf741165a4fef7652
Reviewed-on: https://chromium-review.googlesource.com/523270
Commit-Ready: Achuith Bhandarkar <achuith@chromium.org>
Tested-by: Achuith Bhandarkar <achuith@chromium.org>
Reviewed-by: Ryan Cui <rcui@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/deploy_chrome.py b/scripts/deploy_chrome.py
index c4f4c3f..e4f05b1 100644
--- a/scripts/deploy_chrome.py
+++ b/scripts/deploy_chrome.py
@@ -188,7 +188,7 @@
     # Developers sometimes run session_manager manually, in which case we'll
     # need to help shut the chrome processes down.
     try:
-      with timeout_util.Timeout(KILL_PROC_MAX_WAIT):
+      with timeout_util.Timeout(self.options.process_timeout):
         while self._ChromeFileInUse():
           logging.warning('The chrome binary on the device is in use.')
           logging.warning('Killing chrome and session_manager processes...\n')
@@ -200,7 +200,8 @@
           logging.info('Rechecking the chrome binary...')
     except timeout_util.TimeoutError:
       msg = ('Could not kill processes after %s seconds.  Please exit any '
-             'running chrome processes and try again.' % KILL_PROC_MAX_WAIT)
+             'running chrome processes and try again.'
+             % self.options.process_timeout)
       raise DeployFailure(msg)
 
   def _MountRootfsAsWritable(self, error_code_ok=True):
@@ -445,6 +446,9 @@
                           "Overrides the default arguments.")
   group.add_argument('--ping', action='store_true', default=False,
                      help='Ping the device before connection attempt.')
+  group.add_argument('--process-timeout', type=int,
+                     default=KILL_PROC_MAX_WAIT,
+                     help='Timeout for process shutdown.')
 
   group = parser.add_argument_group(
       'Metadata Overrides (Advanced)',