diff --git a/virtcontainers/container.go b/virtcontainers/container.go index 5408d858b..f11fe997b 100644 --- a/virtcontainers/container.go +++ b/virtcontainers/container.go @@ -276,6 +276,7 @@ type Container struct { runPath string configPath string containerPath string + rootfsSuffix string state types.State @@ -640,6 +641,7 @@ func newContainer(sandbox *Sandbox, contConfig ContainerConfig) (*Container, err runPath: store.ContainerRuntimeRootPath(sandbox.id, contConfig.ID), configPath: store.ContainerConfigurationRootPath(sandbox.id, contConfig.ID), containerPath: filepath.Join(sandbox.id, contConfig.ID), + rootfsSuffix: "rootfs", state: types.State{}, process: Process{}, mounts: contConfig.Mounts, @@ -1131,6 +1133,10 @@ func (c *Container) hotplugDrive() error { return nil } + if dev.mountPoint == c.rootFs { + c.rootfsSuffix = "" + } + // If device mapper device, then fetch the full path of the device devicePath, fsType, err := getDevicePathAndFsType(dev.mountPoint) if err != nil { diff --git a/virtcontainers/kata_agent.go b/virtcontainers/kata_agent.go index f07b89106..bec20373e 100644 --- a/virtcontainers/kata_agent.go +++ b/virtcontainers/kata_agent.go @@ -986,7 +986,7 @@ func (k *kataAgent) createContainer(sandbox *Sandbox, c *Container) (p *Process, // This is the guest absolute root path for that container. rootPathParent := filepath.Join(kataGuestSharedDir, c.id) - rootPath := filepath.Join(rootPathParent, rootfsDir) + rootPath := filepath.Join(rootPathParent, c.rootfsSuffix) // In case the container creation fails, the following defer statement // takes care of rolling back actions previously performed.