Allow custom disk paths

Normally vm-bhyve uses an image file in the guest directory, or
a ZVOL directory under the guest dataset for the disk images.
If you want anything else, you can now specify 'custom' as the device type.
This means you can store the guest image anywhere, or even use raw disks or
iSCSI targets (any disk device really).
disk0_dev="custom"
disk0_name="/full/path/to/disk"
This commit is contained in:
Matt Churchyard
2015-10-23 13:24:06 +01:00
parent 5ce20cccf5
commit 129356e481
3 changed files with 38 additions and 16 deletions

View File

@@ -426,12 +426,18 @@ __vm_bhyve_device_passthru(){
fi
}
# get the path to a disk image depending on type
# get the path to a disk image depending on type.
# the disk name in configuration is usually the name of the file
# or zvol, directly under the guest directory/dataset.
# if a user wants the disk image anywhere else, they can specify
# the following:
# diskX_type="custom"
# diskX_name="/full/path/to/disk/device/or/file"
#
# @param string _var variable to put disk path into
# @param string _name the name of the guest
# @param string _disk the name of the disk
# @param string _disk_dev=file|zvol|sparse-zvol type of device
# @param string _disk_dev=file|zvol|sparse-zvol|custom type of device
#
__vm_get_disk_path(){
local _var="$1"
@@ -446,6 +452,9 @@ __vm_get_disk_path(){
# need to look at this, don't really want to reference VM_ZFS* variables here
setvar "${_var}" "/dev/zvol/${VM_ZFS_DATASET}/${_name}/${_disk}"
;;
custom)
setvar "${_var}" "${_disk}"
;;
*)
setvar "${_var}" "${vm_dir}/${_name}/${_disk}"
;;

View File

@@ -179,9 +179,10 @@ __zfs_snapshot(){
# 'vm rollback'
# roll a guest back to a previous snapshot
# we output zfs here as it will fail if the snapshot is not the most recent
# we show zfs errors here as it will fail if the snapshot is not the most recent.
# zfs will output an error mentioning to use '-r', and listing the snapshots
# that will be deleted. makes sense to just support that option directly
# that will be deleted. makes sense to let user see this and just support
# that option directly
#
# @param flag (-r) force deletion of more recent snapshots
# @param string _name name of the guest

36
vm.8
View File

@@ -681,21 +681,33 @@ values, replacing
with the next available integer.
.It disk0_name
The filename for the first virtual disk. The first disk is created automatically when
provisioning a new virtual machine. If additional disks are added, the image will need
to be manually created, usually done using the
.Xr truncate 1
command.
.It disk0_dev
The type of device to use for the disk. If not specified, this will default to 'file',
and a sparse file, located in the guest directory, will be used as the disk image.
Other options include 'zvol' & 'sparse-zvol', which will used a ZVOL as the disk image.
.Pp
The primary disk will be created automatically when the virtual machine is created.
Any additional disks will need to be created manually, using either then
provisioning a new virtual machine. If additional disks are added manually, the image will need
to be created, usually done using the
.Xr truncate 1
or
.Xr zfs 8
command, depending on the type of disk device required.
commands. Alternatively, you can use the
.Pa vm add
command, which will create the disk image for you.
.Pp
Normally disk images or zvols are stored directly inside the guest. To use a disk
image that is stored anywhere else, you can specify the full path in this option,
and configure the device as
.Sy custom
.It disk0_dev
The type of device to use for the disk. If not specified, this will default to
.Sy file ,
and a sparse file, located in the guest directory, will be used as the disk image.
Other options include
.Sy zvol
&
.Sy sparse-zvol ,
which will used a ZVOL as the disk image, created directly under the guest dataset.
Alternatively you can specify
.Sy custom ,
in which case
.Pa diskX_name
should be the full path to the image file or device.
.It uuid
This option allows you to specify a fixed UUID for the guests SMBIOS. Normally, the
UUID is generated by