Modify the function that sends commands to the KVM monitor so that it is possible to specify an optional timeout after which the command is killed.
Signed-off-by: Michele Tartara <[email protected]> --- lib/hypervisor/hv_kvm.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 3c1bc8c..4a65c58 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -1680,10 +1680,15 @@ class KVMHypervisor(hv_base.BaseHypervisor): self._SaveKVMRuntime(instance, kvm_runtime) self._ExecuteKVMRuntime(instance, kvm_runtime, kvmhelp) - def _CallMonitorCommand(self, instance_name, command): + def _CallMonitorCommand(self, instance_name, command, timeout=None): """Invoke a command on the instance monitor. """ + if timeout is not None: + timeout_cmd = "timeout %s" % (timeout, ) + else: + timeout_cmd = "" + # TODO: Replace monitor calls with QMP once KVM >= 0.14 is the minimum # version. The monitor protocol is designed for human consumption, whereas # QMP is made for programmatic usage. In the worst case QMP can also -- 1.9.0.279.gdc9e3eb
