From 4fbe0a3a5336c28e94e6040fc3ed03bab7c6a5c8 Mon Sep 17 00:00:00 2001 From: Wedson Almeida Filho Date: Fri, 16 Jun 2023 00:44:34 -0300 Subject: [PATCH] runtime: bind-mount mounted block device into container When the mounted block device isn't a layer, we want to mount it into containers, but since it's already mounted with the correct fs (e.g., tar, ext4, etc.) in the pod, we just bind-mount it into the container. Fixes: #7536 Signed-off-by: Wedson Almeida Filho --- src/runtime/virtcontainers/kata_agent.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/virtcontainers/kata_agent.go b/src/runtime/virtcontainers/kata_agent.go index e102484c4c..810deeee54 100644 --- a/src/runtime/virtcontainers/kata_agent.go +++ b/src/runtime/virtcontainers/kata_agent.go @@ -1662,6 +1662,10 @@ func (k *kataAgent) handleBlkOCIMounts(c *Container, spec *specs.Spec) ([]*grpc. "new-source": path, }).Debug("Replacing OCI mount source") spec.Mounts[idx].Source = path + if HasOption(spec.Mounts[idx].Options, vcAnnotations.IsFileBlockDevice) { + // The device is already mounted, just bind to path in container. + spec.Mounts[idx].Options = []string{"bind"} + } break }