diff --git a/Makefile b/Makefile index bc7f1d9c13..98aefddde4 100644 --- a/Makefile +++ b/Makefile @@ -158,6 +158,8 @@ DEFENTROPYSOURCE := /dev/urandom DEFDISABLEBLOCK := false DEFSHAREDFS := virtio-9p DEFVIRTIOFSDAEMON := +# Default DAX mapping cache size in MiB +DEFVIRTIOFSCACHESIZE := 8192 DEFENABLEIOTHREADS := false DEFENABLEMEMPREALLOC := false DEFENABLEHUGEPAGES := false @@ -324,6 +326,7 @@ USER_VARS += DEFBLOCKSTORAGEDRIVER_FC USER_VARS += DEFBLOCKSTORAGEDRIVER_QEMU USER_VARS += DEFSHAREDFS USER_VARS += DEFVIRTIOFSDAEMON +USER_VARS += DEFVIRTIOFSCACHESIZE USER_VARS += DEFENABLEIOTHREADS USER_VARS += DEFENABLEMEMPREALLOC USER_VARS += DEFENABLEHUGEPAGES @@ -462,6 +465,7 @@ $(GENERATED_FILES): %: %.in $(MAKEFILE_LIST) VERSION .git-commit -e "s|@DEFBLOCKSTORAGEDRIVER_QEMU@|$(DEFBLOCKSTORAGEDRIVER_QEMU)|g" \ -e "s|@DEFSHAREDFS@|$(DEFSHAREDFS)|g" \ -e "s|@DEFVIRTIOFSDAEMON@|$(DEFVIRTIOFSDAEMON)|g" \ + -e "s|@DEFVIRTIOFSCACHESIZE@|$(DEFVIRTIOFSCACHESIZE)|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 5836fe9151..574e47f288 100644 --- a/cli/config/configuration-qemu.toml.in +++ b/cli/config/configuration-qemu.toml.in @@ -105,6 +105,9 @@ shared_fs = "@DEFSHAREDFS@" # Path to vhost-user-fs daemon. virtio_fs_daemon = "@DEFVIRTIOFSDAEMON@" +# Default size of DAX cache in MiB +virtio_fs_cache_size = @DEFVIRTIOFSCACHESIZE@ + # 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 f786234715..7454a841ea 100644 --- a/pkg/katautils/config.go +++ b/pkg/katautils/config.go @@ -94,6 +94,7 @@ type hypervisor struct { EntropySource string `toml:"entropy_source"` SharedFS string `toml:"shared_fs"` VirtioFSDaemon string `toml:"virtio_fs_daemon"` + VirtioFSCacheSize uint32 `toml:"virtio_fs_cache_size"` BlockDeviceCacheSet bool `toml:"block_device_cache_set"` BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"` BlockDeviceCacheNoflush bool `toml:"block_device_cache_noflush"` @@ -578,6 +579,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { DisableBlockDeviceUse: h.DisableBlockDeviceUse, SharedFS: sharedFS, VirtioFSDaemon: h.VirtioFSDaemon, + VirtioFSCacheSize: h.VirtioFSCacheSize, MemPrealloc: h.MemPrealloc, HugePages: h.HugePages, Mlock: !h.Swap, diff --git a/virtcontainers/device/config/config.go b/virtcontainers/device/config/config.go index 2f31fd3bc4..2a1cd5cabf 100644 --- a/virtcontainers/device/config/config.go +++ b/virtcontainers/device/config/config.go @@ -187,7 +187,8 @@ type VhostUserDeviceAttrs struct { MacAddress string // These are only meaningful for vhost user fs devices - Tag string + Tag string + CacheSize uint32 } // GetHostPathFunc is function pointer used to mock GetHostPath in tests. diff --git a/virtcontainers/documentation/api/1.0/api.md b/virtcontainers/documentation/api/1.0/api.md index 59f151fbc9..e5d7331c3a 100644 --- a/virtcontainers/documentation/api/1.0/api.md +++ b/virtcontainers/documentation/api/1.0/api.md @@ -146,6 +146,9 @@ type HypervisorConfig struct { // VirtioFSDaemon is the virtio-fs vhost-user daemon path VirtioFSDaemon string + // VirtioFSCacheSize is the virtio-fs DAX cache size in MiB + VirtioFSCacheSize uint32 + // KernelParams are additional guest kernel parameters. KernelParams []Param diff --git a/virtcontainers/hypervisor.go b/virtcontainers/hypervisor.go index fba567d1bf..d2c12be09a 100644 --- a/virtcontainers/hypervisor.go +++ b/virtcontainers/hypervisor.go @@ -170,6 +170,9 @@ type HypervisorConfig struct { // MemOffset specifies memory space for nvdimm device MemOffset uint32 + // VirtioFSCacheSize is the DAX cache size in MiB + VirtioFSCacheSize uint32 + // KernelParams are additional guest kernel parameters. KernelParams []Param diff --git a/virtcontainers/qemu.go b/virtcontainers/qemu.go index 8820946a0b..0e3ec4bcae 100644 --- a/virtcontainers/qemu.go +++ b/virtcontainers/qemu.go @@ -1376,8 +1376,9 @@ func (q *qemu) addDevice(devInfo interface{}, devType deviceType) error { } vhostDev := config.VhostUserDeviceAttrs{ - Tag: v.MountTag, - Type: config.VhostUserFS, + Tag: v.MountTag, + Type: config.VhostUserFS, + CacheSize: q.config.VirtioFSCacheSize, } vhostDev.SocketPath = sockPath vhostDev.DevID = id diff --git a/virtcontainers/qemu_arch_base.go b/virtcontainers/qemu_arch_base.go index 5bd154dcce..2c0d540e2a 100644 --- a/virtcontainers/qemu_arch_base.go +++ b/virtcontainers/qemu_arch_base.go @@ -530,6 +530,7 @@ func (q *qemuArchBase) appendVhostUserDevice(devices []govmmQemu.Device, attr co case config.VhostUserFS: qemuVhostUserDevice.TypeDevID = utils.MakeNameID("fs", attr.DevID, maxDevIDSize) qemuVhostUserDevice.Tag = attr.Tag + qemuVhostUserDevice.CacheSize = attr.CacheSize } qemuVhostUserDevice.VhostUserType = govmmQemu.DeviceDriver(attr.Type)