Update runhcs-shim to use go-bindings

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
This commit is contained in:
Justin Terry (VM)
2018-09-19 14:35:09 -07:00
parent 16b42fce94
commit 7768ab1b5e
21 changed files with 384 additions and 186 deletions

View File

@@ -23,13 +23,13 @@ import (
"encoding/json"
"io"
"os"
"os/exec"
"path/filepath"
"strings"
"syscall"
"time"
"unsafe"
"github.com/Microsoft/hcsshim/cmd/go-runhcs"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
@@ -337,16 +337,19 @@ func (s *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
continue
}
defer slock.Close()
// Create the scratch
cmd := exec.Command(
"runhcs.exe",
"create-scratch",
"--destpath", scratchPath)
if bytes, err := cmd.CombinedOutput(); err != nil {
_ = os.Remove(scratchPath)
return nil, errors.Wrapf(err, "failed to create scratch.vhdx. additional info: '%s'", string(bytes))
// Create the scratch
rhcs := runhcs.Runhcs{
Debug: true,
Log: filepath.Join(s.root, "runhcs-scratch.log"),
LogFormat: runhcs.JSON,
Owner: "containerd",
}
if err := rhcs.CreateScratch(ctx, scratchPath); err != nil {
_ = os.Remove(scratchPath)
return nil, errors.Wrap(err, "failed to create scratch.vhdx")
}
// Successfully created scratch in the cache. Open and copy
continue
} else {