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:
parent
39d52118f5
commit
2a425990cf
@ -165,10 +165,6 @@ var (
|
||||
Name: "memory-limit",
|
||||
Usage: "memory limit (in bytes) for the container",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "device",
|
||||
Usage: "file path to a device to add to the container; or a path to a directory tree of devices to add to the container",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "cap-add",
|
||||
Usage: "add Linux capabilities (Set capabilities with 'CAP_' prefix)",
|
||||
|
@ -40,5 +40,8 @@ func init() {
|
||||
}, cli.StringFlag{
|
||||
Name: "rootfs-propagation",
|
||||
Usage: "set the propagation of the container rootfs",
|
||||
}, cli.StringSliceFlag{
|
||||
Name: "device",
|
||||
Usage: "file path to a device to add to the container; or a path to a directory tree of devices to add to the container",
|
||||
})
|
||||
}
|
||||
|
@ -24,5 +24,8 @@ func init() {
|
||||
ContainerFlags = append(ContainerFlags, cli.Uint64Flag{
|
||||
Name: "cpu-count",
|
||||
Usage: "number of CPUs available to the container",
|
||||
}, cli.StringSliceFlag{
|
||||
Name: "device",
|
||||
Usage: "identifier of a device to add to the container (e.g. class://5B45201D-F2F2-4F3B-85BB-30FF1F953599)",
|
||||
})
|
||||
}
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user