mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-09-30 19:11:50 +00:00
vendor: Update hyperkit go bindings
This will break compilation, until the next commit Also update some package strings in 'vendor.conf' as the new vndr was complaining about them not being root imports. Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
57
vendor/github.com/docker/hyperkit/go/hyperkit.go
generated
vendored
57
vendor/github.com/docker/hyperkit/go/hyperkit.go
generated
vendored
@@ -31,12 +31,12 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/go-ps"
|
||||
"github.com/rneugeba/iso9660wrap"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -94,10 +94,6 @@ type HyperKit struct {
|
||||
// connected to. ConsoleStdio and ConsoleFile are supported.
|
||||
Console int `json:"console"`
|
||||
|
||||
// UserData, if non empty, will be added to a ISO under the
|
||||
// filename `config` and passed to the VM.
|
||||
UserData string `json:"user_data"`
|
||||
|
||||
// Below here are internal members, but they are exported so
|
||||
// that they are written to the state json file, if configured.
|
||||
|
||||
@@ -118,7 +114,7 @@ type HyperKit struct {
|
||||
// - If vpnkitsock is empty no networking is configured. If it is set
|
||||
// to "auto" it tries to re-use the Docker for Mac VPNKit connection.
|
||||
// - If statedir is "" no state is written to disk.
|
||||
func New(hyperkit, statedir, vpnkitsock, diskimage string) (*HyperKit, error) {
|
||||
func New(hyperkit, vpnkitsock, statedir string) (*HyperKit, error) {
|
||||
h := HyperKit{}
|
||||
var err error
|
||||
|
||||
@@ -131,13 +127,11 @@ func New(hyperkit, statedir, vpnkitsock, diskimage string) (*HyperKit, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
h.DiskImage = diskimage
|
||||
|
||||
h.CPUs = defaultCPUs
|
||||
h.Memory = defaultMemory
|
||||
|
||||
h.Console = ConsoleStdio
|
||||
h.UserData = ""
|
||||
|
||||
return &h, nil
|
||||
}
|
||||
@@ -199,9 +193,6 @@ func (h *HyperKit) execute(cmdline string) error {
|
||||
if h.Console == ConsoleFile && h.StateDir == "" {
|
||||
return fmt.Errorf("If ConsoleFile is set, StateDir must be specified")
|
||||
}
|
||||
if h.UserData != "" && h.ISOImage != "" {
|
||||
return fmt.Errorf("If UserData is supplied, ISOImage must not be set")
|
||||
}
|
||||
if h.ISOImage != "" {
|
||||
if _, err = os.Stat(h.ISOImage); os.IsNotExist(err) {
|
||||
return fmt.Errorf("ISO %s does not exist", h.ISOImage)
|
||||
@@ -210,9 +201,6 @@ func (h *HyperKit) execute(cmdline string) error {
|
||||
if h.VSock && h.StateDir == "" {
|
||||
return fmt.Errorf("If virtio-sockets are enabled, StateDir must be specified")
|
||||
}
|
||||
if h.UserData != "" && h.StateDir == "" {
|
||||
return fmt.Errorf("If UserData is supplied, StateDir must be specified")
|
||||
}
|
||||
if _, err = os.Stat(h.Kernel); os.IsNotExist(err) {
|
||||
return fmt.Errorf("Kernel %s does not exist", h.Kernel)
|
||||
}
|
||||
@@ -241,12 +229,6 @@ func (h *HyperKit) execute(cmdline string) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
if h.UserData != "" {
|
||||
h.ISOImage, err = createUserDataISO(h.StateDir, h.UserData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Run
|
||||
h.buildArgs(cmdline)
|
||||
@@ -331,6 +313,13 @@ func (h *HyperKit) String() string {
|
||||
|
||||
// CreateDiskImage creates a empty file suitable for use as a disk image for a hyperkit VM.
|
||||
func CreateDiskImage(location string, sizeMB int) error {
|
||||
diskDir := path.Dir(location)
|
||||
if diskDir != "." {
|
||||
if err := os.MkdirAll(diskDir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
f, err := os.Create(location)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -446,6 +435,9 @@ func (h *HyperKit) execHyperKit() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// Make sure we reap the child when it exits
|
||||
go cmd.Wait()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -478,31 +470,6 @@ func stream(r io.ReadCloser, dest chan<- string) {
|
||||
}()
|
||||
}
|
||||
|
||||
// Create a ISO with Userdata in the specified directory
|
||||
func createUserDataISO(dir string, init string) (string, error) {
|
||||
cfgName := filepath.Join(dir, "config")
|
||||
isoName := cfgName + ".iso"
|
||||
|
||||
if err := ioutil.WriteFile(cfgName, []byte(init), 0644); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
outfh, err := os.OpenFile(isoName, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
infh, err := os.Open(cfgName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = iso9660wrap.WriteFile(outfh, infh)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return isoName, nil
|
||||
}
|
||||
|
||||
// checkHyperKit tries to find and/or validate the path of hyperkit
|
||||
func checkHyperKit(hyperkit string) (string, error) {
|
||||
if hyperkit != "" {
|
||||
|
Reference in New Issue
Block a user