diff --git a/src/runtime/pkg/katautils/config.go b/src/runtime/pkg/katautils/config.go index 3e15929ff3..3cb37780db 100644 --- a/src/runtime/pkg/katautils/config.go +++ b/src/runtime/pkg/katautils/config.go @@ -860,52 +860,56 @@ func newClhHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) { } return vc.HypervisorConfig{ - HypervisorPath: hypervisor, - HypervisorPathList: h.HypervisorPathList, - KernelPath: kernel, - InitrdPath: initrd, - ImagePath: image, - FirmwarePath: firmware, - MachineAccelerators: machineAccelerators, - KernelParams: vc.DeserializeParams(strings.Fields(kernelParams)), - HypervisorMachineType: machineType, - NumVCPUs: h.defaultVCPUs(), - DefaultMaxVCPUs: h.defaultMaxVCPUs(), - MemorySize: h.defaultMemSz(), - MemSlots: h.defaultMemSlots(), - MemOffset: h.defaultMemOffset(), - VirtioMem: h.VirtioMem, - EntropySource: h.GetEntropySource(), - EntropySourceList: h.EntropySourceList, - DefaultBridges: h.defaultBridges(), - DisableBlockDeviceUse: h.DisableBlockDeviceUse, - SharedFS: sharedFS, - VirtioFSDaemon: h.VirtioFSDaemon, - VirtioFSDaemonList: h.VirtioFSDaemonList, - VirtioFSCacheSize: h.VirtioFSCacheSize, - VirtioFSCache: h.VirtioFSCache, - MemPrealloc: h.MemPrealloc, - HugePages: h.HugePages, - FileBackedMemRootDir: h.FileBackedMemRootDir, - FileBackedMemRootList: h.FileBackedMemRootList, - Debug: h.Debug, - DisableNestingChecks: h.DisableNestingChecks, - BlockDeviceDriver: blockDriver, - BlockDeviceCacheSet: h.BlockDeviceCacheSet, - BlockDeviceCacheDirect: h.BlockDeviceCacheDirect, - BlockDeviceCacheNoflush: h.BlockDeviceCacheNoflush, - EnableIOThreads: h.EnableIOThreads, - Msize9p: h.msize9p(), - HotplugVFIOOnRootBus: h.HotplugVFIOOnRootBus, - PCIeRootPort: h.PCIeRootPort, - DisableVhostNet: true, - GuestHookPath: h.guestHookPath(), - VirtioFSExtraArgs: h.VirtioFSExtraArgs, - SGXEPCSize: defaultSGXEPCSize, - EnableAnnotations: h.EnableAnnotations, - DisableSeccomp: h.DisableSeccomp, - ConfidentialGuest: h.ConfidentialGuest, - DisableSeLinux: h.DisableSeLinux, + HypervisorPath: hypervisor, + HypervisorPathList: h.HypervisorPathList, + KernelPath: kernel, + InitrdPath: initrd, + ImagePath: image, + FirmwarePath: firmware, + MachineAccelerators: machineAccelerators, + KernelParams: vc.DeserializeParams(strings.Fields(kernelParams)), + HypervisorMachineType: machineType, + NumVCPUs: h.defaultVCPUs(), + DefaultMaxVCPUs: h.defaultMaxVCPUs(), + MemorySize: h.defaultMemSz(), + MemSlots: h.defaultMemSlots(), + MemOffset: h.defaultMemOffset(), + VirtioMem: h.VirtioMem, + EntropySource: h.GetEntropySource(), + EntropySourceList: h.EntropySourceList, + DefaultBridges: h.defaultBridges(), + DisableBlockDeviceUse: h.DisableBlockDeviceUse, + SharedFS: sharedFS, + VirtioFSDaemon: h.VirtioFSDaemon, + VirtioFSDaemonList: h.VirtioFSDaemonList, + VirtioFSCacheSize: h.VirtioFSCacheSize, + VirtioFSCache: h.VirtioFSCache, + MemPrealloc: h.MemPrealloc, + HugePages: h.HugePages, + FileBackedMemRootDir: h.FileBackedMemRootDir, + FileBackedMemRootList: h.FileBackedMemRootList, + Debug: h.Debug, + DisableNestingChecks: h.DisableNestingChecks, + BlockDeviceDriver: blockDriver, + BlockDeviceCacheSet: h.BlockDeviceCacheSet, + BlockDeviceCacheDirect: h.BlockDeviceCacheDirect, + BlockDeviceCacheNoflush: h.BlockDeviceCacheNoflush, + EnableIOThreads: h.EnableIOThreads, + Msize9p: h.msize9p(), + HotplugVFIOOnRootBus: h.HotplugVFIOOnRootBus, + PCIeRootPort: h.PCIeRootPort, + DisableVhostNet: true, + GuestHookPath: h.guestHookPath(), + VirtioFSExtraArgs: h.VirtioFSExtraArgs, + SGXEPCSize: defaultSGXEPCSize, + EnableAnnotations: h.EnableAnnotations, + DisableSeccomp: h.DisableSeccomp, + ConfidentialGuest: h.ConfidentialGuest, + DisableSeLinux: h.DisableSeLinux, + NetRateLimiterBwMaxRate: h.getNetRateLimiterBwMaxRate(), + NetRateLimiterBwOneTimeBurst: h.getNetRateLimiterBwOneTimeBurst(), + NetRateLimiterOpsMaxRate: h.getNetRateLimiterOpsMaxRate(), + NetRateLimiterOpsOneTimeBurst: h.getNetRateLimiterOpsOneTimeBurst(), }, nil } diff --git a/src/runtime/pkg/katautils/config_test.go b/src/runtime/pkg/katautils/config_test.go index 2f85adcb3b..778f6ec6de 100644 --- a/src/runtime/pkg/katautils/config_test.go +++ b/src/runtime/pkg/katautils/config_test.go @@ -810,6 +810,10 @@ func TestNewClhHypervisorConfig(t *testing.T) { kernelPath := path.Join(tmpdir, "kernel") imagePath := path.Join(tmpdir, "image") virtioFsDaemon := path.Join(tmpdir, "virtiofsd") + netRateLimiterBwMaxRate := int64(1000) + netRateLimiterBwOneTimeBurst := int64(1000) + netRateLimiterOpsMaxRate := int64(0) + netRateLimiterOpsOneTimeBurst := int64(1000) for _, file := range []string{imagePath, hypervisorPath, kernelPath, virtioFsDaemon} { err := createEmptyFile(file) @@ -817,11 +821,15 @@ func TestNewClhHypervisorConfig(t *testing.T) { } hypervisor := hypervisor{ - Path: hypervisorPath, - Kernel: kernelPath, - Image: imagePath, - VirtioFSDaemon: virtioFsDaemon, - VirtioFSCache: "always", + Path: hypervisorPath, + Kernel: kernelPath, + Image: imagePath, + VirtioFSDaemon: virtioFsDaemon, + VirtioFSCache: "always", + NetRateLimiterBwMaxRate: netRateLimiterBwMaxRate, + NetRateLimiterBwOneTimeBurst: netRateLimiterBwOneTimeBurst, + NetRateLimiterOpsMaxRate: netRateLimiterOpsMaxRate, + NetRateLimiterOpsOneTimeBurst: netRateLimiterOpsOneTimeBurst, } config, err := newClhHypervisorConfig(hypervisor) if err != nil { @@ -852,6 +860,22 @@ func TestNewClhHypervisorConfig(t *testing.T) { t.Errorf("Expected VirtioFSCache %v, got %v", true, config.VirtioFSCache) } + if config.NetRateLimiterBwMaxRate != netRateLimiterBwMaxRate { + t.Errorf("Expected value for network bandwidth rate limiter %v, got %v", netRateLimiterBwMaxRate, config.NetRateLimiterBwMaxRate) + } + + if config.NetRateLimiterBwOneTimeBurst != netRateLimiterBwOneTimeBurst { + t.Errorf("Expected value for network bandwidth one time burst %v, got %v", netRateLimiterBwOneTimeBurst, config.NetRateLimiterBwOneTimeBurst) + } + + if config.NetRateLimiterOpsMaxRate != netRateLimiterOpsMaxRate { + t.Errorf("Expected value for network operations rate limiter %v, got %v", netRateLimiterOpsMaxRate, config.NetRateLimiterOpsMaxRate) + } + + // We expect 0 (zero) here as netRateLimiterOpsMaxRate is not set (set to zero). + if config.NetRateLimiterOpsOneTimeBurst != 0 { + t.Errorf("Expected value for network operations one time burst %v, got %v", netRateLimiterOpsOneTimeBurst, config.NetRateLimiterOpsOneTimeBurst) + } } func TestHypervisorDefaults(t *testing.T) {