Skip to content
Snippets Groups Projects
Commit b52d85c1 authored by Guido Trotter's avatar Guido Trotter
Browse files

KVM: Add function to check the hypervisor version


Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent e964cc85
No related branches found
No related tags found
No related merge requests found
......@@ -212,6 +212,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
_MIGRATION_INFO_MAX_BAD_ANSWERS = 5
_MIGRATION_INFO_RETRY_DELAY = 2
_VERSION_RE = re.compile(r"\b(\d+)\.(\d+)\.(\d+)\b")
ANCILLARY_FILES = [
_KVM_NETWORK_SCRIPT,
]
......@@ -815,6 +817,21 @@ class KVMHypervisor(hv_base.BaseHypervisor):
return result
@classmethod
def _GetKVMVersion(cls):
"""Return the installed KVM version
@return: (version, v_maj, v_min, v_rev), or None
"""
result = utils.RunCmd([constants.KVM_PATH, "--help"])
if result.failed:
return None
match = cls._VERSION_RE.search(result.output.splitlines()[0])
if not match:
return None
return (match.group(0), match.group(1), match.group(2), match.group(3))
def StopInstance(self, instance, force=False, retry=False, name=None):
"""Stop an instance.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment