Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit ec0fb68

Browse files
dagrhstefanhaRH
authored andcommitted
virtiofs: Add cache size option
Add VirtioFSCacheSize aka virtio_fs_cache_size option to set the size (in GiB) of the DAX cache. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1 parent 2aa70ff commit ec0fb68

File tree

8 files changed

+21
-3
lines changed

8 files changed

+21
-3
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ DEFENTROPYSOURCE := /dev/urandom
158158
DEFDISABLEBLOCK := false
159159
DEFSHAREDFS := virtio-9p
160160
DEFVIRTIOFSDAEMON :=
161+
# Default DAX mapping cache size in MiB
162+
DEFVIRTIOFSCACHESIZE := 8192
161163
DEFENABLEIOTHREADS := false
162164
DEFENABLEMEMPREALLOC := false
163165
DEFENABLEHUGEPAGES := false
@@ -324,6 +326,7 @@ USER_VARS += DEFBLOCKSTORAGEDRIVER_FC
324326
USER_VARS += DEFBLOCKSTORAGEDRIVER_QEMU
325327
USER_VARS += DEFSHAREDFS
326328
USER_VARS += DEFVIRTIOFSDAEMON
329+
USER_VARS += DEFVIRTIOFSCACHESIZE
327330
USER_VARS += DEFENABLEIOTHREADS
328331
USER_VARS += DEFENABLEMEMPREALLOC
329332
USER_VARS += DEFENABLEHUGEPAGES
@@ -462,6 +465,7 @@ $(GENERATED_FILES): %: %.in $(MAKEFILE_LIST) VERSION .git-commit
462465
-e "s|@DEFBLOCKSTORAGEDRIVER_QEMU@|$(DEFBLOCKSTORAGEDRIVER_QEMU)|g" \
463466
-e "s|@DEFSHAREDFS@|$(DEFSHAREDFS)|g" \
464467
-e "s|@DEFVIRTIOFSDAEMON@|$(DEFVIRTIOFSDAEMON)|g" \
468+
-e "s|@DEFVIRTIOFSCACHESIZE@|$(DEFVIRTIOFSCACHESIZE)|g" \
465469
-e "s|@DEFENABLEIOTHREADS@|$(DEFENABLEIOTHREADS)|g" \
466470
-e "s|@DEFENABLEMEMPREALLOC@|$(DEFENABLEMEMPREALLOC)|g" \
467471
-e "s|@DEFENABLEHUGEPAGES@|$(DEFENABLEHUGEPAGES)|g" \

cli/config/configuration-qemu.toml.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ shared_fs = "@DEFSHAREDFS@"
105105
# Path to vhost-user-fs daemon.
106106
virtio_fs_daemon = "@DEFVIRTIOFSDAEMON@"
107107

108+
# Default size of DAX cache in GiB
109+
virtio_fs_cache_size = @DEFVIRTIOFSCACHESIZE@
110+
108111
# Block storage driver to be used for the hypervisor in case the container
109112
# rootfs is backed by a block device. This is virtio-scsi, virtio-blk
110113
# or nvdimm.

pkg/katautils/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ type hypervisor struct {
9494
EntropySource string `toml:"entropy_source"`
9595
SharedFS string `toml:"shared_fs"`
9696
VirtioFSDaemon string `toml:"virtio_fs_daemon"`
97+
VirtioFSCacheSize uint32 `toml:"virtio_fs_cache_size"`
9798
BlockDeviceCacheSet bool `toml:"block_device_cache_set"`
9899
BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"`
99100
BlockDeviceCacheNoflush bool `toml:"block_device_cache_noflush"`
@@ -578,6 +579,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
578579
DisableBlockDeviceUse: h.DisableBlockDeviceUse,
579580
SharedFS: sharedFS,
580581
VirtioFSDaemon: h.VirtioFSDaemon,
582+
VirtioFSCacheSize: h.VirtioFSCacheSize,
581583
MemPrealloc: h.MemPrealloc,
582584
HugePages: h.HugePages,
583585
Mlock: !h.Swap,

virtcontainers/device/config/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ type VhostUserDeviceAttrs struct {
187187
MacAddress string
188188

189189
// These are only meaningful for vhost user fs devices
190-
Tag string
190+
Tag string
191+
CacheSize uint32
191192
}
192193

193194
// GetHostPathFunc is function pointer used to mock GetHostPath in tests.

virtcontainers/documentation/api/1.0/api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ type HypervisorConfig struct {
146146
// VirtioFSDaemon is the virtio-fs vhost-user daemon path
147147
VirtioFSDaemon string
148148

149+
// VirtioFSCacheSize is the virtio-fs DAX cache size in MiB
150+
VirtioFSCacheSize uint32
151+
149152
// KernelParams are additional guest kernel parameters.
150153
KernelParams []Param
151154

virtcontainers/hypervisor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ type HypervisorConfig struct {
170170
// MemOffset specifies memory space for nvdimm device
171171
MemOffset uint32
172172

173+
// VirtioFSCacheSize is the DAX cache size in MiB
174+
VirtioFSCacheSize uint32
175+
173176
// KernelParams are additional guest kernel parameters.
174177
KernelParams []Param
175178

virtcontainers/qemu.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,8 +1376,9 @@ func (q *qemu) addDevice(devInfo interface{}, devType deviceType) error {
13761376
}
13771377

13781378
vhostDev := config.VhostUserDeviceAttrs{
1379-
Tag: v.MountTag,
1380-
Type: config.VhostUserFS,
1379+
Tag: v.MountTag,
1380+
Type: config.VhostUserFS,
1381+
CacheSize: q.config.VirtioFSCacheSize,
13811382
}
13821383
vhostDev.SocketPath = sockPath
13831384
vhostDev.DevID = id

virtcontainers/qemu_arch_base.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ func (q *qemuArchBase) appendVhostUserDevice(devices []govmmQemu.Device, attr co
530530
case config.VhostUserFS:
531531
qemuVhostUserDevice.TypeDevID = utils.MakeNameID("fs", attr.DevID, maxDevIDSize)
532532
qemuVhostUserDevice.Tag = attr.Tag
533+
qemuVhostUserDevice.CacheSize = attr.CacheSize
533534
}
534535

535536
qemuVhostUserDevice.VhostUserType = govmmQemu.DeviceDriver(attr.Type)

0 commit comments

Comments
 (0)