Modify the function that runs Xen commands 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_xen.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index cb0c061..88f71d1 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -360,13 +360,21 @@ class XenHypervisor(hv_base.BaseHypervisor): return cmd - def _RunXen(self, args): + def _RunXen(self, args, timeout=None): """Wrapper around L{utils.process.RunCmd} to run Xen command. + If a timeout (in seconds) is specified, the command will be terminated after + that number of seconds. + @see: L{utils.process.RunCmd} """ - cmd = [self._GetCommand()] + cmd = [] + + if timeout is not None: + cmd.extend(["timeout", str(timeout)]) + + cmd.extend([self._GetCommand()]) cmd.extend(args) return self._run_cmd_fn(cmd) -- 1.9.0.279.gdc9e3eb
