From 330913cadf1fcca00be4b6b841ceb8d14471f470 Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 22 Jun 2017 14:06:40 -0700 Subject: [PATCH 1/3] LCOW: Update for platforms latest schema Signed-off-by: John Howard --- libcontainerd/client_windows.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libcontainerd/client_windows.go b/libcontainerd/client_windows.go index e9f7e696d47a8..d7f312e6e41fe 100644 --- a/libcontainerd/client_windows.go +++ b/libcontainerd/client_windows.go @@ -299,7 +299,9 @@ func (clnt *client) createLinux(containerID string, checkpoint string, checkpoin Owner: defaultOwner, TerminateOnLastHandleClosed: true, HvRuntime: &hcsshim.HvRuntime{ - ImagePath: `c:\program files\lcow`, + ImagePath: `c:\program files\lcow`, + LinuxKernelFile: `bootx64.efi`, + LinuxInitrdFile: `initrd.img`, }, } From 9508c605d882a5981a480ab0a07cc9b77568b4d8 Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 22 Jun 2017 14:14:38 -0700 Subject: [PATCH 2/3] Vendor Microsoft/hcsshim v0.5.25 Signed-off-by: John Howard --- vendor.conf | 2 +- vendor/github.com/Microsoft/hcsshim/interface.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vendor.conf b/vendor.conf index aae9ba7c8dfa2..e4b1fe1d2cbe0 100644 --- a/vendor.conf +++ b/vendor.conf @@ -1,6 +1,6 @@ # the following lines are in sorted order, FYI github.com/Azure/go-ansiterm 388960b655244e76e24c75f48631564eaefade62 -github.com/Microsoft/hcsshim v0.5.23 +github.com/Microsoft/hcsshim v0.5.25 github.com/Microsoft/go-winio v0.4.2 github.com/Sirupsen/logrus v0.11.0 github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 diff --git a/vendor/github.com/Microsoft/hcsshim/interface.go b/vendor/github.com/Microsoft/hcsshim/interface.go index a499fe46a07b1..5238a641ea12a 100644 --- a/vendor/github.com/Microsoft/hcsshim/interface.go +++ b/vendor/github.com/Microsoft/hcsshim/interface.go @@ -11,6 +11,7 @@ import ( type ProcessConfig struct { ApplicationName string `json:",omitempty"` CommandLine string `json:",omitempty"` + CommandArgs []string `json:",omitempty"` // Used by Linux Containers on Windows User string `json:",omitempty"` WorkingDirectory string `json:",omitempty"` Environment map[string]string `json:",omitempty"` @@ -39,8 +40,8 @@ type MappedDir struct { type HvRuntime struct { ImagePath string `json:",omitempty"` SkipTemplate bool `json:",omitempty"` - LinuxInitrdPath string `json:",omitempty"` // Host path to an initrd image for starting a Linux utility VM - LinuxKernelPath string `json:",omitempty"` // Host path to kernel for starting a Linux utility VM + LinuxInitrdFile string `json:",omitempty"` // File under ImagePath on host containing an initrd image for starting a Linux utility VM + LinuxKernelFile string `json:",omitempty"` // File under ImagePath on host containing a kernel for starting a Linux utility VM } type MappedVirtualDisk struct { From c75db46d5b4faae326793b7c6c5fc35be39fca7d Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 22 Jun 2017 14:13:46 -0700 Subject: [PATCH 3/3] Vendor jhowardmsft/opengcs v0.0.4 Signed-off-by: John Howard --- vendor.conf | 2 +- .../opengcs/gogcs/client/config.go | 71 ++++++++++--------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/vendor.conf b/vendor.conf index e4b1fe1d2cbe0..f434435c4b98d 100644 --- a/vendor.conf +++ b/vendor.conf @@ -8,7 +8,7 @@ github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git github.com/gorilla/context v1.1 github.com/gorilla/mux v1.1 -github.com/jhowardmsft/opengcs v0.0.3 +github.com/jhowardmsft/opengcs v0.0.4 github.com/kr/pty 5cf931ef8f github.com/mattn/go-shellwords v1.0.3 github.com/tchap/go-patricia v2.2.6 diff --git a/vendor/github.com/jhowardmsft/opengcs/gogcs/client/config.go b/vendor/github.com/jhowardmsft/opengcs/gogcs/client/config.go index db4ccb6f6d90d..830d37bef0bfe 100644 --- a/vendor/github.com/jhowardmsft/opengcs/gogcs/client/config.go +++ b/vendor/github.com/jhowardmsft/opengcs/gogcs/client/config.go @@ -51,12 +51,11 @@ const ( // must be in the same directory. // // VHD is the priority. -// -// All paths are full host path-names. type Config struct { - Kernel string // Kernel for Utility VM (embedded in a UEFI bootloader) - Initrd string // Initrd image for Utility VM - Vhdx string // VHD for booting the utility VM + KirdPath string // Path to where kernel/initrd are found (defaults to c:\program files\lcow) + KernelFile string // Kernel for Utility VM (embedded in a UEFI bootloader) - does NOT include full path, just filename + InitrdFile string // Initrd image for Utility VM - does NOT include full path, just filename + Vhdx string // VHD for booting the utility VM - is a full path Name string // Name of the utility VM RequestedMode Mode // What mode is preferred when validating ActualMode Mode // What mode was obtained during validation @@ -67,12 +66,6 @@ type Config struct { // GenerateDefault generates a default config from a set of options // If baseDir is not supplied, defaults to $env:ProgramFiles\lcow func (config *Config) GenerateDefault(options []string) error { - baseDir := filepath.Join(os.Getenv("ProgramFiles"), "lcow") - - if _, err := os.Stat(baseDir); os.IsNotExist(err) { - return fmt.Errorf("opengcs: cannot create default utility VM configuration as directory '%s' was not found", baseDir) - } - if config.UvmTimeoutSeconds < 0 { return fmt.Errorf("opengcs: cannot generate a config when supplied a negative utility VM timeout") } @@ -93,18 +86,16 @@ func (config *Config) GenerateDefault(options []string) error { } } - config.Vhdx = filepath.Join(baseDir, `uvm.vhdx`) - config.Kernel = filepath.Join(baseDir, `bootx64.efi`) - config.Initrd = filepath.Join(baseDir, `initrd.img`) - for _, v := range options { opt := strings.SplitN(v, "=", 2) if len(opt) == 2 { switch strings.ToLower(opt[0]) { + case "opengcskirdpath": + config.KirdPath = opt[1] case "opengcskernel": - config.Kernel = opt[1] + config.KernelFile = opt[1] case "opengcsinitrd": - config.Initrd = opt[1] + config.InitrdFile = opt[1] case "opengcsvhdx": config.Vhdx = opt[1] case "opengcstimeoutsecs": @@ -119,6 +110,20 @@ func (config *Config) GenerateDefault(options []string) error { } } + if config.KirdPath == "" { + config.KirdPath = filepath.Join(os.Getenv("ProgramFiles"), "lcow") + } + + if config.Vhdx == "" { + config.Vhdx = filepath.Join(config.KirdPath, `uvm.vhdx`) + } + if config.KernelFile == "" { + config.KernelFile = `bootx64.efi` + } + if config.InitrdFile == "" { + config.InitrdFile = `initrd.img` + } + // Which timeout are we going to take? If not through option or environment, // then use the default constant, otherwise the maximum of the option or // environment supplied setting. A requested on in the config supplied @@ -143,7 +148,7 @@ func (config *Config) validate() error { if config.RequestedMode == ModeRequestVhdx && config.Vhdx == "" { return fmt.Errorf("opengcs: config is invalid - request for VHDX mode did not supply a VHDX") } - if config.RequestedMode == ModeRequestKernelInitrd && (config.Kernel == "" || config.Initrd == "") { + if config.RequestedMode == ModeRequestKernelInitrd && (config.KernelFile == "" || config.InitrdFile == "") { return fmt.Errorf("opengcs: config is invalid - request for Kernel+Initrd mode must supply both kernel and initrd") } @@ -160,22 +165,23 @@ func (config *Config) validate() error { } // So must be kernel+initrd, or auto where we fallback as the VHDX doesn't exist - if config.Initrd == "" || config.Kernel == "" { + if config.InitrdFile == "" || config.KernelFile == "" { if config.RequestedMode == ModeRequestKernelInitrd { return fmt.Errorf("opengcs: both initrd and kernel options for utility VM boot must be supplied") } return fmt.Errorf("opengcs: configuration is invalid") } - if _, err := os.Stat(config.Kernel); os.IsNotExist(err) { - return fmt.Errorf("opengcs: kernel '%s' was not found", config.Kernel) - } - if _, err := os.Stat(config.Initrd); os.IsNotExist(err) { - return fmt.Errorf("opengcs: initrd '%s' was not found", config.Initrd) + + // Move to validation + //if _, err := os.Stat(baseDir); os.IsNotExist(err) { + // return fmt.Errorf("opengcs: cannot create default utility VM configuration as directory '%s' was not found", baseDir) + //} + + if _, err := os.Stat(filepath.Join(config.KirdPath, config.KernelFile)); os.IsNotExist(err) { + return fmt.Errorf("opengcs: kernel '%s' was not found", filepath.Join(config.KirdPath, config.KernelFile)) } - dk, _ := filepath.Split(config.Kernel) - di, _ := filepath.Split(config.Initrd) - if dk != di { - return fmt.Errorf("initrd '%s' and kernel '%s' must be located in the same directory", config.Initrd, config.Kernel) + if _, err := os.Stat(filepath.Join(config.KirdPath, config.InitrdFile)); os.IsNotExist(err) { + return fmt.Errorf("opengcs: initrd '%s' was not found", filepath.Join(config.KirdPath, config.InitrdFile)) } config.ActualMode = ModeActualKernelInitrd @@ -203,13 +209,10 @@ func (config *Config) Create() error { ImagePath: config.Vhdx, } } else { - // TODO @jhowardmsft - with a platform change that is in-flight, remove ImagePath for - // initrd/kernel boot. Current platform requires it. - dir, _ := filepath.Split(config.Initrd) configuration.HvRuntime = &hcsshim.HvRuntime{ - ImagePath: dir, - LinuxInitrdPath: config.Initrd, - LinuxKernelPath: config.Kernel, + ImagePath: config.KirdPath, + LinuxInitrdFile: config.InitrdFile, + LinuxKernelFile: config.KernelFile, } }