Revision 585c8187 lib/hypervisor/hv_kvm.py
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
209 | 209 |
_MIGRATION_INFO_MAX_BAD_ANSWERS = 5 |
210 | 210 |
_MIGRATION_INFO_RETRY_DELAY = 2 |
211 | 211 |
|
212 |
_VERSION_RE = re.compile(r"\b(\d+)\.(\d+)\.(\d+)\b")
|
|
212 |
_VERSION_RE = re.compile(r"\b(\d+)\.(\d+)(\.(\d+))?\b")
|
|
213 | 213 |
|
214 | 214 |
ANCILLARY_FILES = [ |
215 | 215 |
_KVM_NETWORK_SCRIPT, |
... | ... | |
1007 | 1007 |
return result |
1008 | 1008 |
|
1009 | 1009 |
@classmethod |
1010 |
def _ParseKVMVersion(cls, text): |
|
1011 |
"""Parse the KVM version from the --help output. |
|
1012 |
|
|
1013 |
@type text: string |
|
1014 |
@param text: output of kvm --help |
|
1015 |
@return: (version, v_maj, v_min, v_rev) |
|
1016 |
@raise L{errors.HypervisorError}: when the KVM version cannot be retrieved |
|
1017 |
|
|
1018 |
""" |
|
1019 |
match = cls._VERSION_RE.search(text.splitlines()[0]) |
|
1020 |
if not match: |
|
1021 |
raise errors.HypervisorError("Unable to get KVM version") |
|
1022 |
|
|
1023 |
v_all = match.group(0) |
|
1024 |
v_maj = int(match.group(1)) |
|
1025 |
v_min = int(match.group(2)) |
|
1026 |
if match.group(4): |
|
1027 |
v_rev = int(match.group(4)) |
|
1028 |
else: |
|
1029 |
v_rev = 0 |
|
1030 |
return (v_all, v_maj, v_min, v_rev) |
|
1031 |
|
|
1032 |
@classmethod |
|
1010 | 1033 |
def _GetKVMVersion(cls): |
1011 | 1034 |
"""Return the installed KVM version. |
1012 | 1035 |
|
... | ... | |
1017 | 1040 |
result = utils.RunCmd([constants.KVM_PATH, "--help"]) |
1018 | 1041 |
if result.failed: |
1019 | 1042 |
raise errors.HypervisorError("Unable to get KVM version") |
1020 |
match = cls._VERSION_RE.search(result.output.splitlines()[0]) |
|
1021 |
if not match: |
|
1022 |
raise errors.HypervisorError("Unable to get KVM version") |
|
1023 |
|
|
1024 |
return (match.group(0), int(match.group(1)), int(match.group(2)), |
|
1025 |
int(match.group(3))) |
|
1043 |
return cls._ParseKVMVersion(result.output) |
|
1026 | 1044 |
|
1027 | 1045 |
def StopInstance(self, instance, force=False, retry=False, name=None): |
1028 | 1046 |
"""Stop an instance. |
Also available in: Unified diff