virt

# list all vms
virsh list --all

virt-install \
--name ubuntu1604 \
#--ram 2048 \
--disk path=./ubuntu1604.qcow2,size=8 \
--accelerate \
--vcpus 2, maxvcpus=3 \
--memory=1024, maxmemory=2048 \
--memballoon virtio \
#--vcpus 2 \
--os-type linux \
--os-variant generic \
--network bridge=virbr0 \
--graphics none \
--console pty, target_type=serial \
--location "http://archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64/" \
--extra-args "console=ttyS0, 115200n8 serial"

virt-install \
--name ubuntu1604 \
--disk path=./ubuntu1604.qcow2,size=8 \
--accelerate \
--vcpus 2,maxvcpus=3 \
--memory 256,maxmemory=1024 \
--memballoon virtio \
--os-type linux \
--os-variant generic \
--network bridge=virbr0,mac=00:11:22:33:44:55 \
--graphics none \
--console pty,target_type=serial \
--location "http://archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64/" \
--extra-args "console=ttyS0,115200n8 serial url=http://preseed.panticz.de/preseed/ubuntu-minimal.seed auto=true"

virt-install \
--name www.example.com \
--virt-type kvm \
--disk /var/lib/libvirt/images/www.example.com_1.qcow2,bus=sata \
--disk /var/lib/libvirt/images/www.example.com_2.qcow2,bus=sata \
--accelerate \
--vcpus 4 \
--ram 6144 \
--os-type linux \
--os-variant ubuntu14.04 \
--network bridge=br0 \
--graphics vnc \
--noautoconsole \
-c /var/lib/libvirt/images/iso/ubuntu-16.04.3-desktop-amd64.iso

# configuration files
/etc/libvirt/qemu/vm01.xml

# virsh
virsh reset vm1
virsh shutdown vm1
virsh destroy vm1

# restart all
for VM in $(virsh list --name); do
virsh shutdown ${VM}
done
sleep 120
for VM in $(virsh list --all --name); do
virsh start ${VM}
done

# virsh: reload xml config
virsh define /etc/libvirt/qemu/vm01.xml

# delete vm
virsh undefine vm1

# ubuntu cloud image
http://cloud-images.ubuntu.com/xenial/current/
kvm -net nic -net tap -hda ubuntu-16.04-server-cloudimg-amd64-disk1.img -hdb my-seed.img -m 2048 -vnc :1

virt-install \
--name ubuntu-16.04-server-cloudimg-amd64 \
--virt-type kvm \
--disk path=/var/lib/libvirt/images/ubuntu-16.04-server-cloudimg-amd64-disk1.img,format=qcow2,bus=virtio,cache=none \
--disk path=/var/lib/libvirt/images/my-seed.img,format=qcow2,bus=virtio,cache=none \
--accelerate \
--vcpus 2,maxvcpus=2 \
--ram 2048 \
--os-type linux \
--os-variant ubuntu16.04 \
--network bridge=br0,mac=00:0a:0b:0c:0d:11 \
--graphics vnc \
--noautoconsole \
--boot hd

# get vnc port used by vm
virsh vncdisplay vm01
virsh vncdisplay 1
virsh domdisplay vn01

# enable autostart for a vm
virsh autostart vm01

virsh list --all --name

Attach / detach harddisk
http://manpages.ubuntu.com/manpages/precise/man1/virt-install.1.html
https://www.cyberciti.biz/faq/howto-linux-delete-a-running-vm-guest-on-kvm/virsh-kvm-list-vms/
virsh attach-disk vm1.example.com /var/lib/libvirt/images/vm1.example.com_1.qcow2 vdb --cache none
virsh detach-disk vm1.example.com vdb

Stop all VMs
for VM in $(virsh list --name); do
virsh shutdown ${VM}
done