KVM(7) Standards, Environments, and Macros KVM(7)

kvm
zone brand for running a virtual machine instance under the KVM hypervisor

A kvm branded zone uses the brands(7) framework to provide an environment for running a virtual machine under the KVM hypervisor.

kvm zones are configured mostly via custom attributes in the zone configuration.

Supported attributes are:

bootdisk path[,serial=serial]

Specifies a ZFS volume dataset name which will be attached to the guest as the boot disk. Additional disks can be specified using the disk attribute, see below.

If the optional serial number is not provided, one will be automatically generated from the disk index. The ZFS volume must also be mapped into the zone using a device block as shown in the example below.

A suitable ZFS volume can be created using the ‘zfs create -V’ command, for example:

zfs create -V 30G rpool/bootdisk2
cdrom[N] path

Specifies the path to one or more CD/DVD image (.iso) files that will be inserted into virtual CD/DVD drive(s) in the guest. To specify multiple image files, create multiple attributes with different values of N, starting with 0. If only a single CD image is required, N can be omitted.

Each image file must also be mapped into the zone using an fs block, as shown in the example below.

console options

This parameter configures where the guest's console device is presented. The default value is pipe,id=console0,path=/dev/zconsole which means that the guest's console can be accessed via:

zlogin -C <zone>
disk[N] dataset[,serial=serial]

Specifies one or more ZFS volume dataset names which will be attached to the guest as disks. To attach multiple disks, create multiple attributes with different values of N. In that case, the disk will be presented on target N. If only a single disk is required, N can be omitted. The disks specified via the disk attribute are in addition to the system boot disk, which is specified using bootdisk.

If the optional serial number is not provided, one will be automatically generated from the disk index. Each ZFS volume must also be mapped into the zone using a device block as shown in the example below.

diskif type

Specifies the type of interface to which the disks will be attached. Available options are:

  • ahci
  • virtio (default)
netif type

Specifies the type of network interface that will be used for the interfaces presented to the guest. Available options are:

  • virtio-net-pci (default)
  • e1000
ram size[KMGT]

Specify the guest's physical memory size. The size argument may be suffixed with one of K, M, G or T to indicate a multiple of kibibytes, mebibytes, gibibytes or tebibytes. If no suffix is given, the value is assumed to be in mebibytes.

The default value, if this attribute is not specified, is 1G.

type type

Specifies the type of the virtual machine. This needs to be set for some guest operating systems so that things are set up as they expect. For most guests, this can be left unset. Supported values are:

  • generic (default)
  • openbsd
  • windows
vcpus number

Specify the number of guest virtual CPUs. The default value is 1.

vnc on|off|options

This parameter controls whether a virtual frambuffer is attached to the guest and made available via VNC. Available options are:

on
An alias for unix:/tmp/vm.vnc which creates the VNC socket within /tmp inside the zone.
off
Disable the framebuffer. This is the same as omitting the vnc attribute.
unix:path
Sets up a VNC server on a UNIX socket at the specified path. Note that this path is relative to the zone root.
extra options

Any extra options to be passed directly to the kvm hypervisor.

An example kvm zone is shown below:

create -t kvm
set zonepath=/zones/kvm
add net
    set allowed-address=10.0.0.112/24
    set physical=vm0
end
add device
    set match=/dev/zvol/rdsk/rpool/kvm0
end
add attr
    set name=ram
    set type=string
    set value=2G
end
add attr
    set name=vcpus
    set type=string
    set value=8
end
add attr
    set name=bootdisk
    set type=string
    set value=rpool/kvm0
end
add fs
    set dir=/rpool/iso/debian-9.4.0-amd64-netinst.iso
    set special=/rpool/iso/debian-9.4.0-amd64-netinst.iso
    set type=lofs
    add options ro
    add options nodevices
end
add attr
    set name=cdrom
    set type=string
    set value=/rpool/iso/debian-9.4.0-amd64-netinst.iso
end

mdb(1), proc(1), brands(7), privileges(7), resource_controls(7), zones(7), dtrace(8), zfs(8), zoneadm(8), zonecfg(8)
February 19, 2021 OmniOS