aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2022-01-14 20:10:22 +0100
committerJake Hunsaker <jhunsake@redhat.com>2022-01-17 12:24:16 -0500
commit747fef695e4ff08f320c5f03090bdefa7154c761 (patch)
tree201ad35fc513ff2dfa6c0a496d353791a0acf968
parent137abd394f64a63b6633949b5c81159af12038b7 (diff)
downloadsos-747fef695e4ff08f320c5f03090bdefa7154c761.tar.gz
[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 <pmoravec@redhat.com>
-rw-r--r--sos/report/plugins/virsh.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/sos/report/plugins/virsh.py b/sos/report/plugins/virsh.py
index d6b7c167..08f9a848 100644
--- a/sos/report/plugins/virsh.py
+++ b/sos/report/plugins/virsh.py
@@ -39,26 +39,30 @@ class LibvirtClient(Plugin, IndependentPlugin):
]
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