Skip to content

Commit

Permalink
Added msize and 9p-version flags to mount. Also changed their default…
Browse files Browse the repository at this point in the history
…s to be more usable
  • Loading branch information
aaron-prindle committed Jul 17, 2017
1 parent 601e762 commit 6f42d58
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
8 changes: 6 additions & 2 deletions cmd/minikube/cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand All @@ -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")
}
4 changes: 2 additions & 2 deletions pkg/minikube/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
}
Expand Down
28 changes: 16 additions & 12 deletions pkg/minikube/cluster/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/minikube/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ const (
DefaultUfsPort = "5640"
DefaultUfsDebugLvl = 0
DefaultMountEndpoint = "/minikube-host"
DefaultMsize = 262144
DefaultMountVersion = "9p2000.u"
)

const IsMinikubeChildProcess = "IS_MINIKUBE_CHILD_PROCESS"

0 comments on commit 6f42d58

Please sign in to comment.