virtio-fs: add virtio_fs_extra_args for virtiofsd

Since virtio-fs is under active development, more
options will be added increasingly. To avaoid frequent
change on runtime side to handle option changes, use
one mingled arg to ease testing new option/feature of
virtiofsd.

See `virtiofsd -h` for more option details.

Fixes: #1999
Signed-off-by: Eric Ren <renzhen@linux.alibaba.com>
This commit is contained in:
Eric Ren 2019-08-18 11:28:18 +08:00
parent b3987e4786
commit 712e06ae84
6 changed files with 65 additions and 38 deletions

View File

@ -174,6 +174,7 @@ DEFVIRTIOFSDAEMON := $(VIRTIOFSDBINDIR)/virtiofsd-x86_64
# Default DAX mapping cache size in MiB # Default DAX mapping cache size in MiB
DEFVIRTIOFSCACHESIZE := 1024 DEFVIRTIOFSCACHESIZE := 1024
DEFVIRTIOFSCACHE := always DEFVIRTIOFSCACHE := always
DEFVIRTIOFSEXTRAARGS := []
DEFENABLEIOTHREADS := false DEFENABLEIOTHREADS := false
DEFENABLEMEMPREALLOC := false DEFENABLEMEMPREALLOC := false
DEFENABLEHUGEPAGES := false DEFENABLEHUGEPAGES := false
@ -414,6 +415,7 @@ USER_VARS += DEFSHAREDFS_NEMU
USER_VARS += DEFVIRTIOFSDAEMON USER_VARS += DEFVIRTIOFSDAEMON
USER_VARS += DEFVIRTIOFSCACHESIZE USER_VARS += DEFVIRTIOFSCACHESIZE
USER_VARS += DEFVIRTIOFSCACHE USER_VARS += DEFVIRTIOFSCACHE
USER_VARS += DEFVIRTIOFSEXTRAARGS
USER_VARS += DEFENABLEIOTHREADS USER_VARS += DEFENABLEIOTHREADS
USER_VARS += DEFENABLEMEMPREALLOC USER_VARS += DEFENABLEMEMPREALLOC
USER_VARS += DEFENABLEHUGEPAGES USER_VARS += DEFENABLEHUGEPAGES
@ -569,6 +571,7 @@ $(GENERATED_FILES): %: %.in $(MAKEFILE_LIST) VERSION .git-commit
-e "s|@DEFVIRTIOFSDAEMON@|$(DEFVIRTIOFSDAEMON)|g" \ -e "s|@DEFVIRTIOFSDAEMON@|$(DEFVIRTIOFSDAEMON)|g" \
-e "s|@DEFVIRTIOFSCACHESIZE@|$(DEFVIRTIOFSCACHESIZE)|g" \ -e "s|@DEFVIRTIOFSCACHESIZE@|$(DEFVIRTIOFSCACHESIZE)|g" \
-e "s|@DEFVIRTIOFSCACHE@|$(DEFVIRTIOFSCACHE)|g" \ -e "s|@DEFVIRTIOFSCACHE@|$(DEFVIRTIOFSCACHE)|g" \
-e "s|@DEFVIRTIOFSEXTRAARGS@|$(DEFVIRTIOFSEXTRAARGS)|g" \
-e "s|@DEFENABLEIOTHREADS@|$(DEFENABLEIOTHREADS)|g" \ -e "s|@DEFENABLEIOTHREADS@|$(DEFENABLEIOTHREADS)|g" \
-e "s|@DEFENABLEMEMPREALLOC@|$(DEFENABLEMEMPREALLOC)|g" \ -e "s|@DEFENABLEMEMPREALLOC@|$(DEFENABLEMEMPREALLOC)|g" \
-e "s|@DEFENABLEHUGEPAGES@|$(DEFENABLEHUGEPAGES)|g" \ -e "s|@DEFENABLEHUGEPAGES@|$(DEFENABLEHUGEPAGES)|g" \

View File

@ -123,6 +123,14 @@ virtio_fs_cache_size = @DEFVIRTIOFSCACHESIZE@
# Metadata, data, and pathname lookup are cached in guest and never expire. # Metadata, data, and pathname lookup are cached in guest and never expire.
virtio_fs_cache = "@DEFVIRTIOFSCACHE@" virtio_fs_cache = "@DEFVIRTIOFSCACHE@"
# Extra args for virtiofsd daemon
#
# Format example:
# ["-o", "arg1=xxx,arg2", "-o", "hello world", "--arg3=yyy"]
#
# see `virtiofsd -h` for possible options.
virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
# Block storage driver to be used for the hypervisor in case the container # 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 # rootfs is backed by a block device. This is virtio-scsi, virtio-blk
# or nvdimm. # or nvdimm.

View File

@ -108,6 +108,14 @@ virtio_fs_daemon = "@DEFVIRTIOFSDAEMON@"
# Default size of DAX cache in MiB # Default size of DAX cache in MiB
virtio_fs_cache_size = @DEFVIRTIOFSCACHESIZE@ virtio_fs_cache_size = @DEFVIRTIOFSCACHESIZE@
# Extra args for virtiofsd daemon
#
# Format example:
# ["-o", "arg1=xxx,arg2", "-o", "hello world", "--arg3=yyy"]
#
# see `virtiofsd -h` for possible options.
virtio_fs_extra_args = @DEFVIRTIOFSEXTRAARGS@
# Cache mode: # Cache mode:
# #
# - none # - none

View File

@ -83,44 +83,45 @@ type factory struct {
} }
type hypervisor struct { type hypervisor struct {
Path string `toml:"path"` Path string `toml:"path"`
JailerPath string `toml:"jailer_path"` JailerPath string `toml:"jailer_path"`
Kernel string `toml:"kernel"` Kernel string `toml:"kernel"`
CtlPath string `toml:"ctlpath"` CtlPath string `toml:"ctlpath"`
Initrd string `toml:"initrd"` Initrd string `toml:"initrd"`
Image string `toml:"image"` Image string `toml:"image"`
Firmware string `toml:"firmware"` Firmware string `toml:"firmware"`
MachineAccelerators string `toml:"machine_accelerators"` MachineAccelerators string `toml:"machine_accelerators"`
KernelParams string `toml:"kernel_params"` KernelParams string `toml:"kernel_params"`
MachineType string `toml:"machine_type"` MachineType string `toml:"machine_type"`
BlockDeviceDriver string `toml:"block_device_driver"` BlockDeviceDriver string `toml:"block_device_driver"`
EntropySource string `toml:"entropy_source"` EntropySource string `toml:"entropy_source"`
SharedFS string `toml:"shared_fs"` SharedFS string `toml:"shared_fs"`
VirtioFSDaemon string `toml:"virtio_fs_daemon"` VirtioFSDaemon string `toml:"virtio_fs_daemon"`
VirtioFSCache string `toml:"virtio_fs_cache"` VirtioFSCache string `toml:"virtio_fs_cache"`
VirtioFSCacheSize uint32 `toml:"virtio_fs_cache_size"` VirtioFSExtraArgs []string `toml:"virtio_fs_extra_args"`
BlockDeviceCacheSet bool `toml:"block_device_cache_set"` VirtioFSCacheSize uint32 `toml:"virtio_fs_cache_size"`
BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"` BlockDeviceCacheSet bool `toml:"block_device_cache_set"`
BlockDeviceCacheNoflush bool `toml:"block_device_cache_noflush"` BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"`
NumVCPUs int32 `toml:"default_vcpus"` BlockDeviceCacheNoflush bool `toml:"block_device_cache_noflush"`
DefaultMaxVCPUs uint32 `toml:"default_maxvcpus"` NumVCPUs int32 `toml:"default_vcpus"`
MemorySize uint32 `toml:"default_memory"` DefaultMaxVCPUs uint32 `toml:"default_maxvcpus"`
MemSlots uint32 `toml:"memory_slots"` MemorySize uint32 `toml:"default_memory"`
MemOffset uint32 `toml:"memory_offset"` MemSlots uint32 `toml:"memory_slots"`
DefaultBridges uint32 `toml:"default_bridges"` MemOffset uint32 `toml:"memory_offset"`
Msize9p uint32 `toml:"msize_9p"` DefaultBridges uint32 `toml:"default_bridges"`
DisableBlockDeviceUse bool `toml:"disable_block_device_use"` Msize9p uint32 `toml:"msize_9p"`
MemPrealloc bool `toml:"enable_mem_prealloc"` DisableBlockDeviceUse bool `toml:"disable_block_device_use"`
HugePages bool `toml:"enable_hugepages"` MemPrealloc bool `toml:"enable_mem_prealloc"`
FileBackedMemRootDir string `toml:"file_mem_backend"` HugePages bool `toml:"enable_hugepages"`
Swap bool `toml:"enable_swap"` FileBackedMemRootDir string `toml:"file_mem_backend"`
Debug bool `toml:"enable_debug"` Swap bool `toml:"enable_swap"`
DisableNestingChecks bool `toml:"disable_nesting_checks"` Debug bool `toml:"enable_debug"`
EnableIOThreads bool `toml:"enable_iothreads"` DisableNestingChecks bool `toml:"disable_nesting_checks"`
UseVSock bool `toml:"use_vsock"` EnableIOThreads bool `toml:"enable_iothreads"`
HotplugVFIOOnRootBus bool `toml:"hotplug_vfio_on_root_bus"` UseVSock bool `toml:"use_vsock"`
DisableVhostNet bool `toml:"disable_vhost_net"` HotplugVFIOOnRootBus bool `toml:"hotplug_vfio_on_root_bus"`
GuestHookPath string `toml:"guest_hook_path"` DisableVhostNet bool `toml:"disable_vhost_net"`
GuestHookPath string `toml:"guest_hook_path"`
} }
type proxy struct { type proxy struct {
@ -617,6 +618,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
VirtioFSDaemon: h.VirtioFSDaemon, VirtioFSDaemon: h.VirtioFSDaemon,
VirtioFSCacheSize: h.VirtioFSCacheSize, VirtioFSCacheSize: h.VirtioFSCacheSize,
VirtioFSCache: h.VirtioFSCache, VirtioFSCache: h.VirtioFSCache,
VirtioFSExtraArgs: h.VirtioFSExtraArgs,
MemPrealloc: h.MemPrealloc, MemPrealloc: h.MemPrealloc,
HugePages: h.HugePages, HugePages: h.HugePages,
FileBackedMemRootDir: h.FileBackedMemRootDir, FileBackedMemRootDir: h.FileBackedMemRootDir,

View File

@ -260,6 +260,9 @@ type HypervisorConfig struct {
// VirtioFSCache cache mode for fs version cache or "none" // VirtioFSCache cache mode for fs version cache or "none"
VirtioFSCache string VirtioFSCache string
// VirtioFSExtraArgs passes options to virtiofsd daemon
VirtioFSExtraArgs []string
// customAssets is a map of assets. // customAssets is a map of assets.
// Each value in that map takes precedence over the configured 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, // For example, if there is a value for the "kernel" key in this map,

View File

@ -613,6 +613,9 @@ func (q *qemu) virtiofsdArgs(sockPath string) []string {
args = append(args, "-f") args = append(args, "-f")
} }
if len(q.config.VirtioFSExtraArgs) != 0 {
args = append(args, q.config.VirtioFSExtraArgs...)
}
return args return args
} }