User question: how to connect two VMs using serial port?
Hello
I would like to connect two VMs using serial port for kernel debugging purposes. It is quite simple in VirtualBox:
https://www.howtoforge.com/how-to-set-up-a-serial-port-between-two-virtual-machines-in-virtualbox
I wonder how to do the same in KVM?
Signature · 3 lines
Best regards, Aleksander Alekseev http://eax.me/
Not an expert, but looks like
$ mkfifo x $ kvm -hda img -serial pipe:x& $ kvm -hda img -serial pipe:x&
Could do the trick.
You can cat and echo information from the VMs when using this approach
Quoted 17 lines · Aleksander Alekseev
Hello
I would like to connect two VMs using serial port for kernel debugging purposes. It is quite simple in VirtualBox:
https://www.howtoforge.com/how-to-set-up-a-serial-port-between-two-virtual-machines-in-virtualbox
I wonder how to do the same in KVM?
--
Best regards,
Aleksander Alekseev
http://eax.me/
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello, Elazar
Thanks for your reply. Do I right understand that such a connection will not vanish after host reboot?
Signature · 3 lines
Best regards, Aleksander Alekseev http://eax.me/
Yes,
qemu is connecting the serial port to a FIFO, and qemu is resident even after host reboot.
In fact, even if you'll kill the qemu process and restart it with the same FIFO, it should still work.
Please try it, and report if it indeed worked for you.
Quoted 9 lines · Aleksander Alekseev
Hello, Elazar
Thanks for your reply. Do I right understand that such a connection will not vanish after host reboot?
--
Best regards,
Aleksander Alekseev
http://eax.me/
Quoted 9 lines
Yes,
qemu is connecting the serial port to a FIFO, and qemu is resident even after host reboot.
In fact, even if you'll kill the qemu process and restart it with the same FIFO, it should still work.
Please try it, and report if it indeed worked for you.
Frankly I'm still having some problems. But let me tell you a full story first.
I have Ubuntu 14.04 LTS installed on my laptop Fujitsu Lifebook E733. I created two VMs with FreeBSD 11.0 CURRENT. What I'm trying to do is to debug a FreeBSD kernel using kgdb, thus I need two systems connected via serial port.
Unfortunately using mkfifo as you described above didn't work. Right solution was found here:
http://blog.bauermann.eng.br/2013/09/04/connecting-qemukvm-virtual-machines-via-serial-port/
Now when I start VMs:
sudo kvm -hda /path/to/freebsd11.img \
-serial pipe:/path/to/null-cable-1
sudo kvm -hda /path/to/freebsd11kgdb.img \
-serial pipe:/path/to/null-cable-2
... serial port (/dev/cuau0) is seen in both VMs. Then I edited /boot/device.hints on freebsd11 VM like this:
hint.uart.0.flags="0x90"
..., restarted this VM, entered boot prompt (by pressing 3 in boot menu), and typed:
boot kernel -d
This command boots kernel in debug mode. In DDB prompt I typed:
gdb
Now system awaits connection from 2nd system by serial port. Here is how to do this:
su
cd /usr/src
sudo kgdb -r /dev/cuau0 /boot/kernel/kernel
Good news is --- it works!
http://i.imgur.com/bP8uioX.png
But I don't have a network connection and other stuff I configured using virsh. So I tried virsh edit MVNAME as described here:
http://blog.vmsplice.net/2011/04/how-to-pass-qemu-command-line-options.html
Unfortunately now when I start VM I got an error:
``` eax@fujitsu:~$ sudo virsh start freebsd11 error: Failed to start domain freebsd11 error: internal error: process exited while connecting to monitor: qemu-system-x86_64: -serial pipe:/var/lib/libvirt/pipes/null-cable-1: Failed to create chardev qemu: could not connect serial device to character backend 'pipe:/var/lib/libvirt/pipes/null-cable-1' ```
Here is a full sudo virsh dumpxml freebsd11 output:
http://paste.ubuntu.com/15386277/
Here is part of /var/log/libvirt/qemu/freebsd11.log, which contains long KVM command executed by virsh:
http://paste.ubuntu.com/15386302/
And here is how sudo strace virsh start freebsd11 looks like:
http://paste.ubuntu.com/15386306/
Any ideas how to solve this issue? Naturally if there is any other debug information you need I will be happy to provide it.
Best regards,
Aleksander Alekseev
http://eax.me/
Oh, never mind. I discovered that everything could be configured using virt-manager.
Problem solved. Thanks a lot for your help!
Quoted 96 lines · On Mon, 14 Mar 2016 22:34:49 +0300 Aleksander Alekseev <[email protected]>…
Quoted 9 lines
Yes,
qemu is connecting the serial port to a FIFO, and qemu is resident even after host reboot.
In fact, even if you'll kill the qemu process and restart it with the same FIFO, it should still work.
Please try it, and report if it indeed worked for you.
Frankly I'm still having some problems. But let me tell you a full story first.
I have Ubuntu 14.04 LTS installed on my laptop Fujitsu Lifebook E733. I created two VMs with FreeBSD 11.0 CURRENT. What I'm trying to do is to debug a FreeBSD kernel using kgdb, thus I need two systems connected via serial port.
Unfortunately using mkfifo as you described above didn't work. Right solution was found here:
http://blog.bauermann.eng.br/2013/09/04/connecting-qemukvm-virtual-machines-via-serial-port/
Now when I start VMs:
sudo kvm -hda /path/to/freebsd11.img \
-serial pipe:/path/to/null-cable-1
sudo kvm -hda /path/to/freebsd11kgdb.img \
-serial pipe:/path/to/null-cable-2... serial port (
/dev/cuau0) is seen in both VMs. Then I edited/boot/device.hintson freebsd11 VM like this:hint.uart.0.flags="0x90"
..., restarted this VM, entered boot prompt (by pressing 3 in boot menu), and typed:
boot kernel -d
This command boots kernel in debug mode. In DDB prompt I typed:
gdb
Now system awaits connection from 2nd system by serial port. Here is how to do this:
su
cd/usr/src
sudo kgdb -r/dev/cuau0/boot/kernel/kernelGood news is --- it works!
http://i.imgur.com/bP8uioX.png
But I don't have a network connection and other stuff I configured using
virsh. So I triedvirsh edit MVNAMEas described here:http://blog.vmsplice.net/2011/04/how-to-pass-qemu-command-line-options.html
Unfortunately now when I start VM I got an error:
``` eax@fujitsu:~$ sudo virsh start freebsd11 error: Failed to start domain freebsd11 error: internal error: process exited while connecting to monitor: qemu-system-x86_64: -serial pipe:/var/lib/libvirt/pipes/null-cable-1: Failed to create chardev qemu: could not connect serial device to character backend 'pipe:/var/lib/libvirt/pipes/null-cable-1' ```Here is a full
sudo virsh dumpxml freebsd11output:http://paste.ubuntu.com/15386277/
Here is part of
/var/log/libvirt/qemu/freebsd11.log, which contains long KVM command executed by virsh:http://paste.ubuntu.com/15386302/
And here is how
sudo strace virsh start freebsd11looks like:http://paste.ubuntu.com/15386306/
Any ideas how to solve this issue? Naturally if there is any other debug information you need I will be happy to provide it.
Best regards,
Aleksander Alekseev
http://eax.me/
--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Best regards, Aleksander Alekseev http://eax.me/