mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 01:29:07 +00:00
infrakit: Move default VM directory to .infrakit/hyperkit-vms
Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
95fa38f879
commit
d1ad02e079
@ -4,10 +4,10 @@ This is a Hyper/Kit Moby instance plugin for infrakit. The instance
|
||||
plugin is capable to start/manage several hyperkit instances with with
|
||||
different configurations and Moby configurations.
|
||||
|
||||
The plugin keeps state in a local directory (default `./vms`) where
|
||||
each instance keeps some state in a sub-directory. The VM state
|
||||
directory can be specified at the kernel command line using the
|
||||
`--vm-dir` option.
|
||||
The plugin keeps state in a local directory (default
|
||||
`.infrakit/hyperkit-vms`) where each instance keeps some state in a
|
||||
sub-directory. The VM state directory can be specified at the kernel
|
||||
command line using the `--vm-dir` option.
|
||||
|
||||
## Building
|
||||
|
||||
@ -20,7 +20,7 @@ make
|
||||
|
||||
To play round with the plugin, simply follow the [infrakit tutorial](https://github.com/docker/infrakit/blob/master/docs/tutorial.md) and replace the file instance plugin with:
|
||||
```
|
||||
./build/infrakit-instance-hyperkit --vm-lib ./vmlib
|
||||
./build/infrakit-instance-hyperkit
|
||||
```
|
||||
where `./vmlib` contains a sub-directory named `default` with a `vmlinuz64` and `initrd.img` image.
|
||||
|
||||
|
@ -4,7 +4,9 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
@ -40,14 +42,9 @@ func main() {
|
||||
Use: os.Args[0],
|
||||
Short: "HyperKit instance plugin",
|
||||
}
|
||||
defaultVMDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defaultVMDir = path.Join(defaultVMDir, "vms")
|
||||
homeDir := os.Getenv("HOME")
|
||||
defaultVPNKitSock = path.Join(homeDir, defaultVPNKitSock)
|
||||
|
||||
defaultVMDir := filepath.Join(getHome(), ".infrakit/hyperkit-vms")
|
||||
defaultVPNKitSock = path.Join(getHome(), defaultVPNKitSock)
|
||||
|
||||
name := cmd.Flags().String("name", "instance-hyperkit", "Plugin name to advertise for discovery")
|
||||
logLevel := cmd.Flags().Int("log", cli.DefaultLogLevel, "Logging level. 0 is least verbose. Max is 5")
|
||||
@ -70,6 +67,8 @@ func main() {
|
||||
return err
|
||||
}
|
||||
|
||||
os.MkdirAll(*vmDir, os.ModePerm)
|
||||
|
||||
cli.SetLogLevel(*logLevel)
|
||||
cli.RunPlugin(*name,
|
||||
instance_plugin.PluginServer(NewHyperKitPlugin(*vmDir, *hyperkit, *vpnkitSock, thyper, tkern)),
|
||||
@ -105,3 +104,10 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func getHome() string {
|
||||
if usr, err := user.Current(); err == nil {
|
||||
return usr.HomeDir
|
||||
}
|
||||
return os.Getenv("HOME")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user