To enable console access for a KVM virtual machine (VM) managed by virsh on Ubuntu Linux, you need to perform the following steps:
- Connect to the virtual machine using
virsh:
virsh -c qemu:///system console <VM_name>
- Log into the virtual machine as the root user.
- Install the
gettypackage, if it is not already installed:
apt-get install agetty
- Open the
/etc/default/grubfile and add the following line:
GRUB_CMDLINE_LINUX="console=ttyS0,115200n8"
- Update the grub configuration:
update-grub
- Restart the virtual machine:
reboot
- After the virtual machine has restarted, connect to the virtual machine console again:
virsh -c qemu:///system console <VM_name>
You should now have console access to the virtual machine through the virsh command. Note that the <VM_name> should be replaced with the actual name of your virtual machine.