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

Commit

Permalink
virtiofs: add virtio_fs_shared_versions option
Browse files Browse the repository at this point in the history
Shared version metadata is managed by the 'ireg' daemon for virtio-fs.
Add an option to enable it.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanhaRH committed Feb 11, 2019
1 parent 3c2e2f4 commit e1546ce
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ DEFVIRTIOFSDAEMON :=
# Default DAX mapping cache size in GiB
DEFVIRTIOFSCACHESIZE := 2
DEFVIRTIOFSCACHE := none
DEFVIRTIOFSSHAREDVERSIONS := false
DEFENABLEIOTHREADS := false
DEFENABLEMEMPREALLOC := false
DEFENABLEHUGEPAGES := false
Expand Down Expand Up @@ -325,6 +326,7 @@ USER_VARS += DEFVIRTIOFS
USER_VARS += DEFVIRTIOFSDAEMON
USER_VARS += DEFVIRTIOFSCACHESIZE
USER_VARS += DEFVIRTIOFSCACHE
USER_VARS += DEFVIRTIOFSSHAREDVERSIONS
USER_VARS += DEFENABLEIOTHREADS
USER_VARS += DEFENABLEMEMPREALLOC
USER_VARS += DEFENABLEHUGEPAGES
Expand Down Expand Up @@ -518,6 +520,7 @@ $(GENERATED_FILES): %: %.in Makefile VERSION
-e "s|@DEFVIRTIOFSDAEMON@|$(DEFVIRTIOFSDAEMON)|g" \
-e "s|@DEFVIRTIOFSCACHESIZE@|$(DEFVIRTIOFSCACHESIZE)|g" \
-e "s|@DEFVIRTIOFSCACHE@|$(DEFVIRTIOFSCACHE)|g" \
-e "s|@DEFVIRTIOFSSHAREDVERSIONS@|$(DEFVIRTIOFSSHAREDVERSIONS)|g" \
-e "s|@DEFENABLEIOTHREADS@|$(DEFENABLEIOTHREADS)|g" \
-e "s|@DEFENABLEMEMPREALLOC@|$(DEFENABLEMEMPREALLOC)|g" \
-e "s|@DEFENABLEHUGEPAGES@|$(DEFENABLEHUGEPAGES)|g" \
Expand Down
3 changes: 3 additions & 0 deletions cli/config/configuration-qemu.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ virtio_fs_cache_size = @DEFVIRTIOFSCACHESIZE@
# Metadata, data, and pathname lookup are cached in guest and never expire.
virtio_fs_cache = "@DEFVIRTIOFSCACHE@"

# Use shared version metadata
virtio_fs_shared_versions = @DEFVIRTIOFSSHAREDVERSIONS@

# 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.
Expand Down
2 changes: 2 additions & 0 deletions pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type hypervisor struct {
VirtioFSDaemon string `toml:"virtio_fs_daemon"`
VirtioFSCacheSize uint32 `toml:"virtio_fs_cache_size"`
VirtioFSCache string `toml:"virtio_fs_cache"`
VirtioFSSharedVersions bool `toml:"virtio_fs_shared_versions"`
MemPrealloc bool `toml:"enable_mem_prealloc"`
HugePages bool `toml:"enable_hugepages"`
Swap bool `toml:"enable_swap"`
Expand Down Expand Up @@ -542,6 +543,7 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
VirtioFSDaemon: h.VirtioFSDaemon,
VirtioFSCacheSize: h.VirtioFSCacheSize,
VirtioFSCache: h.VirtioFSCache,
VirtioFSSharedVersions: h.VirtioFSSharedVersions,
MemPrealloc: h.MemPrealloc,
HugePages: h.HugePages,
Mlock: !h.Swap,
Expand Down
4 changes: 4 additions & 0 deletions vendor/github.com/intel/govmm/qemu/qemu.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions virtcontainers/device/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ type VhostUserDeviceAttrs struct {
Tag string
CacheSize uint32
Cache string
SharedVersions bool
}

// GetHostPathFunc is function pointer used to mock GetHostPath in tests.
Expand Down
3 changes: 3 additions & 0 deletions virtcontainers/documentation/api/1.0/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ type HypervisorConfig struct {
// VirtioFSCache cache mode for fs version cache or "none"
VirtioFSCache string

// VirtioFSSharedVersions enables shared version metadata daemon
VirtioFSSharedVersions bool

// KernelParams are additional guest kernel parameters.
KernelParams []Param

Expand Down
3 changes: 3 additions & 0 deletions virtcontainers/hypervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ type HypervisorConfig struct {
// VirtioFSCache cache mode for fs version cache or "none"
VirtioFSCache string

// VirtioFSSharedVersions enables shared version metadata daemon
VirtioFSSharedVersions bool

// EnableIOThreads enables IO to be processed in a separate thread.
// Supported currently for virtio-scsi driver.
EnableIOThreads bool
Expand Down
19 changes: 13 additions & 6 deletions virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,15 +582,21 @@ func (q *qemu) startSandbox(timeout int) error {
return err
}

sourcePath := filepath.Join(kataHostSharedDir, q.id)

var args []string
args = append(args, "-o", "virtio_socket=" + sockPath,
"-o", "source=" + sourcePath,
"-o", "cache=" + q.config.VirtioFSCache)
if q.config.VirtioFSSharedVersions {
args = append(args, "-o", "shared")
}
args = append(args, "/")

// The daemon will terminate when the vhost-user socket
// connection with QEMU closes. Therefore we do not keep track
// of this child process.
sourcePath := filepath.Join(kataHostSharedDir, q.id)
cmd = exec.Command(q.config.VirtioFSDaemon,
"-o", "virtio_socket=" + sockPath,
"-o", "source=" + sourcePath,
"-o", "cache=" + q.config.VirtioFSCache,
"/")
cmd = exec.Command(q.config.VirtioFSDaemon, args...)

if err := cmd.Start(); err != nil {
return err
Expand Down Expand Up @@ -1274,6 +1280,7 @@ func (q *qemu) addDevice(devInfo interface{}, devType deviceType) error {
Type: config.VhostUserFS,
CacheSize: q.config.VirtioFSCacheSize,
Cache: q.config.VirtioFSCache,
SharedVersions: q.config.VirtioFSSharedVersions,
}
vhostDev.SocketPath = sockPath
vhostDev.DevID = id
Expand Down
1 change: 1 addition & 0 deletions virtcontainers/qemu_arch_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ func (q *qemuArchBase) appendVhostUserDevice(devices []govmmQemu.Device, attr co
qemuVhostUserDevice.Tag = attr.Tag
qemuVhostUserDevice.CacheSize = attr.CacheSize
qemuVhostUserDevice.Cache = attr.Cache
qemuVhostUserDevice.SharedVersions = attr.SharedVersions
}

qemuVhostUserDevice.VhostUserType = govmmQemu.DeviceDriver(attr.Type)
Expand Down

0 comments on commit e1546ce

Please sign in to comment.