mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-18 17:01:07 +00:00
cmd: Add a -state option to hyperkit runner (and enable vsock)
The state directory is used to store: - the disk image, if not specified via '-disk' - the ISO for metadata, if '-data' is used - the Unix domain socket for virtio sockets - the PID of the hyperkit process - a JSON file with the hyperkit configuration This patch also enables the virtio socket device for the VM. While at it, also fix .gitignore to ignore kernel images again. Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
5f5c27cbba
commit
5231e06dec
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,6 +11,7 @@ Dockerfile.media
|
||||
*.vhdx
|
||||
*.efi
|
||||
*.qcow2
|
||||
*-kernel$
|
||||
*-kernel
|
||||
*-cmdline
|
||||
*-state
|
||||
artifacts/*
|
||||
|
2
Makefile
2
Makefile
@ -74,4 +74,4 @@ ci-pr:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf bin *.log *-kernel *-cmdline *.img *.iso *.gz *.qcow2 *.vhd *.vmx *.vmdk *.tar
|
||||
rm -rf bin *.log *-kernel *-cmdline *-state *.img *.iso *.gz *.qcow2 *.vhd *.vmx *.vmdk *.tar
|
||||
|
@ -31,6 +31,7 @@ func runHyperKit(args []string) {
|
||||
disk := hyperkitCmd.String("disk", "", "Path to disk image to used")
|
||||
data := hyperkitCmd.String("data", "", "Metadata to pass to VM (either a path to a file or a string)")
|
||||
ipStr := hyperkitCmd.String("ip", "", "IP address for the VM")
|
||||
state := hyperkitCmd.String("state", "", "Path to directory to keep VM state in")
|
||||
|
||||
if err := hyperkitCmd.Parse(args); err != nil {
|
||||
log.Fatal("Unable to parse args")
|
||||
@ -43,6 +44,13 @@ func runHyperKit(args []string) {
|
||||
}
|
||||
prefix := remArgs[0]
|
||||
|
||||
if *state == "" {
|
||||
*state = prefix + "-state"
|
||||
}
|
||||
if err := os.MkdirAll(*state, 0755); err != nil {
|
||||
log.Fatalf("Could not create state directory: %v", err)
|
||||
}
|
||||
|
||||
isoPath := ""
|
||||
if *data != "" {
|
||||
var d []byte
|
||||
@ -54,9 +62,9 @@ func runHyperKit(args []string) {
|
||||
log.Fatalf("Cannot read user data: %v", err)
|
||||
}
|
||||
}
|
||||
isoPath = prefix + "-data.iso"
|
||||
isoPath = filepath.Join(*state, "data.iso")
|
||||
if err := WriteMetadataISO(isoPath, d); err != nil {
|
||||
log.Fatalf("Cannot write user data ISO: %s", err)
|
||||
log.Fatalf("Cannot write user data ISO: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,10 +92,10 @@ func runHyperKit(args []string) {
|
||||
}
|
||||
|
||||
if *diskSz != 0 && *disk == "" {
|
||||
*disk = prefix + "-disk.img"
|
||||
*disk = filepath.Join(*state, "disk.img")
|
||||
}
|
||||
|
||||
h, err := hyperkit.New(*hyperkitPath, "auto", "")
|
||||
h, err := hyperkit.New(*hyperkitPath, "auto", *state)
|
||||
if err != nil {
|
||||
log.Fatalln("Error creating hyperkit: ", err)
|
||||
}
|
||||
@ -98,6 +106,7 @@ func runHyperKit(args []string) {
|
||||
h.UUID = vmUUID
|
||||
h.DiskImage = *disk
|
||||
h.ISOImage = isoPath
|
||||
h.VSock = true
|
||||
h.CPUs = *cpus
|
||||
h.Memory = *mem
|
||||
h.DiskSize = *diskSz
|
||||
|
Loading…
Reference in New Issue
Block a user