On Mon, Oct 4, 2010 at 17:29, Guido Trotter <[email protected]> wrote:
> 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])

Please use splitlines, not split("\n").

Also, are you sure that this is OK as is, just looking for num.num.num
in the first line? Maybe \s\d.\d.\d? If you're OK, then LGTM, but
seems a bit brittle using it without a start separator.

iustin

Reply via email to