]> xenbits.xensource.com Git - people/iwj/osstest.git/commitdiff
logm: Introduce $logm_prefix, and annotate nested guest messages
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 16 Nov 2015 15:21:12 +0000 (15:21 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 17 Nov 2015 12:44:18 +0000 (12:44 +0000)
This allows code elsewhere to annotate log messages which might
otherwise be confusing.  The variable should be localised, and the
value should always start with a space, if not empty.

Use this to annotate the calls to selecthost and selectguest from
within selecthost-for-an-L1.  Otherwise some of the log messages can
be very confusing.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Osstest/TestSupport.pm

index d0acdc663c902a75df4a6a069b55a71f14cd3993..6c08c6d27f703e2db7bbf86ed48e0427f2ef99c1 100644 (file)
@@ -41,7 +41,8 @@ BEGIN {
                       tsreadconfig %r $flight $job $stash
                       ts_get_host_guest
 
-                      fail broken logm $logm_handle get_filecontents
+                      fail broken logm $logm_handle $logm_prefix
+                      get_filecontents
                       report_once
 
                       store_runvar get_runvar get_runvar_maybe
@@ -132,6 +133,7 @@ our %timeout= qw(RebootDown   100
                  HardRebootUp 600);
 
 our $logm_handle= new IO::File ">& STDERR" or die $!;
+our $logm_prefix= '';
 
 #---------- test script startup ----------
 
@@ -194,7 +196,7 @@ sub ts_get_host_guest { # pass this @ARGV
 sub logm ($) {
     my ($m) = @_;
     my @t = gmtime;
-    my $fm = (show_abs_time time)." $m\n";
+    my $fm = (show_abs_time time)."$logm_prefix $m \n";
     foreach my $h ((ref($logm_handle) eq 'ARRAY')
                   ? @$logm_handle : $logm_handle) {
        print $h $fm or die $!;
@@ -866,6 +868,7 @@ sub selecthost ($) {
 
     if ($name =~ s/^(.*)://) {
        my $parentname = $1;
+       local $logm_prefix = $logm_prefix." [host $ident]";
        my $parent = selecthost($parentname);
        my $child = selectguest($name,$parent);
        $child->{Ident} = $ho->{Ident};