Skip to content

Commit

Permalink
susedistribution: Run user virtio console on it's own socket
Browse files Browse the repository at this point in the history
This allows switching between root and non-root user.

NOTE: passing socked_path is possible only to updated os-autoinst
backend/qemu.pm (must have this path in virtio_console_names())
thus guarded with $OpenQA::Isotovideo::Interface::version ge 35
detection (changes in 20d0119b ("backend/qemu.pm: Add
virtio_console_user fifo name")).

Console names should be handled in library (why tests should care about
the internals?), but for now at least properly document that.

This also requires to add new getty (serial console) to
system_prepare.pm (will be working with newly generated images) and
shift numbers in wickedbase.pm. This will work also on older
backend/qemu.pm, getty just won't be used.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
pevik committed Jan 23, 2023
1 parent cabcded commit 4a89bfb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
23 changes: 20 additions & 3 deletions lib/serial_terminal.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,37 @@ sub add_serial_console {
prepare_serial_console();
Wrapper for add_serial_console.
Configure serial consoles for virtio support (root-virtio-terminal and
user-virtio-terminal).
NOTE: if test plans to use more consoles via VIRTIO_CONSOLE_NUM, it have to
call add_serial_console() with proper console name (beware different number
for ppc64le).
=cut

sub prepare_serial_console {
# Configure serial consoles for virtio support
# poo#18860 Enable console on hvc0 on SLES < 12-SP2
# poo#44699 Enable console on hvc1 to fix login issues on ppc64le
record_info('getty before', script_output('systemctl | grep serial-getty'));

if (!check_var('VIRTIO_CONSOLE', 0)) {
my $console = 'hvc1';

# poo#18860 Enable console on hvc0 on SLES < 12-SP2 (root-virtio-terminal)
if (is_sle('<12-SP2') && !is_s390x) {
add_serial_console('hvc0');
}
# poo#44699 Enable console on hvc1 to fix login issues on ppc64le
# (root-virtio-terminal)
elsif (get_var('OFW')) {
add_serial_console('hvc1');
$console = 'hvc2';
}

# user-virtio-terminal
add_serial_console($console);
}

record_info('getty after', script_output('systemctl | grep serial-getty'));
}

=head2 get_login_message
Expand Down
7 changes: 6 additions & 1 deletion lib/susedistribution.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use Utils::Backends;
use backend::svirt qw(SERIAL_TERMINAL_DEFAULT_DEVICE SERIAL_TERMINAL_DEFAULT_PORT);
use Cwd;
use autotest 'query_isotovideo';
use isotovideo;

=head1 SUSEDISTRIBUTION
Expand Down Expand Up @@ -428,7 +429,11 @@ sub init_consoles {

if (is_qemu) {
$self->add_console('root-virtio-terminal', 'virtio-terminal', {});
$self->add_console('user-virtio-terminal', 'virtio-terminal', {});

$self->add_console('user-virtio-terminal', 'virtio-terminal',
isotovideo::get_version() >= 35 ?
{socked_path => cwd() . '/virtio_console_user'} : {});

for (my $num = 1; $num < get_var('VIRTIO_CONSOLE_NUM', 1); $num++) {
$self->add_console('root-virtio-terminal' . $num, 'virtio-terminal', {socked_path => cwd() . '/virtio_console' . $num});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/wickedbase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ sub pre_run_hook {
wait_serial($coninfo, undef, 0, no_regex => 1);
send_key 'ret';
if ($self->{name} eq 'before_test' && get_var('VIRTIO_CONSOLE_NUM', 1) > 1) {
my $serial_terminal = is_ppc64le ? 'hvc2' : 'hvc1';
my $serial_terminal = is_ppc64le ? 'hvc3' : 'hvc2';
add_serial_console($serial_terminal);
}
if ($self->{name} ne 'before_test' && get_var('WICKED_TCPDUMP')) {
Expand Down
2 changes: 1 addition & 1 deletion tests/console/system_prepare.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Summary: Execute SUT changes which should be permanent
# - Grant permissions on serial device
# - Add hvc0/hvc1 to /etc/securetty
# - Add hvc0/hvc1 and hvc1/hvc2 to /etc/securetty
# - Register modules if SCC_ADDONS, MEDIA_UPGRADE and in Regression flavor
# are defined
# - If system is vmware, set resolution to 1024x768 (and write to grub)
Expand Down

0 comments on commit 4a89bfb

Please sign in to comment.