acloud: check kvm support or not and provide guidience.

show how to deal with the same error of rmmod: ERROR: Module kvm_intel is not currently loade

Bug: 196194537
Test: acloud-dev setup --host --force on cloudtop and workstation.
Change-Id: Ica50776b692de173a9666c6ed52ad3e503a4fca4
diff --git a/setup/host_setup_runner.py b/setup/host_setup_runner.py
index e272d88..9560e77 100644
--- a/setup/host_setup_runner.py
+++ b/setup/host_setup_runner.py
@@ -25,8 +25,10 @@
 import logging
 import os
 import shutil
+import subprocess
 import sys
 import tempfile
+import re
 
 from acloud.internal import constants
 from acloud.internal.lib import utils
@@ -42,6 +44,9 @@
 _BASE_REQUIRED_PKGS = ["ssvnc", "lzop", "python3-tk"]
 _CUTTLEFISH_COMMOM_PKG = "cuttlefish-common"
 _CF_COMMOM_FOLDER = "cf-common"
+_CHECK_KVM_CMD = "virt-host-validate"
+_CHECK_KVM_PATTERN = r".*:.Checking for hardware virtualization.*PASS\n"
+
 _LIST_OF_MODULES = ["kvm_intel", "kvm"]
 _UPDATE_APT_GET_CMD = "sudo apt-get update"
 _INSTALL_CUTTLEFISH_COMMOM_CMD = [
@@ -248,8 +253,33 @@
                 all_modules_present = False
         return all_modules_present
 
+    @staticmethod
+    def _IsSupportedKvm():
+        """Check if support kvm.
+
+        Returns:
+            True if environment supported kvm.
+        """
+        process = subprocess.Popen([_CHECK_KVM_CMD],
+                                   stdout=subprocess.PIPE,
+                                   universal_newlines=True)
+        stdout, _ = process.communicate()
+        re_pattern = re.compile(_CHECK_KVM_PATTERN)
+        if re_pattern.match(stdout):
+            return True
+
+        utils.PrintColorString(
+            "The environment doesn't support virtualization. If you want to "
+            "launch AVD on the local instance, Please refer to http://go/"
+            "acloud-cloudtop#acloud-create-local-instance-on-the-cloudtop ",
+            utils.TextColors.FAIL)
+        return False
+
     def _Run(self):
         """Setup host environment for local cuttlefish instance support."""
+        if not self._IsSupportedKvm():
+            return
+
         # TODO: provide --uid args to let user use prefered username
         username = getpass.getuser()
         setup_cmds = [