Signed-off-by: Guido Trotter <[email protected]>
---
lib/hypervisor/hv_kvm.py | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index 069337a..cd54139 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -213,6 +213,8 @@ class KVMHypervisor(hv_base.BaseHypervisor):
_MIGRATION_INFO_MAX_BAD_ANSWERS = 5
_MIGRATION_INFO_RETRY_DELAY = 2
+ _VERSION_RE = re.compile('(\d+)\.(\d+)\.(\d+)')
+
ANCILLARY_FILES = [
_KVM_NETWORK_SCRIPT,
]
@@ -821,6 +823,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.split("\n")[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.
--
1.7.1