From e3b896285d53a40a32670b17960d95172a2e6bde Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Fri, 11 Jan 2013 16:25:43 +0000
Subject: [PATCH] kvm: abstract getting --help output

This will be used later, for now nothing changes.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/hypervisor/hv_kvm.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index f222f59b3..1a99fff91 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -1642,6 +1642,19 @@ class KVMHypervisor(hv_base.BaseHypervisor):
       v_rev = 0
     return (v_all, v_maj, v_min, v_rev)
 
+  @classmethod
+  def _GetKVMHelpOutput(cls):
+    """Return the KVM help output.
+
+    @return: output of kvm --help
+    @raise errors.HypervisorError: when the KVM help output cannot be retrieved
+
+    """
+    result = utils.RunCmd([constants.KVM_PATH, "--help"])
+    if result.failed:
+      raise errors.HypervisorError("Unable to get KVM help output")
+    return result.output
+
   @classmethod
   def _GetKVMVersion(cls):
     """Return the installed KVM version.
@@ -1650,10 +1663,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     @raise errors.HypervisorError: when the KVM version cannot be retrieved
 
     """
-    result = utils.RunCmd([constants.KVM_PATH, "--help"])
-    if result.failed:
-      raise errors.HypervisorError("Unable to get KVM version")
-    return cls._ParseKVMVersion(result.output)
+    return cls._ParseKVMVersion(cls._GetKVMHelpOutput())
 
   def StopInstance(self, instance, force=False, retry=False, name=None):
     """Stop an instance.
-- 
GitLab