Added msize and 9p-version flags to mount. Also changed their defaults to be more usable

pull/1705/head
Aaron Prindle 2017-07-17 10:00:41 -07:00
parent 601e762e46
commit 6f42d583d2
4 changed files with 26 additions and 16 deletions

View File

@ -29,14 +29,17 @@ import (
cmdUtil "k8s.io/minikube/cmd/util" cmdUtil "k8s.io/minikube/cmd/util"
"k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/machine" "k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/third_party/go9p/ufs" "k8s.io/minikube/third_party/go9p/ufs"
) )
var mountIP string var mountIP string
var mountVersion string
var isKill bool var isKill bool
var uid int var uid int
var gid int var gid int
var msize int
// mountCmd represents the mount command // mountCmd represents the mount command
var mountCmd = &cobra.Command{ var mountCmd = &cobra.Command{
@ -130,7 +133,7 @@ var mountCmd = &cobra.Command{
ufs.StartServer(net.JoinHostPort(ip.String(), port), debugVal, hostPath) ufs.StartServer(net.JoinHostPort(ip.String(), port), debugVal, hostPath)
wg.Done() 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 { if err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
os.Exit(1) os.Exit(1)
@ -141,8 +144,9 @@ var mountCmd = &cobra.Command{
func init() { func init() {
mountCmd.Flags().StringVar(&mountIP, "ip", "", "Specify the ip that the mount should be setup on") 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().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(&uid, "uid", 1001, "Default user id used for the mount")
mountCmd.Flags().IntVar(&gid, "gid", 1001, "Default group 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")
} }

View File

@ -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 // 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) host, err := CheckIfApiExistsAndLoad(api)
if err != nil { if err != nil {
return errors.Wrap(err, "Error checking that api exists and loading it") 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)) 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 { if err != nil {
return errors.Wrap(err, "Error getting mount command") return errors.Wrap(err, "Error getting mount command")
} }

View File

@ -233,24 +233,28 @@ func GetMountCleanupCommand(path string) string {
var mountTemplate = ` var mountTemplate = `
sudo mkdir -p {{.Path}} || true; 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}};` 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)) t := template.Must(template.New("mountCommand").Parse(mountTemplate))
buf := bytes.Buffer{} buf := bytes.Buffer{}
data := struct { data := struct {
IP string IP string
Path string Path string
Port string Port string
UID int Version string
GID int UID int
GID int
Msize int
}{ }{
IP: ip.String(), IP: ip.String(),
Path: path, Path: path,
Port: port, Port: port,
UID: uid, Version: mountVersion,
GID: gid, UID: uid,
GID: gid,
Msize: msize,
} }
if err := t.Execute(&buf, data); err != nil { if err := t.Execute(&buf, data); err != nil {
return "", err return "", err

View File

@ -133,6 +133,8 @@ const (
DefaultUfsPort = "5640" DefaultUfsPort = "5640"
DefaultUfsDebugLvl = 0 DefaultUfsDebugLvl = 0
DefaultMountEndpoint = "/minikube-host" DefaultMountEndpoint = "/minikube-host"
DefaultMsize = 262144
DefaultMountVersion = "9p2000.u"
) )
const IsMinikubeChildProcess = "IS_MINIKUBE_CHILD_PROCESS" const IsMinikubeChildProcess = "IS_MINIKUBE_CHILD_PROCESS"