diff --git a/vendor.conf b/vendor.conf index 2b8d6fd5d7..676c4bfdee 100644 --- a/vendor.conf +++ b/vendor.conf @@ -7,7 +7,7 @@ github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://githu github.com/golang/gddo 9b12a26f3fbd7397dee4e20939ddca719d840d2a github.com/gorilla/context v1.1 github.com/gorilla/mux v1.1 -github.com/Microsoft/opengcs v0.3.8 +github.com/Microsoft/opengcs v0.3.9 github.com/kr/pty 5cf931ef8f github.com/mattn/go-shellwords v1.0.3 github.com/sirupsen/logrus v1.0.6 diff --git a/vendor/github.com/Microsoft/opengcs/client/createext4vhdx.go b/vendor/github.com/Microsoft/opengcs/client/createext4vhdx.go index 48daaeb048..8fb7520b41 100644 --- a/vendor/github.com/Microsoft/opengcs/client/createext4vhdx.go +++ b/vendor/github.com/Microsoft/opengcs/client/createext4vhdx.go @@ -97,7 +97,7 @@ func (config *Config) CreateExt4Vhdx(destFile string, sizeGB uint32, cacheFile s return fmt.Errorf("failed to `%s` following hot-add %s to utility VM: %s", testdCommand, destFile, err) } defer testdProc.Close() - testdProc.WaitTimeout(time.Duration(int(time.Second) * config.UvmTimeoutSeconds)) + testdProc.WaitTimeout(time.Second * time.Duration(config.UvmTimeoutSeconds)) testdExitCode, err := testdProc.ExitCode() if err != nil { config.dismount(destFile) @@ -117,7 +117,7 @@ func (config *Config) CreateExt4Vhdx(destFile string, sizeGB uint32, cacheFile s return fmt.Errorf("failed to `%s` following hot-add %s to utility VM: %s", lsCommand, destFile, err) } defer lsProc.Close() - lsProc.WaitTimeout(time.Duration(int(time.Second) * config.UvmTimeoutSeconds)) + lsProc.WaitTimeout(time.Second * time.Duration(config.UvmTimeoutSeconds)) lsExitCode, err := lsProc.ExitCode() if err != nil { config.dismount(destFile) @@ -139,7 +139,7 @@ func (config *Config) CreateExt4Vhdx(destFile string, sizeGB uint32, cacheFile s return fmt.Errorf("failed to RunProcess %q following hot-add %s to utility VM: %s", destFile, mkfsCommand, err) } defer mkfsProc.Close() - mkfsProc.WaitTimeout(time.Duration(int(time.Second) * config.UvmTimeoutSeconds)) + mkfsProc.WaitTimeout(time.Second * time.Duration(config.UvmTimeoutSeconds)) mkfsExitCode, err := mkfsProc.ExitCode() if err != nil { config.dismount(destFile) diff --git a/vendor/github.com/Microsoft/opengcs/client/process.go b/vendor/github.com/Microsoft/opengcs/client/process.go index 822a90b18e..a8ffdf98e6 100644 --- a/vendor/github.com/Microsoft/opengcs/client/process.go +++ b/vendor/github.com/Microsoft/opengcs/client/process.go @@ -158,7 +158,7 @@ func (config *Config) DebugGCS() { logrus.Debugln("benign failure getting gcs logs: ", err) } if proc != nil { - proc.WaitTimeout(time.Duration(int(time.Second) * 30)) + proc.WaitTimeout(time.Second * 30) } logrus.Debugf("GCS Debugging:\n%s\n\nEnd GCS Debugging", strings.TrimSpace(out.String())) } diff --git a/vendor/github.com/Microsoft/opengcs/service/gcsutils/README b/vendor/github.com/Microsoft/opengcs/service/gcsutils/README deleted file mode 100644 index 85e54428a0..0000000000 --- a/vendor/github.com/Microsoft/opengcs/service/gcsutils/README +++ /dev/null @@ -1,4 +0,0 @@ -1. This program only runs in Linux. So you just first copy the files over to a Linux machine. -2. Get Go and and then run make get-deps && make. This is set the $GOPATH for you and build the binaries. -3. vhd_to_tar and tar_to_vhd are the standalone executables that read/write to stdin/out and do the tar <-> vhd conversion. - tar2vhd_server is the service VM server that takes client requests over hvsock. diff --git a/vendor/github.com/Microsoft/opengcs/vsockexec/vsockexec.c b/vendor/github.com/Microsoft/opengcs/vsockexec/vsockexec.c new file mode 100644 index 0000000000..7a26d4c0da --- /dev/null +++ b/vendor/github.com/Microsoft/opengcs/vsockexec/vsockexec.c @@ -0,0 +1,129 @@ +// vsockexec opens vsock connections for the specified stdio descriptors and +// then execs the specified process. + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef USE_TCP +static const int tcpmode = 1; +#else +static const int tcpmode; +#endif + +static int openvsock(unsigned int cid, unsigned int port) +{ + int s = socket(AF_VSOCK, SOCK_STREAM, 0); + if (s < 0) { + perror("socket: AF_VSOCK"); + return -1; + } + + struct sockaddr_vm addr = {0}; + addr.svm_family = AF_VSOCK; + addr.svm_port = port; + addr.svm_cid = cid; + if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + fprintf(stderr, "connect: port %u: %s", port, strerror(errno)); + return -1; + } + + return s; +} + +static int opentcp(unsigned short port) +{ + int s = socket(AF_INET, SOCK_STREAM, 0); + if (s < 0) { + perror("socket: AF_INET"); + return -1; + } + + struct sockaddr_in addr = {0}; + addr.sin_family = AF_INET; + addr.sin_port = htons(port); + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + fprintf(stderr, "connect: port %u: %s\n", port, strerror(errno)); + return -1; + } + + return s; +} + +_Noreturn static void usage(const char *argv0) +{ + fprintf(stderr, "%s [-i port] [-o port] [-e port] -- program [args...]\n", argv0); + exit(1); +} + +int main(int argc, char **argv) +{ + unsigned int ports[3] = {0}; + int sockets[3] = {-1, -1, -1}; + int c; + while ((c = getopt(argc, argv, "+i:o:e:")) != -1) { + switch (c) { + case 'i': + ports[0] = strtoul(optarg, NULL, 10); + break; + + case 'o': + ports[1] = strtoul(optarg, NULL, 10); + break; + + case 'e': + ports[2] = strtoul(optarg, NULL, 10); + break; + + default: + usage(argv[0]); + } + } + + if (optind == argc) { + fprintf(stderr, "%s: missing program argument\n", argv[0]); + usage(argv[0]); + } + + for (int i = 0; i < 3; i++) { + if (ports[i] != 0) { + int j; + for (j = 0; j < i; j++) { + if (ports[i] == ports[j]) { + int s = dup(sockets[j]); + if (s < 0) { + perror("dup"); + return 1; + } + sockets[i] = s; + break; + } + } + + if (j == i) { + int s = tcpmode ? opentcp(ports[i]) : openvsock(VMADDR_CID_HOST, ports[i]); + if (s < 0) { + return 1; + } + sockets[i] = s; + } + } + } + + for (int i = 0; i < 3; i++) { + if (sockets[i] >= 0) { + dup2(sockets[i], i); + close(sockets[i]); + } + } + + execvp(argv[optind], argv + optind); + fprintf(stderr, "execvp: %s: %s\n", argv[optind], strerror(errno)); + return 1; +}