[GUIDE] How to install KVM + WebvirtMgr

    • [GUIDE] How to install KVM + WebvirtMgr

      Currently I don't use KVM on OMV
      I recommend to USE PROXMOX or OTHER HYPERVISOR


      Why KVM not using virtualbox?
      1. more performance (benchmark is here)
        (but if you content with virtualbox performance, keep continue using)
      2. pci passthrough
        especially vga passthrough supported (what is vga passthrough? watch this video)
      What is WebvirtMgr
      see first what it is, screenshot is here

      How to install?
      webvirtmgr uses libvirt (cli interface for KVM, and other hypervisor such as XEN)
      and libvirt uses KVM (already included in linux kernel) and qemu

      for OMV 3.x


      1. apt-get install -t jessie-backports python-dev libxml2-dev libvirt-dev zlib1g-dev python-pip ebtables dnsmasq libvirt-bin git supervisor virtualenv pkg-config build-essential qemu
      2. usermod -a -G libvirt www-data
      3. usermod -a -G kvm www-data
      4. cd /var/www/
      5. git clone https://github.com/luxflow/webvirtmgr
      6. cd webvirtmgr
      7. virtualenv env
      8. source env/bin/activate
      9. pip install --upgrade pip
      10. pip install -r requirements.txt
      11. ./manage.py syncdb
      12. ./manage.py collectstatic
      13. deactivate
      14. chown -R www-data:www-data .
      15. echo -e '''[program:webvirtmgr]
      16. command=/var/www/webvirtmgr/env/bin/python /var/www/webvirtmgr/manage.py run_gunicorn -c /var/www/webvirtmgr/conf/gunicorn.conf.py
      17. directory=/var/www/webvirtmgr
      18. autostart=true
      19. autorestart=true
      20. stdout_logfile=/var/log/supervisor/webvirtmgr.log
      21. redirect_stderr=true
      22. user=www-data
      23. [program:webvirtmgr-console]
      24. command=/var/www/webvirtmgr/env/bin/python /var/www/webvirtmgr/console/webvirtmgr-console
      25. directory=/var/www/webvirtmgr
      26. autostart=true
      27. autorestart=true
      28. stdout_logfile=/var/log/supervisor/webvirtmgr-console.log
      29. redirect_stderr=true
      30. user=root''' > /etc/supervisor/conf.d/webvirtmgr.conf
      31. systemctl stop dnsmasq
      32. systemctl restart libvirtd
      33. systemctl enable supervisor
      34. systemctl start supervisor
      Display All

      (for OMV 2.x change
      `jessie-backports` to `wheezy-backports`
      `virtualenv` to `python-virtualenv`
      change `2.9.1` to `2.8.0` using `nano /var/www/webvirtmgr/requirements.txt`
      `systemctl stop dnsmasq` to `/etc/init.d/dnsmasq stop`
      `systemctl retstart libvirtd` to `/etc/init.d/libvirtd restart`
      `systemctl enable supervisor` to `update-rc.d supervisor defaults`
      `systemctl start supervisor` to `/etc/init.d/supervisor start`

      by default, webvirtmgr listen on
      so you cannot access without ssh tunneling (guide is here)

      another method is change listen address but it is not secure
      vim /var/www/webvirtmgr/conf/gunicorn.conf.py
      bind = ''
      bind = ''

      but be sure! http connection is not secure your data can be sniffed
      (I don't explain about this detail but this is easy, hacker in public wifi, evil goverment can see your packet)

      I'am planning to make a guide for how to setup secure https and reverse proxy but I'm not sure when
      when I make a guide I will link it here

      Known bug
      1. In storage menu
      creating ISO dosen't work
      workaround for this is create DIR with name 'iso' (case sensitive)

      2. In webconsole, key AltGr in German keylayout dosen't work

      Optional: VGA Passthrough (for advanced user)

      1. your motherboard and cpu support vt-d which is differnt from vt-x
        you should enabled vt-d in your bios setting ( search google your cpu model to know it is support vt-d)
      2. your kernel should be at least >=3.9
        so you shuld install backports kernel in OMV 2.x (in OMV 3.x, stock kernel is ok, but I recommend backports kernel too)
      3. you have at least 2 gpu in your system, one graphic card is for host (intergrated, external graphic all ok), the other are for guest (external graphic card only)
      4. An UEFI compatible GPU (Most modern gpus support this, Does my graphics card ROM support EFI?
      5. An UEFI compatible GUEST (ex: Windows 7 and up)

      you shuld update kernel boot parameter
      for intel cpu
      append kernel boot parameter permanently `kvm.ignore_msrs=1 intel_iommu=on` (click here)
      and reboot

      check lspci -Dnn
      result format is
      domain:bus:slot.function device_name [vender_id:device_id]
      find your graphic card with device_name

      edit /etc/rc.local
      below is example for gpu pass through
      change constant according to your graphic domain:bus:slot.function
      I enclose constant that you need to change with []
      after that execute /etc/rc.local

      for OMV 3.x ( for OMV 2.x change all vfio-pci to pci-stub except `modprobe vfio-pci`, change it to `modprobe pci_stub`)


      1. echo -e '''#!/bin/sh -e
      2. modprobe vfio-pci
      4. #echo [0000:01:00.0] > /sys/bus/pci/devices/[0000\:01\:00.0]/driver/unbind
      5. #echo [10de 128b] > /sys/bus/pci/drivers/vfio-pci/new_id
      6. #echo "vfio-pci" > /sys/bus/pci/devices/[0000:01:00.0]/driver_override
      7. #echo [0000:01:00.1] > /sys/bus/pci/devices/[0000\:01\:00.1]/driver/unbind
      8. #echo [10de 0e0f] > /sys/bus/pci/drivers/vfio-pci/new_id
      9. #echo "vfio-pci" > /sys/bus/pci/devices/[0000:01:00.1]/driver_override
      10. exit 0''' > /etc/rc.local
      Display All
      install OVMF bios for qemu
      for OMV 3.X apt-get install ovmf
      for OMV 2.X
      wget ftp.us.debian.org/debian/pool/…131112.2590861a-3_all.deb
      dpkg -i ovmf_0~20131112.2590861a-3_all.deb

      create VM in webvirtmgr, go settings -> XML in webvirtmgr
      append hostdev elements, and loader like below exmaple
      change bus slow function to your gpu

      XML Source Code

      1. <domain>
      2. ...
      3. <os>
      4. <loader type='pflash'>/usr/share/ovmf/OVMF.fd</loader>
      5. </os>
      6. ...
      7. <devices>
      8. ...
      9. <hostdev mode='subsystem' type='pci' managed='yes'>
      10. <driver name='vfio'/>
      11. <source>
      12. <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      13. </source>
      14. </hostdev>
      15. <hostdev mode='subsystem' type='pci' managed='yes'>
      16. <driver name='vfio'/>
      17. <source>
      18. <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      19. </source>
      20. </hostdev>
      21. ...
      22. </devices>
      23. </domain>
      Display All

      Optional: intel intergrated gpu (intel HD) passthrough (for advanced++ user)
      1. intel cpu >= sandybridge
      2. no need to additional external graphic card
      3. kernel >= 4.6 (if you are OMV 2.X manually compile kernel, if you are OMV 3.X install backports kernel)
      4. qemu >= v2.7.0-rc0 (there is no official package for this, manually packaging it)
      5. latest seabios (also you should manually compile)

      see manual (I belive advanced++ user, and I'm lazy :) )

      Question & Discussion

      you can ask question if something goes wrong
      OMV3 on Proxmox
      Intel E3-1245 v5 | 32GB ECC RAM | 4x3TB RAID10 HDD
      omv-zfs | omv-nginx | omv-letsencrypt | omv-openvpn
      Click link for more details

      The post was edited 37 times, last by luxflow ().