Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

20.16.17. 主机物理机器接口

字符设备作为以下类型之一向主机物理机器表示自己:

表 20.23. 字符设备元素

参数描述XML 片断
域日志文件禁用字符设备上的所有输入,并将输出发送到虚拟机的 logfile
      			   	   <devices>
      			   	      <console type='stdio'>
      			   	         <target port='1'/>
                           </console>
                        </devices>
设备日志文件一个文件被打开,发送到 字符设备的所有数据都将写入该文件。
      			   	   <devices>
      			   	      <serial type="file">
      			   	         <source path="/var/log/vm/vm-serial.log"/>
      			   	         <target port="1"/>
      			   	      </serial>
      			   	   </devices>
虚拟控制台将字符设备连接到虚拟控制台中的图形帧缓冲器。这通常通过特殊的热键序列访问,如 "ctrl+alt+3"
      			   	   <devices>
      			   	      <serial type='vc'>
                              <target port="1"/>
                           </serial>
                        </devices>
null 设备将字符设备连接到 void.未向输入提供数据。所有写入的数据都会被丢弃。
                        <devices>
                           <serial type='null'>
                              <target port="1"/>
                           </serial>
                        </devices>
伪 TTY使用 /dev/ptmx 分配 Pseudo TTY。virsh 控制台 等适合的客户端可以连接本地的串行端口交互。
                        <devices>
                           <serial type="pty">
                              <source path="/dev/pts/3"/>
                              <target port="1"/>
                           </serial>
                        </devices>
NB 特殊问题单NB 特殊情况( <如果控制台 type='pty'> ),则 TTY 路径也作为顶级 <控制台> 标签上的 tty='/dev/pts/3' 属性重复。这为 <console> 标签提供了与现有语法兼容。 
主机物理机器设备代理字符设备通过 传递给底层物理字符设备。设备类型必须匹配,将模拟串行端口应仅连接到主机物理机器串行端口 - 不将串行端口连接到并行端口。
                        <devices>
                           <serial type="dev">
                              <source path="/dev/ttyS0"/>
                              <target port="1"/>
                           </serial>
                        </devices>
命名管道字符设备会将输出写入命名管道。如需更多信息,请参阅 pipe(7)手册页。
                        <devices>
                           <serial type="pipe">
                              <source path="/tmp/mypipe"/>
                              <target port="1"/>
                           </serial>
                        </devices>
TCP 客户端/服务器字符设备充当连接到远程服务器的 TCP 客户端。
                        <devices>
                           <serial type="tcp">
                              <source mode="connect" host="0.0.0.0" service="2445"/>
                              <protocol type="raw"/>
                              <target port="1"/>
                           </serial>
                        </devices>
或 作为等待客户端连接的 TCP 服务器。
                        <devices>
                           <serial type="tcp">
                              <source mode="bind" host="127.0.0.1" service="2445"/>
                              <protocol type="raw"/>
                              <target port="1"/>
                           </serial>
                        </devices>
或者,您可以使用 telnet 替代原始 TCP。另外,您还可以使用 telnets(安全 telnet)和 tls。
                        <devices>
                           <serial type="tcp">
                              <source mode="connect" host="0.0.0.0" service="2445"/>
                              <protocol type="telnet"/>
                              <target port="1"/>
                           </serial>
                           <serial type="tcp">
                              <source mode="bind" host="127.0.0.1" service="2445"/>
                              <protocol type="telnet"/>
                              <target port="1"/>
                           </serial>
                        </devices>
UDP 网络控制台字符设备充当 UDP netconsole 服务,发送和接收数据包。这是一个丢失的服务。
                        <devices>
                           <serial type="udp">
                              <source mode="bind" host="0.0.0.0" service="2445"/>
                              <source mode="connect" host="0.0.0.0" service="2445"/>
                              <target port="1"/>
                           </serial>
                        </devices>
UNIX 域套接字客户端/服务器字符设备充当 UNIX 域套接字服务器,接受来自本地客户端的连接。
                        <devices>
                           <serial type="unix">
                              <source mode="bind" path="/tmp/foo"/>
                              <target port="1"/>
                           </serial>
                           </devices>