[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 22/22] Serial: Add new serial method object for `guest' type



From: Robert Ho <robert.hu@xxxxxxxxx>

L1 guests' serial ports are owned by qemu in L0.  We can send them
debug keys by writing to the qemu pipe.

(xl debug-key looks like it would be useful but it actually sends
debug keys to the hypervisor of the host it is running on.  We want to
send the debug keys to the hypervisor and kernel from the outside.)

Log fetching is not needed because from the POV of the L0 the L1 is a
guest, so the L0's log capture will already fetch the L1's serial
console output.

XXX THIS PATCH IS TOTALLY UNTESTED

Signed-off-by: Robert Ho <robert.hu@xxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

---
v16: Mostly rewritten: now uses new keys_real base class, and
     uses the qemu pipe rather than xl debug-keys.
v15: New patch.
---
 Osstest/Serial/guest.pm |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 Osstest/TestSupport.pm  |    2 +-
 2 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 Osstest/Serial/guest.pm

diff --git a/Osstest/Serial/guest.pm b/Osstest/Serial/guest.pm
new file mode 100644
index 0000000..e2902ee
--- /dev/null
+++ b/Osstest/Serial/guest.pm
@@ -0,0 +1,93 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2015 Intel Inc.
+# Copyright (C) 2015 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Send debug keys to nested host (L1).
+
+package Osstest::Serial::guest;
+
+use strict;
+use warnings;
+
+use Osstest;
+use Osstest::TestSupport;
+use Osstest::Serial::keys_real;
+
+BEGIN {
+    use Exporter ();
+    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+    $VERSION     = 1.00;
+    @ISA         = qw(Exporter Osstest::Serial::keys_real);
+    @EXPORT      = qw();
+    %EXPORT_TAGS = ( );
+
+    @EXPORT_OK   = qw();
+}
+
+sub new {
+    my ($class, $l1ho, $methname, @args) = @_;
+    my $mo = { Target => $l1ho, Parent => $l1ho->{Host} };
+
+    logm("serial method $methname $mo->{Target}{Name}: @args");
+    return bless $mo, $class;
+}
+
+sub keys_prepare {
+    my ($mo) = @_;
+
+    my $gho = $mo->{Target};
+    my $pho = $mo->{Parent};
+    my $puho = sshuho('root',$pho);
+
+    my $fifo = "/root/$flight.$job.$gho->{Name}.serial.in";
+
+    # NB this by-hand construction and execution of an
+    # ssh command line bypasses the usual timeout arrangements.
+    my ($sshopts) = sshopts();
+
+    # timeouts: open will carry on regardless even if the command hangs
+    open SERIALWRITE, "|ssh @$sshopts $puho cat >$fifo" or die $!;
+    autoflush SERIALWRITE 1;
+}
+
+sub keys_write {
+    my ($mo, $what,$str,$pause) = @_;
+    logm("xenuse sending $what");
+
+    # timeouts: we are going to write much less than any plausible
+    # PIPE_MAX so there is no risk that we will block on write
+    print SERIALWRITE $str or die $!;
+    sleep($pause);
+}
+
+sub keys_shutdown {
+    my ($mo) = @_;
+
+    # timeouts: close waits for the child to exit, so set an alarm
+    alarm(15);
+    $!=0; $?=0; close SERIALWRITE or die "$? $!";
+    alarm(0);
+}
+
+sub fetch_logs {
+    my ($mo);
+
+    logm("$mo->{Target}{Name} (nested host) serial console logs".
+        " will be found in guest logs from $mo->{Parent}{Name} (parent)");
+    return;
+}
+
+1;
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 0a47b52..bfc5652 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -874,7 +874,7 @@ sub selecthost ($) {
        $child->{Power} = 'guest';
        power_cycle_host_setup($child);
 
-       $child->{Properties}{Serial} = 'noop'; # todo
+       $child->{Properties}{Serial} = 'guest';
        serial_host_setup($child);
 
        my $msg = "L$child->{NestingLevel} host $child->{Ident}:";
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.