Connect to KVM: virsh
Serial Console
You can access a KVM instance directly using a serial console interface.
The following information describes how to establish a serial console connection to a KVM instance by using the virsh console
command.
Note:
A serial console connection to a KVM instance might be useful when a the instance isn't configured with a GUI display, or if the instance lacks a network configuration, preventing SSH access.What Do you Need?
- Administrator privileges
- Name of the KVM instance.
- The KVM instance is configured for serial console use. For example:
- KVM serial console device defined – Ensure that a serial console device is defined on KVM. For example:
If output is shown, a serial console device is defined. Otherwise, define a serial console in the KVM XML configuration. One method you can use issudo virsh ttyconsole kvm_name
virsh edit
. For example, run:
Within thesudo virsh edit
<devices>
tag, add the following text to the XML. For example:
See Domain XML format for more information.<devices> <console type='pty'/> </devices>
- KVM kernel console option enabled – Ensure that
console=ttyS0
kernel option is enabled on KVM. If this option isn't configured, thevirsh console
connection to the serial console will be unresponsive.To verify the
console=ttyS0
kernel option is configured on the KVM, use thecat /proc/cmdline
command. The output configuration must includeconsole=[console-name]
. If the output doesn't include a console configuration, you must enable theconsole=ttyS0
kernel option.To enable theconsole=ttyS0
kernel option, (1) type:
(2) Ensure that the changes were applied, type:sudo grubby --update-kernel=ALL --args="console=ttyS0"
(3) Reboot the KVM instance.sudo grub2-editenv - unset kernelopts
- KVM serial console device defined – Ensure that a serial console device is defined on KVM. For example:
Steps
Follow these steps to directly connect to the KVM serial console.