mirror of
				https://github.com/kata-containers/kata-containers.git
				synced 2025-10-31 09:26:52 +00:00 
			
		
		
		
	govmm: add VhostUserFS vhost-user device type
The QEMU vhost-user-fs-pci device provides virtio-fs host<->guest file system sharing (https://virtio-fs.gitlab.io/). The device is instantiated like this: $ qemu -chardev socket,path=/tmp/vhost-fs.sock,id=chr0 -device vhost-user-fs-pci,tag=myfs,chardev=chr0,cache-size=4G,versiontable=/dev/shm/fuse_shared_versions This patch adds the VhostUserFS DeviceDriver and command-line generation for this QEMU device. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
		
				
					committed by
					
						 Stefan Hajnoczi
						Stefan Hajnoczi
					
				
			
			
				
	
			
			
			
						parent
						
							78d079db6d
						
					
				
				
					commit
					3c84b1daa3
				
			
							
								
								
									
										29
									
								
								qemu/qemu.go
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								qemu/qemu.go
									
									
									
									
									
								
							| @@ -92,6 +92,9 @@ const ( | |||||||
| 	//VhostUserBlk represents a block vhostuser device type. | 	//VhostUserBlk represents a block vhostuser device type. | ||||||
| 	VhostUserBlk DeviceDriver = "vhost-user-blk-pci" | 	VhostUserBlk DeviceDriver = "vhost-user-blk-pci" | ||||||
|  |  | ||||||
|  | 	//VhostUserFS represents a virtio-fs vhostuser device type | ||||||
|  | 	VhostUserFS DeviceDriver = "vhost-user-fs-pci" | ||||||
|  |  | ||||||
| 	// PCIBridgeDriver represents a PCI bridge device type. | 	// PCIBridgeDriver represents a PCI bridge device type. | ||||||
| 	PCIBridgeDriver DeviceDriver = "pci-bridge" | 	PCIBridgeDriver DeviceDriver = "pci-bridge" | ||||||
|  |  | ||||||
| @@ -740,11 +743,14 @@ func (blkdev BlockDevice) QemuParams(config *Config) []string { | |||||||
| // VhostUserDevice represents a qemu vhost-user device meant to be passed | // VhostUserDevice represents a qemu vhost-user device meant to be passed | ||||||
| // in to the guest | // in to the guest | ||||||
| type VhostUserDevice struct { | type VhostUserDevice struct { | ||||||
| 	SocketPath    string //path to vhostuser socket on host | 	SocketPath     string //path to vhostuser socket on host | ||||||
| 	CharDevID     string | 	CharDevID      string | ||||||
| 	TypeDevID     string //variable QEMU parameter based on value of VhostUserType | 	TypeDevID      string //variable QEMU parameter based on value of VhostUserType | ||||||
| 	Address       string //used for MAC address in net case | 	Address        string //used for MAC address in net case | ||||||
| 	VhostUserType DeviceDriver | 	Tag            string //virtio-fs volume id for mounting inside guest | ||||||
|  | 	CacheSize      uint32 //virtio-fs DAX cache size in GiB | ||||||
|  | 	SharedVersions bool   //enable virtio-fs shared version metadata | ||||||
|  | 	VhostUserType  DeviceDriver | ||||||
|  |  | ||||||
| 	// ROMFile specifies the ROM file being used for this device. | 	// ROMFile specifies the ROM file being used for this device. | ||||||
| 	ROMFile string | 	ROMFile string | ||||||
| @@ -767,6 +773,10 @@ func (vhostuserDev VhostUserDevice) Valid() bool { | |||||||
| 			return false | 			return false | ||||||
| 		} | 		} | ||||||
| 	case VhostUserBlk: | 	case VhostUserBlk: | ||||||
|  | 	case VhostUserFS: | ||||||
|  | 		if vhostuserDev.Tag == "" { | ||||||
|  | 			return false | ||||||
|  | 		} | ||||||
| 	default: | 	default: | ||||||
| 		return false | 		return false | ||||||
| 	} | 	} | ||||||
| @@ -809,6 +819,15 @@ func (vhostuserDev VhostUserDevice) QemuParams(config *Config) []string { | |||||||
| 		devParams = append(devParams, "logical_block_size=4096") | 		devParams = append(devParams, "logical_block_size=4096") | ||||||
| 		devParams = append(devParams, "size=512M") | 		devParams = append(devParams, "size=512M") | ||||||
| 		devParams = append(devParams, fmt.Sprintf("chardev=%s", vhostuserDev.CharDevID)) | 		devParams = append(devParams, fmt.Sprintf("chardev=%s", vhostuserDev.CharDevID)) | ||||||
|  | 	case VhostUserFS: | ||||||
|  | 		driver = VhostUserFS | ||||||
|  | 		devParams = append(devParams, string(driver)) | ||||||
|  | 		devParams = append(devParams, fmt.Sprintf("chardev=%s", vhostuserDev.CharDevID)) | ||||||
|  | 		devParams = append(devParams, fmt.Sprintf("tag=%s", vhostuserDev.Tag)) | ||||||
|  | 		devParams = append(devParams, fmt.Sprintf("cache-size=%dG", vhostuserDev.CacheSize)) | ||||||
|  | 		if vhostuserDev.SharedVersions { | ||||||
|  | 			devParams = append(devParams, "versiontable=/dev/shm/fuse_shared_versions") | ||||||
|  | 		} | ||||||
| 	default: | 	default: | ||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user