...
1
2
3 package wcow
4
5 import (
6 "context"
7 "os"
8 "path/filepath"
9
10 "github.com/Microsoft/hcsshim/internal/copyfile"
11 "github.com/Microsoft/hcsshim/internal/wclayer"
12 )
13
14
15
16 func CreateUVMScratch(ctx context.Context, imagePath, destDirectory, vmID string) error {
17 sourceScratch := filepath.Join(imagePath, `UtilityVM\SystemTemplate.vhdx`)
18 targetScratch := filepath.Join(destDirectory, "sandbox.vhdx")
19 if err := copyfile.CopyFile(ctx, sourceScratch, targetScratch, true); err != nil {
20 return err
21 }
22 if err := wclayer.GrantVmAccess(ctx, vmID, targetScratch); err != nil {
23 os.Remove(targetScratch)
24 return err
25 }
26 return nil
27 }
28
View as plain text