fix(host): make disk mount point shared for unshared post overlay (#23980)

This commit is contained in:
Zexi Li
2025-12-24 15:33:31 +08:00
committed by GitHub
parent 4dd9e26225
commit 29dc02f484
2 changed files with 14 additions and 0 deletions
@@ -33,6 +33,7 @@ import (
"yunion.io/x/onecloud/pkg/hostman/guestman/desc"
"yunion.io/x/onecloud/pkg/hostman/storageman"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/util/mountutils"
"yunion.io/x/onecloud/pkg/util/procutils"
)
@@ -176,6 +177,11 @@ func (d disk) mountDisk(devPath string, mntPoint string, fs string, resUid int,
if err := container_storage.MountWithResId(devPath, mntPoint, fs, resUid, resGid); err != nil {
return errors.Wrapf(err, "mount %s to %s", devPath, mntPoint)
}
// make mount point shared
if err := mountutils.MakeShared(mntPoint); err != nil {
return errors.Wrapf(err, "mount %s to %s", devPath, mntPoint)
}
return nil
}
+8
View File
@@ -264,3 +264,11 @@ func getMountPointDevices(mountPoint string) ([]string, error) {
}
return devs.List(), nil
}
func MakeShared(mountPoint string) error {
out, err := procutils.NewRemoteCommandAsFarAsPossible("mount", "--make-shared", mountPoint).Output()
if err != nil {
return errors.Wrapf(err, "'mount --make-shared %s' failed: %s", mountPoint, out)
}
return nil
}