mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +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
|
plugin is capable to start/manage several hyperkit instances with with
|
||||||
different configurations and Moby configurations.
|
different configurations and Moby configurations.
|
||||||
|
|
||||||
The plugin keeps state in a local directory (default `./vms`) where
|
The plugin keeps state in a local directory (default
|
||||||
each instance keeps some state in a sub-directory. The VM state
|
`.infrakit/hyperkit-vms`) where each instance keeps some state in a
|
||||||
directory can be specified at the kernel command line using the
|
sub-directory. The VM state directory can be specified at the kernel
|
||||||
`--vm-dir` option.
|
command line using the `--vm-dir` option.
|
||||||
|
|
||||||
## Building
|
## 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:
|
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.
|
where `./vmlib` contains a sub-directory named `default` with a `vmlinuz64` and `initrd.img` image.
|
||||||
|
|
||||||
|
@ -4,7 +4,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/user"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -40,14 +42,9 @@ func main() {
|
|||||||
Use: os.Args[0],
|
Use: os.Args[0],
|
||||||
Short: "HyperKit instance plugin",
|
Short: "HyperKit instance plugin",
|
||||||
}
|
}
|
||||||
defaultVMDir, err := os.Getwd()
|
|
||||||
if err != nil {
|
defaultVMDir := filepath.Join(getHome(), ".infrakit/hyperkit-vms")
|
||||||
log.Error(err)
|
defaultVPNKitSock = path.Join(getHome(), defaultVPNKitSock)
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
defaultVMDir = path.Join(defaultVMDir, "vms")
|
|
||||||
homeDir := os.Getenv("HOME")
|
|
||||||
defaultVPNKitSock = path.Join(homeDir, defaultVPNKitSock)
|
|
||||||
|
|
||||||
name := cmd.Flags().String("name", "instance-hyperkit", "Plugin name to advertise for discovery")
|
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")
|
logLevel := cmd.Flags().Int("log", cli.DefaultLogLevel, "Logging level. 0 is least verbose. Max is 5")
|
||||||
@ -70,6 +67,8 @@ func main() {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.MkdirAll(*vmDir, os.ModePerm)
|
||||||
|
|
||||||
cli.SetLogLevel(*logLevel)
|
cli.SetLogLevel(*logLevel)
|
||||||
cli.RunPlugin(*name,
|
cli.RunPlugin(*name,
|
||||||
instance_plugin.PluginServer(NewHyperKitPlugin(*vmDir, *hyperkit, *vpnkitSock, thyper, tkern)),
|
instance_plugin.PluginServer(NewHyperKitPlugin(*vmDir, *hyperkit, *vpnkitSock, thyper, tkern)),
|
||||||
@ -105,3 +104,10 @@ func main() {
|
|||||||
os.Exit(1)
|
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