Reference: RH Serial Console
When working with KVM virtual machines, the virsh command is the main interface for managing guest domains or DOMs, in libvirt jargon.
It is used for many tasks, such as creating, modifying, and destroying virtual machines. One function that I find very useful is connecting to a guest's console.
As you know, on a physical system, console access allows you to modify the BIOS. It also allows you to watch and interact with the system during the boot process or Linux OS installation. The same is true here but through a serial connection instead of direct.
I find this to be an invaluable tool when designing or troubleshooting an installation server that is hosting PXE and TFTPBOOT. It's like a virtual crash cart!
It's extremely easy to configure, here's how.
Log into the virtual machine that you would like to access. We are going to add console=ttyS0 to the end of the grub configuration file and reboot the vm.
cd /etc/default
cp grub grub.orig
vi grub
Append console=ttyS0 to the end of the GRUB_CMDLINE_LINUX variable. Don't forget, the backslash is only there to indicate the lines continuation, so don't include them!
GRUB_CMDLINE_LINUX="crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M \
resume=/dev/mapper/system-swap rd.lvm.lv=system/root rd.lvm.lv=system/swap \
rd.lvm.lv=system/usr verbose console=ttyS0"
grub2-mkconfig -o /boot/grub2/grubreboot
Now log into your KVM server to test connectivity to the serial console.
virsh list
virsh console vm-1