Date: Fri, 14 Feb 2025 19:36:21 -0500 From: peter garshtja <peter.garshtja@ambient-md.com> To: Michael Gmelin <grembo@freebsd.org> Cc: Paul Vixie <paul@redbarn.org>, virtualization@freebsd.org, freebsd-virtualization@freebsd.org Subject: Re: bhyve vm and virtio-console Message-ID: <CALFUBVHEV=Ee4Wvdhrq622KPnbEv6M8mkFH%2BxZ7nioLrqCmVgw@mail.gmail.com> In-Reply-To: <CALFUBVE2j54=iDXP=NpbBnrf=aMR2-kD3PLwRkzT0Aaf1Ywfhw@mail.gmail.com> References: <9865e8dd-7af9-4cc6-97c7-2e3197c62e62@ambient-md.com> <899331A6-1635-4546-ADE6-FE21B52138FF@freebsd.org> <CALFUBVE2j54=iDXP=NpbBnrf=aMR2-kD3PLwRkzT0Aaf1Ywfhw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] Alright, I was missing the point, in my case if I want to get shell access via virtio-console then I should have attached getty to that console inside the guest os, and eventually I expected to see the same behavior as I have experienced with null modem emulator. Thx On Fri, Feb 14, 2025, 18:16 peter garshtja <peter.garshtja@ambient-md.com> wrote: > Exactly, I expect to get the shell after I connect with socat, something > similar to docker exec -it. > > On Fri, Feb 14, 2025, 18:10 Michael Gmelin <grembo@freebsd.org> wrote: > >> >> >> > On 14. Feb 2025, at 23:46, Petru Garstea <peter.garshtja@ambient-md.com> >> wrote: >> > >> > Spinning up the vm with /dev/nmdm* and connecting with cu -l is not an >> issue on my end. >> > I am trying to create a vm using freebsd cloud image and connect to >> guest OS terminal with virtio-console and socat(no X11). >> > When spawning the vm the unix socket indeed is created, however when I >> connect to it with socat nothing is being shown(not actions on any terminal >> commands as well). >> > Also, I noticed there is a kernel module(virtio_console.ko) and >> apparently I believe it has to be loaded it, not sure here. >> > >> > Please advise, >> > >> >> You can connect to the device inside the vm like I wrote and pass data to >> the socat connected socket on the outside (this is what I tested, please >> see my previous email). >> >> Are you trying to get some sort of shell over this connection? >> >> -m >> >> >> >> On 2/14/25 17:23, Paul Vixie wrote: >> >> if you want to use cu, you have to use -l to map guest com1 to some >> host nmdm >> >> device. if you want to use virtio-console, it will create unix domain >> sockets >> >> not pseudo tty endpoints. from bhyve(8) we see: >> >> >> >>> Virtio console device backends: >> >>> • >> >>> port1=/path/to/port1.sock[,portN=/path/to/port2.sock >> ...] >> >>> A maximum of 16 ports per device >> can be created. Every >> >>> port >> >>> is named and corresponds to a Unix domain socket >> created by >> >>> bhyve. bhyve accepts at most one connection per >> port at a >> >>> time. >> >>> Limitations: >> >>> • Due to lack of destructors in >> bhyve, sockets on the >> >>> filesystem must be cleaned up manually after >> bhyve >> >>> exits. >> >>> • There is no way to use the >> “console port” feature, nor >> >>> the console port resize at present. >> >>> • Emergency write is advertised, >> but no-op at present. >> >> i know of no host-side client which will connect to these unix domain >> sockets >> >> and offer a cu-like user interface. "unidirectional" may be the >> experience >> >> you'll get from "socat". >> >> >> >> if what you're trying to accomplish is a graphical console, >> virtio-console is >> >> not the way to do it. rather, you'll want "fbuf" to create a guest >> VGA/similar >> >> that gateways to a host VNC. >> >> >> >> re: >> >> >> >>> On Friday, February 14, 2025 9:55:23 PM UTC Petru Garstea wrote: >> >>> I tried with the following command, and got the same result. >> >>> >> >>> */usr/sbin/bhyve -H -P -A -c 1 -m 1500M \ >> >>> -s 0,hostbridge \ >> >>> -s 6,virtio-console,0=/tmp/vtcon.0 \ >> >>> -s 31,lpc \ >> >>> -l bootrom,/tmp/BHYVE_UEFI.fd \ >> >>> -s 1,virtio-blk,/tmp/fbsd.img \ >> >>> -s 2,virtio-net,tap0 \ >> >>> tmp* >> >>> >> >>> >> >>> I also able to connect but the bidirectional connection is not >> happening >> >>> >> >>> *socat - UNIX-CONNECT:/tmp/vtcon.0 >> >>> ls >> >>> * >> >>> PS: if I use null modem emulation instead virtio-console, then >> >>> connecting with cu is not an issue. >> >>> >> >>> any ideas ? >> >>> >> >>> Thanks >> >>> >> >>> On 2/14/25 14:57, Michael Gmelin wrote: >> >>>> On Fri, 14 Feb 2025 14:21:07 -0500 >> >>>> >> >>>> Petru Garstea<peter.garshtja@ambient-md.com> wrote: >> >>>>> Hi, >> >>>>> I am trying to configure bhyve vm with support of virtio-console, >> the >> >>>>> following option is added to bhyve command line >> >>>>> >> >>>>> *-s 3,virtio-console,port1=/test/console.sock >> >>>>> >> >>>>> *However when trying to connect to socket with socat trere are no >> >>>>> input/ouptut is observed. >> >>>>> >> >>>>> Has virtio-console ever worked ? >> >>>> Yes it works, I just tried it using sysutils/vm-bhyve (just add >> >>>> virt_console0="Yes" to the configuration file). >> >>>> >> >>>> Based on the logs, these device settings are used by it: >> >>>> bhyve devices: >> >>>> -s 0,hostbridge \ >> >>>> -s 31,lpc \ >> >>>> -s 4:0,virtio-blk,/dev/zvol/zroot/vms/freebsd14-test/disk0 \ >> >>>> -s 5:0,virtio-net,tap0,mac=58:9c:fc:aa:aa:aa \ >> >>>> -s 6:0,virtio-console,0=/vms/freebsd14-test/vtcon.0 >> >>>> >> >>>> I could connect to /vms/freebsd14-test/vtcon.0 using socat: >> >>>> socat - UNIX-CONNECT:/vms/freebsd14-test/vtcon.0 >> >>>> >> >>>> Inside the vm it's /dev/vtcon/0. >> >>>> >> >>>> -m >> >> >> > >> >> [-- Attachment #2 --] <div dir="auto">Alright, I was missing the point, in my case if I want to get shell access via virtio-console then I should have attached getty to that console inside the guest os, and eventually I expected to see the same behavior as I have experienced with null modem emulator.<div dir="auto"><br></div><div dir="auto">Thx</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Feb 14, 2025, 18:16 peter garshtja <<a href="mailto:peter.garshtja@ambient-md.com">peter.garshtja@ambient-md.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Exactly, I expect to get the shell after I connect with socat, something similar to docker exec -it. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 14, 2025, 18:10 Michael Gmelin <<a href="mailto:grembo@freebsd.org" target="_blank" rel="noreferrer">grembo@freebsd.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br> <br> > On 14. Feb 2025, at 23:46, Petru Garstea <<a href="mailto:peter.garshtja@ambient-md.com" rel="noreferrer noreferrer" target="_blank">peter.garshtja@ambient-md.com</a>> wrote:<br> > <br> > Spinning up the vm with /dev/nmdm* and connecting with cu -l is not an issue on my end.<br> > I am trying to create a vm using freebsd cloud image and connect to guest OS terminal with virtio-console and socat(no X11).<br> > When spawning the vm the unix socket indeed is created, however when I connect to it with socat nothing is being shown(not actions on any terminal commands as well).<br> > Also, I noticed there is a kernel module(virtio_console.ko) and apparently I believe it has to be loaded it, not sure here.<br> > <br> > Please advise,<br> > <br> <br> You can connect to the device inside the vm like I wrote and pass data to the socat connected socket on the outside (this is what I tested, please see my previous email).<br> <br> Are you trying to get some sort of shell over this connection?<br> <br> -m<br> <br> <br> >> On 2/14/25 17:23, Paul Vixie wrote:<br> >> if you want to use cu, you have to use -l to map guest com1 to some host nmdm<br> >> device. if you want to use virtio-console, it will create unix domain sockets<br> >> not pseudo tty endpoints. from bhyve(8) we see:<br> >> <br> >>> Virtio console device backends:<br> >>> •<br> >>> port1=/path/to/port1.sock[,portN=/path/to/port2.sock ...]<br> >>> A maximum of 16 ports per device can be created. Every<br> >>> port<br> >>> is named and corresponds to a Unix domain socket created by<br> >>> bhyve. bhyve accepts at most one connection per port at a<br> >>> time.<br> >>> Limitations:<br> >>> • Due to lack of destructors in bhyve, sockets on the<br> >>> filesystem must be cleaned up manually after bhyve<br> >>> exits.<br> >>> • There is no way to use the “console port” feature, nor<br> >>> the console port resize at present.<br> >>> • Emergency write is advertised, but no-op at present.<br> >> i know of no host-side client which will connect to these unix domain sockets<br> >> and offer a cu-like user interface. "unidirectional" may be the experience<br> >> you'll get from "socat".<br> >> <br> >> if what you're trying to accomplish is a graphical console, virtio-console is<br> >> not the way to do it. rather, you'll want "fbuf" to create a guest VGA/similar<br> >> that gateways to a host VNC.<br> >> <br> >> re:<br> >> <br> >>> On Friday, February 14, 2025 9:55:23 PM UTC Petru Garstea wrote:<br> >>> I tried with the following command, and got the same result.<br> >>> <br> >>> */usr/sbin/bhyve -H -P -A -c 1 -m 1500M \<br> >>> -s 0,hostbridge \<br> >>> -s 6,virtio-console,0=/tmp/vtcon.0 \<br> >>> -s 31,lpc \<br> >>> -l bootrom,/tmp/BHYVE_UEFI.fd \<br> >>> -s 1,virtio-blk,/tmp/fbsd.img \<br> >>> -s 2,virtio-net,tap0 \<br> >>> tmp*<br> >>> <br> >>> <br> >>> I also able to connect but the bidirectional connection is not happening<br> >>> <br> >>> *socat - UNIX-CONNECT:/tmp/vtcon.0<br> >>> ls<br> >>> *<br> >>> PS: if I use null modem emulation instead virtio-console, then<br> >>> connecting with cu is not an issue.<br> >>> <br> >>> any ideas ?<br> >>> <br> >>> Thanks<br> >>> <br> >>> On 2/14/25 14:57, Michael Gmelin wrote:<br> >>>> On Fri, 14 Feb 2025 14:21:07 -0500<br> >>>> <br> >>>> Petru Garstea<<a href="mailto:peter.garshtja@ambient-md.com" rel="noreferrer noreferrer" target="_blank">peter.garshtja@ambient-md.com</a>> wrote:<br> >>>>> Hi,<br> >>>>> I am trying to configure bhyve vm with support of virtio-console, the<br> >>>>> following option is added to bhyve command line<br> >>>>> <br> >>>>> *-s 3,virtio-console,port1=/test/console.sock<br> >>>>> <br> >>>>> *However when trying to connect to socket with socat trere are no<br> >>>>> input/ouptut is observed.<br> >>>>> <br> >>>>> Has virtio-console ever worked ?<br> >>>> Yes it works, I just tried it using sysutils/vm-bhyve (just add<br> >>>> virt_console0="Yes" to the configuration file).<br> >>>> <br> >>>> Based on the logs, these device settings are used by it:<br> >>>> bhyve devices:<br> >>>> -s 0,hostbridge \<br> >>>> -s 31,lpc \<br> >>>> -s 4:0,virtio-blk,/dev/zvol/zroot/vms/freebsd14-test/disk0 \<br> >>>> -s 5:0,virtio-net,tap0,mac=58:9c:fc:aa:aa:aa \<br> >>>> -s 6:0,virtio-console,0=/vms/freebsd14-test/vtcon.0<br> >>>> <br> >>>> I could connect to /vms/freebsd14-test/vtcon.0 using socat:<br> >>>> socat - UNIX-CONNECT:/vms/freebsd14-test/vtcon.0<br> >>>> <br> >>>> Inside the vm it's /dev/vtcon/0.<br> >>>> <br> >>>> -m<br> >> <br> > <br> <br> </blockquote></div> </blockquote></div>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALFUBVHEV=Ee4Wvdhrq622KPnbEv6M8mkFH%2BxZ7nioLrqCmVgw>
