From 0b4f7c2ee7643334a2430df4fe8b36f444caa2a4 Mon Sep 17 00:00:00 2001 From: ChengyuZhu6 Date: Mon, 4 Sep 2023 13:29:16 +0800 Subject: [PATCH] runtime: redefine and add functions to handle VirtualVolume to storage 1) Extract function `handleBlockVolume` to create Storage only. 2) Add functions to handle KataVirtualVolume device and construct corresponding storages. Signed-off-by: ChengyuZhu6 --- src/runtime/virtcontainers/kata_agent.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/runtime/virtcontainers/kata_agent.go b/src/runtime/virtcontainers/kata_agent.go index 3194ec6e84..e4eb2824e4 100644 --- a/src/runtime/virtcontainers/kata_agent.go +++ b/src/runtime/virtcontainers/kata_agent.go @@ -1543,14 +1543,11 @@ func (k *kataAgent) handleLocalStorage(mounts []specs.Mount, sandboxID string, r return localStorages, nil } -// handleDeviceBlockVolume handles volume that is block device file -// and DeviceBlock type. -func (k *kataAgent) handleDeviceBlockVolume(c *Container, m Mount, device api.Device) (*grpc.Storage, error) { +func handleBlockVolume(c *Container, device api.Device) (*grpc.Storage, error) { vol := &grpc.Storage{} blockDrive, ok := device.GetDeviceInfo().(*config.BlockDrive) if !ok || blockDrive == nil { - k.Logger().Error("malformed block drive") return nil, fmt.Errorf("malformed block drive") } switch { @@ -1575,6 +1572,22 @@ func (k *kataAgent) handleDeviceBlockVolume(c *Container, m Mount, device api.De default: return nil, fmt.Errorf("Unknown block device driver: %s", c.sandbox.config.HypervisorConfig.BlockDeviceDriver) } + return vol, nil +} + +// handleVirtualVolumeStorageObject handles KataVirtualVolume that is block device file. +func handleVirtualVolumeStorageObject(c *Container, blockDeviceId string, virtVolume *types.KataVirtualVolume) (*grpc.Storage, error) { + var vol *grpc.Storage = &grpc.Storage{} + return vol, nil +} + +// handleDeviceBlockVolume handles volume that is block device file +// and DeviceBlock type. +func (k *kataAgent) handleDeviceBlockVolume(c *Container, m Mount, device api.Device) (*grpc.Storage, error) { + vol, err := handleBlockVolume(c, device) + if err != nil { + return nil, err + } vol.MountPoint = m.Destination