From 2a765279fac29a3f4040f3a41a38d6bbacc2d35e Mon Sep 17 00:00:00 2001 From: John Starks Date: Fri, 23 Sep 2016 14:19:36 -0700 Subject: [PATCH] Windows: Use the top-most utility VM image Microsoft will be distributing non-base layers that have utility VM image updates. Update libcontainerd to use the top-most utility VM image that is available in the image chain when launching Hyper-V-isolated container. Signed-off-by: John Starks --- libcontainerd/client_windows.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/libcontainerd/client_windows.go b/libcontainerd/client_windows.go index b6a4b6b939..df0453f5b8 100644 --- a/libcontainerd/client_windows.go +++ b/libcontainerd/client_windows.go @@ -161,12 +161,25 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir } if configuration.HvPartition { - // Make sure the Utility VM image is present in the base layer directory. + // Find the upper-most utility VM image, since the utility VM does not + // use layering in RS1. // TODO @swernli/jhowardmsft at some point post RS1 this may be re-locatable. - configuration.HvRuntime = &hcsshim.HvRuntime{ImagePath: filepath.Join(layerOpt.LayerPaths[len(layerOpt.LayerPaths)-1], "UtilityVM")} - if _, err := os.Stat(configuration.HvRuntime.ImagePath); os.IsNotExist(err) { - return fmt.Errorf("utility VM image '%s' could not be found", configuration.HvRuntime.ImagePath) + var uvmImagePath string + for _, path := range layerOpt.LayerPaths { + fullPath := filepath.Join(path, "UtilityVM") + _, err := os.Stat(fullPath) + if err == nil { + uvmImagePath = fullPath + break + } + if !os.IsNotExist(err) { + return err + } } + if uvmImagePath == "" { + return errors.New("utility VM image could not be found") + } + configuration.HvRuntime = &hcsshim.HvRuntime{ImagePath: uvmImagePath} } else { configuration.VolumePath = spec.Root.Path configuration.LayerFolderPath = layerOpt.LayerFolderPath