virt-install

ifconfig xenbr0
osinfo-query os | grep centos

ubuntu

using generic because arful does not exist yet into osinfo (Jan 2018),

virt-install \
--name artful \
--ram 512 \
--disk path=/data/kvm/artful.qcow2,size=8,bus=virtio \
--vcpus 2 \
--os-type linux \
--os-variant generic \
--network bridge=xenbr0,model=virtio \
--graphics none \
    --accelerate \
--console pty,target_type=serial \
--location 'http://archive.ubuntu.com/ubuntu/dists/artful/main/installer-amd64/' \
--extra-args 'console=ttyS0,115200n8 serial'

ref. https://raymii.org/s/articles/virt-install_introduction_and_copy_paste_distro_install_commands.html#Ubuntu_14.04

you need to fix GRUB setup for talking to the serial console,

mkdir -p /tmp/kvmloop/
guestmount --help
guestmount -d ubuntu17.10 -i /tmp/kvmloop
#-w

grub-update has troubles inside the image chroot,

grub-probe: error: unknown filesystem.

so fix grub like a dirty bastard,

cp -pi /tmp/kvmloop/boot/grub/grub.cfg /tmp/kvmloop/boot/grub/grub.cfg
vi /tmp/kvmloop/boot/grub/grub.cfg

(vmlinuz lines... after ro) console=ttyS0,19200 earlyprint=serial,ttyS0,115200

guestunmount /tmp/kvmloop

and eventually do it properly once the guest has booted,

cd /etc/default/
cp -pi grub grub.dist
vi grub

GRUB_CMDLINE_LINUX='console=tty0 console=ttyS0,115200n8'
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

update-grub

refs.

netbsd

either launch the installation with graphics,

 virt-install \
    --name netbsd \
    --ram 128 \
    --disk path=/data/kvm/netbsd.qcow2,size=2,bus=virtio \
    --vcpus 1 \
    --os-type generic \
    --os-variant generic \
    --network bridge=xenbr0,model=virtio \
    --graphics vnc,port=5999 \
    --console pty,target_type=serial \
    --cdrom /data/ISO-IMAGES/NetBSD-7.1-amd64.iso

and define com0/115200 for boot blocks or use the boot-com.iso to start from serial console right away!

wget -O - http://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-7.1.1/amd64/installation/cdrom/boot-com.iso > /data/guests/ISO-IMAGES/boot-com.iso
wget -O - http://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-7.1.1/amd64/installation/cdrom/SHA512 > /data/guests/ISO-IMAGES/SHA512.netbsd.bootcom

virt-install \
    --virt-type kvm \
    --name netbsdserial \
    --ram 128 \
    --disk path=/data/kvm/netbsdserial.qcow2,size=2,bus=virtio \
    --vcpus 1 \
    --network bridge=xenbr0,model=virtio \
    --graphics none \
    --console pty,target_type=serial \
    --accelerate \
    --noautoconsole \
    --cdrom /data/ISO-IMAGES/boot-com.iso \
    --cpu host

during the installation, choose com0 and baud rate as for boot blocks, and you are good to continue with virsh console already.

Note. the only drawback with the boot-com.iso method is that you will have to provide another source than CDROM as for the installation sets (e.g. network through vioif0). The command,

/sbin/mount -rt cd9660 /dev/cd0a /mnt2

does not work during the installation when using boot-com.iso (83M instead of 374M for the full one).

refs.

ubuntu-vm-builder

draft

ubuntu-vm-builder kvm xenial --name guestbuilder --libvirt qemu:///system
#--components 'main,universe,restricted'
tail -F /tmp/tmpARZ01Y

refs.

uvtool

apt install uvtool
uvt-simplestreams-libvirt sync release=xenial arch=amd64
uvt-simplestreams-libvirt sync release=artful arch=amd64

it wants an RSA key pair, not ECDSA or what ever is much better, so let us give this crappy tool some slack,

ssh-keygen

and finally run a guest,

uvt-kvm create guestuvt
uvt-kvm list
virsh list

and access it,

uvt-kvm ssh guestuvt

refs.