Skip to content

Commit 9e8ef22

Browse files
Merge pull request #1705 from aaron-prindle/msize
Added msize and 9p-version flags to mount. Also changed their defaul…
2 parents 32dc5d0 + 6f42d58 commit 9e8ef22

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

cmd/minikube/cmd/mount.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ import (
2929
cmdUtil "k8s.io/minikube/cmd/util"
3030
"k8s.io/minikube/pkg/minikube/cluster"
3131
"k8s.io/minikube/pkg/minikube/config"
32+
"k8s.io/minikube/pkg/minikube/constants"
3233
"k8s.io/minikube/pkg/minikube/machine"
3334
"k8s.io/minikube/third_party/go9p/ufs"
3435
)
3536

3637
var mountIP string
38+
var mountVersion string
3739
var isKill bool
3840
var uid int
3941
var gid int
42+
var msize int
4043

4144
// mountCmd represents the mount command
4245
var mountCmd = &cobra.Command{
@@ -130,7 +133,7 @@ var mountCmd = &cobra.Command{
130133
ufs.StartServer(net.JoinHostPort(ip.String(), port), debugVal, hostPath)
131134
wg.Done()
132135
}()
133-
err = cluster.MountHost(api, vmPath, ip, port, uid, gid)
136+
err = cluster.MountHost(api, ip, vmPath, port, mountVersion, uid, gid, msize)
134137
if err != nil {
135138
fmt.Println(err.Error())
136139
os.Exit(1)
@@ -141,8 +144,9 @@ var mountCmd = &cobra.Command{
141144

142145
func init() {
143146
mountCmd.Flags().StringVar(&mountIP, "ip", "", "Specify the ip that the mount should be setup on")
147+
mountCmd.Flags().StringVar(&mountVersion, "9p-version", constants.DefaultMountVersion, "Specify the 9p version that the mount should use")
144148
mountCmd.Flags().BoolVar(&isKill, "kill", false, "Kill the mount process spawned by minikube start")
145149
mountCmd.Flags().IntVar(&uid, "uid", 1001, "Default user id used for the mount")
146150
mountCmd.Flags().IntVar(&gid, "gid", 1001, "Default group id used for the mount")
147-
RootCmd.AddCommand(mountCmd)
151+
mountCmd.Flags().IntVar(&msize, "msize", constants.DefaultMsize, "The number of bytes to use for 9p packet payload")
148152
}

pkg/minikube/cluster/cluster.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ func GetHostLogs(api libmachine.API, follow bool) (string, error) {
449449
}
450450

451451
// MountHost runs the mount command from the 9p client on the VM to the 9p server on the host
452-
func MountHost(api libmachine.API, path string, ip net.IP, port string, uid, gid int) error {
452+
func MountHost(api libmachine.API, ip net.IP, path, mountVersion, port string, uid, gid, msize int) error {
453453
host, err := CheckIfApiExistsAndLoad(api)
454454
if err != nil {
455455
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
461461
}
462462
}
463463
host.RunSSHCommand(GetMountCleanupCommand(path))
464-
mountCmd, err := GetMountCommand(ip, path, port, uid, gid)
464+
mountCmd, err := GetMountCommand(ip, path, port, mountVersion, uid, gid, msize)
465465
if err != nil {
466466
return errors.Wrap(err, "Error getting mount command")
467467
}

pkg/minikube/cluster/commands.go

+16-12
Original file line numberDiff line numberDiff line change
@@ -233,24 +233,28 @@ func GetMountCleanupCommand(path string) string {
233233

234234
var mountTemplate = `
235235
sudo mkdir -p {{.Path}} || true;
236-
sudo mount -t 9p -o trans=tcp -o port={{.Port}} -o dfltuid={{.UID}} -o dfltgid={{.GID}} {{.IP}} {{.Path}};
236+
sudo mount -t 9p -o trans=tcp,port={{.Port}},dfltuid={{.UID}},dfltgid={{.GID}},version={{.Version}},msize={{.Msize}} {{.IP}} {{.Path}};
237237
sudo chmod 775 {{.Path}};`
238238

239-
func GetMountCommand(ip net.IP, path, port string, uid, gid int) (string, error) {
239+
func GetMountCommand(ip net.IP, path, port, mountVersion string, uid, gid, msize int) (string, error) {
240240
t := template.Must(template.New("mountCommand").Parse(mountTemplate))
241241
buf := bytes.Buffer{}
242242
data := struct {
243-
IP string
244-
Path string
245-
Port string
246-
UID int
247-
GID int
243+
IP string
244+
Path string
245+
Port string
246+
Version string
247+
UID int
248+
GID int
249+
Msize int
248250
}{
249-
IP: ip.String(),
250-
Path: path,
251-
Port: port,
252-
UID: uid,
253-
GID: gid,
251+
IP: ip.String(),
252+
Path: path,
253+
Port: port,
254+
Version: mountVersion,
255+
UID: uid,
256+
GID: gid,
257+
Msize: msize,
254258
}
255259
if err := t.Execute(&buf, data); err != nil {
256260
return "", err

pkg/minikube/constants/constants.go

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ const (
133133
DefaultUfsPort = "5640"
134134
DefaultUfsDebugLvl = 0
135135
DefaultMountEndpoint = "/minikube-host"
136+
DefaultMsize = 262144
137+
DefaultMountVersion = "9p2000.u"
136138
)
137139

138140
const IsMinikubeChildProcess = "IS_MINIKUBE_CHILD_PROCESS"

0 commit comments

Comments
 (0)