From 8a22e26c53bcf0ca71ebdfcf6ca19a7ef7e81a3f Mon Sep 17 00:00:00 2001 From: Kathryn Baldauf Date: Wed, 7 Apr 2021 20:23:12 -0700 Subject: [PATCH] Add a utility function to exec in shimdiag for cri-containerd tests Signed-off-by: Kathryn Baldauf --- cmd/shimdiag/exec.go | 39 +- cmd/shimdiag/list.go | 3 +- cmd/shimdiag/share.go | 2 +- cmd/shimdiag/shimdiag.go | 82 +- cmd/shimdiag/stacks.go | 2 +- internal/cmd/io_npipe.go | 44 ++ internal/devices/assigned_devices.go | 19 +- internal/shimdiag/shimdiag.go | 87 ++ test/cri-containerd/exec.go | 45 ++ .../Microsoft/hcsshim/.gometalinter.json | 17 - .../hcsshim/computestorage/helpers.go | 4 +- .../Microsoft/hcsshim/hcn/hcnnamespace.go | 2 +- .../Microsoft/hcsshim/hcn/hcnpolicy.go | 8 + .../Microsoft/hcsshim/internal/cmd/cmd.go | 2 +- .../hcsshim/internal/cmd/io_npipe.go | 41 + .../internal/computeagent/computeagent.pb.go | 740 +++++++++++++++++- .../internal/computeagent/computeagent.proto | 17 +- .../internal/devices/assigned_devices.go | 19 +- .../hcsshim/internal/gcs/guestconnection.go | 2 +- .../Microsoft/hcsshim/internal/hcs/system.go | 4 +- .../hcsshim/internal/hcsoci/create.go | 4 +- .../hcsshim/internal/layers/layers.go | 4 +- .../Microsoft/hcsshim/internal/lcow/disk.go | 2 +- .../hcsshim/internal/lcow/scratch.go | 2 +- .../ncproxyttrpc/networkconfigproxy.proto | 2 +- .../hcsshim/internal/runhcs/container.go | 2 +- .../hcsshim/internal/safefile/safeopen.go | 2 +- .../schema2/interrupt_moderation_mode.go | 42 + .../hcsshim/internal/schema2/iov_settings.go | 22 + .../internal/schema2/network_adapter.go | 3 +- .../hcsshim/internal/shimdiag/shimdiag.go | 103 +++ .../hcsshim/internal/uvm/computeagent.go | 49 ++ .../Microsoft/hcsshim/internal/uvm/create.go | 9 +- .../Microsoft/hcsshim/internal/uvm/network.go | 10 + .../Microsoft/hcsshim/internal/uvm/share.go | 4 +- .../Microsoft/hcsshim/internal/uvm/start.go | 9 +- .../Microsoft/hcsshim/internal/uvm/vsmb.go | 4 +- .../hcsshim/internal/wclayer/legacy.go | 6 +- .../hcsshim/internal/winapi/system.go | 52 ++ .../hcsshim/internal/winapi/thread.go | 9 + .../hcsshim/internal/winapi/winapi.go | 2 +- .../internal/winapi/zsyscall_windows.go | 9 +- 42 files changed, 1284 insertions(+), 246 deletions(-) create mode 100644 internal/shimdiag/shimdiag.go delete mode 100644 test/vendor/github.com/Microsoft/hcsshim/.gometalinter.json create mode 100644 test/vendor/github.com/Microsoft/hcsshim/internal/schema2/interrupt_moderation_mode.go create mode 100644 test/vendor/github.com/Microsoft/hcsshim/internal/schema2/iov_settings.go create mode 100644 test/vendor/github.com/Microsoft/hcsshim/internal/shimdiag/shimdiag.go create mode 100644 test/vendor/github.com/Microsoft/hcsshim/internal/winapi/system.go diff --git a/cmd/shimdiag/exec.go b/cmd/shimdiag/exec.go index 54fd7aa6af..dc54332777 100644 --- a/cmd/shimdiag/exec.go +++ b/cmd/shimdiag/exec.go @@ -8,12 +8,10 @@ import ( "os/signal" "syscall" - "github.com/Microsoft/go-winio" - "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/hcsshim/internal/appargs" + "github.com/Microsoft/hcsshim/internal/cmd" "github.com/Microsoft/hcsshim/internal/shimdiag" "github.com/containerd/console" - "github.com/sirupsen/logrus" "github.com/urfave/cli" ) @@ -46,7 +44,7 @@ var execCommand = cli.Command{ Before: appargs.Validate(appargs.String, appargs.String, appargs.Rest(appargs.String)), Action: func(clictx *cli.Context) error { args := clictx.Args() - shim, err := getShim(args[0]) + shim, err := shimdiag.GetShim(args[0]) if err != nil { return err } @@ -69,17 +67,17 @@ var execCommand = cli.Command{ } } - stdin, err := makePipe(osStdin, true) + stdin, err := cmd.CreatePipeAndListen(osStdin, true) if err != nil { return err } - stdout, err := makePipe(os.Stdout, false) + stdout, err := cmd.CreatePipeAndListen(os.Stdout, false) if err != nil { return err } var stderr string if !execTty { - stderr, err = makePipe(os.Stderr, false) + stderr, err = cmd.CreatePipeAndListen(os.Stderr, false) if err != nil { return err } @@ -105,30 +103,3 @@ var execCommand = cli.Command{ return cli.NewExitError(errors.New(""), int(resp.ExitCode)) }, } - -func makePipe(f interface{}, in bool) (string, error) { - r, err := guid.NewV4() - if err != nil { - return "", err - } - p := `\\.\pipe\` + r.String() - l, err := winio.ListenPipe(p, nil) - if err != nil { - return "", err - } - go func() { - c, err := l.Accept() - if err != nil { - logrus.WithError(err).Error("failed to accept pipe") - return - } - - if in { - _, _ = io.Copy(c, f.(io.Reader)) - c.Close() - } else { - _, _ = io.Copy(f.(io.Writer), c) - } - }() - return p, nil -} diff --git a/cmd/shimdiag/list.go b/cmd/shimdiag/list.go index ee90cce482..4bb771acec 100644 --- a/cmd/shimdiag/list.go +++ b/cmd/shimdiag/list.go @@ -6,6 +6,7 @@ import ( "text/tabwriter" "github.com/Microsoft/hcsshim/internal/appargs" + "github.com/Microsoft/hcsshim/internal/shimdiag" "github.com/urfave/cli" ) @@ -22,7 +23,7 @@ var listCommand = cli.Command{ Before: appargs.Validate(), Action: func(ctx *cli.Context) error { pids := ctx.Bool("pids") - shims, err := findShims("") + shims, err := shimdiag.FindShims("") if err != nil { return err } diff --git a/cmd/shimdiag/share.go b/cmd/shimdiag/share.go index a9ac75e9fa..328e32f83f 100644 --- a/cmd/shimdiag/share.go +++ b/cmd/shimdiag/share.go @@ -33,7 +33,7 @@ var shareCommand = cli.Command{ hostPath = args[1] uvmPath = args[2] ) - shim, err := getShim(shimName) + shim, err := shimdiag.GetShim(shimName) if err != nil { return err } diff --git a/cmd/shimdiag/shimdiag.go b/cmd/shimdiag/shimdiag.go index 9dfeaac3e5..55fbb4687b 100644 --- a/cmd/shimdiag/shimdiag.go +++ b/cmd/shimdiag/shimdiag.go @@ -4,20 +4,9 @@ import ( "context" "fmt" "os" - "path/filepath" - "sort" - "strings" - "github.com/Microsoft/go-winio" "github.com/Microsoft/hcsshim/internal/shimdiag" - "github.com/containerd/ttrpc" "github.com/urfave/cli" - "golang.org/x/sys/windows" -) - -const ( - shimPrefix = `\\.\pipe\ProtectedPrefix\Administrators\containerd-shim-` - shimSuffix = `-pipe` ) func main() { @@ -36,77 +25,8 @@ func main() { } } -func findPipes(pattern string) ([]string, error) { - path := `\\.\pipe\*` - path16, err := windows.UTF16FromString(path) - if err != nil { - return nil, err - } - var data windows.Win32finddata - h, err := windows.FindFirstFile(&path16[0], &data) - if err != nil { - return nil, &os.PathError{Op: "FindFirstFile", Path: path, Err: err} - } - var names []string - for { - name := `\\.\pipe\` + windows.UTF16ToString(data.FileName[:]) - if matched, _ := filepath.Match(pattern, name); matched { - names = append(names, name) - } - err = windows.FindNextFile(h, &data) - if err == windows.ERROR_NO_MORE_FILES { - break - } - if err != nil { - return nil, &os.PathError{Op: "FindNextFile", Path: path, Err: err} - } - } - return names, nil -} - -func findShims(name string) ([]string, error) { - pipes, err := findPipes(shimPrefix + name + "*" + shimSuffix) - if err != nil { - return nil, err - } - for i, p := range pipes { - pipes[i] = p[len(shimPrefix) : len(p)-len(shimSuffix)] - } - sort.Strings(pipes) - return pipes, nil -} - -func findShim(name string) (string, error) { - if strings.ContainsAny(name, "*?\\/") { - return "", fmt.Errorf("invalid shim name %s", name) - } - shims, err := findShims(name) - if err != nil { - return "", err - } - if len(shims) == 0 { - return "", fmt.Errorf("no such shim %s", name) - } - if len(shims) > 1 && shims[0] != name { - return "", fmt.Errorf("multiple shims beginning with %s", name) - } - return shims[0], nil -} - -func getShim(name string) (*ttrpc.Client, error) { - shim, err := findShim(name) - if err != nil { - return nil, err - } - conn, err := winio.DialPipe(shimPrefix+shim+shimSuffix, nil) - if err != nil { - return nil, err - } - return ttrpc.NewClient(conn), nil -} - func getPid(shimName string) (int32, error) { - shim, err := getShim(shimName) + shim, err := shimdiag.GetShim(shimName) if err != nil { return 0, err } diff --git a/cmd/shimdiag/stacks.go b/cmd/shimdiag/stacks.go index 1926074157..1ef6561d85 100644 --- a/cmd/shimdiag/stacks.go +++ b/cmd/shimdiag/stacks.go @@ -15,7 +15,7 @@ var stacksCommand = cli.Command{ ArgsUsage: "", Before: appargs.Validate(appargs.String), Action: func(c *cli.Context) error { - shim, err := getShim(c.Args()[0]) + shim, err := shimdiag.GetShim(c.Args()[0]) if err != nil { return err } diff --git a/internal/cmd/io_npipe.go b/internal/cmd/io_npipe.go index f4650538a9..e116362453 100644 --- a/internal/cmd/io_npipe.go +++ b/internal/cmd/io_npipe.go @@ -3,9 +3,11 @@ package cmd import ( "context" "io" + "net" "sync" winio "github.com/Microsoft/go-winio" + "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/hcsshim/internal/log" "github.com/sirupsen/logrus" ) @@ -136,3 +138,45 @@ func (nio *npipeio) StderrPath() string { func (nio *npipeio) Terminal() bool { return nio.terminal } + +// CreatePipeAndListen is a helper function to create a pipe listener +// and accept connections. Returns the created pipe path on success. +// +// If `in` is true, `f` should implement io.Reader +// If `in` is false, `f` should implement io.Writer +func CreatePipeAndListen(f interface{}, in bool) (string, error) { + p, l, err := CreateNamedPipeListener() + if err != nil { + return "", err + } + go func() { + c, err := l.Accept() + if err != nil { + logrus.WithError(err).Error("failed to accept pipe") + return + } + + if in { + _, _ = io.Copy(c, f.(io.Reader)) + c.Close() + } else { + _, _ = io.Copy(f.(io.Writer), c) + } + }() + return p, nil +} + +// CreateNamedPipeListener is a helper function to create and return a pipe listener +// and it's created path. +func CreateNamedPipeListener() (string, net.Listener, error) { + g, err := guid.NewV4() + if err != nil { + return "", nil, err + } + p := `\\.\pipe\` + g.String() + l, err := winio.ListenPipe(p, nil) + if err != nil { + return "", nil, err + } + return p, l, nil +} diff --git a/internal/devices/assigned_devices.go b/internal/devices/assigned_devices.go index f712009571..8cdc3d9419 100644 --- a/internal/devices/assigned_devices.go +++ b/internal/devices/assigned_devices.go @@ -9,8 +9,6 @@ import ( "net" "strings" - winio "github.com/Microsoft/go-winio" - "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/hcsshim/internal/cmd" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/shimdiag" @@ -62,7 +60,7 @@ func AddDevice(ctx context.Context, vm *uvm.UtilityVM, idType, deviceID, deviceU // parent bus device for the children devices' location paths from the uvm's view. // Returns a slice of strings representing the resulting children location paths func getChildrenDeviceLocationPaths(ctx context.Context, vm *uvm.UtilityVM, vmBusInstanceID string, deviceUtilPath string) ([]string, error) { - p, l, err := createNamedPipeListener() + p, l, err := cmd.CreateNamedPipeListener() if err != nil { return nil, err } @@ -111,21 +109,6 @@ func createDeviceUtilChildrenCommand(deviceUtilPath string, vmBusInstanceID stri return args } -// createNamedPipeListener is a helper function to create and return a pipe listener -// and it's created path. -func createNamedPipeListener() (string, net.Listener, error) { - g, err := guid.NewV4() - if err != nil { - return "", nil, err - } - p := `\\.\pipe\` + g.String() - l, err := winio.ListenPipe(p, nil) - if err != nil { - return "", nil, err - } - return p, l, nil -} - // readCsPipeOutput is a helper function that connects to a listener and reads // the connection's comma separated output until done. resulting comma separated // values are returned in the `result` param. The `errChan` param is used to diff --git a/internal/shimdiag/shimdiag.go b/internal/shimdiag/shimdiag.go new file mode 100644 index 0000000000..2d1242da42 --- /dev/null +++ b/internal/shimdiag/shimdiag.go @@ -0,0 +1,87 @@ +package shimdiag + +import ( + fmt "fmt" + "os" + "path/filepath" + "sort" + strings "strings" + + "github.com/Microsoft/go-winio" + "github.com/containerd/ttrpc" + "golang.org/x/sys/windows" +) + +const ( + shimPrefix = `\\.\pipe\ProtectedPrefix\Administrators\containerd-shim-` + shimSuffix = `-pipe` +) + +func findPipes(pattern string) ([]string, error) { + path := `\\.\pipe\*` + path16, err := windows.UTF16FromString(path) + if err != nil { + return nil, err + } + var data windows.Win32finddata + h, err := windows.FindFirstFile(&path16[0], &data) + if err != nil { + return nil, &os.PathError{Op: "FindFirstFile", Path: path, Err: err} + } + var names []string + for { + name := `\\.\pipe\` + windows.UTF16ToString(data.FileName[:]) + if matched, _ := filepath.Match(pattern, name); matched { + names = append(names, name) + } + err = windows.FindNextFile(h, &data) + if err == windows.ERROR_NO_MORE_FILES { + break + } + if err != nil { + return nil, &os.PathError{Op: "FindNextFile", Path: path, Err: err} + } + } + return names, nil +} + +func FindShims(name string) ([]string, error) { + pipes, err := findPipes(shimPrefix + name + "*" + shimSuffix) + if err != nil { + return nil, err + } + for i, p := range pipes { + pipes[i] = p[len(shimPrefix) : len(p)-len(shimSuffix)] + } + sort.Strings(pipes) + return pipes, nil +} + +func findShim(name string) (string, error) { + if strings.ContainsAny(name, "*?\\/") { + return "", fmt.Errorf("invalid shim name %s", name) + } + shims, err := FindShims(name) + if err != nil { + return "", err + } + if len(shims) == 0 { + return "", fmt.Errorf("no such shim %s", name) + } + if len(shims) > 1 && shims[0] != name { + return "", fmt.Errorf("multiple shims beginning with %s", name) + } + return shims[0], nil +} + +func GetShim(name string) (*ttrpc.Client, error) { + shim, err := findShim(name) + if err != nil { + return nil, err + } + conn, err := winio.DialPipe(shimPrefix+shim+shimSuffix, nil) + if err != nil { + return nil, err + } + return ttrpc.NewClient(conn), nil +} diff --git a/test/cri-containerd/exec.go b/test/cri-containerd/exec.go index 7c8d846d25..657177aa5a 100644 --- a/test/cri-containerd/exec.go +++ b/test/cri-containerd/exec.go @@ -4,8 +4,11 @@ package cri_containerd import ( "context" + "io" "testing" + "github.com/Microsoft/hcsshim/internal/cmd" + "github.com/Microsoft/hcsshim/internal/shimdiag" runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) @@ -24,3 +27,45 @@ func execRequest(t *testing.T, client runtime.RuntimeServiceClient, ctx context. } return response.Url } + +// execInHost executes command in the container's host. +// `stdinBuf` is an optional parameter to specify an io.Reader that can be used as stdin for the executed program. +// `stdoutBuf` is an optional parameter to specify an io.Writer that can be used as stdout for the executed program. +// `stderrBuf` is an optional parameter to specify an io.Writer that can be used as stderr for the executed program. +func execInHost(t *testing.T, ctx context.Context, client shimdiag.ShimDiagService, args []string, stdinBuf *io.Reader, stdoutBuf, stderrBuf *io.Writer) (_ int32, err error) { + var ( + stdin = "" + stdout = "" + stderr = "" + ) + + if stdinBuf != nil { + stdin, err = cmd.CreatePipeAndListen(stdinBuf, true) + if err != nil { + return 0, err + } + } + if stdoutBuf != nil { + stdout, err = cmd.CreatePipeAndListen(stdoutBuf, false) + if err != nil { + return 0, err + } + } + if stderrBuf != nil { + stderr, err = cmd.CreatePipeAndListen(stderrBuf, false) + if err != nil { + return 0, err + } + } + + resp, err := client.DiagExecInHost(ctx, &shimdiag.ExecProcessRequest{ + Args: args, + Stdin: stdin, + Stdout: stdout, + Stderr: stderr, + }) + if err != nil { + return 0, err + } + return resp.ExitCode, nil +} diff --git a/test/vendor/github.com/Microsoft/hcsshim/.gometalinter.json b/test/vendor/github.com/Microsoft/hcsshim/.gometalinter.json deleted file mode 100644 index 00e9a6e2ec..0000000000 --- a/test/vendor/github.com/Microsoft/hcsshim/.gometalinter.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "Vendor": true, - "Deadline": "2m", - "Sort": [ - "linter", - "severity", - "path", - "line" - ], - "Skip": [ - "internal\\schema2" - ], - "EnableGC": true, - "Enable": [ - "gofmt" - ] -} \ No newline at end of file diff --git a/test/vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go b/test/vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go index 88867959da..87fee452cd 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go +++ b/test/vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go @@ -70,7 +70,7 @@ func SetupContainerBaseLayer(ctx context.Context, layerPath, baseVhdPath, diffVh defer func() { if err != nil { - syscall.CloseHandle(handle) //nolint:errcheck + _ = syscall.CloseHandle(handle) os.RemoveAll(baseVhdPath) os.RemoveAll(diffVhdPath) } @@ -146,7 +146,7 @@ func SetupUtilityVMBaseLayer(ctx context.Context, uvmPath, baseVhdPath, diffVhdP defer func() { if err != nil { - syscall.CloseHandle(handle) //nolint:errcheck + _ = syscall.CloseHandle(handle) os.RemoveAll(baseVhdPath) os.RemoveAll(diffVhdPath) } diff --git a/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go b/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go index 60d83ef135..d2ef229609 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go +++ b/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnnamespace.go @@ -378,7 +378,7 @@ func (namespace *HostComputeNamespace) Sync() error { // The shim is likey gone. Simply ignore the sync as if it didn't exist. if perr, ok := err.(*os.PathError); ok && perr.Err == syscall.ERROR_FILE_NOT_FOUND { // Remove the reg key there is no point to try again - cfg.Remove() //nolint:errcheck + _ = cfg.Remove() return nil } f := map[string]interface{}{ diff --git a/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnpolicy.go b/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnpolicy.go index 99493a4df4..c032d79490 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnpolicy.go +++ b/test/vendor/github.com/Microsoft/hcsshim/hcn/hcnpolicy.go @@ -19,6 +19,7 @@ const ( L4WFPPROXY EndpointPolicyType = "L4WFPPROXY" PortName EndpointPolicyType = "PortName" EncapOverhead EndpointPolicyType = "EncapOverhead" + IOV EndpointPolicyType = "Iov" // Endpoint and Network have InterfaceConstraint and ProviderAddress NetworkProviderAddress EndpointPolicyType = "ProviderAddress" NetworkInterfaceConstraint EndpointPolicyType = "InterfaceConstraint" @@ -171,6 +172,13 @@ type EncapOverheadEndpointPolicySetting struct { Overhead uint16 `json:",omitempty"` } +// IovPolicySetting sets the Iov settings for an endpoint. +type IovPolicySetting struct { + IovOffloadWeight uint32 `json:",omitempty"` + QueuePairsRequested uint32 `json:",omitempty"` + InterruptModeration uint32 `json:",omitempty"` +} + /// Endpoint and Network Policy objects // ProviderAddressEndpointPolicySetting sets the PA for an endpoint. diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/cmd.go b/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/cmd.go index 6f877efae7..d0b3868892 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/cmd.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/cmd.go @@ -240,7 +240,7 @@ func (c *Cmd) Start() error { go func() { select { case <-c.Context.Done(): - c.Process.Kill(context.TODO()) //nolint:errcheck + _, _ = c.Process.Kill(context.TODO()) case <-c.allDoneCh: } }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/io_npipe.go b/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/io_npipe.go index f4650538a9..6575d2c8e5 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/io_npipe.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/cmd/io_npipe.go @@ -3,9 +3,11 @@ package cmd import ( "context" "io" + "net" "sync" winio "github.com/Microsoft/go-winio" + "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/hcsshim/internal/log" "github.com/sirupsen/logrus" ) @@ -136,3 +138,42 @@ func (nio *npipeio) StderrPath() string { func (nio *npipeio) Terminal() bool { return nio.terminal } + +// CreatePipeAndListen is a helper function to create a pipe listener +// and accept connections. Returns the created pipe path on success. +func CreatePipeAndListen(f interface{}, in bool) (string, error) { + p, l, err := CreateNamedPipeListener() + if err != nil { + return "", err + } + go func() { + c, err := l.Accept() + if err != nil { + logrus.WithError(err).Error("failed to accept pipe") + return + } + + if in { + _, _ = io.Copy(c, f.(io.Reader)) + c.Close() + } else { + _, _ = io.Copy(f.(io.Writer), c) + } + }() + return p, nil +} + +// CreateNamedPipeListener is a helper function to create and return a pipe listener +// and it's created path. +func CreateNamedPipeListener() (string, net.Listener, error) { + g, err := guid.NewV4() + if err != nil { + return "", nil, err + } + p := `\\.\pipe\` + g.String() + l, err := winio.ListenPipe(p, nil) + if err != nil { + return "", nil, err + } + return p, l, nil +} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/computeagent/computeagent.pb.go b/test/vendor/github.com/Microsoft/hcsshim/internal/computeagent/computeagent.pb.go index 4fa9dd36e9..fa92638697 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/computeagent/computeagent.pb.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/computeagent/computeagent.pb.go @@ -104,6 +104,85 @@ func (m *AddNICInternalResponse) XXX_DiscardUnknown() { var xxx_messageInfo_AddNICInternalResponse proto.InternalMessageInfo +type ModifyNICInternalRequest struct { + NicID string `protobuf:"bytes,1,opt,name=nic_id,json=nicId,proto3" json:"nic_id,omitempty"` + EndpointName string `protobuf:"bytes,2,opt,name=endpoint_name,json=endpointName,proto3" json:"endpoint_name,omitempty"` + IovPolicySettings *IovSettings `protobuf:"bytes,3,opt,name=iov_policy_settings,json=iovPolicySettings,proto3" json:"iov_policy_settings,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ModifyNICInternalRequest) Reset() { *m = ModifyNICInternalRequest{} } +func (*ModifyNICInternalRequest) ProtoMessage() {} +func (*ModifyNICInternalRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_7f2f03dc308add4c, []int{2} +} +func (m *ModifyNICInternalRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModifyNICInternalRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModifyNICInternalRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ModifyNICInternalRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModifyNICInternalRequest.Merge(m, src) +} +func (m *ModifyNICInternalRequest) XXX_Size() int { + return m.Size() +} +func (m *ModifyNICInternalRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ModifyNICInternalRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ModifyNICInternalRequest proto.InternalMessageInfo + +type ModifyNICInternalResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ModifyNICInternalResponse) Reset() { *m = ModifyNICInternalResponse{} } +func (*ModifyNICInternalResponse) ProtoMessage() {} +func (*ModifyNICInternalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7f2f03dc308add4c, []int{3} +} +func (m *ModifyNICInternalResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModifyNICInternalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModifyNICInternalResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ModifyNICInternalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModifyNICInternalResponse.Merge(m, src) +} +func (m *ModifyNICInternalResponse) XXX_Size() int { + return m.Size() +} +func (m *ModifyNICInternalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ModifyNICInternalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ModifyNICInternalResponse proto.InternalMessageInfo + type DeleteNICInternalRequest struct { ContainerID string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` NicID string `protobuf:"bytes,2,opt,name=nic_id,json=nicId,proto3" json:"nic_id,omitempty"` @@ -116,7 +195,7 @@ type DeleteNICInternalRequest struct { func (m *DeleteNICInternalRequest) Reset() { *m = DeleteNICInternalRequest{} } func (*DeleteNICInternalRequest) ProtoMessage() {} func (*DeleteNICInternalRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_7f2f03dc308add4c, []int{2} + return fileDescriptor_7f2f03dc308add4c, []int{4} } func (m *DeleteNICInternalRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -154,7 +233,7 @@ type DeleteNICInternalResponse struct { func (m *DeleteNICInternalResponse) Reset() { *m = DeleteNICInternalResponse{} } func (*DeleteNICInternalResponse) ProtoMessage() {} func (*DeleteNICInternalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7f2f03dc308add4c, []int{3} + return fileDescriptor_7f2f03dc308add4c, []int{5} } func (m *DeleteNICInternalResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -183,11 +262,55 @@ func (m *DeleteNICInternalResponse) XXX_DiscardUnknown() { var xxx_messageInfo_DeleteNICInternalResponse proto.InternalMessageInfo +type IovSettings struct { + IovOffloadWeight uint32 `protobuf:"varint,1,opt,name=IovOffloadWeight,proto3" json:"IovOffloadWeight,omitempty"` + QueuePairsRequested uint32 `protobuf:"varint,2,opt,name=QueuePairsRequested,proto3" json:"QueuePairsRequested,omitempty"` + InterruptModeration uint32 `protobuf:"varint,3,opt,name=InterruptModeration,proto3" json:"InterruptModeration,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *IovSettings) Reset() { *m = IovSettings{} } +func (*IovSettings) ProtoMessage() {} +func (*IovSettings) Descriptor() ([]byte, []int) { + return fileDescriptor_7f2f03dc308add4c, []int{6} +} +func (m *IovSettings) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IovSettings) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IovSettings.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IovSettings) XXX_Merge(src proto.Message) { + xxx_messageInfo_IovSettings.Merge(m, src) +} +func (m *IovSettings) XXX_Size() int { + return m.Size() +} +func (m *IovSettings) XXX_DiscardUnknown() { + xxx_messageInfo_IovSettings.DiscardUnknown(m) +} + +var xxx_messageInfo_IovSettings proto.InternalMessageInfo + func init() { proto.RegisterType((*AddNICInternalRequest)(nil), "AddNICInternalRequest") proto.RegisterType((*AddNICInternalResponse)(nil), "AddNICInternalResponse") + proto.RegisterType((*ModifyNICInternalRequest)(nil), "ModifyNICInternalRequest") + proto.RegisterType((*ModifyNICInternalResponse)(nil), "ModifyNICInternalResponse") proto.RegisterType((*DeleteNICInternalRequest)(nil), "DeleteNICInternalRequest") proto.RegisterType((*DeleteNICInternalResponse)(nil), "DeleteNICInternalResponse") + proto.RegisterType((*IovSettings)(nil), "IovSettings") } func init() { @@ -195,29 +318,38 @@ func init() { } var fileDescriptor_7f2f03dc308add4c = []byte{ - // 339 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x92, 0xb1, 0x4f, 0xfa, 0x40, - 0x14, 0xc7, 0x7b, 0xbf, 0x5f, 0x20, 0xe1, 0xc0, 0x98, 0x5c, 0x14, 0x4b, 0x4d, 0x0a, 0xa9, 0x8b, - 0x53, 0x9b, 0xe0, 0xc8, 0x60, 0x80, 0x3a, 0x74, 0x90, 0xa1, 0x93, 0xba, 0x90, 0x72, 0x7d, 0x96, - 0x4b, 0xe8, 0x5d, 0xed, 0x1d, 0xbb, 0xff, 0x82, 0x26, 0xfe, 0x4f, 0x8c, 0x8e, 0x4e, 0x44, 0xee, - 0x2f, 0x31, 0xa5, 0x42, 0xd4, 0xc0, 0xe0, 0xe6, 0xf6, 0xde, 0x37, 0xdf, 0xdc, 0x7d, 0xde, 0xf7, - 0x3d, 0x7c, 0x95, 0x30, 0x35, 0x9d, 0x4f, 0x5c, 0x2a, 0x52, 0xef, 0x9a, 0xd1, 0x5c, 0x48, 0x71, - 0xaf, 0xbc, 0x29, 0x95, 0x72, 0xca, 0x52, 0x8f, 0x71, 0x05, 0x39, 0x8f, 0x66, 0x1e, 0x15, 0x69, - 0x36, 0x57, 0x10, 0x25, 0xc0, 0xd5, 0xb7, 0xc6, 0xcd, 0x72, 0xa1, 0x84, 0x75, 0x94, 0x88, 0x44, - 0xac, 0x4b, 0xaf, 0xa8, 0x4a, 0xd5, 0x79, 0x46, 0xf8, 0xb8, 0x1f, 0xc7, 0xa3, 0x60, 0x18, 0x7c, - 0x3e, 0x14, 0xc2, 0xc3, 0x1c, 0xa4, 0x22, 0x5d, 0xdc, 0xa0, 0x82, 0xab, 0x88, 0x71, 0xc8, 0xc7, - 0x2c, 0x36, 0x51, 0x07, 0x9d, 0xd7, 0x06, 0x87, 0x7a, 0xd9, 0xae, 0x0f, 0x37, 0x7a, 0xe0, 0x87, - 0xf5, 0xad, 0x29, 0x88, 0x49, 0x07, 0x57, 0x39, 0xa3, 0x85, 0xfb, 0xdf, 0xda, 0x5d, 0xd3, 0xcb, - 0x76, 0x65, 0xc4, 0x68, 0xe0, 0x87, 0x15, 0xce, 0x68, 0x10, 0x93, 0x33, 0x7c, 0x00, 0x3c, 0xce, - 0x04, 0xe3, 0x6a, 0xcc, 0xa3, 0x14, 0xcc, 0xff, 0x85, 0x31, 0x6c, 0x6c, 0xc4, 0x51, 0x94, 0x82, - 0x63, 0xe2, 0xe6, 0x4f, 0x26, 0x99, 0x09, 0x2e, 0xc1, 0x79, 0x41, 0xd8, 0xf4, 0x61, 0x06, 0x0a, - 0xfe, 0x16, 0xf1, 0x29, 0x6e, 0xed, 0xc0, 0x2a, 0xa1, 0xbb, 0x4f, 0x08, 0x37, 0x86, 0xe5, 0x42, - 0xfa, 0xc5, 0x42, 0x48, 0x0f, 0x57, 0xcb, 0xf9, 0x48, 0xd3, 0xdd, 0x19, 0xbe, 0x75, 0xe2, 0xee, - 0x09, 0xc0, 0x20, 0x3e, 0xae, 0x6d, 0xbf, 0x22, 0x2d, 0x77, 0x5f, 0x1a, 0x96, 0xe5, 0xee, 0x25, - 0x72, 0x8c, 0xc1, 0xed, 0x62, 0x65, 0x1b, 0x6f, 0x2b, 0xdb, 0x78, 0xd4, 0x36, 0x5a, 0x68, 0x1b, - 0xbd, 0x6a, 0x1b, 0xbd, 0x6b, 0x1b, 0xdd, 0x5d, 0xfe, 0xfe, 0xdc, 0x7a, 0x5f, 0x9b, 0x1b, 0x63, - 0x52, 0x5d, 0xdf, 0xd6, 0xc5, 0x47, 0x00, 0x00, 0x00, 0xff, 0xff, 0x77, 0xdb, 0x0e, 0x0a, 0xba, - 0x02, 0x00, 0x00, + // 492 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x94, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0xb3, 0x45, 0x8d, 0x94, 0x4d, 0x22, 0x60, 0x0b, 0xc5, 0x71, 0x25, 0xb7, 0x0a, 0x17, + 0xc4, 0xc1, 0x46, 0xe1, 0x58, 0x24, 0xd4, 0x26, 0x1c, 0x7c, 0x48, 0x28, 0xe6, 0xc0, 0x9f, 0x4b, + 0xe4, 0xda, 0x13, 0x67, 0xa4, 0x78, 0xc7, 0xd8, 0xeb, 0x48, 0xbd, 0xf1, 0x0c, 0x48, 0x1c, 0x11, + 0xaf, 0xd3, 0x23, 0x37, 0x38, 0x55, 0xd4, 0x4f, 0x82, 0xec, 0x38, 0xa1, 0x50, 0x5b, 0x82, 0x5b, + 0x6f, 0xde, 0x6f, 0x3f, 0xef, 0xfc, 0x76, 0xe6, 0xd3, 0xf2, 0x17, 0x01, 0xaa, 0x79, 0x7a, 0x6a, + 0x7a, 0x14, 0x5a, 0x63, 0xf4, 0x62, 0x4a, 0x68, 0xa6, 0xac, 0xb9, 0x97, 0x24, 0x73, 0x0c, 0x2d, + 0x94, 0x0a, 0x62, 0xe9, 0x2e, 0x2c, 0x8f, 0xc2, 0x28, 0x55, 0xe0, 0x06, 0x20, 0xd5, 0x1f, 0x0b, + 0x33, 0x8a, 0x49, 0x91, 0x7e, 0x2f, 0xa0, 0x80, 0x8a, 0x4f, 0x2b, 0xff, 0x5a, 0xa9, 0xfd, 0x4f, + 0x8c, 0xdf, 0x3f, 0xf2, 0xfd, 0x89, 0x3d, 0xb4, 0xcb, 0x83, 0x1c, 0xf8, 0x90, 0x42, 0xa2, 0xc4, + 0x80, 0x77, 0x3c, 0x92, 0xca, 0x45, 0x09, 0xf1, 0x14, 0x7d, 0x8d, 0x1d, 0xb0, 0x47, 0xad, 0xe3, + 0xdb, 0xd9, 0xc5, 0x7e, 0x7b, 0xb8, 0xd6, 0xed, 0x91, 0xd3, 0xde, 0x98, 0x6c, 0x5f, 0x1c, 0xf0, + 0xa6, 0x44, 0x2f, 0x77, 0x6f, 0x15, 0xee, 0x56, 0x76, 0xb1, 0xbf, 0x3d, 0x41, 0xcf, 0x1e, 0x39, + 0xdb, 0x12, 0x3d, 0xdb, 0x17, 0x0f, 0x79, 0x17, 0xa4, 0x1f, 0x11, 0x4a, 0x35, 0x95, 0x6e, 0x08, + 0xda, 0xad, 0xdc, 0xe8, 0x74, 0xd6, 0xe2, 0xc4, 0x0d, 0xa1, 0xaf, 0xf1, 0xdd, 0xbf, 0x99, 0x92, + 0x88, 0x64, 0x02, 0xfd, 0xaf, 0x8c, 0x6b, 0x63, 0xf2, 0x71, 0x76, 0x56, 0x41, 0xfc, 0xbb, 0x3a, + 0xfb, 0xd7, 0xea, 0x5b, 0xd7, 0xab, 0x8b, 0x67, 0x7c, 0x07, 0x69, 0x39, 0x8d, 0x68, 0x81, 0xde, + 0xd9, 0x34, 0x01, 0xa5, 0x50, 0x06, 0x49, 0x01, 0xda, 0x1e, 0x74, 0x4c, 0x9b, 0x96, 0xaf, 0x4b, + 0xcd, 0xb9, 0x8b, 0xb4, 0x3c, 0x29, 0x7c, 0x6b, 0xa9, 0xbf, 0xc7, 0x7b, 0x15, 0x80, 0x25, 0xfe, + 0x67, 0xc6, 0xb5, 0x11, 0x2c, 0x40, 0xc1, 0xcd, 0x6a, 0xf8, 0x1e, 0xef, 0x55, 0x60, 0x95, 0xd0, + 0x5f, 0x18, 0x6f, 0x5f, 0xb9, 0xb4, 0x78, 0xcc, 0xef, 0xd8, 0xb4, 0x7c, 0x39, 0x9b, 0x2d, 0xc8, + 0xf5, 0xdf, 0x00, 0x06, 0x73, 0x55, 0xb0, 0x76, 0x9d, 0x6b, 0xba, 0x78, 0xc2, 0x77, 0x5e, 0xa5, + 0x90, 0xc2, 0x89, 0x8b, 0x71, 0x52, 0x5e, 0x14, 0x56, 0xb0, 0x5d, 0xa7, 0x6a, 0x2b, 0xff, 0xa3, + 0x20, 0x88, 0xd3, 0x48, 0x8d, 0xc9, 0x87, 0xd8, 0x55, 0x48, 0xb2, 0xa0, 0xee, 0x3a, 0x55, 0x5b, + 0x83, 0xef, 0x8c, 0x77, 0x86, 0xab, 0xbc, 0x1f, 0xe5, 0x79, 0x17, 0x87, 0xbc, 0xb9, 0x8a, 0x8f, + 0xd8, 0x35, 0x2b, 0xb3, 0xad, 0x3f, 0x30, 0x6b, 0xf2, 0xd5, 0x10, 0x23, 0xde, 0xda, 0xcc, 0x4f, + 0xf4, 0xcc, 0xba, 0xb0, 0xe9, 0xba, 0x59, 0x3f, 0xe6, 0xe2, 0x94, 0x4d, 0x43, 0x45, 0xcf, 0xac, + 0x9b, 0xb9, 0xae, 0x9b, 0xf5, 0x7d, 0x6f, 0x1c, 0xbf, 0x3b, 0xbf, 0x34, 0x1a, 0x3f, 0x2e, 0x8d, + 0xc6, 0xc7, 0xcc, 0x60, 0xe7, 0x99, 0xc1, 0xbe, 0x65, 0x06, 0xfb, 0x99, 0x19, 0xec, 0xfd, 0xf3, + 0xff, 0x7f, 0x13, 0x0e, 0xaf, 0x2e, 0xde, 0x36, 0x4e, 0x9b, 0xc5, 0x03, 0xf0, 0xf4, 0x57, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x20, 0x70, 0xc7, 0x0f, 0x5f, 0x04, 0x00, 0x00, } func (m *AddNICInternalRequest) Marshal() (dAtA []byte, err error) { @@ -280,6 +412,70 @@ func (m *AddNICInternalResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *ModifyNICInternalRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ModifyNICInternalRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.NicID) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintComputeagent(dAtA, i, uint64(len(m.NicID))) + i += copy(dAtA[i:], m.NicID) + } + if len(m.EndpointName) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintComputeagent(dAtA, i, uint64(len(m.EndpointName))) + i += copy(dAtA[i:], m.EndpointName) + } + if m.IovPolicySettings != nil { + dAtA[i] = 0x1a + i++ + i = encodeVarintComputeagent(dAtA, i, uint64(m.IovPolicySettings.Size())) + n1, err := m.IovPolicySettings.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *ModifyNICInternalResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ModifyNICInternalResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + func (m *DeleteNICInternalRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -340,6 +536,42 @@ func (m *DeleteNICInternalResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *IovSettings) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IovSettings) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.IovOffloadWeight != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintComputeagent(dAtA, i, uint64(m.IovOffloadWeight)) + } + if m.QueuePairsRequested != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintComputeagent(dAtA, i, uint64(m.QueuePairsRequested)) + } + if m.InterruptModeration != 0 { + dAtA[i] = 0x18 + i++ + i = encodeVarintComputeagent(dAtA, i, uint64(m.InterruptModeration)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + func encodeVarintComputeagent(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -385,6 +617,42 @@ func (m *AddNICInternalResponse) Size() (n int) { return n } +func (m *ModifyNICInternalRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.NicID) + if l > 0 { + n += 1 + l + sovComputeagent(uint64(l)) + } + l = len(m.EndpointName) + if l > 0 { + n += 1 + l + sovComputeagent(uint64(l)) + } + if m.IovPolicySettings != nil { + l = m.IovPolicySettings.Size() + n += 1 + l + sovComputeagent(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *ModifyNICInternalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *DeleteNICInternalRequest) Size() (n int) { if m == nil { return 0 @@ -421,6 +689,27 @@ func (m *DeleteNICInternalResponse) Size() (n int) { return n } +func (m *IovSettings) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IovOffloadWeight != 0 { + n += 1 + sovComputeagent(uint64(m.IovOffloadWeight)) + } + if m.QueuePairsRequested != 0 { + n += 1 + sovComputeagent(uint64(m.QueuePairsRequested)) + } + if m.InterruptModeration != 0 { + n += 1 + sovComputeagent(uint64(m.InterruptModeration)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func sovComputeagent(x uint64) (n int) { for { n++ @@ -457,6 +746,29 @@ func (this *AddNICInternalResponse) String() string { }, "") return s } +func (this *ModifyNICInternalRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ModifyNICInternalRequest{`, + `NicID:` + fmt.Sprintf("%v", this.NicID) + `,`, + `EndpointName:` + fmt.Sprintf("%v", this.EndpointName) + `,`, + `IovPolicySettings:` + strings.Replace(fmt.Sprintf("%v", this.IovPolicySettings), "IovSettings", "IovSettings", 1) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *ModifyNICInternalResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ModifyNICInternalResponse{`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} func (this *DeleteNICInternalRequest) String() string { if this == nil { return "nil" @@ -480,6 +792,19 @@ func (this *DeleteNICInternalResponse) String() string { }, "") return s } +func (this *IovSettings) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&IovSettings{`, + `IovOffloadWeight:` + fmt.Sprintf("%v", this.IovOffloadWeight) + `,`, + `QueuePairsRequested:` + fmt.Sprintf("%v", this.QueuePairsRequested) + `,`, + `InterruptModeration:` + fmt.Sprintf("%v", this.InterruptModeration) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} func valueToStringComputeagent(v interface{}) string { rv := reflect.ValueOf(v) if rv.IsNil() { @@ -491,6 +816,7 @@ func valueToStringComputeagent(v interface{}) string { type ComputeAgentService interface { AddNIC(ctx context.Context, req *AddNICInternalRequest) (*AddNICInternalResponse, error) + ModifyNIC(ctx context.Context, req *ModifyNICInternalRequest) (*ModifyNICInternalResponse, error) DeleteNIC(ctx context.Context, req *DeleteNICInternalRequest) (*DeleteNICInternalResponse, error) } @@ -503,6 +829,13 @@ func RegisterComputeAgentService(srv *github_com_containerd_ttrpc.Server, svc Co } return svc.AddNIC(ctx, &req) }, + "ModifyNIC": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) { + var req ModifyNICInternalRequest + if err := unmarshal(&req); err != nil { + return nil, err + } + return svc.ModifyNIC(ctx, &req) + }, "DeleteNIC": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) { var req DeleteNICInternalRequest if err := unmarshal(&req); err != nil { @@ -531,6 +864,14 @@ func (c *computeAgentClient) AddNIC(ctx context.Context, req *AddNICInternalRequ return &resp, nil } +func (c *computeAgentClient) ModifyNIC(ctx context.Context, req *ModifyNICInternalRequest) (*ModifyNICInternalResponse, error) { + var resp ModifyNICInternalResponse + if err := c.client.Call(ctx, "ComputeAgent", "ModifyNIC", req, &resp); err != nil { + return nil, err + } + return &resp, nil +} + func (c *computeAgentClient) DeleteNIC(ctx context.Context, req *DeleteNICInternalRequest) (*DeleteNICInternalResponse, error) { var resp DeleteNICInternalResponse if err := c.client.Call(ctx, "ComputeAgent", "DeleteNIC", req, &resp); err != nil { @@ -742,7 +1083,7 @@ func (m *AddNICInternalResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *DeleteNICInternalRequest) Unmarshal(dAtA []byte) error { +func (m *ModifyNICInternalRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -765,15 +1106,15 @@ func (m *DeleteNICInternalRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: DeleteNICInternalRequest: wiretype end group for non-group") + return fmt.Errorf("proto: ModifyNICInternalRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteNICInternalRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ModifyNICInternalRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ContainerID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NicID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -801,11 +1142,11 @@ func (m *DeleteNICInternalRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ContainerID = string(dAtA[iNdEx:postIndex]) + m.NicID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NicID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EndpointName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -833,13 +1174,13 @@ func (m *DeleteNICInternalRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.NicID = string(dAtA[iNdEx:postIndex]) + m.EndpointName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EndpointName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field IovPolicySettings", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowComputeagent @@ -849,23 +1190,27 @@ func (m *DeleteNICInternalRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthComputeagent } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthComputeagent } if postIndex > l { return io.ErrUnexpectedEOF } - m.EndpointName = string(dAtA[iNdEx:postIndex]) + if m.IovPolicySettings == nil { + m.IovPolicySettings = &IovSettings{} + } + if err := m.IovPolicySettings.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -892,7 +1237,211 @@ func (m *DeleteNICInternalRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *DeleteNICInternalResponse) Unmarshal(dAtA []byte) error { +func (m *ModifyNICInternalResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeagent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ModifyNICInternalResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModifyNICInternalResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipComputeagent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthComputeagent + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthComputeagent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeleteNICInternalRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeagent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeleteNICInternalRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteNICInternalRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContainerID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeagent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthComputeagent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthComputeagent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContainerID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NicID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeagent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthComputeagent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthComputeagent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NicID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndpointName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeagent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthComputeagent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthComputeagent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EndpointName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipComputeagent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthComputeagent + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthComputeagent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeleteNICInternalResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -946,6 +1495,117 @@ func (m *DeleteNICInternalResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *IovSettings) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeagent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IovSettings: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IovSettings: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IovOffloadWeight", wireType) + } + m.IovOffloadWeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeagent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.IovOffloadWeight |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueuePairsRequested", wireType) + } + m.QueuePairsRequested = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeagent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueuePairsRequested |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field InterruptModeration", wireType) + } + m.InterruptModeration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowComputeagent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.InterruptModeration |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipComputeagent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthComputeagent + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthComputeagent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipComputeagent(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/computeagent/computeagent.proto b/test/vendor/github.com/Microsoft/hcsshim/internal/computeagent/computeagent.proto index 49fa7f36cb..06e301063b 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/computeagent/computeagent.proto +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/computeagent/computeagent.proto @@ -6,6 +6,7 @@ import weak "gogoproto/gogo.proto"; service ComputeAgent{ rpc AddNIC(AddNICInternalRequest) returns (AddNICInternalResponse) {} + rpc ModifyNIC(ModifyNICInternalRequest) returns (ModifyNICInternalResponse) {} rpc DeleteNIC(DeleteNICInternalRequest) returns (DeleteNICInternalResponse) {} } @@ -17,10 +18,24 @@ message AddNICInternalRequest { message AddNICInternalResponse {} +message ModifyNICInternalRequest { + string nic_id = 1; + string endpoint_name = 2; + IovSettings iov_policy_settings = 3; +} + +message ModifyNICInternalResponse {} + message DeleteNICInternalRequest { string container_id = 1; string nic_id = 2; string endpoint_name = 3; } -message DeleteNICInternalResponse {} \ No newline at end of file +message DeleteNICInternalResponse {} + +message IovSettings { + uint32 IovOffloadWeight = 1; + uint32 QueuePairsRequested = 2; + uint32 InterruptModeration = 3; +} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/devices/assigned_devices.go b/test/vendor/github.com/Microsoft/hcsshim/internal/devices/assigned_devices.go index f712009571..8cdc3d9419 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/devices/assigned_devices.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/devices/assigned_devices.go @@ -9,8 +9,6 @@ import ( "net" "strings" - winio "github.com/Microsoft/go-winio" - "github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/hcsshim/internal/cmd" "github.com/Microsoft/hcsshim/internal/log" "github.com/Microsoft/hcsshim/internal/shimdiag" @@ -62,7 +60,7 @@ func AddDevice(ctx context.Context, vm *uvm.UtilityVM, idType, deviceID, deviceU // parent bus device for the children devices' location paths from the uvm's view. // Returns a slice of strings representing the resulting children location paths func getChildrenDeviceLocationPaths(ctx context.Context, vm *uvm.UtilityVM, vmBusInstanceID string, deviceUtilPath string) ([]string, error) { - p, l, err := createNamedPipeListener() + p, l, err := cmd.CreateNamedPipeListener() if err != nil { return nil, err } @@ -111,21 +109,6 @@ func createDeviceUtilChildrenCommand(deviceUtilPath string, vmBusInstanceID stri return args } -// createNamedPipeListener is a helper function to create and return a pipe listener -// and it's created path. -func createNamedPipeListener() (string, net.Listener, error) { - g, err := guid.NewV4() - if err != nil { - return "", nil, err - } - p := `\\.\pipe\` + g.String() - l, err := winio.ListenPipe(p, nil) - if err != nil { - return "", nil, err - } - return p, l, nil -} - // readCsPipeOutput is a helper function that connects to a listener and reads // the connection's comma separated output until done. resulting comma separated // values are returned in the `result` param. The `errChan` param is used to diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/guestconnection.go b/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/guestconnection.go index 921e5f490b..765e6d69c4 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/guestconnection.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/gcs/guestconnection.go @@ -70,7 +70,7 @@ func (gcc *GuestConnectionConfig) Connect(ctx context.Context, isColdStart bool) gc.brdg = newBridge(gcc.Conn, gc.notify, gcc.Log) gc.brdg.Start() go func() { - gc.brdg.Wait() //nolint:errcheck + _ = gc.brdg.Wait() gc.clearNotifies() }() err = gc.connect(ctx, isColdStart) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go index 5eb140d511..1caf3d2e9b 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go @@ -73,7 +73,7 @@ func CreateComputeSystem(ctx context.Context, id string, hcsDocumentInterface in if err = computeSystem.registerCallback(ctx); err != nil { // Terminate the compute system if it still exists. We're okay to // ignore a failure here. - computeSystem.Terminate(ctx) //nolint:errcheck + _ = computeSystem.Terminate(ctx) return nil, makeSystemError(computeSystem, operation, "", err, nil) } } @@ -83,7 +83,7 @@ func CreateComputeSystem(ctx context.Context, id string, hcsDocumentInterface in if err == ErrTimeout { // Terminate the compute system if it still exists. We're okay to // ignore a failure here. - computeSystem.Terminate(ctx) //nolint:errcheck + _ = computeSystem.Terminate(ctx) } return nil, makeSystemError(computeSystem, operation, hcsDocument, err, events) } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/create.go b/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/create.go index 8d58df2689..546e3516c2 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/create.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/create.go @@ -271,7 +271,7 @@ func CreateContainer(ctx context.Context, createOptions *CreateOptions) (_ cow.C defer func() { if err != nil { if !coi.DoNotReleaseResourcesOnFailure { - resources.ReleaseResources(ctx, r, coi.HostingSystem, true) //nolint:errcheck + _ = resources.ReleaseResources(ctx, r, coi.HostingSystem, true) } } }() @@ -388,7 +388,7 @@ func CloneContainer(ctx context.Context, createOptions *CreateOptions) (_ cow.Co defer func() { if err != nil { if !coi.DoNotReleaseResourcesOnFailure { - resources.ReleaseResources(ctx, r, coi.HostingSystem, true) //nolint:errcheck + _ = resources.ReleaseResources(ctx, r, coi.HostingSystem, true) } } }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/layers/layers.go b/test/vendor/github.com/Microsoft/hcsshim/internal/layers/layers.go index 0391d7450e..f3f4e77edd 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/layers/layers.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/layers/layers.go @@ -83,7 +83,7 @@ func MountContainerLayers(ctx context.Context, layerFolders []string, guestRoot } defer func() { if err != nil { - wclayer.DeactivateLayer(ctx, path) //nolint:errcheck + _ = wclayer.DeactivateLayer(ctx, path) } }() @@ -92,7 +92,7 @@ func MountContainerLayers(ctx context.Context, layerFolders []string, guestRoot } defer func() { if err != nil { - wclayer.UnprepareLayer(ctx, path) //nolint:errcheck + _ = wclayer.UnprepareLayer(ctx, path) } }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/disk.go b/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/disk.go index ebe6efcb1e..a208cb7231 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/disk.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/disk.go @@ -34,7 +34,7 @@ func FormatDisk(ctx context.Context, lcowUVM *uvm.UtilityVM, destPath string) er } defer func() { - scsi.Release(ctx) //nolint:errcheck + _ = scsi.Release(ctx) }() log.G(ctx).WithFields(logrus.Fields{ diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/scratch.go b/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/scratch.go index 4060885a99..8d1e337b52 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/scratch.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/lcow/scratch.go @@ -73,7 +73,7 @@ func CreateScratch(ctx context.Context, lcowUVM *uvm.UtilityVM, destFile string, removeSCSI := true defer func() { if removeSCSI { - lcowUVM.RemoveSCSI(ctx, destFile) //nolint:errcheck + _ = lcowUVM.RemoveSCSI(ctx, destFile) } }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/ncproxyttrpc/networkconfigproxy.proto b/test/vendor/github.com/Microsoft/hcsshim/internal/ncproxyttrpc/networkconfigproxy.proto index 9ec8864c3e..882d8c3008 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/ncproxyttrpc/networkconfigproxy.proto +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/ncproxyttrpc/networkconfigproxy.proto @@ -26,4 +26,4 @@ message ConfigureNetworkingInternalRequest{ RequestTypeInternal request_type = 2; } -message ConfigureNetworkingInternalResponse{} \ No newline at end of file +message ConfigureNetworkingInternalResponse{} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/runhcs/container.go b/test/vendor/github.com/Microsoft/hcsshim/internal/runhcs/container.go index 79f0dbfe36..a161c204e2 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/runhcs/container.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/runhcs/container.go @@ -51,7 +51,7 @@ func GetErrorFromPipe(pipe io.Reader, p *os.Process) error { extra := "" if p != nil { - p.Kill() //nolint:errcheck + _ = p.Kill() state, err := p.Wait() if err != nil { panic(err) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go b/test/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go index b800e8e02c..66b8d7e035 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/safefile/safeopen.go @@ -244,7 +244,7 @@ func RemoveRelative(path string, root *os.File) error { err = deleteOnClose(f) if err == syscall.ERROR_ACCESS_DENIED { // Maybe the file is marked readonly. Clear the bit and retry. - clearReadOnly(f) //nolint:errcheck + _ = clearReadOnly(f) err = deleteOnClose(f) } } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/interrupt_moderation_mode.go b/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/interrupt_moderation_mode.go new file mode 100644 index 0000000000..a614d63bd7 --- /dev/null +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/interrupt_moderation_mode.go @@ -0,0 +1,42 @@ +/* + * HCS API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 2.4 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package hcsschema + +type InterruptModerationName string + +// The valid interrupt moderation modes for I/O virtualization (IOV) offloading. +const ( + DefaultName InterruptModerationName = "Default" + AdaptiveName InterruptModerationName = "Adaptive" + OffName InterruptModerationName = "Off" + LowName InterruptModerationName = "Low" + MediumName InterruptModerationName = "Medium" + HighName InterruptModerationName = "High" +) + +type InterruptModerationValue uint32 + +const ( + DefaultValue InterruptModerationValue = iota + AdaptiveValue + OffValue + LowValue InterruptModerationValue = 100 + MediumValue InterruptModerationValue = 200 + HighValue InterruptModerationValue = 300 +) + +var InterruptModerationValueToName = map[InterruptModerationValue]InterruptModerationName{ + DefaultValue: DefaultName, + AdaptiveValue: AdaptiveName, + OffValue: OffName, + LowValue: LowName, + MediumValue: MediumName, + HighValue: HighName, +} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/iov_settings.go b/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/iov_settings.go new file mode 100644 index 0000000000..2a55cc37cd --- /dev/null +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/iov_settings.go @@ -0,0 +1,22 @@ +/* + * HCS API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 2.4 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ + +package hcsschema + +type IovSettings struct { + // The weight assigned to this port for I/O virtualization (IOV) offloading. + // Setting this to 0 disables IOV offloading. + OffloadWeight *uint32 `json:"OffloadWeight,omitempty"` + + // The number of queue pairs requested for this port for I/O virtualization (IOV) offloading. + QueuePairsRequested *uint32 `json:"QueuePairsRequested,omitempty"` + + // The interrupt moderation mode for I/O virtualization (IOV) offloading. + InterruptModeration *InterruptModerationName `json:"InterruptModeration,omitempty"` +} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/network_adapter.go b/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/network_adapter.go index a9c750b341..7408abd317 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/network_adapter.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/schema2/network_adapter.go @@ -11,6 +11,7 @@ package hcsschema type NetworkAdapter struct { EndpointId string `json:"EndpointId,omitempty"` - MacAddress string `json:"MacAddress,omitempty"` + // The I/O virtualization (IOV) offloading configuration. + IovSettings *IovSettings `json:"IovSettings,omitempty"` } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/shimdiag/shimdiag.go b/test/vendor/github.com/Microsoft/hcsshim/internal/shimdiag/shimdiag.go new file mode 100644 index 0000000000..0ef2e56a32 --- /dev/null +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/shimdiag/shimdiag.go @@ -0,0 +1,103 @@ +package shimdiag + +import ( + context "context" + fmt "fmt" + "os" + "path/filepath" + "sort" + strings "strings" + + "github.com/Microsoft/go-winio" + "github.com/containerd/ttrpc" + "golang.org/x/sys/windows" +) + +const ( + shimPrefix = `\\.\pipe\ProtectedPrefix\Administrators\containerd-shim-` + shimSuffix = `-pipe` +) + +func findPipes(pattern string) ([]string, error) { + path := `\\.\pipe\*` + path16, err := windows.UTF16FromString(path) + if err != nil { + return nil, err + } + var data windows.Win32finddata + h, err := windows.FindFirstFile(&path16[0], &data) + if err != nil { + return nil, &os.PathError{Op: "FindFirstFile", Path: path, Err: err} + } + var names []string + for { + name := `\\.\pipe\` + windows.UTF16ToString(data.FileName[:]) + if matched, _ := filepath.Match(pattern, name); matched { + names = append(names, name) + } + err = windows.FindNextFile(h, &data) + if err == windows.ERROR_NO_MORE_FILES { + break + } + if err != nil { + return nil, &os.PathError{Op: "FindNextFile", Path: path, Err: err} + } + } + return names, nil +} + +func FindShims(name string) ([]string, error) { + pipes, err := findPipes(shimPrefix + name + "*" + shimSuffix) + if err != nil { + return nil, err + } + for i, p := range pipes { + pipes[i] = p[len(shimPrefix) : len(p)-len(shimSuffix)] + } + sort.Strings(pipes) + return pipes, nil +} + +func findShim(name string) (string, error) { + if strings.ContainsAny(name, "*?\\/") { + return "", fmt.Errorf("invalid shim name %s", name) + } + shims, err := FindShims(name) + if err != nil { + return "", err + } + if len(shims) == 0 { + return "", fmt.Errorf("no such shim %s", name) + } + if len(shims) > 1 && shims[0] != name { + return "", fmt.Errorf("multiple shims beginning with %s", name) + } + return shims[0], nil +} + +func GetShim(name string) (*ttrpc.Client, error) { + shim, err := findShim(name) + if err != nil { + return nil, err + } + conn, err := winio.DialPipe(shimPrefix+shim+shimSuffix, nil) + if err != nil { + return nil, err + } + return ttrpc.NewClient(conn), nil +} + +func GetPid(shimName string) (int32, error) { + shim, err := GetShim(shimName) + if err != nil { + return 0, err + } + defer shim.Close() + + svc := NewShimDiagClient(shim) + resp, err := svc.DiagPid(context.Background(), &PidRequest{}) + if err != nil { + return 0, err + } + return resp.Pid, nil +} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go index a2cfc8215f..a3d6ac62e0 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/computeagent.go @@ -7,10 +7,13 @@ import ( "github.com/Microsoft/go-winio" "github.com/Microsoft/hcsshim/internal/computeagent" "github.com/Microsoft/hcsshim/internal/hns" + hcsschema "github.com/Microsoft/hcsshim/internal/schema2" "github.com/Microsoft/hcsshim/pkg/octtrpc" "github.com/containerd/ttrpc" "github.com/pkg/errors" "github.com/sirupsen/logrus" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/Microsoft/hcsshim/internal/log" ) @@ -36,6 +39,10 @@ func (ca *computeAgent) AddNIC(ctx context.Context, req *computeagent.AddNICInte "nicID": req.NicID, }).Info("AddNIC request") + if req.NicID == "" || req.EndpointName == "" { + return nil, status.Error(codes.InvalidArgument, "received empty field in request") + } + endpoint, err := hns.GetHNSEndpointByName(req.EndpointName) if err != nil { return nil, errors.Wrapf(err, "failed to get endpoint with name %q", req.EndpointName) @@ -46,6 +53,44 @@ func (ca *computeAgent) AddNIC(ctx context.Context, req *computeagent.AddNICInte return &computeagent.AddNICInternalResponse{}, nil } +// ModifyNIC will modify a NIC from the computeagent services hosting UVM. +func (ca *computeAgent) ModifyNIC(ctx context.Context, req *computeagent.ModifyNICInternalRequest) (*computeagent.ModifyNICInternalResponse, error) { + log.G(ctx).WithFields(logrus.Fields{ + "nicID": req.NicID, + "endpointName": req.EndpointName, + }).Info("ModifyNIC request") + + if req.NicID == "" || req.EndpointName == "" || req.IovPolicySettings == nil { + return nil, status.Error(codes.InvalidArgument, "received empty field in request") + } + + endpoint, err := hns.GetHNSEndpointByName(req.EndpointName) + if err != nil { + return nil, errors.Wrapf(err, "failed to get endpoint with name `%s`", req.EndpointName) + } + + moderationValue := hcsschema.InterruptModerationValue(req.IovPolicySettings.InterruptModeration) + moderationName := hcsschema.InterruptModerationValueToName[moderationValue] + + iovSettings := &hcsschema.IovSettings{ + OffloadWeight: &req.IovPolicySettings.IovOffloadWeight, + QueuePairsRequested: &req.IovPolicySettings.QueuePairsRequested, + InterruptModeration: &moderationName, + } + + nic := &hcsschema.NetworkAdapter{ + EndpointId: endpoint.Id, + MacAddress: endpoint.MacAddress, + IovSettings: iovSettings, + } + + if err := ca.uvm.UpdateNIC(ctx, req.NicID, nic); err != nil { + return nil, errors.Wrap(err, "failed to update UVM's network adapter") + } + + return &computeagent.ModifyNICInternalResponse{}, nil +} + // DeleteNIC will delete a NIC from the computeagent services hosting UVM. func (ca *computeAgent) DeleteNIC(ctx context.Context, req *computeagent.DeleteNICInternalRequest) (*computeagent.DeleteNICInternalResponse, error) { log.G(ctx).WithFields(logrus.Fields{ @@ -54,6 +99,10 @@ func (ca *computeAgent) DeleteNIC(ctx context.Context, req *computeagent.DeleteN "endpointName": req.EndpointName, }).Info("DeleteNIC request") + if req.NicID == "" || req.EndpointName == "" { + return nil, status.Error(codes.InvalidArgument, "received empty field in request") + } + endpoint, err := hns.GetHNSEndpointByName(req.EndpointName) if err != nil { return nil, errors.Wrapf(err, "failed to get endpoint with name %q", req.EndpointName) diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go index b40fce1280..d688ef5733 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/create.go @@ -216,10 +216,9 @@ func (uvm *UtilityVM) create(ctx context.Context, doc interface{}) error { return err } defer func() { - //nolint:errcheck if system != nil { - system.Terminate(ctx) - system.Wait() + _ = system.Terminate(ctx) + _ = system.Wait() } }() @@ -252,8 +251,8 @@ func (uvm *UtilityVM) Close() (err error) { if err := uvm.ReleaseCPUGroup(ctx); err != nil { log.G(ctx).WithError(err).Warn("failed to release VM resource") } - uvm.hcsSystem.Terminate(ctx) //nolint:errcheck - uvm.Wait() //nolint:errcheck + _ = uvm.hcsSystem.Terminate(ctx) + _ = uvm.Wait() } if err := uvm.CloseGCSConnection(); err != nil { diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go index 1b72d7ce56..04f4b9252a 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/network.go @@ -642,3 +642,13 @@ func (uvm *UtilityVM) RemoveAllNICs(ctx context.Context) error { } return nil } + +// UpdateNIC updates a UVM's network adapter. +func (uvm *UtilityVM) UpdateNIC(ctx context.Context, id string, settings *hcsschema.NetworkAdapter) error { + req := &hcsschema.ModifySettingRequest{ + RequestType: requesttype.Update, + ResourcePath: fmt.Sprintf(networkResourceFormat, id), + Settings: settings, + } + return uvm.modify(ctx, req) +} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go index 71ff206954..ad0adfddaa 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/share.go @@ -22,7 +22,7 @@ func (uvm *UtilityVM) Share(ctx context.Context, reqHostPath, reqUVMPath string, } defer func() { if err != nil { - vsmbShare.Release(ctx) //nolint:errcheck + _ = vsmbShare.Release(ctx) } }() @@ -64,7 +64,7 @@ func (uvm *UtilityVM) Share(ctx context.Context, reqHostPath, reqUVMPath string, } defer func() { if err != nil { - plan9Share.Release(ctx) //nolint:errcheck + _ = plan9Share.Release(ctx) } }() } diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go index bc3ac9503a..81c8a479d8 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/start.go @@ -153,7 +153,9 @@ func (uvm *UtilityVM) configureHvSocketForGCS(ctx context.Context) (err error) { func (uvm *UtilityVM) Start(ctx context.Context) (err error) { ctx, cancel := context.WithTimeout(ctx, 2*time.Minute) g, gctx := errgroup.WithContext(ctx) - defer g.Wait() //nolint:errcheck + defer func() { + _ = g.Wait() + }() defer cancel() // Prepare to provide entropy to the init process in the background. This @@ -197,10 +199,9 @@ func (uvm *UtilityVM) Start(ctx context.Context) (err error) { return err } defer func() { - //nolint:errcheck if err != nil { - uvm.hcsSystem.Terminate(ctx) - uvm.hcsSystem.Wait() + _ = uvm.hcsSystem.Terminate(ctx) + _ = uvm.hcsSystem.Wait() } }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go index 5d2e3c2ff4..85692d8824 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/uvm/vsmb.go @@ -141,7 +141,9 @@ func forceNoDirectMap(path string) (bool, error) { if err != nil { return false, err } - defer windows.CloseHandle(h) //nolint:errcheck + defer func() { + _ = windows.CloseHandle(h) + }() var info winapi.FILE_ID_INFO // We check for any error, rather than just ERROR_INVALID_PARAMETER. It seems better to also // fall back if e.g. some other backing filesystem is used which returns a different error. diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go index 043c56dee2..83ba72cfad 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go @@ -390,7 +390,7 @@ func (w *legacyLayerWriter) CloseRoots() { w.destRoot = nil } for i := range w.parentRoots { - w.parentRoots[i].Close() //nolint:errcheck + _ = w.parentRoots[i].Close() } w.parentRoots = nil } @@ -640,7 +640,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro defer func() { if f != nil { f.Close() - safefile.RemoveRelative(name, w.destRoot) //nolint:errcheck + _ = safefile.RemoveRelative(name, w.destRoot) } }() @@ -676,7 +676,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro defer func() { if f != nil { f.Close() - safefile.RemoveRelative(fname, w.root) //nolint:errcheck + _ = safefile.RemoveRelative(fname, w.root) } }() diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/system.go b/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/system.go new file mode 100644 index 0000000000..327f57d7c2 --- /dev/null +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/system.go @@ -0,0 +1,52 @@ +package winapi + +import "golang.org/x/sys/windows" + +const SystemProcessInformation = 5 + +const STATUS_INFO_LENGTH_MISMATCH = 0xC0000004 + +// __kernel_entry NTSTATUS NtQuerySystemInformation( +// SYSTEM_INFORMATION_CLASS SystemInformationClass, +// PVOID SystemInformation, +// ULONG SystemInformationLength, +// PULONG ReturnLength +// ); +//sys NtQuerySystemInformation(systemInfoClass int, systemInformation uintptr, systemInfoLength uint32, returnLength *uint32) (status uint32) = ntdll.NtQuerySystemInformation + +type SYSTEM_PROCESS_INFORMATION struct { + NextEntryOffset uint32 // ULONG + NumberOfThreads uint32 // ULONG + WorkingSetPrivateSize int64 // LARGE_INTEGER + HardFaultCount uint32 // ULONG + NumberOfThreadsHighWatermark uint32 // ULONG + CycleTime uint64 // ULONGLONG + CreateTime int64 // LARGE_INTEGER + UserTime int64 // LARGE_INTEGER + KernelTime int64 // LARGE_INTEGER + ImageName UnicodeString // UNICODE_STRING + BasePriority int32 // KPRIORITY + UniqueProcessID windows.Handle // HANDLE + InheritedFromUniqueProcessID windows.Handle // HANDLE + HandleCount uint32 // ULONG + SessionID uint32 // ULONG + UniqueProcessKey *uint32 // ULONG_PTR + PeakVirtualSize uintptr // SIZE_T + VirtualSize uintptr // SIZE_T + PageFaultCount uint32 // ULONG + PeakWorkingSetSize uintptr // SIZE_T + WorkingSetSize uintptr // SIZE_T + QuotaPeakPagedPoolUsage uintptr // SIZE_T + QuotaPagedPoolUsage uintptr // SIZE_T + QuotaPeakNonPagedPoolUsage uintptr // SIZE_T + QuotaNonPagedPoolUsage uintptr // SIZE_T + PagefileUsage uintptr // SIZE_T + PeakPagefileUsage uintptr // SIZE_T + PrivatePageCount uintptr // SIZE_T + ReadOperationCount int64 // LARGE_INTEGER + WriteOperationCount int64 // LARGE_INTEGER + OtherOperationCount int64 // LARGE_INTEGER + ReadTransferCount int64 // LARGE_INTEGER + WriteTransferCount int64 // LARGE_INTEGER + OtherTransferCount int64 // LARGE_INTEGER +} diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/thread.go b/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/thread.go index 2a1dac26ac..4724713e3e 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/thread.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/thread.go @@ -1,3 +1,12 @@ package winapi +// HANDLE CreateRemoteThread( +// HANDLE hProcess, +// LPSECURITY_ATTRIBUTES lpThreadAttributes, +// SIZE_T dwStackSize, +// LPTHREAD_START_ROUTINE lpStartAddress, +// LPVOID lpParameter, +// DWORD dwCreationFlags, +// LPDWORD lpThreadId +// ); //sys CreateRemoteThread(process windows.Handle, sa *windows.SecurityAttributes, stackSize uint32, startAddr uintptr, parameter uintptr, creationFlags uint32, threadID *uint32) (handle windows.Handle, err error) = kernel32.CreateRemoteThread diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/winapi.go b/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/winapi.go index e783d61f66..ec88c0d212 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/winapi.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/winapi.go @@ -2,4 +2,4 @@ // be thought of as an extension to golang.org/x/sys/windows. package winapi -//go:generate go run ..\..\mksyscall_windows.go -output zsyscall_windows.go net.go path.go thread.go iocp.go jobobject.go logon.go memory.go process.go processor.go devices.go filesystem.go errors.go +//go:generate go run ..\..\mksyscall_windows.go -output zsyscall_windows.go system.go net.go path.go thread.go iocp.go jobobject.go logon.go memory.go process.go processor.go devices.go filesystem.go errors.go diff --git a/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/zsyscall_windows.go b/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/zsyscall_windows.go index 8dd3d3e9bd..2941b0f980 100644 --- a/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/zsyscall_windows.go +++ b/test/vendor/github.com/Microsoft/hcsshim/internal/winapi/zsyscall_windows.go @@ -37,13 +37,14 @@ func errnoErr(e syscall.Errno) error { } var ( + modntdll = windows.NewLazySystemDLL("ntdll.dll") modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll") modkernel32 = windows.NewLazySystemDLL("kernel32.dll") - modntdll = windows.NewLazySystemDLL("ntdll.dll") modadvapi32 = windows.NewLazySystemDLL("advapi32.dll") modpsapi = windows.NewLazySystemDLL("psapi.dll") modcfgmgr32 = windows.NewLazySystemDLL("cfgmgr32.dll") + procNtQuerySystemInformation = modntdll.NewProc("NtQuerySystemInformation") procSetJobCompartmentId = modiphlpapi.NewProc("SetJobCompartmentId") procSearchPathW = modkernel32.NewProc("SearchPathW") procCreateRemoteThread = modkernel32.NewProc("CreateRemoteThread") @@ -73,6 +74,12 @@ var ( procRtlNtStatusToDosError = modntdll.NewProc("RtlNtStatusToDosError") ) +func NtQuerySystemInformation(systemInfoClass int, systemInformation uintptr, systemInfoLength uint32, returnLength *uint32) (status uint32) { + r0, _, _ := syscall.Syscall6(procNtQuerySystemInformation.Addr(), 4, uintptr(systemInfoClass), uintptr(systemInformation), uintptr(systemInfoLength), uintptr(unsafe.Pointer(returnLength)), 0, 0) + status = uint32(r0) + return +} + func SetJobCompartmentId(handle windows.Handle, compartmentId uint32) (win32Err error) { r0, _, _ := syscall.Syscall(procSetJobCompartmentId.Addr(), 2, uintptr(handle), uintptr(compartmentId), 0) if r0 != 0 {