From 747fef695e4ff08f320c5f03090bdefa7154c761 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Fri, 14 Jan 2022 20:10:22 +0100 Subject: [PATCH] [virsh] Call virsh commands in the foreground / with a TTY In some virsh errors (like unable to connect to a hypervisor), the tool requires to communicate to TTY otherwise it can get stuck (when called via Popen with a timeout). Calling it on foreground prevents the stuck / waiting on cmd timeout. Resolves: #2825 Signed-off-by: Pavel Moravec --- sos/report/plugins/virsh.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sos/report/plugins/virsh.py b/sos/report/plugins/virsh.py index d6b7c16761..08f9a8488c 100644 --- a/sos/report/plugins/virsh.py +++ b/sos/report/plugins/virsh.py @@ -39,26 +39,30 @@ def setup(self): ] for subcmd in subcmds: - self.add_cmd_output('%s %s' % (cmd, subcmd)) + self.add_cmd_output('%s %s' % (cmd, subcmd), foreground=True) # get network, pool and nwfilter elements for k in ['net', 'nwfilter', 'pool']: - k_list = self.collect_cmd_output('%s %s-list' % (cmd, k)) + k_list = self.collect_cmd_output('%s %s-list' % (cmd, k), + foreground=True) if k_list['status'] == 0: k_lines = k_list['output'].splitlines() # the 'Name' column position changes between virsh cmds pos = k_lines[0].split().index('Name') for j in filter(lambda x: x, k_lines[2:]): n = j.split()[pos] - self.add_cmd_output('%s %s-dumpxml %s' % (cmd, k, n)) + self.add_cmd_output('%s %s-dumpxml %s' % (cmd, k, n), + foreground=True) # cycle through the VMs/domains list, ignore 2 header lines and latest # empty line, and dumpxml domain name in 2nd column - domains_output = self.exec_cmd('%s list --all' % cmd) + domains_output = self.exec_cmd('%s list --all' % cmd, foreground=True) if domains_output['status'] == 0: domains_lines = domains_output['output'].splitlines()[2:] for domain in filter(lambda x: x, domains_lines): d = domain.split()[1] for x in ['dumpxml', 'dominfo', 'domblklist']: - self.add_cmd_output('%s %s %s' % (cmd, x, d)) + self.add_cmd_output('%s %s %s' % (cmd, x, d), + foreground=True) + # vim: et ts=4 sw=4