From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [OSSTEST PATCH 3/4] ts-logs-capture: Break out guest listing and do it earlier
Date: Thu, 2 Jul 2015 18:11:06 +0100 [thread overview]
Message-ID: <1435857067-10704-4-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1435857067-10704-1-git-send-email-ian.jackson@eu.citrix.com>
Break out the function find_guests from what was
fetch_logs_host_guests, and have it save its results in the @guests
global.
We do this soon because in the next patch we are going to want to
do something to each guest before we call serial_fetch_logs.
The loop containing fetch_logs_guest is now in the main program.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
ts-logs-capture | 60 ++++++++++++++++++++++++++++++++-----------------------
1 file changed, 35 insertions(+), 25 deletions(-)
diff --git a/ts-logs-capture b/ts-logs-capture
index 13795e8..7127675 100755
--- a/ts-logs-capture
+++ b/ts-logs-capture
@@ -33,6 +33,34 @@ our ($whhost) = @ARGV;
$whhost ||= 'host';
our $ho= selecthost($whhost);
+our @guests;
+
+sub find_guests () {
+ my $sth= $dbh_tests->prepare(<<END);
+ SELECT name FROM runvars WHERE flight=? AND job=?
+ AND name LIKE '%_domname'
+ ORDER BY name
+END
+ $sth->execute($flight, $job);
+ my $row;
+ while ($row= $sth->fetchrow_hashref) {
+ my $gn= $row->{name};
+ $gn =~ s/_domname$//;
+
+ my $gho= selectguest($gn,$ho);
+ if (!eval {
+ guest_find_domid($ho,$gho);
+ 1;
+ }) {
+ logm("cannot find domid: $@");;
+ next;
+ }
+
+ push @guests, $gho;
+ }
+ $sth->finish();
+}
+
sub try_fetch_logs ($$) {
my ($lho, $logfilepats) = @_;
my $ok= 0;
@@ -97,7 +125,7 @@ sub try_cmd_output_save ($;$) {
close $fh or die $!;
}
-sub fetch_logs_host_guests () {
+sub fetch_logs_host () {
my $logs= [qw(
/var/log/kern.log*
/var/log/syslog*
@@ -173,33 +201,13 @@ sub fetch_logs_host_guests () {
) {
try_cmd_output_save($cmd);
}
-
- my $sth= $dbh_tests->prepare(<<END);
- SELECT name FROM runvars WHERE flight=? AND job=?
- AND name LIKE '%_domname'
- ORDER BY name
-END
- $sth->execute($flight, $job);
- my $row;
- while ($row= $sth->fetchrow_hashref) {
- my $gn= $row->{name};
- $gn =~ s/_domname$//;
- fetch_logs_guest($gn);
- }
- $sth->finish();
}
sub fetch_logs_guest ($) {
- my ($gn) = @_;
+ my ($gho) = @_;
+ my $gn = $gho->{Name};
logm("saving logs for $gn");
- my $gho= selectguest($gn,$ho);
- if (!eval {
- guest_find_domid($ho,$gho);
- 1;
- }) {
- logm("cannot find domid: $@");
- return;
- }
+
my $consolecmd= toolstack($ho)->consolecmd($gho);
try_cmd_output_save("sleep 1 | $consolecmd | cat",
"guest-$gho->{Name}-console");
@@ -226,6 +234,8 @@ sub fetch_logs_guest ($) {
}
}
+find_guests();
serial_fetch_logs($ho);
-fetch_logs_host_guests();
+fetch_logs_host();
+fetch_logs_guest($_) foreach @guests;
logm("logs captured to $stash");
--
1.7.10.4
next prev parent reply other threads:[~2015-07-02 17:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-02 17:11 [OSSTEST PATCH 0/4] Fix use of xenctx Ian Jackson
2015-07-02 17:11 ` [OSSTEST PATCH 1/4] guest_find_domid: Set Vcpus correctly Ian Jackson
2015-07-03 8:52 ` Ian Campbell
2015-07-02 17:11 ` [OSSTEST PATCH 2/4] ts-logs-capture: Find xenctx in /usr/local as well Ian Jackson
2015-07-03 8:52 ` Ian Campbell
2015-07-02 17:11 ` Ian Jackson [this message]
2015-07-03 8:54 ` [OSSTEST PATCH 3/4] ts-logs-capture: Break out guest listing and do it earlier Ian Campbell
2015-07-02 17:11 ` [OSSTEST PATCH 4/4] ts-logs-capture: Run xenctx earlier Ian Jackson
2015-07-03 8:55 ` Ian Campbell
2015-07-03 11:25 ` Ian Jackson
2015-07-03 11:49 ` [OSSTEST PATCH 1/6] guest_find_domid: Set Vcpus correctly Ian Jackson
2015-07-03 11:49 ` [OSSTEST PATCH 2/6] ts-logs-capture: Find xenctx in /usr/local as well Ian Jackson
2015-07-03 11:49 ` [OSSTEST PATCH 3/6] ts-logs-capture: Break out guest listing and do it earlier Ian Jackson
2015-07-03 11:49 ` [OSSTEST PATCH 4/6] ts-logs-capture: Run xenctx earlier Ian Jackson
2015-07-03 11:49 ` [OSSTEST PATCH 5/6] ts-logs-capture: Run xenctx twice for each guest vcpu Ian Jackson
2015-07-03 12:07 ` Ian Campbell
2015-07-03 11:49 ` [OSSTEST PATCH 6/6] ts-logs-capture: Explicitly set xenctx capture filename Ian Jackson
2015-07-03 12:08 ` Ian Campbell
2015-07-03 13:20 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435857067-10704-4-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).