To Create a KVM guest VM from command line.

I have an existing ISO directory at:
/myzpool/iso/

And I am storing the KVM at:
/myzpool/kvm

The command that creates the virtual machine is this:

$ sudo virt-install --name server01debian10-server3 \
--os-type linux \
--os-variant Debian10 \
--ram 2048\
--disk /myzpool/kvm/debian10-server3.qcow2,device=disk,bus=virtio,size=10,format=qcow2 \
--graphics none \
--noautoconsole \
--hvm \
--cdrom /iso/debian-10.9.0-amd64-netinst.iso \
--boot cdrom,hd

Or

virt-install --name=centos \
--memory=2048 --vcpus=1 \
--location=/myzpool/iso/debian-10.9.0-amd64-netinst.iso \
--disk /myzpool/kvm/debian10-server3.qcow2,device=disk,bus=virtio,size=8 \
--network bridge:br0 \
--os-type=linux  \
--nographics \
--extra-args='console=tty0 console=ttyS0,115200n8 serial'

This articles describes how to enable virsh console on KVM Guests

List Virtual Machines

$ sudo virsh list --all
 Id   Name               State
-----------------------------------
 13   debian10-server3   running

After installing KVM and trying to console, all I see is below and no access to machine:

$ sudo virsh console debian10-server3
Connected to domain centos8
Escape character is ^]

Type the following to exit:

$ Ctrl+]

Enable Virsh Console Access For KVM Guests

Log in via ssh or kvm virtual machine manager to the KVM guest system (virtual machine), not in the KVM host.

Run the following:

$ sudo systemctl enable serial-getty@ttyS0.service
Created symlink /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service → /lib/systemd/system/serial-getty@.service.

 

$ sudo systemctl start serial-getty@ttyS0.service

verify it by looking into the VM’s configuration XML file from the Host:

$ sudo virsh edit debian10-server3

Scroll to see the following lines…

Now start the virsh console of the guest system from the host using command:

$ sudo virsh console debian10-server3
Connected to domain centos8
Escape character is ^]

Press ENTER again and type your user name and password to connect to the guest machine. To exit, type Ctrl+]