summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorIliyan Malchev <malchev@google.com>2020-04-14 09:40:41 -0700
committerCommit Bot <commit-bot@chromium.org>2020-04-19 22:22:46 +0000
commit2c1417b43a1846d21bc589563460de4b962afcc6 (patch)
tree4f9149bc581c1ba6e91a314f7f932be2e6a9d47e /tests
parent043aaea79be76508cc52f07e54da6b933b1987ef (diff)
downloadcrosvm-2c1417b43a1846d21bc589563460de4b962afcc6.tar
crosvm-2c1417b43a1846d21bc589563460de4b962afcc6.tar.gz
crosvm-2c1417b43a1846d21bc589563460de4b962afcc6.tar.bz2
crosvm-2c1417b43a1846d21bc589563460de4b962afcc6.tar.lz
crosvm-2c1417b43a1846d21bc589563460de4b962afcc6.tar.xz
crosvm-2c1417b43a1846d21bc589563460de4b962afcc6.tar.zst
crosvm-2c1417b43a1846d21bc589563460de4b962afcc6.zip
Serial: add input path overriding stdin for --serial
Allowing the input to be specified for file-based serial ports allows
the user of pipes as input/output. That enables kgdb over serial.

TEST=
Build a kernel with support for gdb

```
make x86_64_defconfig
make kvmconfig
./scripts/config --enable GDB_SCRIPTS
./scripts/config --enable KGDB
./scripts/config --enable KGDB_SERIAL_CONSOLE
./scripts/config --enable KGDB_LOW_LEVEL_TRAP
./scripts/config --enable KGDB_KDB
./scripts/config --enable KDB_KEYBOARD
./scripts/config --enable GDB_SCRIPTS
./scripts/config --set-val KDB_CONTINUE_CATASTROPHIC 0
make -j33
```

Setup devices for PTYs

To make sure crosvm doesn't create an ordinary file if socat is started
after it, create these named pipes first:

```
mkfifo ~/console_{in,out} ~/kgdb_{in,out}
```

Set up two PTYs: ~/kgdb for the debugger, and ~/serial for the console.
PTY ~/kgdb connects to ~/kgdb{in,out}, and ~/serial connects to
~/console{in,out}

```
socat -d -d -d \
    'PIPE:$HOME/console_out,rdonly=1,nonblock=1,ignoreeof=1!!PIPE:$HOME/console_in,wronly=1' \
    PTY,link=$HOME/serial,ctty,raw,echo=0

socat -d -d -d \
    'PIPE:$HOME/kgdb_out,rdonly=1,nonblock=1,ignoreeof=1!!PIPE:$HOME/kgdb_in,wronly=1' \
    PTY,link=$HOME/kgdb,ctty,raw,echo=0
```

Start crosvm with serial ports pointed at ~/console{in,out} and ~/kgdb{in,out}.

```
cargo run run -p 'init=/bin/sh panic=0 kgdboc=ttyS1,115200 kgdbwait kgdbcon' \
    --serial type=file,path=$HOME/console_out,num=1,console=true,stdin=false,input=$HOME/console_in \
    --serial type=file,path=$HOME/kgdb_out,input=$HOME/kgdb_in,num=2,console=false,stdin=false \
    -r ~/rootfs.img \
    ~/src/linux/arch/x86/boot/bzImage
```

Start GDB

```
gdb vmlinux -ex "target remote /home/dgreid/kgdb"
```

To break into gdb, open up the serial console, mount /proc and send a SysRq

```
minicom -D ~/serial
mount -t proc none /proc
echo g > /proc/sysrq-trigger
```

Change-Id: I18a9c1087d38301df49de08eeae2f8559b03463a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2151856
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/boot.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/boot.rs b/tests/boot.rs
index f74f38e..d5f52dc 100644
--- a/tests/boot.rs
+++ b/tests/boot.rs
@@ -232,6 +232,7 @@ fn boot() {
         SerialParameters {
             type_: SerialType::Sink,
             path: None,
+            input: None,
             num: 1,
             console: false,
             stdin: false,