Console访问

对于Linux服务器还可以通过virsh console访问虚拟机。

编辑KVM配置

从宿主机编辑虚拟机的配置

<serial type='pty'>
  <source path='/dev/pts/0'/>
  <target type='isa-serial' port='0'>
    <model name='isa-serial'/>
  </target>
  <alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/0'>
  <source path='/dev/pts/0'/>
  <target type='serial' port='0'/>
  <alias name='serial0'/>
</console>

虚拟机启用串口

方案1:从虚拟机启用串口服务

sudo systemctl enable --now [email protected]

方案2:将console参数加到GRUB配置grub.cfg

GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8"

使用

virsh console <vmname>