]> xenbits.xensource.com Git - people/iwj/osstest.git/commitdiff
HVM guests: Use qemu "pipe:" for serial output logging
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 10 Nov 2015 18:00:03 +0000 (18:00 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 13 Nov 2015 12:42:16 +0000 (12:42 +0000)
Modern qemu has the "pipe:/PATH" character driver.  This opens
/PATH.in for reading and /PATH.out for writing.  In my tests, I found
that:
  - contrary to the documentation, they do not need to be pipes
    (at least, /PATH.out can be a file)
  - but they must both already exist
  - qemu will follow symlinks, so /PATH.out can be a symlink to
    a file
  - if /PATH.in is a fifo, qemu will tolerate other processes opening
    it for writing, and writing things, only occasionally.  (Probably,
    qemu opens it O_RDWR; or perhaps it reopens it after EOF.)

Use this feature to achieve the following:
  - guest serial output ends up in /var/log/xen/osstest-serial-GUEST.log
    (which is already captured by ts-logs-capture) rather than
    interleaved with qemu's stderr output (in the libxl-created logfile)
  - guest serial input comes from a pipe in /root which we can open
    and write to if we want to talk to the guest

We are mostly interested in the final bullet point, because that will
allow us to send debug keys to the emulated serial port of an L1
nested HVM guest.

Looking at the source code of qemu in 4.2 and 4.6 I think the above
approach will work with all relevant qemu-xen's.

If the device model version is qemu-xen-traditional, `pipe:' is not
supported.  If device_model_version is not set, we will be using
whatever the xen.git we used defaults to.  For Xen 4.1 and earlier
that is qemu-xen-traditional, and I'm slightly loathe to break osstest
for those earlier versions.  There doesn't seem to be anything else in
the runvars that would clue us in.  So be cautious and do not use the
new feature unless device_model_version is explicitly set.

The nested tests are all -qemuu so set device_model_version.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v17: Fix fifo mode to be 600, not 700
v16: New patch

Osstest/TestSupport.pm

index 32f29561a3d30deff6fd683a0157ceb62e2a3a1a..47fc1b1bdb3f5a612e437a578ba4c5d523ceb511 100644 (file)
@@ -1884,8 +1884,18 @@ END
        # fd pointing to mini-os's console. IOW any such path used
        # here ends up in the host logs in /var/log/xen/qemu-dm-$guest.log
        $cfg .= "serial='file:/var/log/dm-serial.log'\n";
-    } else {
+    } elsif (!(defined $devmodel) || $devmodel =~ /traditional/) {
        $cfg .= "serial='file:/dev/stderr'\n";
+    } else {
+       my $logpath = "/var/log/xen/osstest-serial-$gho->{Name}.log";
+       my $basepath = "/root/$flight.$job.$gho->{Name}.serial";
+       target_cmd_root($ho, <<END);
+            set -ex
+            test -e $logpath      || touch $logpath
+            test -e $basepath.out || ln -s $logpath $basepath.out
+            test -e $basepath.in  || mkfifo -m600 $basepath.in
+END
+       $cfg .= "serial='pipe:$basepath'\n";
     }
 
     $xopts{VifType} ||= "ioemu";