背景

背景

背景

我正在运行 FreeBSD 12.1-RELEASE 作为主机比维虚拟机。

我有一个在虚拟机内运行的 FreeBSD 12.1-RELEASE 来宾。我想为其配置两个 TTY 级设备。

根据手册页,为了使用两个 TTY 类设备启动 VM,我必须使用类似于以下的命令行选项启动 bhyve:-l com1,/dev/nmdm0B -l com2,/dev/nmdm1B。然后我应该能够通过这两个连接到访客零调制解调器终端cu -l /dev/nmdm0Acu -l /dev/nmdm1A

问题

第一个命令按预期工作:cu -l /dev/nmdm0A向我显示来宾的主控制台。

然而,第二个命令附加到来宾,但不显示任何内容。我希望显示一个登录提示,就像切换到另一个 TTY 一​​样。

我缺少什么?


额外细节

  • 该来宾是全新安装的 FreeBSD。

  • guest上的输出dmesg | grep uart如下:

    uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
    uart0: console (115200,n,8,1)
    uart1: <16550 or compatible> port 0x2f8-0x2ff irq 3 on acpi0
    
  • 我尝试hint.uart.1.flags先设置为0x10,然后设置为0x80(尽管根据我的理解,这是针对内核调试器的)串口(4))并在每次更改后重新启动。它不起作用。

参考

答案1

/etc/ttys解决办法是在guest上修改。在 amd64 上,它具有以下默认值:

#
# $FreeBSD: head/sbin/init/ttys.amd64 338454 2018-09-04 15:48:13Z brd $
#   @(#)ttys    5.1 (Berkeley) 4/17/89
#
# This file specifies various information about terminals on the system.
# It is used by several different programs.  Common entries for the
# various columns include:
#
# name  The name of the terminal device.
#
# getty The program to start running on the terminal.  Typically a
#       getty program, as the name implies.  Other common entries
#       include none, when no getty is needed, and xdm, to start the
#       X Window System.
#
# type The initial terminal type for this port.  For hardwired
#      terminal lines, this will contain the type of terminal used.
#      For virtual consoles, the correct type is typically xterm.
#      Other common values include dialup for incoming modem ports, and
#      unknown when the terminal type cannot be predetermined.
#
# status Must be on or off.  If on, init will run the getty program on
#        the specified port.  If the word "secure" appears, this tty
#        allows root login.
#
# name  getty               type    status      comments
#
# If console is marked "insecure", then init will ask for the root password
# when going to single-user mode.
console none                unknown off secure
#
ttyv0   "/usr/libexec/getty Pc"     xterm   onifexists secure
# Virtual terminals
ttyv1   "/usr/libexec/getty Pc"     xterm   onifexists secure
ttyv2   "/usr/libexec/getty Pc"     xterm   onifexists secure
ttyv3   "/usr/libexec/getty Pc"     xterm   onifexists secure
ttyv4   "/usr/libexec/getty Pc"     xterm   onifexists secure
ttyv5   "/usr/libexec/getty Pc"     xterm   onifexists secure
ttyv6   "/usr/libexec/getty Pc"     xterm   onifexists secure
ttyv7   "/usr/libexec/getty Pc"     xterm   onifexists secure
ttyv8   "/usr/local/bin/xdm -nodaemon"  xterm   off secure
# Serial terminals
# The 'dialup' keyword identifies dialin lines to login, fingerd etc.
ttyu0   "/usr/libexec/getty 3wire"  vt100   onifconsole secure
ttyu1   "/usr/libexec/getty 3wire"  vt100   onifconsole secure
ttyu2   "/usr/libexec/getty 3wire"  vt100   onifconsole secure
ttyu3   "/usr/libexec/getty 3wire"  vt100   onifconsole secure
# Dumb console
dcons   "/usr/libexec/getty std.9600"   vt100   off secure

如您所见,每个 ttyu 终端设备的状态都设置为onifconsole secure(该secure部分与此处无关)。这意味着这些终端设备只有充当控制台时才会打开。为了能够从主机访问这些设备,我们只需替换onifconsoleonifexists.

在我的特殊情况下,我必须替换以下行:

ttyu1   "/usr/libexec/getty 3wire"  vt100   onifconsole secure

和:

ttyu1   "/usr/libexec/getty 3wire"  vt100   ifexists secure

因此,现在可以使用第二个控制台连接到来宾系统:

# cu -l /dev/nmdm1A
Password:
Connected
 
 
FreeBSD/amd64 (testvm) (ttyu1)
 
login: root
Password:
Last login: Fri Jun 26 19:59:40 on ttyu1
FreeBSD 12.1-RELEASE r354233 GENERIC
 
Welcome to FreeBSD!

相关内容