mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-24 16:54:26 +01:00
runtime: device/persist: drop persist dependency from device pkgs
Rather than have device package depend on persist, let's define the (almost duplicate) structures within device itself, and have the Kata Container's persist pkg import these. This'll help avoid unecessary dependencies within our core packages. Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
|
||||
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
)
|
||||
|
||||
@@ -159,13 +158,13 @@ func (device *BlockDevice) GetDeviceInfo() interface{} {
|
||||
}
|
||||
|
||||
// Save converts Device to DeviceState
|
||||
func (device *BlockDevice) Save() persistapi.DeviceState {
|
||||
func (device *BlockDevice) Save() config.DeviceState {
|
||||
ds := device.GenericDevice.Save()
|
||||
ds.Type = string(device.DeviceType())
|
||||
|
||||
drive := device.BlockDrive
|
||||
if drive != nil {
|
||||
ds.BlockDrive = &persistapi.BlockDrive{
|
||||
ds.BlockDrive = &config.BlockDriveState{
|
||||
File: drive.File,
|
||||
Format: drive.Format,
|
||||
ID: drive.ID,
|
||||
@@ -183,7 +182,7 @@ func (device *BlockDevice) Save() persistapi.DeviceState {
|
||||
}
|
||||
|
||||
// Load loads DeviceState and converts it to specific device
|
||||
func (device *BlockDevice) Load(ds persistapi.DeviceState) {
|
||||
func (device *BlockDevice) Load(ds config.DeviceState) {
|
||||
device.GenericDevice = &GenericDevice{}
|
||||
device.GenericDevice.Load(ds)
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
|
||||
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
|
||||
)
|
||||
|
||||
// GenericDevice refers to a device that is neither a VFIO device, block device or VhostUserDevice.
|
||||
@@ -128,8 +127,8 @@ func (device *GenericDevice) bumpAttachCount(attach bool) (skip bool, err error)
|
||||
}
|
||||
|
||||
// Save converts Device to DeviceState
|
||||
func (device *GenericDevice) Save() persistapi.DeviceState {
|
||||
dss := persistapi.DeviceState{
|
||||
func (device *GenericDevice) Save() config.DeviceState {
|
||||
dss := config.DeviceState{
|
||||
ID: device.ID,
|
||||
Type: string(device.DeviceType()),
|
||||
RefCount: device.RefCount,
|
||||
@@ -148,7 +147,7 @@ func (device *GenericDevice) Save() persistapi.DeviceState {
|
||||
}
|
||||
|
||||
// Load loads DeviceState and converts it to specific device
|
||||
func (device *GenericDevice) Load(ds persistapi.DeviceState) {
|
||||
func (device *GenericDevice) Load(ds config.DeviceState) {
|
||||
device.ID = ds.ID
|
||||
device.RefCount = ds.RefCount
|
||||
device.AttachCount = ds.AttachCount
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
|
||||
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
)
|
||||
|
||||
@@ -174,14 +173,14 @@ func (device *VFIODevice) GetDeviceInfo() interface{} {
|
||||
}
|
||||
|
||||
// Save converts Device to DeviceState
|
||||
func (device *VFIODevice) Save() persistapi.DeviceState {
|
||||
func (device *VFIODevice) Save() config.DeviceState {
|
||||
ds := device.GenericDevice.Save()
|
||||
ds.Type = string(device.DeviceType())
|
||||
|
||||
devs := device.VfioDevs
|
||||
for _, dev := range devs {
|
||||
if dev != nil {
|
||||
ds.VFIODevs = append(ds.VFIODevs, &persistapi.VFIODev{
|
||||
ds.VFIODevs = append(ds.VFIODevs, &config.VFIODevState{
|
||||
ID: dev.ID,
|
||||
Type: uint32(dev.Type),
|
||||
BDF: dev.BDF,
|
||||
@@ -193,7 +192,7 @@ func (device *VFIODevice) Save() persistapi.DeviceState {
|
||||
}
|
||||
|
||||
// Load loads DeviceState and converts it to specific device
|
||||
func (device *VFIODevice) Load(ds persistapi.DeviceState) {
|
||||
func (device *VFIODevice) Load(ds config.DeviceState) {
|
||||
device.GenericDevice = &GenericDevice{}
|
||||
device.GenericDevice.Load(ds)
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
|
||||
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -156,13 +155,13 @@ func (device *VhostUserBlkDevice) GetDeviceInfo() interface{} {
|
||||
}
|
||||
|
||||
// Save converts Device to DeviceState
|
||||
func (device *VhostUserBlkDevice) Save() persistapi.DeviceState {
|
||||
func (device *VhostUserBlkDevice) Save() config.DeviceState {
|
||||
ds := device.GenericDevice.Save()
|
||||
ds.Type = string(device.DeviceType())
|
||||
|
||||
vAttr := device.VhostUserDeviceAttrs
|
||||
if vAttr != nil {
|
||||
ds.VhostUserDev = &persistapi.VhostUserDeviceAttrs{
|
||||
ds.VhostUserDev = &config.VhostUserDeviceAttrsState{
|
||||
DevID: vAttr.DevID,
|
||||
SocketPath: vAttr.SocketPath,
|
||||
Type: string(vAttr.Type),
|
||||
@@ -174,7 +173,7 @@ func (device *VhostUserBlkDevice) Save() persistapi.DeviceState {
|
||||
}
|
||||
|
||||
// Load loads DeviceState and converts it to specific device
|
||||
func (device *VhostUserBlkDevice) Load(ds persistapi.DeviceState) {
|
||||
func (device *VhostUserBlkDevice) Load(ds config.DeviceState) {
|
||||
device.GenericDevice = &GenericDevice{}
|
||||
device.GenericDevice.Load(ds)
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
|
||||
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
)
|
||||
|
||||
@@ -75,10 +74,10 @@ func (device *VhostUserNetDevice) GetDeviceInfo() interface{} {
|
||||
}
|
||||
|
||||
// Save converts Device to DeviceState
|
||||
func (device *VhostUserNetDevice) Save() persistapi.DeviceState {
|
||||
func (device *VhostUserNetDevice) Save() config.DeviceState {
|
||||
ds := device.GenericDevice.Save()
|
||||
ds.Type = string(device.DeviceType())
|
||||
ds.VhostUserDev = &persistapi.VhostUserDeviceAttrs{
|
||||
ds.VhostUserDev = &config.VhostUserDeviceAttrsState{
|
||||
DevID: device.DevID,
|
||||
SocketPath: device.SocketPath,
|
||||
Type: string(device.Type),
|
||||
@@ -88,7 +87,7 @@ func (device *VhostUserNetDevice) Save() persistapi.DeviceState {
|
||||
}
|
||||
|
||||
// Load loads DeviceState and converts it to specific device
|
||||
func (device *VhostUserNetDevice) Load(ds persistapi.DeviceState) {
|
||||
func (device *VhostUserNetDevice) Load(ds config.DeviceState) {
|
||||
device.GenericDevice = &GenericDevice{}
|
||||
device.GenericDevice.Load(ds)
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/device/config"
|
||||
persistapi "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"
|
||||
)
|
||||
|
||||
@@ -75,10 +74,10 @@ func (device *VhostUserSCSIDevice) GetDeviceInfo() interface{} {
|
||||
}
|
||||
|
||||
// Save converts Device to DeviceState
|
||||
func (device *VhostUserSCSIDevice) Save() persistapi.DeviceState {
|
||||
func (device *VhostUserSCSIDevice) Save() config.DeviceState {
|
||||
ds := device.GenericDevice.Save()
|
||||
ds.Type = string(device.DeviceType())
|
||||
ds.VhostUserDev = &persistapi.VhostUserDeviceAttrs{
|
||||
ds.VhostUserDev = &config.VhostUserDeviceAttrsState{
|
||||
DevID: device.DevID,
|
||||
SocketPath: device.SocketPath,
|
||||
Type: string(device.Type),
|
||||
@@ -88,7 +87,7 @@ func (device *VhostUserSCSIDevice) Save() persistapi.DeviceState {
|
||||
}
|
||||
|
||||
// Load loads DeviceState and converts it to specific device
|
||||
func (device *VhostUserSCSIDevice) Load(ds persistapi.DeviceState) {
|
||||
func (device *VhostUserSCSIDevice) Load(ds config.DeviceState) {
|
||||
device.GenericDevice = &GenericDevice{}
|
||||
device.GenericDevice.Load(ds)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user