Nethence Newdoc Olddoc Lab Your IP BBDock  

Setting up libvirt/kvm on Ubuntu

hypervisor

req,

egrep '(vmx|svm)' /proc/cpuinfo
egrep ' lm ' /proc/cpuinfo
uname -m

install,

apt install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
apt install virtinst libosinfo-bin libguestfs-tools
#apt install virt-manager

check,

#cat /sys/hypervisor/properties/capabilities
kvm-ok
ls -la /var/run/libvirt/libvirt-sock
ls -l /dev/kvm
#chown root:kvm /dev/kvm
lsmod | grep kvm
#rmmod kvm
#modprobe -a kvm

ps auxw | grep libvirtd$
virsh list --all
#virt-manager

double-check,

systemctl status libvirtd
systemctl status libvirt-bin.service
systemctl status libvirt-guests
virsh nodeinfo
virt-host-validate
libguestfs-test-tool

refs.

storage

assuming /data/ is an NFS mount point already, enable it as KVM storage,

virsh pool-dumpxml default > pool.xml
virsh pool-destroy default
vi pool.xml

    <path>/data/kvm</path>

mkdir /data/kvm
virsh pool-create pool.xml
virsh pool-list

ref. http://ask.xmodulo.com/change-default-location-libvirt-vm-images.html

networking

Create and manage the bridge without libvirt… See [networking]/xen/networking.html).

ref. https://wiki.debian.org/LXC/LibVirtDefaultNetwork

live-migration

to be able to talk to the other hypervisors and enable the farm, you will have to share a few SSH keys.

to migrate a guest, make sure the machine type is compatible on both ends,

kvm -M ?

and fix it (DO NOT USE the pc alias that is pointing to different latest versions depending on the hypervisors – choose the latest available on all hypervisors e.g. pc-i440fx-2.5) if required,

virsh shutdown GUESTNAME
virsh edit GUESTNAME

  <os>
    <type arch='x86_64' machine='pc-i440fx-2.5'>hvm</type>
    <boot dev='hd'/>
  </os>

the available virtual network devices can be displayed as such,

qemu-system-x86_64 -net nic,model=? /dev/null

e.g.,

qemu: Supported NIC models: ne2k_pci,i82551,i82557b,i82559er,rtl8139,e1000,pcnet,virtio

replacing rtl8139 with virtio,

    <interface type='bridge'>
      <mac address='xx:xx:xx:xx:xx:xx'/>
      <source bridge='xenbr0'/>
      <model type='virtio'/>
            <driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5' rx_queue_size='256' tx_queue_size='256'>
              <host csum='off' gso='off' tso4='off' tso6='off' ecn='off' ufo='off' mrg_rxbuf='off'/>
              <guest csum='off' tso4='off' tso6='off' ecn='off' ufo='off'/>
            </driver>
    </interface>

you may also have to disable caching on the virtual drive,

  <driver name='qemu' type='qcow2' cache='none'/>

refs https://access.redhat.com/solutions/158363

you will then be able to live-migrate,

virsh -c qemu+ssh://ANOTHER-KVM-SRV/system list
virsh migrate GUESTNAME qemu+ssh://ANOTHER-KVM-SRV/system

refs.

TRASH

prepare a new bridge config for libvirt and get rid of the crapy defaults,

virsh net-dumpxml default > net-dumpxml.xml
virsh net-destroy default
#virsh net-undefine default
service libvirtd restart

cp net-dumpxml.xml br0.xml
vi br0.xml

<network>
  <name>br0</name>
  <uuid>SOME-UUID-HERE</uuid>
  <bridge name='br0' stp='off' delay='0'/>
</network>

virsh net-create br0.xml

Home | GitHub | Docker Hub | Donate | Contact