TestSupport: export guest_find_lv
PATCH 1/6 TestSupport: export guest_find_lv
We'll need this in a moment.
--- Osstest/TestSupport.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Osstest/TestSupport.pm +1 -1
@@ -114,7 +114,7 @@ BEGIN { prepareguest_part_xencfg guest_umount_lv guest_await guest_await_dhcp_tcp guest_checkrunning $guest_state_running_re - target_check_ip guest_find_ether + target_check_ip guest_find_ether guest_find_lv guest_find_domid guest_check_up guest_check_up_quick guest_get_state guest_await_reboot guest_await_shutdown guest_await_destroy guest_destroy
Signature · 1 line
2.11.0
PATCH 2/6 ts-logs-capture: Introduce @allguests containing even non-running
Nothing looks at this yet.
--- ts-logs-capture | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
ts-logs-capture +4 -3
@@ -39,7 +39,7 @@ if (!$ho) { exit 0; } -our @guests; +our (@allguests, @guests); sub find_guests () { my $sth= $dbh_tests->prepare(<<END);
@@ -59,12 +59,13 @@ END 1; }) { logm("cannot find domid: $@");; - next; } - push @guests, $gho; + push @allguests, $gho; } $sth->finish(); + + @guests = grep { defined $_->{Domid} } @allguests; } sub try_fetch_logs ($$) {
Signature · 1 line
2.11.0
PATCH 3/6 ts-logs-capture: Break logs up into general logs and host logs
In reply to Ian JacksonWe are going to fetch logs out of guests. @general_logs will contain the relevant patterns. Right now we just introduce the variable and split the list. The categorisation is roughly right...
--- ts-logs-capture | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
ts-logs-capture +5 -2
@@ -135,8 +135,7 @@ sub try_cmd_output_save ($;$) { close $fh or die $!; } -sub fetch_logs_host () { - my $logs= [qw( +our @general_logs = qw( /var/log/kern.log* /var/log/syslog* /var/log/daemon.log*
@@ -149,6 +148,10 @@ sub fetch_logs_host () { /var/log/installer/syslog* /var/log/installer/partman* + ); + +sub fetch_logs_host () { + my $logs= [@general_logs, qw( /var/log/xen/xend.log* /var/log/xen/xend-debug.log* /var/log/xen/xen-hotplug.log*
Signature · 1 line
2.11.0
PATCH 4/6 ts-logs-capture: Move some general logs onto @general_logs
In reply to Ian JacksonNow @general_logs contains logs we want from guests as well as hosts.
--- ts-logs-capture | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
ts-logs-capture +5 -6
@@ -148,6 +148,11 @@ our @general_logs = qw( /var/log/installer/syslog* /var/log/installer/partman* + /boot/config* + + /home/osstest/osstest-confirm-booted.log + + /var/core/*.core ); sub fetch_logs_host () {
@@ -172,14 +177,8 @@ sub fetch_logs_host () { /var/log/xen-tools/* - /boot/config* - /etc/xen/* - /home/osstest/osstest-confirm-booted.log - - /var/core/*.core - )]; if (!try_fetch_logs($ho, $logs)) { logm("log fetching failed, trying hard host reboot...");
Signature · 1 line
2.11.0
PATCH 5/6 ts-logs-capture: try_fetch_logs: Honour $fs_ and $out_prefix
In reply to Ian JacksonThis allows us to add some stuff to add to each pattern, and each filename. This will be useful in a moment.
None of the call sites pass this yet.
--- ts-logs-capture | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
ts-logs-capture +7 -4
@@ -68,11 +68,13 @@ END @guests = grep { defined $_->{Domid} } @allguests; } -sub try_fetch_logs ($$) { - my ($lho, $logfilepats) = @_; +sub try_fetch_logs ($$;$$) { + my ($lho, $logfilepats, $fs_prefix,$out_prefix) = @_; + $fs_prefix //= ''; + $out_prefix //= ''; my $ok= 0; foreach my $logfilepat (@$logfilepats) { - my $logfileslist= $logfilepat; + my $logfileslist= $fs_prefix.$logfilepat; if ($logfileslist =~ m/[*?]/) { if (!eval { $logfileslist=
@@ -91,8 +93,9 @@ END } foreach my $logfile (split / /, $logfileslist) { my $llogfile= $logfile; + $llogfile =~ s,^\Q$fs_prefix\E,,; $llogfile =~ s,/,-,g; - $llogfile= hostnamepath($lho)."--$llogfile"; + $llogfile= hostnamepath($lho)."-$out_prefix-$llogfile"; logm("fetching $logfile to $llogfile"); if (!eval { target_getfile_root($lho,60, $logfile,"$stash/$llogfile");
Signature · 1 line
2.11.0
PATCH 6/6 ts-logs-capture: Fish some logs out of guest filesystem
In reply to Ian JacksonThis involves shutting the guests down. We use this shell rune because xl doesn't provide a good way to ensure there are no guests running.
--- ts-logs-capture | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
ts-logs-capture +30 -0
@@ -261,10 +261,40 @@ sub fetch_logs_guest ($) { } } +sub shutdown_guests () { + target_cmd_root($ho, <<'END', 180); + set -x + ( + ( exec 2>/dev/null; sleep 30 ; echo y ) & + ( xl shutdown -a -F -w ; echo y ) & + ) | ( + read x + xl list | awk '!/^Domain-0 |^Name / {print $2}' \ + | xargs -t -r -n1 xl destroy ||: + ) +END +} + +sub extract_logs_guest ($) { + my ($gho) = @_; + if (!eval { + guest_find_lv($gho); + target_cmd_root($ho, "umount /mnt ||:"); + target_cmd_root($ho, "mount -r ".$gho->{Lvdev}." /mnt"); + try_fetch_logs($ho, \@general_logs, '/mnt', "$gho->{Guest}-"); + target_cmd_root($ho, "umount /mnt ||:"); + 1; + }) { + logm("failure extracting logs out of guest fs: $@"); + } +} + power_state($ho,1); find_guests(); fetch_xenctx_guest($_) foreach @guests; serial_fetch_logs($ho); fetch_logs_host(); fetch_logs_guest($_) foreach @guests; +shutdown_guests(); +extract_logs_guest($_) foreach @allguests; logm("logs captured to $stash");
Signature · 1 line
2.11.0