Implement --device idType://id for ctr run on Windows

Also fixes the issue that `ctr run` on Windows offered help for the
non-Windows implementation, but was silently ignored.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
This commit is contained in:
Paul "TBBle" Hampson
2022-03-10 22:55:03 +11:00
parent 39d52118f5
commit 2a425990cf
4 changed files with 17 additions and 4 deletions

View File

@@ -19,6 +19,7 @@ package run
import (
gocontext "context"
"errors"
"strings"
"github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
"github.com/containerd/console"
@@ -142,6 +143,16 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
if ccount != 0 {
opts = append(opts, oci.WithWindowsCPUCount(ccount))
}
for _, dev := range context.StringSlice("device") {
parts := strings.Split(dev, "://")
if len(parts) != 2 {
return nil, errors.New("devices must be in the format IDType://ID")
}
if parts[0] == "" {
return nil, errors.New("devices must have a non-empty IDType")
}
opts = append(opts, oci.WithWindowsDevice(parts[0], parts[1]))
}
}
runtime := context.String("runtime")