rate-limiter: check if hypervisor supports built-in rate limiter

As for some hypervisors, like firecracker, they support built-in rate limiter
to control network I/O bandwidth on VMM level. And for some hypervisors, like qemu,
they don't.

Fixes: #250

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
This commit is contained in:
Penny Zheng 2020-06-09 07:20:53 +00:00
parent c2645f5d5a
commit bd8658e362
6 changed files with 24 additions and 1 deletions

View File

@ -811,3 +811,7 @@ func (a *Acrn) loadInfo() error {
}
return nil
}
func (a *Acrn) isRateLimiterBuiltin() bool {
return false
}

View File

@ -1210,3 +1210,7 @@ func (clh *cloudHypervisor) vmInfo() (chclient.VmInfo, error) {
return info, openAPIClientError(err)
}
func (clh *cloudHypervisor) isRateLimiterBuiltin() bool {
return false
}

View File

@ -25,12 +25,12 @@ import (
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
kataclient "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols/client"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
ops "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/operations"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
kataclient "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols/client"
"github.com/blang/semver"
"github.com/containerd/console"
@ -1212,3 +1212,7 @@ func (fc *firecracker) watchConsole() (*os.File, error) {
return stdio, nil
}
func (fc *firecracker) isRateLimiterBuiltin() bool {
return true
}

View File

@ -802,4 +802,7 @@ type hypervisor interface {
// generate the socket to communicate the host and guest
generateSocket(id string, useVsock bool) (interface{}, error)
// check if hypervisor supports built-in rate limiter.
isRateLimiterBuiltin() bool
}

View File

@ -128,3 +128,7 @@ func (m *mockHypervisor) check() error {
func (m *mockHypervisor) generateSocket(id string, useVsock bool) (interface{}, error) {
return types.Socket{HostPath: "/tmp/socket", Name: "socket"}, nil
}
func (m *mockHypervisor) isRateLimiterBuiltin() bool {
return false
}

View File

@ -2266,3 +2266,7 @@ func (q *qemu) check() error {
func (q *qemu) generateSocket(id string, useVsock bool) (interface{}, error) {
return generateVMSocket(id, useVsock, q.store.RunVMStoragePath())
}
func (q *qemu) isRateLimiterBuiltin() bool {
return false
}