mirror of
				https://github.com/kata-containers/kata-containers.git
				synced 2025-10-31 09:26:52 +00:00 
			
		
		
		
	hypervisor: Add disk bandwidth and operations rate limiters
This is the disk counterpart of the what was introduced for the network as part of the previous commits in this series. The newly added fields are: * DiskRateLimiterBwMaxRate, defined in bits per second, which is used to control the network I/O bandwidth at the VM level. * DiskRateLimiterBwOneTimeBurst, also defined in bits per second, which is used to define an *initial* max rate, which doesn't replenish. * DiskRateLimiterOpsMaxRate, the operations per second equivalent of the DiskRateLimiterBwMaxRate. * DiskRateLimiterOpsOneTimeBurst, the operations per second equivalent of the DiskRateLimiterBwOneTimeBurst. For now those extra fields have only been added to the hypervisor's configuration and they'll be used in the coming patches of this very same series. Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
		| @@ -74,74 +74,78 @@ 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"` | ||||||
| 	FirmwareVolume                string   `toml:"firmware_volume"` | 	FirmwareVolume                 string   `toml:"firmware_volume"` | ||||||
| 	MachineAccelerators           string   `toml:"machine_accelerators"` | 	MachineAccelerators            string   `toml:"machine_accelerators"` | ||||||
| 	CPUFeatures                   string   `toml:"cpu_features"` | 	CPUFeatures                    string   `toml:"cpu_features"` | ||||||
| 	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"` | ||||||
| 	VhostUserStorePath            string   `toml:"vhost_user_store_path"` | 	VhostUserStorePath             string   `toml:"vhost_user_store_path"` | ||||||
| 	FileBackedMemRootDir          string   `toml:"file_mem_backend"` | 	FileBackedMemRootDir           string   `toml:"file_mem_backend"` | ||||||
| 	GuestHookPath                 string   `toml:"guest_hook_path"` | 	GuestHookPath                  string   `toml:"guest_hook_path"` | ||||||
| 	GuestMemoryDumpPath           string   `toml:"guest_memory_dump_path"` | 	GuestMemoryDumpPath            string   `toml:"guest_memory_dump_path"` | ||||||
| 	HypervisorPathList            []string `toml:"valid_hypervisor_paths"` | 	HypervisorPathList             []string `toml:"valid_hypervisor_paths"` | ||||||
| 	JailerPathList                []string `toml:"valid_jailer_paths"` | 	JailerPathList                 []string `toml:"valid_jailer_paths"` | ||||||
| 	CtlPathList                   []string `toml:"valid_ctlpaths"` | 	CtlPathList                    []string `toml:"valid_ctlpaths"` | ||||||
| 	VirtioFSDaemonList            []string `toml:"valid_virtio_fs_daemon_paths"` | 	VirtioFSDaemonList             []string `toml:"valid_virtio_fs_daemon_paths"` | ||||||
| 	VirtioFSExtraArgs             []string `toml:"virtio_fs_extra_args"` | 	VirtioFSExtraArgs              []string `toml:"virtio_fs_extra_args"` | ||||||
| 	PFlashList                    []string `toml:"pflashes"` | 	PFlashList                     []string `toml:"pflashes"` | ||||||
| 	VhostUserStorePathList        []string `toml:"valid_vhost_user_store_paths"` | 	VhostUserStorePathList         []string `toml:"valid_vhost_user_store_paths"` | ||||||
| 	FileBackedMemRootList         []string `toml:"valid_file_mem_backends"` | 	FileBackedMemRootList          []string `toml:"valid_file_mem_backends"` | ||||||
| 	EntropySourceList             []string `toml:"valid_entropy_sources"` | 	EntropySourceList              []string `toml:"valid_entropy_sources"` | ||||||
| 	EnableAnnotations             []string `toml:"enable_annotations"` | 	EnableAnnotations              []string `toml:"enable_annotations"` | ||||||
| 	RxRateLimiterMaxRate          uint64   `toml:"rx_rate_limiter_max_rate"` | 	RxRateLimiterMaxRate           uint64   `toml:"rx_rate_limiter_max_rate"` | ||||||
| 	TxRateLimiterMaxRate          uint64   `toml:"tx_rate_limiter_max_rate"` | 	TxRateLimiterMaxRate           uint64   `toml:"tx_rate_limiter_max_rate"` | ||||||
| 	MemOffset                     uint64   `toml:"memory_offset"` | 	MemOffset                      uint64   `toml:"memory_offset"` | ||||||
| 	NetRateLimiterBwMaxRate       int64    `toml:"net_rate_limiter_bw_max_rate"` | 	DiskRateLimiterBwMaxRate       int64    `toml:"disk_rate_limiter_bw_max_rate"` | ||||||
| 	NetRateLimiterBwOneTimeBurst  int64    `toml:"net_rate_limiter_bw_one_time_burst"` | 	DiskRateLimiterBwOneTimeBurst  int64    `toml:"disk_rate_limiter_bw_one_time_burst"` | ||||||
| 	NetRateLimiterOpsMaxRate      int64    `toml:"net_rate_limiter_ops_max_rate"` | 	DiskRateLimiterOpsMaxRate      int64    `toml:"disk_rate_limiter_ops_max_rate"` | ||||||
| 	NetRateLimiterOpsOneTimeBurst int64    `toml:"net_rate_limiter_ops_one_time_burst"` | 	DiskRateLimiterOpsOneTimeBurst int64    `toml:"disk_rate_limiter_ops_one_time_burst"` | ||||||
| 	VirtioFSCacheSize             uint32   `toml:"virtio_fs_cache_size"` | 	NetRateLimiterBwMaxRate        int64    `toml:"net_rate_limiter_bw_max_rate"` | ||||||
| 	DefaultMaxVCPUs               uint32   `toml:"default_maxvcpus"` | 	NetRateLimiterBwOneTimeBurst   int64    `toml:"net_rate_limiter_bw_one_time_burst"` | ||||||
| 	MemorySize                    uint32   `toml:"default_memory"` | 	NetRateLimiterOpsMaxRate       int64    `toml:"net_rate_limiter_ops_max_rate"` | ||||||
| 	MemSlots                      uint32   `toml:"memory_slots"` | 	NetRateLimiterOpsOneTimeBurst  int64    `toml:"net_rate_limiter_ops_one_time_burst"` | ||||||
| 	DefaultBridges                uint32   `toml:"default_bridges"` | 	VirtioFSCacheSize              uint32   `toml:"virtio_fs_cache_size"` | ||||||
| 	Msize9p                       uint32   `toml:"msize_9p"` | 	DefaultMaxVCPUs                uint32   `toml:"default_maxvcpus"` | ||||||
| 	PCIeRootPort                  uint32   `toml:"pcie_root_port"` | 	MemorySize                     uint32   `toml:"default_memory"` | ||||||
| 	NumVCPUs                      int32    `toml:"default_vcpus"` | 	MemSlots                       uint32   `toml:"memory_slots"` | ||||||
| 	BlockDeviceCacheSet           bool     `toml:"block_device_cache_set"` | 	DefaultBridges                 uint32   `toml:"default_bridges"` | ||||||
| 	BlockDeviceCacheDirect        bool     `toml:"block_device_cache_direct"` | 	Msize9p                        uint32   `toml:"msize_9p"` | ||||||
| 	BlockDeviceCacheNoflush       bool     `toml:"block_device_cache_noflush"` | 	PCIeRootPort                   uint32   `toml:"pcie_root_port"` | ||||||
| 	EnableVhostUserStore          bool     `toml:"enable_vhost_user_store"` | 	NumVCPUs                       int32    `toml:"default_vcpus"` | ||||||
| 	DisableBlockDeviceUse         bool     `toml:"disable_block_device_use"` | 	BlockDeviceCacheSet            bool     `toml:"block_device_cache_set"` | ||||||
| 	MemPrealloc                   bool     `toml:"enable_mem_prealloc"` | 	BlockDeviceCacheDirect         bool     `toml:"block_device_cache_direct"` | ||||||
| 	HugePages                     bool     `toml:"enable_hugepages"` | 	BlockDeviceCacheNoflush        bool     `toml:"block_device_cache_noflush"` | ||||||
| 	VirtioMem                     bool     `toml:"enable_virtio_mem"` | 	EnableVhostUserStore           bool     `toml:"enable_vhost_user_store"` | ||||||
| 	IOMMU                         bool     `toml:"enable_iommu"` | 	DisableBlockDeviceUse          bool     `toml:"disable_block_device_use"` | ||||||
| 	IOMMUPlatform                 bool     `toml:"enable_iommu_platform"` | 	MemPrealloc                    bool     `toml:"enable_mem_prealloc"` | ||||||
| 	Debug                         bool     `toml:"enable_debug"` | 	HugePages                      bool     `toml:"enable_hugepages"` | ||||||
| 	DisableNestingChecks          bool     `toml:"disable_nesting_checks"` | 	VirtioMem                      bool     `toml:"enable_virtio_mem"` | ||||||
| 	EnableIOThreads               bool     `toml:"enable_iothreads"` | 	IOMMU                          bool     `toml:"enable_iommu"` | ||||||
| 	DisableImageNvdimm            bool     `toml:"disable_image_nvdimm"` | 	IOMMUPlatform                  bool     `toml:"enable_iommu_platform"` | ||||||
| 	HotplugVFIOOnRootBus          bool     `toml:"hotplug_vfio_on_root_bus"` | 	Debug                          bool     `toml:"enable_debug"` | ||||||
| 	DisableVhostNet               bool     `toml:"disable_vhost_net"` | 	DisableNestingChecks           bool     `toml:"disable_nesting_checks"` | ||||||
| 	GuestMemoryDumpPaging         bool     `toml:"guest_memory_dump_paging"` | 	EnableIOThreads                bool     `toml:"enable_iothreads"` | ||||||
| 	ConfidentialGuest             bool     `toml:"confidential_guest"` | 	DisableImageNvdimm             bool     `toml:"disable_image_nvdimm"` | ||||||
| 	GuestSwap                     bool     `toml:"enable_guest_swap"` | 	HotplugVFIOOnRootBus           bool     `toml:"hotplug_vfio_on_root_bus"` | ||||||
| 	Rootless                      bool     `toml:"rootless"` | 	DisableVhostNet                bool     `toml:"disable_vhost_net"` | ||||||
| 	DisableSeccomp                bool     `toml:"disable_seccomp"` | 	GuestMemoryDumpPaging          bool     `toml:"guest_memory_dump_paging"` | ||||||
| 	DisableSeLinux                bool     `toml:"disable_selinux"` | 	ConfidentialGuest              bool     `toml:"confidential_guest"` | ||||||
|  | 	GuestSwap                      bool     `toml:"enable_guest_swap"` | ||||||
|  | 	Rootless                       bool     `toml:"rootless"` | ||||||
|  | 	DisableSeccomp                 bool     `toml:"disable_seccomp"` | ||||||
|  | 	DisableSeLinux                 bool     `toml:"disable_selinux"` | ||||||
| } | } | ||||||
|  |  | ||||||
| type runtime struct { | type runtime struct { | ||||||
| @@ -486,6 +490,34 @@ func (h hypervisor) getInitrdAndImage() (initrd string, image string, err error) | |||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (h hypervisor) getDiskRateLimiterBwMaxRate() int64 { | ||||||
|  | 	return h.DiskRateLimiterBwMaxRate | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (h hypervisor) getDiskRateLimiterBwOneTimeBurst() int64 { | ||||||
|  | 	if h.DiskRateLimiterBwOneTimeBurst != 0 && h.getDiskRateLimiterBwMaxRate() == 0 { | ||||||
|  | 		kataUtilsLogger.Warn("The DiskRateLimiterBwOneTimeBurst is set but DiskRateLimiterBwMaxRate is not set, this option will be ignored.") | ||||||
|  |  | ||||||
|  | 		h.DiskRateLimiterBwOneTimeBurst = 0 | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return h.DiskRateLimiterBwOneTimeBurst | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (h hypervisor) getDiskRateLimiterOpsMaxRate() int64 { | ||||||
|  | 	return h.DiskRateLimiterOpsMaxRate | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (h hypervisor) getDiskRateLimiterOpsOneTimeBurst() int64 { | ||||||
|  | 	if h.DiskRateLimiterOpsOneTimeBurst != 0 && h.getDiskRateLimiterOpsMaxRate() == 0 { | ||||||
|  | 		kataUtilsLogger.Warn("The DiskRateLimiterOpsOneTimeBurst is set but DiskRateLimiterOpsMaxRate is not set, this option will be ignored.") | ||||||
|  |  | ||||||
|  | 		h.DiskRateLimiterOpsOneTimeBurst = 0 | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return h.DiskRateLimiterOpsOneTimeBurst | ||||||
|  | } | ||||||
|  |  | ||||||
| func (h hypervisor) getRxRateLimiterCfg() uint64 { | func (h hypervisor) getRxRateLimiterCfg() uint64 { | ||||||
| 	return h.RxRateLimiterMaxRate | 	return h.RxRateLimiterMaxRate | ||||||
| } | } | ||||||
|   | |||||||
| @@ -380,6 +380,24 @@ type HypervisorConfig struct { | |||||||
| 	// Enable SGX. Hardware-based isolation and memory encryption. | 	// Enable SGX. Hardware-based isolation and memory encryption. | ||||||
| 	SGXEPCSize int64 | 	SGXEPCSize int64 | ||||||
|  |  | ||||||
|  | 	// DiskRateLimiterBwRate is used to control disk I/O bandwidth on VM level. | ||||||
|  | 	// The same value, defined in bits per second, is used for inbound and outbound bandwidth. | ||||||
|  | 	DiskRateLimiterBwMaxRate int64 | ||||||
|  |  | ||||||
|  | 	// DiskRateLimiterBwOneTimeBurst is used to control disk I/O bandwidth on VM level. | ||||||
|  | 	// This increases the initial max rate and this initial extra credit does *NOT* replenish | ||||||
|  | 	// and can be used for an *initial* burst of data. | ||||||
|  | 	DiskRateLimiterBwOneTimeBurst int64 | ||||||
|  |  | ||||||
|  | 	// DiskRateLimiterOpsRate is used to control disk I/O operations on VM level. | ||||||
|  | 	// The same value, defined in operations per second, is used for inbound and outbound bandwidth. | ||||||
|  | 	DiskRateLimiterOpsMaxRate int64 | ||||||
|  |  | ||||||
|  | 	// DiskRateLimiterOpsOneTimeBurst is used to control disk I/O operations on VM level. | ||||||
|  | 	// This increases the initial max rate and this initial extra credit does *NOT* replenish | ||||||
|  | 	// and can be used for an *initial* burst of data. | ||||||
|  | 	DiskRateLimiterOpsOneTimeBurst int64 | ||||||
|  |  | ||||||
| 	// RxRateLimiterMaxRate is used to control network I/O inbound bandwidth on VM level. | 	// RxRateLimiterMaxRate is used to control network I/O inbound bandwidth on VM level. | ||||||
| 	RxRateLimiterMaxRate uint64 | 	RxRateLimiterMaxRate uint64 | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user