Added msize and 9p-version flags to mount. Also changed their defaults to be more usable
parent
601e762e46
commit
6f42d583d2
|
@ -29,14 +29,17 @@ import (
|
|||
cmdUtil "k8s.io/minikube/cmd/util"
|
||||
"k8s.io/minikube/pkg/minikube/cluster"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/machine"
|
||||
"k8s.io/minikube/third_party/go9p/ufs"
|
||||
)
|
||||
|
||||
var mountIP string
|
||||
var mountVersion string
|
||||
var isKill bool
|
||||
var uid int
|
||||
var gid int
|
||||
var msize int
|
||||
|
||||
// mountCmd represents the mount command
|
||||
var mountCmd = &cobra.Command{
|
||||
|
@ -130,7 +133,7 @@ var mountCmd = &cobra.Command{
|
|||
ufs.StartServer(net.JoinHostPort(ip.String(), port), debugVal, hostPath)
|
||||
wg.Done()
|
||||
}()
|
||||
err = cluster.MountHost(api, vmPath, ip, port, uid, gid)
|
||||
err = cluster.MountHost(api, ip, vmPath, port, mountVersion, uid, gid, msize)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
|
@ -141,8 +144,9 @@ var mountCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
mountCmd.Flags().StringVar(&mountIP, "ip", "", "Specify the ip that the mount should be setup on")
|
||||
mountCmd.Flags().StringVar(&mountVersion, "9p-version", constants.DefaultMountVersion, "Specify the 9p version that the mount should use")
|
||||
mountCmd.Flags().BoolVar(&isKill, "kill", false, "Kill the mount process spawned by minikube start")
|
||||
mountCmd.Flags().IntVar(&uid, "uid", 1001, "Default user id used for the mount")
|
||||
mountCmd.Flags().IntVar(&gid, "gid", 1001, "Default group id used for the mount")
|
||||
RootCmd.AddCommand(mountCmd)
|
||||
mountCmd.Flags().IntVar(&msize, "msize", constants.DefaultMsize, "The number of bytes to use for 9p packet payload")
|
||||
}
|
||||
|
|
|
@ -449,7 +449,7 @@ func GetHostLogs(api libmachine.API, follow bool) (string, error) {
|
|||
}
|
||||
|
||||
// MountHost runs the mount command from the 9p client on the VM to the 9p server on the host
|
||||
func MountHost(api libmachine.API, path string, ip net.IP, port string, uid, gid int) error {
|
||||
func MountHost(api libmachine.API, ip net.IP, path, mountVersion, port string, uid, gid, msize int) error {
|
||||
host, err := CheckIfApiExistsAndLoad(api)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error checking that api exists and loading it")
|
||||
|
@ -461,7 +461,7 @@ func MountHost(api libmachine.API, path string, ip net.IP, port string, uid, gid
|
|||
}
|
||||
}
|
||||
host.RunSSHCommand(GetMountCleanupCommand(path))
|
||||
mountCmd, err := GetMountCommand(ip, path, port, uid, gid)
|
||||
mountCmd, err := GetMountCommand(ip, path, port, mountVersion, uid, gid, msize)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error getting mount command")
|
||||
}
|
||||
|
|
|
@ -233,24 +233,28 @@ func GetMountCleanupCommand(path string) string {
|
|||
|
||||
var mountTemplate = `
|
||||
sudo mkdir -p {{.Path}} || true;
|
||||
sudo mount -t 9p -o trans=tcp -o port={{.Port}} -o dfltuid={{.UID}} -o dfltgid={{.GID}} {{.IP}} {{.Path}};
|
||||
sudo mount -t 9p -o trans=tcp,port={{.Port}},dfltuid={{.UID}},dfltgid={{.GID}},version={{.Version}},msize={{.Msize}} {{.IP}} {{.Path}};
|
||||
sudo chmod 775 {{.Path}};`
|
||||
|
||||
func GetMountCommand(ip net.IP, path, port string, uid, gid int) (string, error) {
|
||||
func GetMountCommand(ip net.IP, path, port, mountVersion string, uid, gid, msize int) (string, error) {
|
||||
t := template.Must(template.New("mountCommand").Parse(mountTemplate))
|
||||
buf := bytes.Buffer{}
|
||||
data := struct {
|
||||
IP string
|
||||
Path string
|
||||
Port string
|
||||
UID int
|
||||
GID int
|
||||
IP string
|
||||
Path string
|
||||
Port string
|
||||
Version string
|
||||
UID int
|
||||
GID int
|
||||
Msize int
|
||||
}{
|
||||
IP: ip.String(),
|
||||
Path: path,
|
||||
Port: port,
|
||||
UID: uid,
|
||||
GID: gid,
|
||||
IP: ip.String(),
|
||||
Path: path,
|
||||
Port: port,
|
||||
Version: mountVersion,
|
||||
UID: uid,
|
||||
GID: gid,
|
||||
Msize: msize,
|
||||
}
|
||||
if err := t.Execute(&buf, data); err != nil {
|
||||
return "", err
|
||||
|
|
|
@ -133,6 +133,8 @@ const (
|
|||
DefaultUfsPort = "5640"
|
||||
DefaultUfsDebugLvl = 0
|
||||
DefaultMountEndpoint = "/minikube-host"
|
||||
DefaultMsize = 262144
|
||||
DefaultMountVersion = "9p2000.u"
|
||||
)
|
||||
|
||||
const IsMinikubeChildProcess = "IS_MINIKUBE_CHILD_PROCESS"
|
||||
|
|
Loading…
Reference in New Issue