0

Command
Here is what I am doing

# Step 1. In host machine
$ qemu-system-x86_64 \
        -enable-kvm -nodefaults -nographic -L /usr/share/qemu \
        -m 8G -smp 4 -boot c \
        -netdev user,hostnet0,hostfwd=tcp::5556-:22 \
        -drive file=ubuntu18.04.qcow2,if=virtio,cache=none \
        -device virtio-net-pci,netdev=hostnet0,id=net0,bus=pci.0,addr=0x3\
        -serial pty  

# Step 2. In guest machine
$ sudo vim /etc/default/grub
# Change GRUB_CMDLINE_LINUX="" as GRUB_CMDLINE_LINUX="console=ttyS0"

# Step 3. In host machine
# There should be a printed log showing 
# which pty is being used when the host runs qemu
# Let say, /dev/pts/3
$ sudo cat /dev/pts/3 

# Step 4. Login /dev/pts/3
$ echo "id" > /dev/pts/3
$ echo "password" > /dev/pts/3

# Step 5. Print dmesg in a log file
$ echo dmesg > /dev/pts/3

What I want to is to get a kernel log from the guest machine. The code above is basically using pty as serial port so I am able to get the log through a certain tty but the problem is there is a warning for this method.

If I send a command, dmesg, I get this message.

[ 0.00000] serial8250: too much work for irq4

I do not believe that this is a critical warning but it is quite annoying to see and it seems to me that several logs are ignored.

I'd like to know the better way to get a log without any warning from the log. I feel this method is not right. The way I used is that I have to login regularly and redirect the quite ugly output of cat.

Is there a way to get a log right away without using echo dmesg?

0

Alternative

# Using a named pipeline
# Step 1. qemu configuration
$ qemu-system-x86_64 \
        -some options like above \
        -serial pipe:/tmp/guest

# Step 2. To get a log
$ mkfifo /tmp/guest.in /tmp/guest.out
$ cat /tmp/guest.out
$ printf "id\n" > /tmp/guest.in
$ printf "pw\n" > /tmp/guest.in
$ printf "cmd\n" > /tmp/guest.in

Link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.