Revision bc0fed4b
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
589 | 589 |
_KVMOPT_HELP = "help" |
590 | 590 |
_KVMOPT_MLIST = "mlist" |
591 | 591 |
_KVMOPT_DEVICELIST = "devicelist" |
592 |
|
|
593 |
# Command to execute to get the output from kvm, and whether to |
|
594 |
# accept the output even on failure. |
|
592 | 595 |
_KVMOPTS_CMDS = { |
593 |
_KVMOPT_HELP: ["--help"],
|
|
594 |
_KVMOPT_MLIST: ["-M", "?"],
|
|
595 |
_KVMOPT_DEVICELIST: ["-device", "?"],
|
|
596 |
_KVMOPT_HELP: (["--help"], False),
|
|
597 |
_KVMOPT_MLIST: (["-M", "?"], False),
|
|
598 |
_KVMOPT_DEVICELIST: (["-device", "?"], True),
|
|
596 | 599 |
} |
597 | 600 |
|
598 | 601 |
def __init__(self): |
... | ... | |
1713 | 1716 |
def _GetKVMOutput(cls, kvm_path, option): |
1714 | 1717 |
"""Return the output of a kvm invocation |
1715 | 1718 |
|
1719 |
@type kvm_path: string |
|
1720 |
@param kvm_path: path to the kvm executable |
|
1721 |
@type option: a key of _KVMOPTS_CMDS |
|
1722 |
@param option: kvm option to fetch the output from |
|
1716 | 1723 |
@return: output a supported kvm invocation |
1717 | 1724 |
@raise errors.HypervisorError: when the KVM help output cannot be retrieved |
1718 | 1725 |
|
1719 | 1726 |
""" |
1720 | 1727 |
assert option in cls._KVMOPTS_CMDS, "Invalid output option" |
1721 | 1728 |
|
1722 |
result = utils.RunCmd([kvm_path] + cls._KVMOPTS_CMDS[option]) |
|
1723 |
if result.failed: |
|
1729 |
optlist, can_fail = cls._KVMOPTS_CMDS[option] |
|
1730 |
|
|
1731 |
result = utils.RunCmd([kvm_path] + optlist) |
|
1732 |
if result.failed and not can_fail: |
|
1724 | 1733 |
raise errors.HypervisorError("Unable to get KVM %s output" % |
1725 | 1734 |
" ".join(cls._KVMOPTS_CMDS[option])) |
1726 | 1735 |
return result.output |
Also available in: Unified diff