Table of Contents

Instalace KVM

TODO: udelat tutorial :)

aptitude -y install qemu-kvm libvirt-bin virtinst bridge-utils 

Vytvoreni guesta

Debian 8

  1. Install gues:
    virt-install -n vps1 --ram=2048 --vcpus=2 --location='http://ftp.cz.debian.org/debian/dists/jessie/main/installer-amd64/' --disk path=/dev/shared_vg/vps1  --network bridge=br0 --os-type linux --console pty,target_type=serial --graphics none --os-variant generic --extra-args 'console=ttyS0,115200n8 serial'
  2. put following line into grubu in line starting with linux
    console=tty0 console=ttyS0,115200
  3. put “console=tty0 console=ttyS0,115200” into /etc/default/grub in GRUB_CMDLINE_LINUX_DEFAULT
    GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200"
  4. update grub (this one i always forget and wondering why it doesn't work :))
    update-grub

Vzdaleny pristup

Pres certifikaty

https://libvirt.org/remote.html

Pres libvirt + ssh

import libvirt
conn = libvirt.open("qemu+ssh://root@10.0.0.120")
 
# vypis bezicich vps (interni ID)
conn.listDomainsID()
 
# nalezeni vps podle ID (pouze bezici)
vps = conn.lookupByID(1)
 
# nalezeni vps podle jmena (bere i masiny, ktere jsou nebezici, ale nadefinovane)
vps1 = conn.lookupByName("vps1")
 
# spusteni
vps1.start()
 
# pause
vps1.suspend()
 
# unpause
vps1.resume()
 
# shut down
vps1.shutdown()
 
# force shutdown
vps1.destroy()
 
# close connection
conn.close()

HOT migration

Correct shutdown

Keywords: Libvirt Can't shutdown or reboot virtual guest.\ I can't reboot or shutdown the guest vm from the host mac

modprobe virtio_console
apt install qemu-guest-agent
service qemu-ga restart
apt install acpid

Test if the agent is running

    virsh qemu-agent-command jakub-sevcik '{"execute":"guest-info"}'