File Coverage

consoles/sshVirtshSUT.pm
Criterion Covered Total %
statement 28 44 63.6
total 28 44 63.6


line stmt code
1   # Copyright 2018-2019 SUSE LLC
2   # SPDX-License-Identifier: GPL-2.0-or-later
3    
4    
5   use Mojo::Base 'consoles::console', -signatures;
6 2 use backend::svirt qw(SERIAL_TERMINAL_DEFAULT_PORT SERIAL_TERMINAL_DEFAULT_DEVICE);
  2  
  2  
7 2 use consoles::ssh_screen;
  2  
  2  
8 2  
  2  
  2  
9   my $self = $class->SUPER::new($testapi_console, $args);
10 2  
  2  
  2  
  2  
  2  
11 2 # TODO: inherit from consoles::sshVirtsh
12   my $instance = $bmwqemu::vars{VIRSH_INSTANCE} // 1;
13   $self->{libvirt_domain} = $args->{libvirt_domain} // "openQA-SUT-$instance";
14 2 $self->{serial_port_no} = $args->{serial_port_no} // SERIAL_TERMINAL_DEFAULT_PORT;
15 2  
16 2 # QEMU on s390x fails to start when added <serial> device due arch limitation
17   # on SCLP console, see "Multiple VT220 operator consoles are not supported"
18   # error at
19   # https://github.com/qemu/qemu/blob/master/hw/char/sclpconsole.c#L226
20   # Therefore <console> must be used for s390x.
21   # ATM there is only s390x using this console, let's make it the default.
22   $self->{pty_dev} = $args->{pty_dev} // SERIAL_TERMINAL_DEFAULT_DEVICE;
23    
24 2 return $self;
25   }
26 2  
27    
28   return unless $self->{ssh};
29 1 $self->{ssh}->disconnect;
  1  
  1  
  1  
30   $self->{ssh} = $self->{chan} = $self->{screen} = undef;
31 0 return;
  0  
  0  
32 0 }
33 0  
34 0 my $backend = $self->{backend};
35 0 bmwqemu::diag(sprintf("Activate console on libvirt_domain:%s devname:%s port:%s",
36   $self->{libvirt_domain}, $self->{pty_dev}, $self->{serial_port_no}));
37   my ($ssh, $chan) = $backend->open_serial_console_via_ssh(
38 0 $self->{libvirt_domain}, devname => $self->{pty_dev}, port => $self->{serial_port_no}, blocking => 0);
  0  
  0  
39 0 $self->{screen} = consoles::ssh_screen->new(ssh_connection => $ssh, ssh_channel => $chan);
40   $self->{ssh} = $ssh;
41 0 return;
42   }
43 0  
44 0  
45 0 1;