Merge pull request #33785 from Microsoft/jjh/hcsschemaupdate
LCOW: Updates necessary due to platform schema change
This commit is contained in:
commit
25a65a185b
4 changed files with 45 additions and 39 deletions
|
@ -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`,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
|
5
vendor/github.com/Microsoft/hcsshim/interface.go
generated
vendored
5
vendor/github.com/Microsoft/hcsshim/interface.go
generated
vendored
|
@ -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 {
|
||||
|
|
71
vendor/github.com/jhowardmsft/opengcs/gogcs/client/config.go
generated
vendored
71
vendor/github.com/jhowardmsft/opengcs/gogcs/client/config.go
generated
vendored
|
@ -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)
|
||||
|
||||
// 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))
|
||||
}
|
||||
if _, err := os.Stat(config.Initrd); os.IsNotExist(err) {
|
||||
return fmt.Errorf("opengcs: initrd '%s' was not found", config.Initrd)
|
||||
}
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue