mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-14 20:04:21 +01:00
This PR got merged while it had some issues with some shim processes being left behind after k8s testing. And because those issues were real issues introduced by this PR (not some random failures), now the master branch is broken and new pull requests cannot get the CI passing. That's the reason why this commit revert the changes introduced by this PR so that we can fix the master branch. Fixes #529 Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
62 lines
1.7 KiB
Go
62 lines
1.7 KiB
Go
// Copyright (c) 2017-2018 Intel Corporation
|
|
// Copyright (c) 2018 Huawei Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package api
|
|
|
|
import (
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
|
)
|
|
|
|
var devLogger = logrus.FieldLogger(logrus.New())
|
|
|
|
// SetLogger sets the logger for device api package.
|
|
func SetLogger(logger logrus.FieldLogger) {
|
|
devLogger = logger
|
|
}
|
|
|
|
// DeviceLogger returns logger for device management
|
|
func DeviceLogger() *logrus.Entry {
|
|
return devLogger.WithField("subsystem", "device")
|
|
}
|
|
|
|
// DeviceReceiver is an interface used for accepting devices
|
|
// a device should be attached/added/plugged to a DeviceReceiver
|
|
type DeviceReceiver interface {
|
|
HotplugAddDevice(Device, config.DeviceType) error
|
|
HotplugRemoveDevice(Device, config.DeviceType) error
|
|
|
|
// this is only for virtio-blk and virtio-scsi support
|
|
GetAndSetSandboxBlockIndex() (int, error)
|
|
DecrementSandboxBlockIndex() error
|
|
|
|
// this is for vhost_user devices
|
|
AddVhostUserDevice(VhostUserDevice, config.DeviceType) error
|
|
}
|
|
|
|
// VhostUserDevice represents a vhost-user device. Shared
|
|
// attributes of a vhost-user device can be retrieved using
|
|
// the Attrs() method. Unique data can be obtained by casting
|
|
// the object to the proper type.
|
|
type VhostUserDevice interface {
|
|
Attrs() *config.VhostUserDeviceAttrs
|
|
Type() config.DeviceType
|
|
}
|
|
|
|
// Device is the virtcontainers device interface.
|
|
type Device interface {
|
|
Attach(DeviceReceiver) error
|
|
Detach(DeviceReceiver) error
|
|
DeviceType() config.DeviceType
|
|
}
|
|
|
|
// DeviceManager can be used to create a new device, this can be used as single
|
|
// device management object.
|
|
type DeviceManager interface {
|
|
NewDevices(devInfos []config.DeviceInfo) ([]Device, error)
|
|
}
|