vendor: Update hyperkit to latest version

Signed-off-by: Magnus Skjegstad <magnus@skjegstad.com>
This commit is contained in:
Magnus Skjegstad 2017-05-23 12:24:23 +02:00
parent 6b937b37d5
commit 32ee53f14e
6 changed files with 64 additions and 26 deletions

View File

@ -5,7 +5,7 @@ github.com/docker/infrakit cb420e3e50ea60afe58538b1d3cab1cb14059433
github.com/golang/protobuf c9c7427a2a70d2eb3bafa0ab2dc163e45f143317
github.com/googleapis/gax-go 8c5154c0fe5bf18cf649634d4c6df50897a32751
github.com/mitchellh/go-ps 4fdf99ab29366514c69ccccddab5dc58b8d84062
github.com/moby/hyperkit fa78d9472a7d98e393233fd61ad5e95adc8c6912
github.com/moby/hyperkit 95a60c3e75ac73a1cfd73bacdb5de94a737b6095
github.com/packethost/packngo 91d54000aa56874149d348a884ba083c41d38091
github.com/rneugeba/iso9660wrap 4606f848a055435cdef85305960b0e1bb788d506
github.com/satori/go.uuid b061729afc07e77a8aa4fad0a2fd840958f1942a

View File

@ -38,7 +38,7 @@ via `brew` and using `opam` to install the appropriate libraries:
$ brew install opam libev
$ opam init
$ eval `opam config env`
$ opam install uri qcow.0.9.5 mirage-block-unix.2.7.0 conf-libev logs fmt mirage-unix
$ opam install uri qcow.0.10.0 qcow-tool mirage-block-unix.2.7.0 conf-libev logs fmt mirage-unix prometheus-app
Notes:

View File

@ -63,6 +63,12 @@ var defaultHyperKits = []string{"hyperkit",
"/Applications/Docker.app/Contents/Resources/bin/hyperkit",
"/Applications/Docker.app/Contents/MacOS/com.docker.hyperkit"}
// Socket9P contains a unix domain socket path and 9p tag
type Socket9P struct {
Path string `json:"path"`
Tag string `json:"tag"`
}
// HyperKit contains the configuration of the hyperkit VM
type HyperKit struct {
// HyperKit is the path to the hyperkit binary
@ -86,6 +92,9 @@ type HyperKit struct {
// VSock guest CID
VSockGuestCID int `json:"vsock_guest_cid"`
// 9P sockets
Sockets9P []Socket9P `json:"9p_sockets"`
// Kernel is the path to the kernel image to boot
Kernel string `json:"kernel"`
// Initrd is the path to the initial ramdisk to boot off
@ -367,32 +376,49 @@ func (h *HyperKit) buildArgs(cmdline string) {
a = append(a, "-m", fmt.Sprintf("%dM", h.Memory))
a = append(a, "-s", "0:0,hostbridge")
a = append(a, "-s", "31,lpc")
nextSlot := 1
if h.VPNKitSock != "" {
if h.VPNKitKey == "" {
a = append(a, "-s", fmt.Sprintf("1:0,virtio-vpnkit,path=%s", h.VPNKitSock))
a = append(a, "-s", fmt.Sprintf("%d:0,virtio-vpnkit,path=%s", nextSlot, h.VPNKitSock))
} else {
a = append(a, "-s", fmt.Sprintf("1:0,virtio-vpnkit,path=%s,uuid=%s", h.VPNKitSock, h.VPNKitKey))
a = append(a, "-s", fmt.Sprintf("%d:0,virtio-vpnkit,path=%s,uuid=%s", nextSlot, h.VPNKitSock, h.VPNKitKey))
}
nextSlot++
}
if h.UUID != "" {
a = append(a, "-U", h.UUID)
}
if h.DiskImage != "" {
a = append(a, "-s", fmt.Sprintf("2:0,virtio-blk,%s", h.DiskImage))
a = append(a, "-s", fmt.Sprintf("%d:0,virtio-blk,%s", nextSlot, h.DiskImage))
nextSlot++
}
if h.VSock {
l := fmt.Sprintf("3,virtio-sock,guest_cid=%d,path=%s", h.VSockGuestCID, h.StateDir)
l := fmt.Sprintf("%d,virtio-sock,guest_cid=%d,path=%s", nextSlot, h.VSockGuestCID, h.StateDir)
if len(h.VSockPorts) > 0 {
l = fmt.Sprintf("%s,guest_forwards=%s", l, intArrayToString(h.VSockPorts, ";"))
}
a = append(a, "-s", l)
}
if h.ISOImage != "" {
a = append(a, "-s", fmt.Sprintf("4,ahci-cd,%s", h.ISOImage))
nextSlot++
}
a = append(a, "-s", "10,virtio-rnd")
a = append(a, "-s", "31,lpc")
if h.ISOImage != "" {
a = append(a, "-s", fmt.Sprintf("%d,ahci-cd,%s", nextSlot, h.ISOImage))
nextSlot++
}
a = append(a, "-s", fmt.Sprintf("%d,virtio-rnd", nextSlot))
nextSlot++
for _, p := range h.Sockets9P {
a = append(a, "-s", fmt.Sprintf("%d,virtio-9p,path=%s,tag=%s", nextSlot, p.Path, p.Tag))
nextSlot++
}
if h.Console == ConsoleFile {
a = append(a, "-l", fmt.Sprintf("com1,autopty=%s/tty,log=%s/console-ring", h.StateDir, h.StateDir))

View File

@ -563,6 +563,7 @@ blockif_open(const char *optstr, const char *ident)
#ifdef HAVE_OCAML_QCOW
char *mirage_qcow_config = NULL;
char *mirage_qcow_stats_config = NULL;
struct mirage_block_stat msbuf;
#endif
@ -597,6 +598,8 @@ blockif_open(const char *optstr, const char *ident)
use_mirage = 1;
else if (strncmp(cp, "qcow-config=", 12) == 0)
mirage_qcow_config = cp + 12;
else if (strncmp(cp, "qcow-stats-config=", 18) == 0)
mirage_qcow_stats_config = cp + 18;
#endif
else if (sscanf(cp, "sectorsize=%d/%d", &ssopt, &pssopt) == 2)
;
@ -622,7 +625,7 @@ blockif_open(const char *optstr, const char *ident)
if (use_mirage) {
#ifdef HAVE_OCAML_QCOW
mirage_block_register_thread();
mbh = mirage_block_open(nopt, mirage_qcow_config);
mbh = mirage_block_open(nopt, mirage_qcow_config, mirage_qcow_stats_config);
if (mbh < 0) {
perror("Could not open mirage-block device");
goto err;

View File

@ -46,19 +46,26 @@ if (fn == NULL) { \
acquiring the runtime lock. */
static void
ocaml_mirage_block_open(const char *config, const char *options, int *out, int *err) {
ocaml_mirage_block_open(const char *device, const char *qcow_config, const char *stats_config, int *out, int *err) {
CAMLparam0();
CAMLlocal4(ocaml_config, ocaml_options_opt, ocaml_string, handle);
ocaml_config = caml_copy_string(config);
if (options == NULL) {
ocaml_options_opt = Val_int(0); /* None */
CAMLlocal5(ocaml_device, ocaml_qcow_config, ocaml_stats_config, ocaml_string, handle);
ocaml_device = caml_copy_string(device);
if (qcow_config == NULL) {
ocaml_qcow_config = Val_int(0); /* None */
} else {
ocaml_string = caml_copy_string(options);
ocaml_options_opt = caml_alloc(1, 0); /* Some */
Store_field (ocaml_options_opt, 0, ocaml_string);
ocaml_string = caml_copy_string(qcow_config);
ocaml_qcow_config = caml_alloc(1, 0); /* Some */
Store_field (ocaml_qcow_config, 0, ocaml_string);
}
if (stats_config == NULL) {
ocaml_stats_config = Val_int(0); /* None */
} else {
ocaml_string = caml_copy_string(stats_config);
ocaml_stats_config = caml_alloc(1, 0); /* Some */
Store_field (ocaml_stats_config, 0, ocaml_string);
}
OCAML_NAMED_FUNCTION("mirage_block_open")
handle = caml_callback2_exn(*fn, ocaml_config, ocaml_options_opt);
handle = caml_callback3_exn(*fn, ocaml_device, ocaml_qcow_config, ocaml_stats_config);
if (Is_exception_result(handle)){
*err = 1;
} else {
@ -69,11 +76,11 @@ ocaml_mirage_block_open(const char *config, const char *options, int *out, int *
}
mirage_block_handle
mirage_block_open(const char *config, const char *options) {
mirage_block_open(const char *device, const char *qcow_config, const char *stats_config) {
int result;
int err = 1;
caml_acquire_runtime_system();
ocaml_mirage_block_open(config, options, &result, &err);
ocaml_mirage_block_open(device, qcow_config, stats_config, &result, &err);
caml_release_runtime_system();
if (err){
errno = EINVAL;

View File

@ -31,10 +31,12 @@ mirage_block_unregister_thread(void);
/* An opened mirage-block device */
typedef int mirage_block_handle;
/* Open a mirage block device with the given optional string configuration.
To use the default configuration, pass NULL for options. */
/* Open a mirage block device with the given optional qcow and stats
configuration.
To use the default configuration, pass NULL for qcow_config.
To not expose stats, pass NULL for stats_config */
extern mirage_block_handle
mirage_block_open(const char *config, const char *options);
mirage_block_open(const char *device, const char *qcow_config, const char *stats_config);
struct mirage_block_stat {
int candelete; /* 1 if the device supports TRIM/DELETE/DISCARD */