Enable KVM guest console through virsh
From AcrodusWiki
Using the virsh console [vm_name] command can be used to get a shell to the vm. This is very handy when there is no virt-manager/desktop environment or no ssh. Although you will need to get a shell up somehow.
This assumes that the configuration in the xml is correct with <serial> and <console> sections.
sudo systemctl status serial-getty@ttyS0
If this is not active.
sudo systemctl enable serial-getty-ttyS0 and sudo systemctl start serial-getty-ttyS0
When creating the virtual machine make sure that you use the config --extra-args 'console=ttyS0,115200n8 --- console==ttyS0,115200n8'
Actually im going to add the whole shell script ive used for creating kvm guests.
#!/bin/bash
#Script used to create vm's on KVM
set -e
virt-install \
--name vm_samba \
--os-variant debian11 \
--memory 4096 \
--boot uefi,bootmenu.enable=on,bios.useserial=on \
--console pty,target.type=virtio \
--serial pty \
--extra-args 'console=ttyS0,115200n8 --- console=ttyS0,115200n8' \
--vcpus 2 \
--graphics none \
--video virtio \
--cpu host \
--network bridge=br0 \
--rng /dev/urandom \
--controller type=scsi,model=virtio-scsi,driver.iommu=on \
--disk path=/dev/vg1/lv_vm_samba \
--location /var/lib/libvirt/images/debian-12.5.0-amd64-DVD-1.iso