diff --git a/Makefile b/Makefile index 7025341431..bc7f1d9c13 100644 --- a/Makefile +++ b/Makefile @@ -157,6 +157,7 @@ DEFENTROPYSOURCE := /dev/urandom DEFDISABLEBLOCK := false DEFSHAREDFS := virtio-9p +DEFVIRTIOFSDAEMON := DEFENABLEIOTHREADS := false DEFENABLEMEMPREALLOC := false DEFENABLEHUGEPAGES := false @@ -322,6 +323,7 @@ USER_VARS += DEFDISABLEBLOCK USER_VARS += DEFBLOCKSTORAGEDRIVER_FC USER_VARS += DEFBLOCKSTORAGEDRIVER_QEMU USER_VARS += DEFSHAREDFS +USER_VARS += DEFVIRTIOFSDAEMON USER_VARS += DEFENABLEIOTHREADS USER_VARS += DEFENABLEMEMPREALLOC USER_VARS += DEFENABLEHUGEPAGES @@ -459,6 +461,7 @@ $(GENERATED_FILES): %: %.in $(MAKEFILE_LIST) VERSION .git-commit -e "s|@DEFBLOCKSTORAGEDRIVER_FC@|$(DEFBLOCKSTORAGEDRIVER_FC)|g" \ -e "s|@DEFBLOCKSTORAGEDRIVER_QEMU@|$(DEFBLOCKSTORAGEDRIVER_QEMU)|g" \ -e "s|@DEFSHAREDFS@|$(DEFSHAREDFS)|g" \ + -e "s|@DEFVIRTIOFSDAEMON@|$(DEFVIRTIOFSDAEMON)|g" \ -e "s|@DEFENABLEIOTHREADS@|$(DEFENABLEIOTHREADS)|g" \ -e "s|@DEFENABLEMEMPREALLOC@|$(DEFENABLEMEMPREALLOC)|g" \ -e "s|@DEFENABLEHUGEPAGES@|$(DEFENABLEHUGEPAGES)|g" \ diff --git a/cli/config/configuration-qemu.toml.in b/cli/config/configuration-qemu.toml.in index 43b910c2b5..5836fe9151 100644 --- a/cli/config/configuration-qemu.toml.in +++ b/cli/config/configuration-qemu.toml.in @@ -102,6 +102,9 @@ disable_block_device_use = @DEFDISABLEBLOCK@ # - virtio-fs shared_fs = "@DEFSHAREDFS@" +# Path to vhost-user-fs daemon. +virtio_fs_daemon = "@DEFVIRTIOFSDAEMON@" + # Block storage driver to be used for the hypervisor in case the container # rootfs is backed by a block device. This is virtio-scsi, virtio-blk # or nvdimm. diff --git a/pkg/katautils/config.go b/pkg/katautils/config.go index 31b58ef2a8..f786234715 100644 --- a/pkg/katautils/config.go +++ b/pkg/katautils/config.go @@ -93,6 +93,7 @@ type hypervisor struct { BlockDeviceDriver string `toml:"block_device_driver"` EntropySource string `toml:"entropy_source"` SharedFS string `toml:"shared_fs"` + VirtioFSDaemon string `toml:"virtio_fs_daemon"` BlockDeviceCacheSet bool `toml:"block_device_cache_set"` BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"` BlockDeviceCacheNoflush bool `toml:"block_device_cache_noflush"` @@ -543,6 +544,11 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { return vc.HypervisorConfig{}, err } + if sharedFS == config.VirtioFS && h.VirtioFSDaemon == "" { + return vc.HypervisorConfig{}, + errors.New("cannot enable virtio-fs without daemon path in configuration file") + } + useVSock := false if h.useVSock() { if utils.SupportsVsocks() { @@ -571,6 +577,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { DefaultBridges: h.defaultBridges(), DisableBlockDeviceUse: h.DisableBlockDeviceUse, SharedFS: sharedFS, + VirtioFSDaemon: h.VirtioFSDaemon, MemPrealloc: h.MemPrealloc, HugePages: h.HugePages, Mlock: !h.Swap, diff --git a/virtcontainers/documentation/api/1.0/api.md b/virtcontainers/documentation/api/1.0/api.md index 69b92ebd25..59f151fbc9 100644 --- a/virtcontainers/documentation/api/1.0/api.md +++ b/virtcontainers/documentation/api/1.0/api.md @@ -143,6 +143,9 @@ type HypervisorConfig struct { // - virtio-fs SharedFS string + // VirtioFSDaemon is the virtio-fs vhost-user daemon path + VirtioFSDaemon string + // KernelParams are additional guest kernel parameters. KernelParams []Param diff --git a/virtcontainers/hypervisor.go b/virtcontainers/hypervisor.go index 6945d62d60..fba567d1bf 100644 --- a/virtcontainers/hypervisor.go +++ b/virtcontainers/hypervisor.go @@ -220,6 +220,9 @@ type HypervisorConfig struct { // - virtio-fs SharedFS string + // VirtioFSDaemon is the virtio-fs vhost-user daemon path + VirtioFSDaemon string + // customAssets is a map of assets. // Each value in that map takes precedence over the configured assets. // For example, if there is a value for the "kernel" key in this map,