mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(host): make disk mount point shared for unshared post overlay (#23980)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user