All of lore.kernel.org
 help / color / mirror / Atom feed
* User question: how to connect two VMs using serial port?
@ 2016-03-14 10:10 Aleksander Alekseev
  2016-03-14 11:22 ` Elazar Leibovich
  0 siblings, 1 reply; 6+ messages in thread
From: Aleksander Alekseev @ 2016-03-14 10:10 UTC (permalink / raw)
  To: KVM devel mailing list

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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: User question: how to connect two VMs using serial port?
  2016-03-14 10:10 User question: how to connect two VMs using serial port? Aleksander Alekseev
@ 2016-03-14 11:22 ` Elazar Leibovich
  2016-03-14 12:03   ` Aleksander Alekseev
  0 siblings, 1 reply; 6+ messages in thread
From: Elazar Leibovich @ 2016-03-14 11:22 UTC (permalink / raw)
  To: Aleksander Alekseev; +Cc: KVM devel mailing list

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

On Mon, Mar 14, 2016 at 12:10 PM, Aleksander Alekseev <afiskon@devzen.ru> wrote:
> 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: User question: how to connect two VMs using serial port?
  2016-03-14 11:22 ` Elazar Leibovich
@ 2016-03-14 12:03   ` Aleksander Alekseev
  2016-03-14 12:19     ` Elazar Leibovich
  0 siblings, 1 reply; 6+ messages in thread
From: Aleksander Alekseev @ 2016-03-14 12:03 UTC (permalink / raw)
  To: Elazar Leibovich; +Cc: KVM devel mailing list

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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: User question: how to connect two VMs using serial port?
  2016-03-14 12:03   ` Aleksander Alekseev
@ 2016-03-14 12:19     ` Elazar Leibovich
  2016-03-14 19:34       ` Aleksander Alekseev
  0 siblings, 1 reply; 6+ messages in thread
From: Elazar Leibovich @ 2016-03-14 12:19 UTC (permalink / raw)
  To: Aleksander Alekseev; +Cc: KVM devel mailing list

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.

On Mon, Mar 14, 2016 at 2:03 PM, Aleksander Alekseev <afiskon@devzen.ru> wrote:
> 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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: User question: how to connect two VMs using serial port?
  2016-03-14 12:19     ` Elazar Leibovich
@ 2016-03-14 19:34       ` Aleksander Alekseev
  2016-03-14 19:52         ` Aleksander Alekseev
  0 siblings, 1 reply; 6+ messages in thread
From: Aleksander Alekseev @ 2016-03-14 19:34 UTC (permalink / raw)
  To: Elazar Leibovich; +Cc: KVM devel mailing list

> 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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: User question: how to connect two VMs using serial port?
  2016-03-14 19:34       ` Aleksander Alekseev
@ 2016-03-14 19:52         ` Aleksander Alekseev
  0 siblings, 0 replies; 6+ messages in thread
From: Aleksander Alekseev @ 2016-03-14 19:52 UTC (permalink / raw)
  To: Elazar Leibovich; +Cc: KVM devel mailing list

Oh, never mind. I discovered that everything could be configured using
virt-manager.

Problem solved. Thanks a lot for your help!

On Mon, 14 Mar 2016 22:34:49 +0300
Aleksander Alekseev <afiskon@devzen.ru> wrote:

> > 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/
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best regards,
Aleksander Alekseev
http://eax.me/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-03-14 19:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-14 10:10 User question: how to connect two VMs using serial port? Aleksander Alekseev
2016-03-14 11:22 ` Elazar Leibovich
2016-03-14 12:03   ` Aleksander Alekseev
2016-03-14 12:19     ` Elazar Leibovich
2016-03-14 19:34       ` Aleksander Alekseev
2016-03-14 19:52         ` Aleksander Alekseev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.