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 <jostarks@microsoft.com>
| ... | ... |
@@ -161,12 +161,25 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir |
| 161 | 161 |
} |
| 162 | 162 |
|
| 163 | 163 |
if configuration.HvPartition {
|
| 164 |
- // Make sure the Utility VM image is present in the base layer directory. |
|
| 164 |
+ // Find the upper-most utility VM image, since the utility VM does not |
|
| 165 |
+ // use layering in RS1. |
|
| 165 | 166 |
// TODO @swernli/jhowardmsft at some point post RS1 this may be re-locatable. |
| 166 |
- configuration.HvRuntime = &hcsshim.HvRuntime{ImagePath: filepath.Join(layerOpt.LayerPaths[len(layerOpt.LayerPaths)-1], "UtilityVM")}
|
|
| 167 |
- if _, err := os.Stat(configuration.HvRuntime.ImagePath); os.IsNotExist(err) {
|
|
| 168 |
- return fmt.Errorf("utility VM image '%s' could not be found", configuration.HvRuntime.ImagePath)
|
|
| 167 |
+ var uvmImagePath string |
|
| 168 |
+ for _, path := range layerOpt.LayerPaths {
|
|
| 169 |
+ fullPath := filepath.Join(path, "UtilityVM") |
|
| 170 |
+ _, err := os.Stat(fullPath) |
|
| 171 |
+ if err == nil {
|
|
| 172 |
+ uvmImagePath = fullPath |
|
| 173 |
+ break |
|
| 174 |
+ } |
|
| 175 |
+ if !os.IsNotExist(err) {
|
|
| 176 |
+ return err |
|
| 177 |
+ } |
|
| 178 |
+ } |
|
| 179 |
+ if uvmImagePath == "" {
|
|
| 180 |
+ return errors.New("utility VM image could not be found")
|
|
| 169 | 181 |
} |
| 182 |
+ configuration.HvRuntime = &hcsshim.HvRuntime{ImagePath: uvmImagePath}
|
|
| 170 | 183 |
} else {
|
| 171 | 184 |
configuration.VolumePath = spec.Root.Path |
| 172 | 185 |
configuration.LayerFolderPath = layerOpt.LayerFolderPath |