@@ -92,6 +92,10 @@ type hypervisor struct {
9292 MachineType string `toml:"machine_type"`
9393 BlockDeviceDriver string `toml:"block_device_driver"`
9494 EntropySource string `toml:"entropy_source"`
95+ SharedFS string `toml:"shared_fs"`
96+ VirtioFSDaemon string `toml:"virtio_fs_daemon"`
97+ VirtioFSCache string `toml:"virtio_fs_cache"`
98+ VirtioFSCacheSize uint32 `toml:"virtio_fs_cache_size"`
9599 BlockDeviceCacheSet bool `toml:"block_device_cache_set"`
96100 BlockDeviceCacheDirect bool `toml:"block_device_cache_direct"`
97101 BlockDeviceCacheNoflush bool `toml:"block_device_cache_noflush"`
@@ -326,6 +330,22 @@ func (h hypervisor) blockDeviceDriver() (string, error) {
326330 return "" , fmt .Errorf ("Invalid hypervisor block storage driver %v specified (supported drivers: %v)" , h .BlockDeviceDriver , supportedBlockDrivers )
327331}
328332
333+ func (h hypervisor ) sharedFS () (string , error ) {
334+ supportedSharedFS := []string {config .Virtio9P , config .VirtioFS }
335+
336+ if h .SharedFS == "" {
337+ return config .Virtio9P , nil
338+ }
339+
340+ for _ , fs := range supportedSharedFS {
341+ if fs == h .SharedFS {
342+ return h .SharedFS , nil
343+ }
344+ }
345+
346+ return "" , fmt .Errorf ("Invalid hypervisor shared file system %v specified (supported file systems: %v)" , h .SharedFS , supportedSharedFS )
347+ }
348+
329349func (h hypervisor ) msize9p () uint32 {
330350 if h .Msize9p == 0 {
331351 return defaultMsize9p
@@ -521,6 +541,16 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
521541 return vc.HypervisorConfig {}, err
522542 }
523543
544+ sharedFS , err := h .sharedFS ()
545+ if err != nil {
546+ return vc.HypervisorConfig {}, err
547+ }
548+
549+ if sharedFS == config .VirtioFS && h .VirtioFSDaemon == "" {
550+ return vc.HypervisorConfig {},
551+ errors .New ("cannot enable virtio-fs without daemon path in configuration file" )
552+ }
553+
524554 useVSock := false
525555 if h .useVSock () {
526556 if utils .SupportsVsocks () {
@@ -548,6 +578,10 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
548578 EntropySource : h .GetEntropySource (),
549579 DefaultBridges : h .defaultBridges (),
550580 DisableBlockDeviceUse : h .DisableBlockDeviceUse ,
581+ SharedFS : sharedFS ,
582+ VirtioFSDaemon : h .VirtioFSDaemon ,
583+ VirtioFSCacheSize : h .VirtioFSCacheSize ,
584+ VirtioFSCache : h .VirtioFSCache ,
551585 MemPrealloc : h .MemPrealloc ,
552586 HugePages : h .HugePages ,
553587 Mlock : ! h .Swap ,
0 commit comments