Virtualization

home

Prerequisites

Processor compatibility can be checked with the following command:


$ dmesg | egrep '(VMX/EPT|SVM/RVI)'

I got the following message


$ vmm0 at mainbus0: VMX/EPT

Before going further, enable and start the vmd(8) service.


$ doas rcctl enable vmd
$ doas rcctl start vmd

Starting a VM

Create /var/vm directory and place install78.iso file there.


$ doas mkdir /var/vm
$ cd /var/vm/ 
$ doas cp /home/masayoshi/Downloads/install78.iso .
$ doas vmctl create -s 50G disk.qcow2
$ doas vmctl start -m 1G -L -i 1 -r install78.iso -d disk.qcow2 OpenBSD

I got the following message


vmctl: started vm 1 successfully, tty /dev/ttyp1

Check vm's status:


$ vmctl show

I got the following message


ID   PID VCPUS  MAXMEM  CURMEM     TTY        OWNER    STATE NAME
1 91205     1    1.0G    179M   ttyp1         root  running OpenBSD

To view the console of the newly created VM, attach to its serial console:


$ doas vmctl console OpenBSD

I got the following message


Connected to /dev/ttyp1 (speed 115200)

Press Enter to begin the installation.

After instalation, type the following command:


$ doas cp /etc/examples/vm.conf /etc/   

Modify /etc/vm.conf if you need to start Virtual Machine:


vm "OpenBSD" {
        memory 1G
        enable
        disk "/var/vm/disk.qcow2"
        local interface
}

Networking

Host


tap0: flags=8843 mtu 1500
	lladdr fe:e1:ba:d1:b3:8e
	description: vm1-if0-OpenBSD
	index 8 priority 0 llprio 3
	groups: tap
	status: active
	inet 100.64.1.2 netmask 0xfffffffe

Virtual Machine


vio0: flags=808b43 mtu 1500
	lladdr fe:e1:bb:d1:30:1a
	index 1 priority 0 llprio 3
	groups: egress
	media: Ethernet autoselect
	status: active
	inet 100.64.1.3 netmask 0xfffffffe

Move the IP configuration from rge0 to vport0:


# mv /etc/hostname.rge0 /etc/hostname.vport0
# echo up >> /etc/hostname.vport0
# echo up >> /etc/hostname.rge0
# sh /etc/netstart rge0 vport0

Create the veb0 interface and add the rge0 and vport0 interfaces:


# cat < /etc/hostname.veb0
add rge0
add vport0
up
END
# sh /etc/netstart veb0

Modify /etc/vmf.conf


switch "my_switch" {
        interface veb0
}
vm "OpenBSD" {
        memory 1G
        enable
        disk "/var/vm/disk.qcow2"
        interface { switch "my_switch"}
}


Create/etc/mygate


192.168.1.1

OpenBSD