mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-03 09:54:33 +00:00
Merge pull request #2220 from tedyu/new-mount-map
vc: Utilize map for newMounts to speed up replaceOCIMountSource
This commit is contained in:
@@ -542,8 +542,8 @@ func (c *Container) shareFiles(m Mount, idx int, hostSharedDir, guestSharedDir s
|
|||||||
// It also updates the container mount list with the HostPath info, and store
|
// It also updates the container mount list with the HostPath info, and store
|
||||||
// container mounts to the storage. This way, we will have the HostPath info
|
// container mounts to the storage. This way, we will have the HostPath info
|
||||||
// available when we will need to unmount those mounts.
|
// available when we will need to unmount those mounts.
|
||||||
func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) ([]Mount, []Mount, error) {
|
func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) (map[string]Mount, []Mount, error) {
|
||||||
var sharedDirMounts []Mount
|
sharedDirMounts := make(map[string]Mount)
|
||||||
var ignoredMounts []Mount
|
var ignoredMounts []Mount
|
||||||
for idx, m := range c.mounts {
|
for idx, m := range c.mounts {
|
||||||
// Skip mounting certain system paths from the source on the host side
|
// Skip mounting certain system paths from the source on the host side
|
||||||
@@ -616,7 +616,7 @@ func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) (
|
|||||||
ReadOnly: readonly,
|
ReadOnly: readonly,
|
||||||
}
|
}
|
||||||
|
|
||||||
sharedDirMounts = append(sharedDirMounts, sharedDirMount)
|
sharedDirMounts[sharedDirMount.Destination] = sharedDirMount
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.sandbox.supportNewStore() {
|
if !c.sandbox.supportNewStore() {
|
||||||
|
@@ -962,15 +962,11 @@ func (k *kataAgent) stopSandbox(sandbox *Sandbox) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) replaceOCIMountSource(spec *specs.Spec, guestMounts []Mount) error {
|
func (k *kataAgent) replaceOCIMountSource(spec *specs.Spec, guestMounts map[string]Mount) error {
|
||||||
ociMounts := spec.Mounts
|
ociMounts := spec.Mounts
|
||||||
|
|
||||||
for index, m := range ociMounts {
|
for index, m := range ociMounts {
|
||||||
for _, guestMount := range guestMounts {
|
if guestMount, ok := guestMounts[m.Destination]; ok {
|
||||||
if guestMount.Destination != m.Destination {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
k.Logger().Debugf("Replacing OCI mount (%s) source %s with %s", m.Destination, m.Source, guestMount.Source)
|
k.Logger().Debugf("Replacing OCI mount (%s) source %s with %s", m.Destination, m.Source, guestMount.Source)
|
||||||
ociMounts[index].Source = guestMount.Source
|
ociMounts[index].Source = guestMount.Source
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user