DilOS platformHow to run QEMU KVM virtual machine on Dilos

How to run QEMU KVM virtual machine on Dilos

QEMU is a generic and open source machine emulator and virtualizer. When it used as a machine emulator, QEMU can run OSes and programs made for one machine (e.g. an ARM board) on a different machine (e.g. your own PC). By using dynamic translation, it achieves very good performance.

When used as a virtualizer, QEMU achieves near native performance by executing the guest code directly on the host CPU. QEMU supports virtualization when executing under the Xen hypervisor or using the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86, server and embedded PowerPC, 64-bit POWER, S390, 32-bit and 64-bit ARM, and MIPS guests.

In this article we will run virtual machine with dilos using QEMU KVM hosted hypervizor  on Dilos host. This is just an example, any guest os can be use instead (CentOS, Debian etc...). Will use noVNC console for accessing guest OS during the installation. 


Configure noVNC e.g. as described on DilOS HowTo WiKi page: How To use noVNC on DilOS

If hosted DilOS OS installed on bare-metal hardware, ensure that CPU Virtualization instructions (VTx/VTd) are enables in BIOS: 

If virtualization platform is used for hosted DilOS VM (e.g. VMware ESXi), ensure that nested virtualization option is ON at properties of this VM. 


1. Install KVM and reboot the hosted DilOS
root@dilos:~# apt update && apt install kvm && reboot
4. Create dataset on hosted DilOS for netsted OS
root@dilos:~# zfs create -V 16Gb rpool/kvm0
5. Prepare networking
root@dilos:~# dladm create-vnic -I vmxnet3s1 vnic1			#Directly connected interface
root@dilos:~# dladm create-vnic -v 300 -I vmxnet3s2 vnic2 	#Interface in VLAN300 on TRUNK link
root@dilos:~# vndadm create vnic1 							#create vSwitch on vnic1 (mgmt link)
root@dilos:~# vndadm create vnic2							#create vSwitch on vnic2 (data link)

We are ready to run nested QEMU/KVM virtual machine

6. Run virtual machine and start installation from boot CD with DilOS image
root@dilos:~# /usr/bin/kvm -smp 2 -m 2048 \
        -drive file=/dev/zvol/rdsk/rpool/kvm1,if=virtio,index=0,media=disk,boot=on,id=disk0  \
        -bios /smartdc/share/qemu/extboot.bin \
        -vnc,password -monitor stdio \
        -device virtio-net-pci,mac=02:08:20:80:8e:d3,tx=timer,x-txtimer=200000,x-txburst=128,vlan=1 \
        -net vnic,vlan=1,name=net1,ifname=vnic1 \
        -device virtio-net-pci,mac=02:08:20:78:6f:55,tx=timer,x-txtimer=200000,x-txburst=128,vlan=2 \
        -net vnic,vlan=2,name=net2,ifname=vnic2 \
        -boot order=cd \
        -drive file=/root/dilos-,media=cdrom,if=ide,index=1 -boot order=cd


-enable-kvm - instruct to use KVM hypervisor module

-smp 2 - swich on the multiprocessor mode with 2 vCPU

-m 2048 - amount of memory to be used with this virtual machine

-boot order=dc - sequence of using boot devices during boot process: here - try hdd fisrtly, then cd-rom.

-drive file=/dev/zvol/rdsk/rpool/kvm1,if=virtio,index=0,media=disk,boot=on,id=disk0  - parameters for the hdd device where quest OS will be installed

-drive file=/root/dilos-,media=cdrom,if=ide,index=1  - description of the cd-rom device and reference to mounted .iso image

-vnc,password -monitor stdio - description of VNC console for accessing this virtual machine: listen on all network interfaces, port 6080.

-device virtio-net-pci,mac=02:08:20:80:8e:d3,tx=timer,x-txtimer=200000,x-txburst=128,vlan=1 - instruct KVM to use virtio paravirtual driver for network card, set up port parameters and configure MAC address for ethernet port for the first interface

-net vnic,vlan=1,name=net1,ifname=vnic1 - indicates VLAN to be provided to this VM and though which interface

(assume similar description of networking for vnic2)

Mode virtio disks with serial:
    -drive file=/dev/zvol/rdsk/ramd/d1,if=none,id=disk1,index=1,serial=1464810172 \
    -device virtio-blk-pci,drive=disk1 \
    -drive file=/dev/zvol/rdsk/ramd/d2,if=none,id=disk2,index=2,serial=1464810173 \
    -device virtio-blk-pci,drive=disk2 \
    -drive file=/dev/zvol/rdsk/ramd/d3,if=none,id=disk3,index=3,serial=1464810175 \
    -device virtio-blk-pci,drive=disk3 \
7. When run this command you will see output like this:
qemu-system-x86_64: -net vnic,vlan=1,name=net1,ifname=vnic1: vnic dhcp disabled

qemu-system-x86_64: -net vnic,vlan=2,name=net2,ifname=vnic2: vnic dhcp disabled

QEMU 0.14.1 monitor - type 'help' for more information
(qemu) Start bios (version
Ram Size=0x80000000 (0x0000000000000000 high)
CPU Mhz=2607
PCI: pci_bios_init_bus_rec bus = 0x0
PIIX3/PIIX4 init: elcr=00 0c
PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237
PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000
PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010
region 4: 0x0000c000
PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113
PCI: bus=0 devfn=0x10: vendor_id=0x1013 device_id=0x00b8
region 0: 0xf0000000
region 1: 0xf2000000
region 6: 0xf2010000
PCI: bus=0 devfn=0x18: vendor_id=0x1af4 device_id=0x1000
region 0: 0x0000c020
region 1: 0xf2020000
region 6: 0xf2040000
PCI: bus=0 devfn=0x20: vendor_id=0x1af4 device_id=0x1000
region 0: 0x0000c040
region 1: 0xf2060000
region 6: 0xf2080000
PCI: bus=0 devfn=0x28: vendor_id=0x1af4 device_id=0x1001
region 0: 0x0000c080
region 1: 0xf20a0000
Found 2 cpu(s) max supported 2 cpu(s)
MP table addr=0x000fdbe0 MPC table addr=0x000fdbf0 size=252
SMBIOS ptr=0x000fdbc0 table=0x7ffffec0
ACPI tables: RSDP=0x000fdb90 RSDT=0x7fffdbd0
Scan for VGA option rom
Running option rom at c000:0003
VGABios $Id$
Turning on vga text mode console
SeaBIOS (version

Found 1 lpt ports
Found 1 serial ports
ATA controller 0 at 1f0/3f4/0 (irq 14 dev 9)
ATA controller 1 at 170/374/0 (irq 15 dev 9)
found virtio-blk at 0:5
ebda moved from 9fc00 to 9dc00
drive 0x000fdb40: PCHS=16383/16/63 translation=lba LCHS=1024/255/63 s=33554432
PS2 keyboard initialized
All threads complete.
Scan for option roms
Running option rom at c900:0003
pmm call arg1=1
pmm call arg1=0
pmm call arg1=1
pmm call arg1=0
Running option rom at ca00:0003
pmm call arg1=1
pmm call arg1=1
Running option rom at cb00:0003
Returned 53248 bytes of ZoneHigh
e820 map has 7 items:
  0: 0000000000000000 - 000000000009dc00 = 1
  1: 000000000009dc00 - 00000000000a0000 = 2
  2: 00000000000f0000 - 0000000000100000 = 2
  3: 0000000000100000 - 000000007fffd000 = 1
  4: 000000007fffd000 - 0000000080000000 = 2
  5: 00000000feffc000 - 00000000ff000000 = 2
  6: 00000000fffc0000 - 0000000100000000 = 2
enter handle_19:
Booting from Hard Disk...
Boot failed: not a bootable disk

enter handle_18:
Booting from DVD/CD...
264MB medium detected
Booting from 0000:7c00

Virtual machine is running. To access QEMU monitor press enter in console and set up the VNC password

8. Set up the VNC password
(qemu) change vnc password
Password: **

Open your favourite browser and connect to VM's console through noVNC service by URL https://YOUR_HOST:6080/vnc.html:

You have configured and run virtual machine using qemu kvm! Proceed with further OS installation procedure.

When you at step of configuration the network interface, choose the Manual setup of  IP addresses and enter appropriate values 

Note that we use paravirtualized driver (vioif0/1) which have been configured inside virtual machine.

Repeat configuration procedure for second network interface (data link) and proceed with installation . 

When installation is completed and VM can boot from virtual HDD, we can put cd-rom device out of command line to simplify the command . 

Command to run VM after it is installed
root@dilos:~# /usr/bin/kvm -smp 2 -m 2048 \
        -drive file=/dev/zvol/rdsk/rpool/kvm1,if=virtio,index=0,media=disk,boot=on,id=disk0  \
        -bios /smartdc/share/qemu/extboot.bin \
        -vnc,password -monitor stdio \
        -device virtio-net-pci,mac=02:08:20:80:8e:d3,tx=timer,x-txtimer=200000,x-txburst=128,vlan=1 \
        -net vnic,vlan=1,name=net1,ifname=vnic1 \
        -device virtio-net-pci,mac=02:08:20:78:6f:55,tx=timer,x-txtimer=200000,x-txburst=128,vlan=2 \
        -net vnic,vlan=2,name=net2,ifname=vnic2
Use QEMU monitor to control and manage the environment. See an examples below:
(qemu) info network
VLAN 1 devices:
  net1: ifname=vnic1
  virtio-net-pci.0: model=virtio-net-pci,macaddr=02:08:20:80:8e:d3
VLAN 2 devices:
  net2: ifname=vnic2
  virtio-net-pci.1: model=virtio-net-pci,macaddr=02:08:20:78:6f:55
Devices not on any VLAN:
(qemu) system_powerdown