diff --git a/.gitignore b/.gitignore index 74b68f0ad9..d8695f7e16 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,5 @@ go.work.sum # keys and related artifacts *.pem *.cose + +rust/target/ \ No newline at end of file diff --git a/internal/computecore/computecore.go b/internal/computecore/computecore.go new file mode 100644 index 0000000000..ea1071cb48 --- /dev/null +++ b/internal/computecore/computecore.go @@ -0,0 +1,916 @@ +//go:build windows + +package computecore + +import ( + gcontext "context" + "syscall" + "time" + "unsafe" + + "github.com/sirupsen/logrus" + "go.opencensus.io/trace" + + "github.com/Microsoft/hcsshim/internal/interop" + "github.com/Microsoft/hcsshim/internal/log" + "github.com/Microsoft/hcsshim/internal/logfields" + "github.com/Microsoft/hcsshim/internal/oc" + "github.com/Microsoft/hcsshim/internal/timeout" +) + +//go:generate go tool github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go computecore.go + +// Operation management +//sys hcsCreateOperation(context uintptr, callback uintptr) (operation HcsOperation, err error) = computecore.HcsCreateOperation? +//sys hcsCreateOperationWithNotifications(eventTypes uint32, context uintptr, callback uintptr) (operation HcsOperation, err error) = computecore.HcsCreateOperationWithNotifications? +//sys hcsCloseOperation(operation HcsOperation) = computecore.HcsCloseOperation +//sys hcsGetOperationContext(operation HcsOperation) (context uintptr) = computecore.HcsGetOperationContext +//sys hcsSetOperationContext(operation HcsOperation, context uintptr) (hr error) = computecore.HcsSetOperationContext? +//sys hcsGetComputeSystemFromOperation(operation HcsOperation) (computeSystem HcsSystem) = computecore.HcsGetComputeSystemFromOperation +//sys hcsGetProcessFromOperation(operation HcsOperation) (process HcsProcess) = computecore.HcsGetProcessFromOperation +//sys hcsGetOperationType(operation HcsOperation) (operationType int32) = computecore.HcsGetOperationType +//sys hcsGetOperationId(operation HcsOperation) (operationId uint64) = computecore.HcsGetOperationId +//sys hcsGetOperationResult(operation HcsOperation, resultDocument **uint16) (hr error) = computecore.HcsGetOperationResult? +//sys hcsGetOperationResultAndProcessInfo(operation HcsOperation, processInformation *HcsProcessInformation, resultDocument **uint16) (hr error) = computecore.HcsGetOperationResultAndProcessInfo? +//sys hcsAddResourceToOperation(operation HcsOperation, resourceType uint32, uri string, handle syscall.Handle) (hr error) = computecore.HcsAddResourceToOperation? +//sys hcsGetProcessorCompatibilityFromSavedState(runtimeFileName string, processorFeaturesString **uint16) (hr error) = computecore.HcsGetProcessorCompatibilityFromSavedState? +//sys hcsWaitForOperationResult(operation HcsOperation, timeoutMs uint32, resultDocument **uint16) (hr error) = computecore.HcsWaitForOperationResult? +//sys hcsWaitForOperationResultAndProcessInfo(operation HcsOperation, timeoutMs uint32, processInformation *HcsProcessInformation, resultDocument **uint16) (hr error) = computecore.HcsWaitForOperationResultAndProcessInfo? +//sys hcsSetOperationCallback(operation HcsOperation, context uintptr, callback uintptr) (hr error) = computecore.HcsSetOperationCallback? +//sys hcsCancelOperation(operation HcsOperation) (hr error) = computecore.HcsCancelOperation? +//sys hcsGetOperationProperties(operation HcsOperation, options string, resultDocument **uint16) (hr error) = computecore.HcsGetOperationProperties? + +// Compute system lifecycle +//sys hcsEnumerateComputeSystems(query string, operation HcsOperation) (hr error) = computecore.HcsEnumerateComputeSystems? +//sys hcsEnumerateComputeSystemsInNamespace(idNamespace string, query string, operation HcsOperation) (hr error) = computecore.HcsEnumerateComputeSystemsInNamespace? +//sys hcsCreateComputeSystem(id string, configuration string, operation HcsOperation, securityDescriptor unsafe.Pointer, computeSystem *HcsSystem) (hr error) = computecore.HcsCreateComputeSystem? +//sys hcsCreateComputeSystemInNamespace(idNamespace string, id string, configuration string, operation HcsOperation, options unsafe.Pointer, computeSystem *HcsSystem) (hr error) = computecore.HcsCreateComputeSystemInNamespace? +//sys hcsOpenComputeSystem(id string, requestedAccess uint32, computeSystem *HcsSystem) (hr error) = computecore.HcsOpenComputeSystem? +//sys hcsOpenComputeSystemInNamespace(idNamespace string, id string, requestedAccess uint32, computeSystem *HcsSystem) (hr error) = computecore.HcsOpenComputeSystemInNamespace? +//sys hcsCloseComputeSystem(computeSystem HcsSystem) = computecore.HcsCloseComputeSystem +//sys hcsStartComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsStartComputeSystem? +//sys hcsShutDownComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsShutDownComputeSystem? +//sys hcsTerminateComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsTerminateComputeSystem? +//sys hcsCrashComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsCrashComputeSystem? +//sys hcsPauseComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsPauseComputeSystem? +//sys hcsResumeComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsResumeComputeSystem? +//sys hcsSaveComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsSaveComputeSystem? +//sys hcsGetComputeSystemProperties(computeSystem HcsSystem, operation HcsOperation, propertyQuery string) (hr error) = computecore.HcsGetComputeSystemProperties? +//sys hcsModifyComputeSystem(computeSystem HcsSystem, operation HcsOperation, configuration string, identity syscall.Handle) (hr error) = computecore.HcsModifyComputeSystem? +//sys hcsWaitForComputeSystemExit(computeSystem HcsSystem, timeoutMs uint32, result **uint16) (hr error) = computecore.HcsWaitForComputeSystemExit? +//sys hcsSetComputeSystemCallback(computeSystem HcsSystem, callbackOptions uint32, context uintptr, callback uintptr) (hr error) = computecore.HcsSetComputeSystemCallback? + +// Live migration +//sys hcsInitializeLiveMigrationOnSource(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsInitializeLiveMigrationOnSource? +//sys hcsStartLiveMigrationOnSource(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsStartLiveMigrationOnSource? +//sys hcsStartLiveMigrationTransfer(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsStartLiveMigrationTransfer? +//sys hcsFinalizeLiveMigration(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) = computecore.HcsFinalizeLiveMigration? + +// Process lifecycle +//sys hcsCreateProcess(computeSystem HcsSystem, processParameters string, operation HcsOperation, securityDescriptor unsafe.Pointer, process *HcsProcess) (hr error) = computecore.HcsCreateProcess? +//sys hcsOpenProcess(computeSystem HcsSystem, pid uint32, requestedAccess uint32, process *HcsProcess) (hr error) = computecore.HcsOpenProcess? +//sys hcsCloseProcess(process HcsProcess) = computecore.HcsCloseProcess +//sys hcsTerminateProcess(process HcsProcess, operation HcsOperation, options string) (hr error) = computecore.HcsTerminateProcess? +//sys hcsSignalProcess(process HcsProcess, operation HcsOperation, options string) (hr error) = computecore.HcsSignalProcess? +//sys hcsGetProcessInfo(process HcsProcess, operation HcsOperation) (hr error) = computecore.HcsGetProcessInfo? +//sys hcsGetProcessProperties(process HcsProcess, operation HcsOperation, propertyQuery string) (hr error) = computecore.HcsGetProcessProperties? +//sys hcsModifyProcess(process HcsProcess, operation HcsOperation, settings string) (hr error) = computecore.HcsModifyProcess? +//sys hcsSetProcessCallback(process HcsProcess, callbackOptions uint32, context uintptr, callback uintptr) (hr error) = computecore.HcsSetProcessCallback? +//sys hcsWaitForProcessExit(process HcsProcess, timeoutMs uint32, result **uint16) (hr error) = computecore.HcsWaitForProcessExit? + +// Service +//sys hcsGetServiceProperties(propertyQuery string, result **uint16) (hr error) = computecore.HcsGetServiceProperties? +//sys hcsModifyServiceSettings(settings string, result **uint16) (hr error) = computecore.HcsModifyServiceSettings? +//sys hcsSubmitWerReport(settings string) (hr error) = computecore.HcsSubmitWerReport? + +// File and VM access +//sys hcsCreateEmptyGuestStateFile(guestStateFilePath string) (hr error) = computecore.HcsCreateEmptyGuestStateFile? +//sys hcsCreateEmptyRuntimeStateFile(runtimeStateFilePath string) (hr error) = computecore.HcsCreateEmptyRuntimeStateFile? +//sys hcsGrantVmAccess(vmId string, filePath string) (hr error) = computecore.HcsGrantVmAccess? +//sys hcsRevokeVmAccess(vmId string, filePath string) (hr error) = computecore.HcsRevokeVmAccess? +//sys hcsGrantVmGroupAccess(filePath string) (hr error) = computecore.HcsGrantVmGroupAccess? +//sys hcsRevokeVmGroupAccess(filePath string) (hr error) = computecore.HcsRevokeVmGroupAccess? + +// errVmcomputeOperationPending is an error encountered when the operation is being completed asynchronously +const errVmcomputeOperationPending = syscall.Errno(0xC0370103) + +// HcsSystem is the handle associated with a created compute system. +type HcsSystem syscall.Handle + +// HcsProcess is the handle associated with a created process in a compute +// system. +type HcsProcess syscall.Handle + +// HcsOperation is the handle associated with an operation on a compute system. +type HcsOperation syscall.Handle + +// HcsCallback is the handle associated with the function to call when events +// occur. +type HcsCallback syscall.Handle + +// HcsProcessInformation is the structure used when creating or getting process +// info. +type HcsProcessInformation struct { + // ProcessID is the pid of the created process. + ProcessID uint32 + _ uint32 // reserved padding + // StdInput is the handle associated with the stdin of the process. + StdInput syscall.Handle + // StdOutput is the handle associated with the stdout of the process. + StdOutput syscall.Handle + // StdError is the handle associated with the stderr of the process. + StdError syscall.Handle +} + +func execute(ctx gcontext.Context, timeout time.Duration, f func() error) error { + now := time.Now() + if timeout > 0 { + var cancel gcontext.CancelFunc + ctx, cancel = gcontext.WithTimeout(ctx, timeout) + defer cancel() + } + + deadline, ok := ctx.Deadline() + trueTimeout := timeout + if ok { + trueTimeout = deadline.Sub(now) + log.G(ctx).WithFields(logrus.Fields{ + logfields.Timeout: trueTimeout, + "desiredTimeout": timeout, + }).Trace("Executing syscall with deadline") + } + + done := make(chan error, 1) + go func() { + done <- f() + }() + select { + case <-ctx.Done(): + if ctx.Err() == gcontext.DeadlineExceeded { + log.G(ctx).WithField(logfields.Timeout, trueTimeout). + Warning("Syscall did not complete within operation timeout. This may indicate a platform issue. " + + "If it appears to be making no forward progress, obtain the stacks and see if there is a syscall " + + "stuck in the platform API for a significant length of time.") + } + return ctx.Err() + case err := <-done: + return err + } +} + +// Operation management + +func HcsCreateOperation(ctx gcontext.Context, callbackContext uintptr, callback uintptr) (operation HcsOperation, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsCreateOperation") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return operation, execute(ctx, timeout.SyscallWatcher, func() error { + var err error + operation, err = hcsCreateOperation(callbackContext, callback) + return err + }) +} + +func HcsCreateOperationWithNotifications(ctx gcontext.Context, eventTypes uint32, callbackContext uintptr, callback uintptr) (operation HcsOperation, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsCreateOperationWithNotifications") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return operation, execute(ctx, timeout.SyscallWatcher, func() error { + var err error + operation, err = hcsCreateOperationWithNotifications(eventTypes, callbackContext, callback) + return err + }) +} + +func HcsCloseOperation(ctx gcontext.Context, operation HcsOperation) { + _, span := oc.StartSpan(ctx, "HcsCloseOperation") + defer span.End() + + hcsCloseOperation(operation) +} + +func HcsGetOperationContext(ctx gcontext.Context, operation HcsOperation) uintptr { + _, span := oc.StartSpan(ctx, "HcsGetOperationContext") + defer span.End() + + return hcsGetOperationContext(operation) +} + +func HcsSetOperationContext(ctx gcontext.Context, operation HcsOperation, callbackContext uintptr) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsSetOperationContext") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsSetOperationContext(operation, callbackContext) + }) +} + +func HcsGetComputeSystemFromOperation(ctx gcontext.Context, operation HcsOperation) HcsSystem { + _, span := oc.StartSpan(ctx, "HcsGetComputeSystemFromOperation") + defer span.End() + + return hcsGetComputeSystemFromOperation(operation) +} + +func HcsGetProcessFromOperation(ctx gcontext.Context, operation HcsOperation) HcsProcess { + _, span := oc.StartSpan(ctx, "HcsGetProcessFromOperation") + defer span.End() + + return hcsGetProcessFromOperation(operation) +} + +func HcsGetOperationType(ctx gcontext.Context, operation HcsOperation) int32 { + _, span := oc.StartSpan(ctx, "HcsGetOperationType") + defer span.End() + + return hcsGetOperationType(operation) +} + +func HcsGetOperationID(ctx gcontext.Context, operation HcsOperation) uint64 { + _, span := oc.StartSpan(ctx, "HcsGetOperationId") + defer span.End() + + return hcsGetOperationId(operation) +} + +func HcsGetOperationResult(ctx gcontext.Context, operation HcsOperation) (resultDocument string, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsGetOperationResult") + defer span.End() + defer func() { + if resultDocument != "" { + span.AddAttributes(trace.StringAttribute("resultDocument", resultDocument)) + } + oc.SetSpanStatus(span, hr) + }() + + return resultDocument, execute(ctx, timeout.SyscallWatcher, func() error { + var resultDocumentp *uint16 + err := hcsGetOperationResult(operation, &resultDocumentp) + if resultDocumentp != nil { + resultDocument = interop.ConvertAndFreeCoTaskMemString(resultDocumentp) + } + return err + }) +} + +func HcsGetOperationResultAndProcessInfo(ctx gcontext.Context, operation HcsOperation) (processInformation HcsProcessInformation, resultDocument string, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsGetOperationResultAndProcessInfo") + defer span.End() + defer func() { + if resultDocument != "" { + span.AddAttributes(trace.StringAttribute("resultDocument", resultDocument)) + } + oc.SetSpanStatus(span, hr) + }() + + return processInformation, resultDocument, execute(ctx, timeout.SyscallWatcher, func() error { + var resultDocumentp *uint16 + err := hcsGetOperationResultAndProcessInfo(operation, &processInformation, &resultDocumentp) + if resultDocumentp != nil { + resultDocument = interop.ConvertAndFreeCoTaskMemString(resultDocumentp) + } + return err + }) +} + +func HcsAddResourceToOperation(ctx gcontext.Context, operation HcsOperation, resourceType uint32, uri string, handle syscall.Handle) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsAddResourceToOperation") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("uri", uri)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsAddResourceToOperation(operation, resourceType, uri, handle) + }) +} + +func HcsGetProcessorCompatibilityFromSavedState(ctx gcontext.Context, runtimeFileName string) (processorFeaturesString string, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsGetProcessorCompatibilityFromSavedState") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("runtimeFileName", runtimeFileName)) + + return processorFeaturesString, execute(ctx, timeout.SyscallWatcher, func() error { + var processorFeaturesStringp *uint16 + err := hcsGetProcessorCompatibilityFromSavedState(runtimeFileName, &processorFeaturesStringp) + if processorFeaturesStringp != nil { + processorFeaturesString = interop.ConvertAndFreeCoTaskMemString(processorFeaturesStringp) + } + return err + }) +} + +func HcsWaitForOperationResult(ctx gcontext.Context, operation HcsOperation, timeoutMs uint32) (resultDocument string, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsWaitForOperationResult") + defer span.End() + defer func() { + if resultDocument != "" { + span.AddAttributes(trace.StringAttribute("resultDocument", resultDocument)) + } + oc.SetSpanStatus(span, hr) + }() + + return resultDocument, execute(ctx, timeout.SyscallWatcher, func() error { + var resultDocumentp *uint16 + err := hcsWaitForOperationResult(operation, timeoutMs, &resultDocumentp) + if resultDocumentp != nil { + resultDocument = interop.ConvertAndFreeCoTaskMemString(resultDocumentp) + } + return err + }) +} + +func HcsWaitForOperationResultAndProcessInfo(ctx gcontext.Context, operation HcsOperation, timeoutMs uint32) (processInformation HcsProcessInformation, resultDocument string, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsWaitForOperationResultAndProcessInfo") + defer span.End() + defer func() { + if resultDocument != "" { + span.AddAttributes(trace.StringAttribute("resultDocument", resultDocument)) + } + oc.SetSpanStatus(span, hr) + }() + + return processInformation, resultDocument, execute(ctx, timeout.SyscallWatcher, func() error { + var resultDocumentp *uint16 + err := hcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, &processInformation, &resultDocumentp) + if resultDocumentp != nil { + resultDocument = interop.ConvertAndFreeCoTaskMemString(resultDocumentp) + } + return err + }) +} + +func HcsSetOperationCallback(ctx gcontext.Context, operation HcsOperation, callbackContext uintptr, callback uintptr) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsSetOperationCallback") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsSetOperationCallback(operation, callbackContext, callback) + }) +} + +func HcsCancelOperation(ctx gcontext.Context, operation HcsOperation) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsCancelOperation") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsCancelOperation(operation) + }) +} + +func HcsGetOperationProperties(ctx gcontext.Context, operation HcsOperation, options string) (resultDocument string, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsGetOperationProperties") + defer span.End() + defer func() { + if resultDocument != "" { + span.AddAttributes(trace.StringAttribute("resultDocument", resultDocument)) + } + oc.SetSpanStatus(span, hr) + }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return resultDocument, execute(ctx, timeout.SyscallWatcher, func() error { + var resultDocumentp *uint16 + err := hcsGetOperationProperties(operation, options, &resultDocumentp) + if resultDocumentp != nil { + resultDocument = interop.ConvertAndFreeCoTaskMemString(resultDocumentp) + } + return err + }) +} + +// Compute system lifecycle + +func HcsEnumerateComputeSystems(ctx gcontext.Context, query string, operation HcsOperation) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsEnumerateComputeSystems") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("query", query)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsEnumerateComputeSystems(query, operation) + }) +} + +func HcsEnumerateComputeSystemsInNamespace(ctx gcontext.Context, idNamespace string, query string, operation HcsOperation) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsEnumerateComputeSystemsInNamespace") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes( + trace.StringAttribute("idNamespace", idNamespace), + trace.StringAttribute("query", query)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsEnumerateComputeSystemsInNamespace(idNamespace, query, operation) + }) +} + +func HcsCreateComputeSystem(ctx gcontext.Context, id string, configuration string, operation HcsOperation, securityDescriptor unsafe.Pointer) (computeSystem HcsSystem, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsCreateComputeSystem") + defer span.End() + defer func() { + if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned + oc.SetSpanStatus(span, hr) + } + }() + span.AddAttributes( + trace.StringAttribute("id", id), + trace.StringAttribute("configuration", configuration)) + + return computeSystem, execute(ctx, timeout.SystemCreate, func() error { + return hcsCreateComputeSystem(id, configuration, operation, securityDescriptor, &computeSystem) + }) +} + +func HcsCreateComputeSystemInNamespace(ctx gcontext.Context, idNamespace string, id string, configuration string, operation HcsOperation, options unsafe.Pointer) (computeSystem HcsSystem, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsCreateComputeSystemInNamespace") + defer span.End() + defer func() { + if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned + oc.SetSpanStatus(span, hr) + } + }() + span.AddAttributes( + trace.StringAttribute("idNamespace", idNamespace), + trace.StringAttribute("id", id), + trace.StringAttribute("configuration", configuration)) + + return computeSystem, execute(ctx, timeout.SystemCreate, func() error { + return hcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, options, &computeSystem) + }) +} + +func HcsOpenComputeSystem(ctx gcontext.Context, id string, requestedAccess uint32) (computeSystem HcsSystem, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsOpenComputeSystem") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return computeSystem, execute(ctx, timeout.SyscallWatcher, func() error { + return hcsOpenComputeSystem(id, requestedAccess, &computeSystem) + }) +} + +func HcsOpenComputeSystemInNamespace(ctx gcontext.Context, idNamespace string, id string, requestedAccess uint32) (computeSystem HcsSystem, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsOpenComputeSystemInNamespace") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("idNamespace", idNamespace)) + + return computeSystem, execute(ctx, timeout.SyscallWatcher, func() error { + return hcsOpenComputeSystemInNamespace(idNamespace, id, requestedAccess, &computeSystem) + }) +} + +func HcsCloseComputeSystem(ctx gcontext.Context, computeSystem HcsSystem) { + _, span := oc.StartSpan(ctx, "HcsCloseComputeSystem") + defer span.End() + + hcsCloseComputeSystem(computeSystem) +} + +func HcsStartComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsStartComputeSystem") + defer span.End() + defer func() { + if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned + oc.SetSpanStatus(span, hr) + } + }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SystemStart, func() error { + return hcsStartComputeSystem(computeSystem, operation, options) + }) +} + +func HcsShutDownComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsShutDownComputeSystem") + defer span.End() + defer func() { + if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned + oc.SetSpanStatus(span, hr) + } + }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsShutDownComputeSystem(computeSystem, operation, options) + }) +} + +func HcsTerminateComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsTerminateComputeSystem") + defer span.End() + defer func() { + if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned + oc.SetSpanStatus(span, hr) + } + }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsTerminateComputeSystem(computeSystem, operation, options) + }) +} + +func HcsCrashComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsCrashComputeSystem") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsCrashComputeSystem(computeSystem, operation, options) + }) +} + +func HcsPauseComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsPauseComputeSystem") + defer span.End() + defer func() { + if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned + oc.SetSpanStatus(span, hr) + } + }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SystemPause, func() error { + return hcsPauseComputeSystem(computeSystem, operation, options) + }) +} + +func HcsResumeComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsResumeComputeSystem") + defer span.End() + defer func() { + if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned + oc.SetSpanStatus(span, hr) + } + }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SystemResume, func() error { + return hcsResumeComputeSystem(computeSystem, operation, options) + }) +} + +func HcsSaveComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsSaveComputeSystem") + defer span.End() + defer func() { + if hr != errVmcomputeOperationPending { //nolint:errorlint // explicitly returned + oc.SetSpanStatus(span, hr) + } + }() + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsSaveComputeSystem(computeSystem, operation, options) + }) +} + +func HcsGetComputeSystemProperties(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, propertyQuery string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsGetComputeSystemProperties") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("propertyQuery", propertyQuery)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsGetComputeSystemProperties(computeSystem, operation, propertyQuery) + }) +} + +func HcsModifyComputeSystem(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, configuration string, identity syscall.Handle) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsModifyComputeSystem") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("configuration", configuration)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsModifyComputeSystem(computeSystem, operation, configuration, identity) + }) +} + +func HcsWaitForComputeSystemExit(ctx gcontext.Context, computeSystem HcsSystem, timeoutMs uint32) (result string, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsWaitForComputeSystemExit") + defer span.End() + defer func() { + if result != "" { + span.AddAttributes(trace.StringAttribute("result", result)) + } + oc.SetSpanStatus(span, hr) + }() + + return result, execute(ctx, timeout.SyscallWatcher, func() error { + var resultp *uint16 + err := hcsWaitForComputeSystemExit(computeSystem, timeoutMs, &resultp) + if resultp != nil { + result = interop.ConvertAndFreeCoTaskMemString(resultp) + } + return err + }) +} + +func HcsSetComputeSystemCallback(ctx gcontext.Context, computeSystem HcsSystem, callbackOptions uint32, callbackContext uintptr, callback uintptr) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsSetComputeSystemCallback") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsSetComputeSystemCallback(computeSystem, callbackOptions, callbackContext, callback) + }) +} + +// Live migration + +func HcsInitializeLiveMigrationOnSource(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsInitializeLiveMigrationOnSource") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsInitializeLiveMigrationOnSource(computeSystem, operation, options) + }) +} + +func HcsStartLiveMigrationOnSource(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsStartLiveMigrationOnSource") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsStartLiveMigrationOnSource(computeSystem, operation, options) + }) +} + +func HcsStartLiveMigrationTransfer(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsStartLiveMigrationTransfer") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsStartLiveMigrationTransfer(computeSystem, operation, options) + }) +} + +func HcsFinalizeLiveMigration(ctx gcontext.Context, computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsFinalizeLiveMigration") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsFinalizeLiveMigration(computeSystem, operation, options) + }) +} + +// Process lifecycle + +func HcsCreateProcess(ctx gcontext.Context, computeSystem HcsSystem, processParameters string, operation HcsOperation, securityDescriptor unsafe.Pointer) (process HcsProcess, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsCreateProcess") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + if span.IsRecordingEvents() { + if s, err := log.ScrubProcessParameters(processParameters); err == nil { + span.AddAttributes(trace.StringAttribute("processParameters", s)) + } + } + + return process, execute(ctx, timeout.SyscallWatcher, func() error { + return hcsCreateProcess(computeSystem, processParameters, operation, securityDescriptor, &process) + }) +} + +func HcsOpenProcess(ctx gcontext.Context, computeSystem HcsSystem, pid uint32, requestedAccess uint32) (process HcsProcess, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsOpenProcess") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.Int64Attribute("pid", int64(pid))) + + return process, execute(ctx, timeout.SyscallWatcher, func() error { + return hcsOpenProcess(computeSystem, pid, requestedAccess, &process) + }) +} + +func HcsCloseProcess(ctx gcontext.Context, process HcsProcess) { + _, span := oc.StartSpan(ctx, "HcsCloseProcess") + defer span.End() + + hcsCloseProcess(process) +} + +func HcsTerminateProcess(ctx gcontext.Context, process HcsProcess, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsTerminateProcess") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsTerminateProcess(process, operation, options) + }) +} + +func HcsSignalProcess(ctx gcontext.Context, process HcsProcess, operation HcsOperation, options string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsSignalProcess") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("options", options)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsSignalProcess(process, operation, options) + }) +} + +func HcsGetProcessInfo(ctx gcontext.Context, process HcsProcess, operation HcsOperation) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsGetProcessInfo") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsGetProcessInfo(process, operation) + }) +} + +func HcsGetProcessProperties(ctx gcontext.Context, process HcsProcess, operation HcsOperation, propertyQuery string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsGetProcessProperties") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsGetProcessProperties(process, operation, propertyQuery) + }) +} + +func HcsModifyProcess(ctx gcontext.Context, process HcsProcess, operation HcsOperation, settings string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsModifyProcess") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("settings", settings)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsModifyProcess(process, operation, settings) + }) +} + +func HcsSetProcessCallback(ctx gcontext.Context, process HcsProcess, callbackOptions uint32, callbackContext uintptr, callback uintptr) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsSetProcessCallback") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsSetProcessCallback(process, callbackOptions, callbackContext, callback) + }) +} + +func HcsWaitForProcessExit(ctx gcontext.Context, process HcsProcess, timeoutMs uint32) (result string, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsWaitForProcessExit") + defer span.End() + defer func() { + if result != "" { + span.AddAttributes(trace.StringAttribute("result", result)) + } + oc.SetSpanStatus(span, hr) + }() + + return result, execute(ctx, timeout.SyscallWatcher, func() error { + var resultp *uint16 + err := hcsWaitForProcessExit(process, timeoutMs, &resultp) + if resultp != nil { + result = interop.ConvertAndFreeCoTaskMemString(resultp) + } + return err + }) +} + +// Service + +func HcsGetServiceProperties(ctx gcontext.Context, propertyQuery string) (result string, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsGetServiceProperties") + defer span.End() + defer func() { + if result != "" { + span.AddAttributes(trace.StringAttribute("result", result)) + } + oc.SetSpanStatus(span, hr) + }() + span.AddAttributes(trace.StringAttribute("propertyQuery", propertyQuery)) + + return result, execute(ctx, timeout.SyscallWatcher, func() error { + var resultp *uint16 + err := hcsGetServiceProperties(propertyQuery, &resultp) + if resultp != nil { + result = interop.ConvertAndFreeCoTaskMemString(resultp) + } + return err + }) +} + +func HcsModifyServiceSettings(ctx gcontext.Context, settings string) (result string, hr error) { + ctx, span := oc.StartSpan(ctx, "HcsModifyServiceSettings") + defer span.End() + defer func() { + if result != "" { + span.AddAttributes(trace.StringAttribute("result", result)) + } + oc.SetSpanStatus(span, hr) + }() + span.AddAttributes(trace.StringAttribute("settings", settings)) + + return result, execute(ctx, timeout.SyscallWatcher, func() error { + var resultp *uint16 + err := hcsModifyServiceSettings(settings, &resultp) + if resultp != nil { + result = interop.ConvertAndFreeCoTaskMemString(resultp) + } + return err + }) +} + +func HcsSubmitWerReport(ctx gcontext.Context, settings string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsSubmitWerReport") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("settings", settings)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsSubmitWerReport(settings) + }) +} + +// File and VM access + +func HcsCreateEmptyGuestStateFile(ctx gcontext.Context, guestStateFilePath string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsCreateEmptyGuestStateFile") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("guestStateFilePath", guestStateFilePath)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsCreateEmptyGuestStateFile(guestStateFilePath) + }) +} + +func HcsCreateEmptyRuntimeStateFile(ctx gcontext.Context, runtimeStateFilePath string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsCreateEmptyRuntimeStateFile") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("runtimeStateFilePath", runtimeStateFilePath)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsCreateEmptyRuntimeStateFile(runtimeStateFilePath) + }) +} + +func HcsGrantVMAccess(ctx gcontext.Context, vmID string, filePath string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsGrantVmAccess") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes( + trace.StringAttribute("vmID", vmID), + trace.StringAttribute("filePath", filePath)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsGrantVmAccess(vmID, filePath) + }) +} + +func HcsRevokeVMAccess(ctx gcontext.Context, vmID string, filePath string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsRevokeVmAccess") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes( + trace.StringAttribute("vmID", vmID), + trace.StringAttribute("filePath", filePath)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsRevokeVmAccess(vmID, filePath) + }) +} + +func HcsGrantVMGroupAccess(ctx gcontext.Context, filePath string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsGrantVmGroupAccess") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("filePath", filePath)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsGrantVmGroupAccess(filePath) + }) +} + +func HcsRevokeVMGroupAccess(ctx gcontext.Context, filePath string) (hr error) { + ctx, span := oc.StartSpan(ctx, "HcsRevokeVmGroupAccess") + defer span.End() + defer func() { oc.SetSpanStatus(span, hr) }() + span.AddAttributes(trace.StringAttribute("filePath", filePath)) + + return execute(ctx, timeout.SyscallWatcher, func() error { + return hcsRevokeVmGroupAccess(filePath) + }) +} diff --git a/internal/computecore/doc.go b/internal/computecore/doc.go new file mode 100644 index 0000000000..b65d0f688a --- /dev/null +++ b/internal/computecore/doc.go @@ -0,0 +1 @@ +package computecore diff --git a/internal/computecore/zsyscall_windows.go b/internal/computecore/zsyscall_windows.go new file mode 100644 index 0000000000..0c528617f7 --- /dev/null +++ b/internal/computecore/zsyscall_windows.go @@ -0,0 +1,1266 @@ +//go:build windows + +// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT. + +package computecore + +import ( + "syscall" + "unsafe" + + "golang.org/x/sys/windows" +) + +var _ unsafe.Pointer + +// Do the interface allocations only once for common +// Errno values. +const ( + errnoERROR_IO_PENDING = 997 +) + +var ( + errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) + errERROR_EINVAL error = syscall.EINVAL +) + +// errnoErr returns common boxed Errno values, to prevent +// allocations at runtime. +func errnoErr(e syscall.Errno) error { + switch e { + case 0: + return errERROR_EINVAL + case errnoERROR_IO_PENDING: + return errERROR_IO_PENDING + } + return e +} + +var ( + modcomputecore = windows.NewLazySystemDLL("computecore.dll") + + procHcsAddResourceToOperation = modcomputecore.NewProc("HcsAddResourceToOperation") + procHcsCancelOperation = modcomputecore.NewProc("HcsCancelOperation") + procHcsCloseComputeSystem = modcomputecore.NewProc("HcsCloseComputeSystem") + procHcsCloseOperation = modcomputecore.NewProc("HcsCloseOperation") + procHcsCloseProcess = modcomputecore.NewProc("HcsCloseProcess") + procHcsCrashComputeSystem = modcomputecore.NewProc("HcsCrashComputeSystem") + procHcsCreateComputeSystem = modcomputecore.NewProc("HcsCreateComputeSystem") + procHcsCreateComputeSystemInNamespace = modcomputecore.NewProc("HcsCreateComputeSystemInNamespace") + procHcsCreateEmptyGuestStateFile = modcomputecore.NewProc("HcsCreateEmptyGuestStateFile") + procHcsCreateEmptyRuntimeStateFile = modcomputecore.NewProc("HcsCreateEmptyRuntimeStateFile") + procHcsCreateOperation = modcomputecore.NewProc("HcsCreateOperation") + procHcsCreateOperationWithNotifications = modcomputecore.NewProc("HcsCreateOperationWithNotifications") + procHcsCreateProcess = modcomputecore.NewProc("HcsCreateProcess") + procHcsEnumerateComputeSystems = modcomputecore.NewProc("HcsEnumerateComputeSystems") + procHcsEnumerateComputeSystemsInNamespace = modcomputecore.NewProc("HcsEnumerateComputeSystemsInNamespace") + procHcsFinalizeLiveMigration = modcomputecore.NewProc("HcsFinalizeLiveMigration") + procHcsGetComputeSystemFromOperation = modcomputecore.NewProc("HcsGetComputeSystemFromOperation") + procHcsGetComputeSystemProperties = modcomputecore.NewProc("HcsGetComputeSystemProperties") + procHcsGetOperationContext = modcomputecore.NewProc("HcsGetOperationContext") + procHcsGetOperationId = modcomputecore.NewProc("HcsGetOperationId") + procHcsGetOperationProperties = modcomputecore.NewProc("HcsGetOperationProperties") + procHcsGetOperationResult = modcomputecore.NewProc("HcsGetOperationResult") + procHcsGetOperationResultAndProcessInfo = modcomputecore.NewProc("HcsGetOperationResultAndProcessInfo") + procHcsGetOperationType = modcomputecore.NewProc("HcsGetOperationType") + procHcsGetProcessFromOperation = modcomputecore.NewProc("HcsGetProcessFromOperation") + procHcsGetProcessInfo = modcomputecore.NewProc("HcsGetProcessInfo") + procHcsGetProcessProperties = modcomputecore.NewProc("HcsGetProcessProperties") + procHcsGetProcessorCompatibilityFromSavedState = modcomputecore.NewProc("HcsGetProcessorCompatibilityFromSavedState") + procHcsGetServiceProperties = modcomputecore.NewProc("HcsGetServiceProperties") + procHcsGrantVmAccess = modcomputecore.NewProc("HcsGrantVmAccess") + procHcsGrantVmGroupAccess = modcomputecore.NewProc("HcsGrantVmGroupAccess") + procHcsInitializeLiveMigrationOnSource = modcomputecore.NewProc("HcsInitializeLiveMigrationOnSource") + procHcsModifyComputeSystem = modcomputecore.NewProc("HcsModifyComputeSystem") + procHcsModifyProcess = modcomputecore.NewProc("HcsModifyProcess") + procHcsModifyServiceSettings = modcomputecore.NewProc("HcsModifyServiceSettings") + procHcsOpenComputeSystem = modcomputecore.NewProc("HcsOpenComputeSystem") + procHcsOpenComputeSystemInNamespace = modcomputecore.NewProc("HcsOpenComputeSystemInNamespace") + procHcsOpenProcess = modcomputecore.NewProc("HcsOpenProcess") + procHcsPauseComputeSystem = modcomputecore.NewProc("HcsPauseComputeSystem") + procHcsResumeComputeSystem = modcomputecore.NewProc("HcsResumeComputeSystem") + procHcsRevokeVmAccess = modcomputecore.NewProc("HcsRevokeVmAccess") + procHcsRevokeVmGroupAccess = modcomputecore.NewProc("HcsRevokeVmGroupAccess") + procHcsSaveComputeSystem = modcomputecore.NewProc("HcsSaveComputeSystem") + procHcsSetComputeSystemCallback = modcomputecore.NewProc("HcsSetComputeSystemCallback") + procHcsSetOperationCallback = modcomputecore.NewProc("HcsSetOperationCallback") + procHcsSetOperationContext = modcomputecore.NewProc("HcsSetOperationContext") + procHcsSetProcessCallback = modcomputecore.NewProc("HcsSetProcessCallback") + procHcsShutDownComputeSystem = modcomputecore.NewProc("HcsShutDownComputeSystem") + procHcsSignalProcess = modcomputecore.NewProc("HcsSignalProcess") + procHcsStartComputeSystem = modcomputecore.NewProc("HcsStartComputeSystem") + procHcsStartLiveMigrationOnSource = modcomputecore.NewProc("HcsStartLiveMigrationOnSource") + procHcsStartLiveMigrationTransfer = modcomputecore.NewProc("HcsStartLiveMigrationTransfer") + procHcsSubmitWerReport = modcomputecore.NewProc("HcsSubmitWerReport") + procHcsTerminateComputeSystem = modcomputecore.NewProc("HcsTerminateComputeSystem") + procHcsTerminateProcess = modcomputecore.NewProc("HcsTerminateProcess") + procHcsWaitForComputeSystemExit = modcomputecore.NewProc("HcsWaitForComputeSystemExit") + procHcsWaitForOperationResult = modcomputecore.NewProc("HcsWaitForOperationResult") + procHcsWaitForOperationResultAndProcessInfo = modcomputecore.NewProc("HcsWaitForOperationResultAndProcessInfo") + procHcsWaitForProcessExit = modcomputecore.NewProc("HcsWaitForProcessExit") +) + +func hcsAddResourceToOperation(operation HcsOperation, resourceType uint32, uri string, handle syscall.Handle) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(uri) + if hr != nil { + return + } + return _hcsAddResourceToOperation(operation, resourceType, _p0, handle) +} + +func _hcsAddResourceToOperation(operation HcsOperation, resourceType uint32, uri *uint16, handle syscall.Handle) (hr error) { + hr = procHcsAddResourceToOperation.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsAddResourceToOperation.Addr(), uintptr(operation), uintptr(resourceType), uintptr(unsafe.Pointer(uri)), uintptr(handle)) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsCancelOperation(operation HcsOperation) (hr error) { + hr = procHcsCancelOperation.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsCancelOperation.Addr(), uintptr(operation)) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsCloseComputeSystem(computeSystem HcsSystem) { + syscall.SyscallN(procHcsCloseComputeSystem.Addr(), uintptr(computeSystem)) + return +} + +func hcsCloseOperation(operation HcsOperation) { + syscall.SyscallN(procHcsCloseOperation.Addr(), uintptr(operation)) + return +} + +func hcsCloseProcess(process HcsProcess) { + syscall.SyscallN(procHcsCloseProcess.Addr(), uintptr(process)) + return +} + +func hcsCrashComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsCrashComputeSystem(computeSystem, operation, _p0) +} + +func _hcsCrashComputeSystem(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsCrashComputeSystem.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsCrashComputeSystem.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsCreateComputeSystem(id string, configuration string, operation HcsOperation, securityDescriptor unsafe.Pointer, computeSystem *HcsSystem) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(id) + if hr != nil { + return + } + var _p1 *uint16 + _p1, hr = syscall.UTF16PtrFromString(configuration) + if hr != nil { + return + } + return _hcsCreateComputeSystem(_p0, _p1, operation, securityDescriptor, computeSystem) +} + +func _hcsCreateComputeSystem(id *uint16, configuration *uint16, operation HcsOperation, securityDescriptor unsafe.Pointer, computeSystem *HcsSystem) (hr error) { + hr = procHcsCreateComputeSystem.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsCreateComputeSystem.Addr(), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(configuration)), uintptr(operation), uintptr(securityDescriptor), uintptr(unsafe.Pointer(computeSystem))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsCreateComputeSystemInNamespace(idNamespace string, id string, configuration string, operation HcsOperation, options unsafe.Pointer, computeSystem *HcsSystem) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(idNamespace) + if hr != nil { + return + } + var _p1 *uint16 + _p1, hr = syscall.UTF16PtrFromString(id) + if hr != nil { + return + } + var _p2 *uint16 + _p2, hr = syscall.UTF16PtrFromString(configuration) + if hr != nil { + return + } + return _hcsCreateComputeSystemInNamespace(_p0, _p1, _p2, operation, options, computeSystem) +} + +func _hcsCreateComputeSystemInNamespace(idNamespace *uint16, id *uint16, configuration *uint16, operation HcsOperation, options unsafe.Pointer, computeSystem *HcsSystem) (hr error) { + hr = procHcsCreateComputeSystemInNamespace.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsCreateComputeSystemInNamespace.Addr(), uintptr(unsafe.Pointer(idNamespace)), uintptr(unsafe.Pointer(id)), uintptr(unsafe.Pointer(configuration)), uintptr(operation), uintptr(options), uintptr(unsafe.Pointer(computeSystem))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsCreateEmptyGuestStateFile(guestStateFilePath string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(guestStateFilePath) + if hr != nil { + return + } + return _hcsCreateEmptyGuestStateFile(_p0) +} + +func _hcsCreateEmptyGuestStateFile(guestStateFilePath *uint16) (hr error) { + hr = procHcsCreateEmptyGuestStateFile.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsCreateEmptyGuestStateFile.Addr(), uintptr(unsafe.Pointer(guestStateFilePath))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsCreateEmptyRuntimeStateFile(runtimeStateFilePath string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(runtimeStateFilePath) + if hr != nil { + return + } + return _hcsCreateEmptyRuntimeStateFile(_p0) +} + +func _hcsCreateEmptyRuntimeStateFile(runtimeStateFilePath *uint16) (hr error) { + hr = procHcsCreateEmptyRuntimeStateFile.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsCreateEmptyRuntimeStateFile.Addr(), uintptr(unsafe.Pointer(runtimeStateFilePath))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsCreateOperation(context uintptr, callback uintptr) (operation HcsOperation, err error) { + err = procHcsCreateOperation.Find() + if err != nil { + return + } + r0, _, e1 := syscall.SyscallN(procHcsCreateOperation.Addr(), uintptr(context), uintptr(callback)) + operation = HcsOperation(r0) + if operation == 0 { + err = errnoErr(e1) + } + return +} + +func hcsCreateOperationWithNotifications(eventTypes uint32, context uintptr, callback uintptr) (operation HcsOperation, err error) { + err = procHcsCreateOperationWithNotifications.Find() + if err != nil { + return + } + r0, _, e1 := syscall.SyscallN(procHcsCreateOperationWithNotifications.Addr(), uintptr(eventTypes), uintptr(context), uintptr(callback)) + operation = HcsOperation(r0) + if operation == 0 { + err = errnoErr(e1) + } + return +} + +func hcsCreateProcess(computeSystem HcsSystem, processParameters string, operation HcsOperation, securityDescriptor unsafe.Pointer, process *HcsProcess) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(processParameters) + if hr != nil { + return + } + return _hcsCreateProcess(computeSystem, _p0, operation, securityDescriptor, process) +} + +func _hcsCreateProcess(computeSystem HcsSystem, processParameters *uint16, operation HcsOperation, securityDescriptor unsafe.Pointer, process *HcsProcess) (hr error) { + hr = procHcsCreateProcess.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsCreateProcess.Addr(), uintptr(computeSystem), uintptr(unsafe.Pointer(processParameters)), uintptr(operation), uintptr(securityDescriptor), uintptr(unsafe.Pointer(process))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsEnumerateComputeSystems(query string, operation HcsOperation) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(query) + if hr != nil { + return + } + return _hcsEnumerateComputeSystems(_p0, operation) +} + +func _hcsEnumerateComputeSystems(query *uint16, operation HcsOperation) (hr error) { + hr = procHcsEnumerateComputeSystems.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsEnumerateComputeSystems.Addr(), uintptr(unsafe.Pointer(query)), uintptr(operation)) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsEnumerateComputeSystemsInNamespace(idNamespace string, query string, operation HcsOperation) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(idNamespace) + if hr != nil { + return + } + var _p1 *uint16 + _p1, hr = syscall.UTF16PtrFromString(query) + if hr != nil { + return + } + return _hcsEnumerateComputeSystemsInNamespace(_p0, _p1, operation) +} + +func _hcsEnumerateComputeSystemsInNamespace(idNamespace *uint16, query *uint16, operation HcsOperation) (hr error) { + hr = procHcsEnumerateComputeSystemsInNamespace.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsEnumerateComputeSystemsInNamespace.Addr(), uintptr(unsafe.Pointer(idNamespace)), uintptr(unsafe.Pointer(query)), uintptr(operation)) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsFinalizeLiveMigration(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsFinalizeLiveMigration(computeSystem, operation, _p0) +} + +func _hcsFinalizeLiveMigration(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsFinalizeLiveMigration.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsFinalizeLiveMigration.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsGetComputeSystemFromOperation(operation HcsOperation) (computeSystem HcsSystem) { + r0, _, _ := syscall.SyscallN(procHcsGetComputeSystemFromOperation.Addr(), uintptr(operation)) + computeSystem = HcsSystem(r0) + return +} + +func hcsGetComputeSystemProperties(computeSystem HcsSystem, operation HcsOperation, propertyQuery string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(propertyQuery) + if hr != nil { + return + } + return _hcsGetComputeSystemProperties(computeSystem, operation, _p0) +} + +func _hcsGetComputeSystemProperties(computeSystem HcsSystem, operation HcsOperation, propertyQuery *uint16) (hr error) { + hr = procHcsGetComputeSystemProperties.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsGetComputeSystemProperties.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(propertyQuery))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsGetOperationContext(operation HcsOperation) (context uintptr) { + r0, _, _ := syscall.SyscallN(procHcsGetOperationContext.Addr(), uintptr(operation)) + context = uintptr(r0) + return +} + +func hcsGetOperationId(operation HcsOperation) (operationId uint64) { + r0, _, _ := syscall.SyscallN(procHcsGetOperationId.Addr(), uintptr(operation)) + operationId = uint64(r0) + return +} + +func hcsGetOperationProperties(operation HcsOperation, options string, resultDocument **uint16) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsGetOperationProperties(operation, _p0, resultDocument) +} + +func _hcsGetOperationProperties(operation HcsOperation, options *uint16, resultDocument **uint16) (hr error) { + hr = procHcsGetOperationProperties.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsGetOperationProperties.Addr(), uintptr(operation), uintptr(unsafe.Pointer(options)), uintptr(unsafe.Pointer(resultDocument))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsGetOperationResult(operation HcsOperation, resultDocument **uint16) (hr error) { + hr = procHcsGetOperationResult.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsGetOperationResult.Addr(), uintptr(operation), uintptr(unsafe.Pointer(resultDocument))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsGetOperationResultAndProcessInfo(operation HcsOperation, processInformation *HcsProcessInformation, resultDocument **uint16) (hr error) { + hr = procHcsGetOperationResultAndProcessInfo.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsGetOperationResultAndProcessInfo.Addr(), uintptr(operation), uintptr(unsafe.Pointer(processInformation)), uintptr(unsafe.Pointer(resultDocument))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsGetOperationType(operation HcsOperation) (operationType int32) { + r0, _, _ := syscall.SyscallN(procHcsGetOperationType.Addr(), uintptr(operation)) + operationType = int32(r0) + return +} + +func hcsGetProcessFromOperation(operation HcsOperation) (process HcsProcess) { + r0, _, _ := syscall.SyscallN(procHcsGetProcessFromOperation.Addr(), uintptr(operation)) + process = HcsProcess(r0) + return +} + +func hcsGetProcessInfo(process HcsProcess, operation HcsOperation) (hr error) { + hr = procHcsGetProcessInfo.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsGetProcessInfo.Addr(), uintptr(process), uintptr(operation)) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsGetProcessProperties(process HcsProcess, operation HcsOperation, propertyQuery string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(propertyQuery) + if hr != nil { + return + } + return _hcsGetProcessProperties(process, operation, _p0) +} + +func _hcsGetProcessProperties(process HcsProcess, operation HcsOperation, propertyQuery *uint16) (hr error) { + hr = procHcsGetProcessProperties.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsGetProcessProperties.Addr(), uintptr(process), uintptr(operation), uintptr(unsafe.Pointer(propertyQuery))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsGetProcessorCompatibilityFromSavedState(runtimeFileName string, processorFeaturesString **uint16) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(runtimeFileName) + if hr != nil { + return + } + return _hcsGetProcessorCompatibilityFromSavedState(_p0, processorFeaturesString) +} + +func _hcsGetProcessorCompatibilityFromSavedState(runtimeFileName *uint16, processorFeaturesString **uint16) (hr error) { + hr = procHcsGetProcessorCompatibilityFromSavedState.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsGetProcessorCompatibilityFromSavedState.Addr(), uintptr(unsafe.Pointer(runtimeFileName)), uintptr(unsafe.Pointer(processorFeaturesString))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsGetServiceProperties(propertyQuery string, result **uint16) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(propertyQuery) + if hr != nil { + return + } + return _hcsGetServiceProperties(_p0, result) +} + +func _hcsGetServiceProperties(propertyQuery *uint16, result **uint16) (hr error) { + hr = procHcsGetServiceProperties.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsGetServiceProperties.Addr(), uintptr(unsafe.Pointer(propertyQuery)), uintptr(unsafe.Pointer(result))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsGrantVmAccess(vmId string, filePath string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(vmId) + if hr != nil { + return + } + var _p1 *uint16 + _p1, hr = syscall.UTF16PtrFromString(filePath) + if hr != nil { + return + } + return _hcsGrantVmAccess(_p0, _p1) +} + +func _hcsGrantVmAccess(vmId *uint16, filePath *uint16) (hr error) { + hr = procHcsGrantVmAccess.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsGrantVmAccess.Addr(), uintptr(unsafe.Pointer(vmId)), uintptr(unsafe.Pointer(filePath))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsGrantVmGroupAccess(filePath string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(filePath) + if hr != nil { + return + } + return _hcsGrantVmGroupAccess(_p0) +} + +func _hcsGrantVmGroupAccess(filePath *uint16) (hr error) { + hr = procHcsGrantVmGroupAccess.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsGrantVmGroupAccess.Addr(), uintptr(unsafe.Pointer(filePath))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsInitializeLiveMigrationOnSource(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsInitializeLiveMigrationOnSource(computeSystem, operation, _p0) +} + +func _hcsInitializeLiveMigrationOnSource(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsInitializeLiveMigrationOnSource.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsInitializeLiveMigrationOnSource.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsModifyComputeSystem(computeSystem HcsSystem, operation HcsOperation, configuration string, identity syscall.Handle) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(configuration) + if hr != nil { + return + } + return _hcsModifyComputeSystem(computeSystem, operation, _p0, identity) +} + +func _hcsModifyComputeSystem(computeSystem HcsSystem, operation HcsOperation, configuration *uint16, identity syscall.Handle) (hr error) { + hr = procHcsModifyComputeSystem.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsModifyComputeSystem.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(configuration)), uintptr(identity)) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsModifyProcess(process HcsProcess, operation HcsOperation, settings string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(settings) + if hr != nil { + return + } + return _hcsModifyProcess(process, operation, _p0) +} + +func _hcsModifyProcess(process HcsProcess, operation HcsOperation, settings *uint16) (hr error) { + hr = procHcsModifyProcess.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsModifyProcess.Addr(), uintptr(process), uintptr(operation), uintptr(unsafe.Pointer(settings))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsModifyServiceSettings(settings string, result **uint16) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(settings) + if hr != nil { + return + } + return _hcsModifyServiceSettings(_p0, result) +} + +func _hcsModifyServiceSettings(settings *uint16, result **uint16) (hr error) { + hr = procHcsModifyServiceSettings.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsModifyServiceSettings.Addr(), uintptr(unsafe.Pointer(settings)), uintptr(unsafe.Pointer(result))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsOpenComputeSystem(id string, requestedAccess uint32, computeSystem *HcsSystem) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(id) + if hr != nil { + return + } + return _hcsOpenComputeSystem(_p0, requestedAccess, computeSystem) +} + +func _hcsOpenComputeSystem(id *uint16, requestedAccess uint32, computeSystem *HcsSystem) (hr error) { + hr = procHcsOpenComputeSystem.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsOpenComputeSystem.Addr(), uintptr(unsafe.Pointer(id)), uintptr(requestedAccess), uintptr(unsafe.Pointer(computeSystem))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsOpenComputeSystemInNamespace(idNamespace string, id string, requestedAccess uint32, computeSystem *HcsSystem) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(idNamespace) + if hr != nil { + return + } + var _p1 *uint16 + _p1, hr = syscall.UTF16PtrFromString(id) + if hr != nil { + return + } + return _hcsOpenComputeSystemInNamespace(_p0, _p1, requestedAccess, computeSystem) +} + +func _hcsOpenComputeSystemInNamespace(idNamespace *uint16, id *uint16, requestedAccess uint32, computeSystem *HcsSystem) (hr error) { + hr = procHcsOpenComputeSystemInNamespace.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsOpenComputeSystemInNamespace.Addr(), uintptr(unsafe.Pointer(idNamespace)), uintptr(unsafe.Pointer(id)), uintptr(requestedAccess), uintptr(unsafe.Pointer(computeSystem))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsOpenProcess(computeSystem HcsSystem, pid uint32, requestedAccess uint32, process *HcsProcess) (hr error) { + hr = procHcsOpenProcess.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsOpenProcess.Addr(), uintptr(computeSystem), uintptr(pid), uintptr(requestedAccess), uintptr(unsafe.Pointer(process))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsPauseComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsPauseComputeSystem(computeSystem, operation, _p0) +} + +func _hcsPauseComputeSystem(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsPauseComputeSystem.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsPauseComputeSystem.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsResumeComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsResumeComputeSystem(computeSystem, operation, _p0) +} + +func _hcsResumeComputeSystem(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsResumeComputeSystem.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsResumeComputeSystem.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsRevokeVmAccess(vmId string, filePath string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(vmId) + if hr != nil { + return + } + var _p1 *uint16 + _p1, hr = syscall.UTF16PtrFromString(filePath) + if hr != nil { + return + } + return _hcsRevokeVmAccess(_p0, _p1) +} + +func _hcsRevokeVmAccess(vmId *uint16, filePath *uint16) (hr error) { + hr = procHcsRevokeVmAccess.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsRevokeVmAccess.Addr(), uintptr(unsafe.Pointer(vmId)), uintptr(unsafe.Pointer(filePath))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsRevokeVmGroupAccess(filePath string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(filePath) + if hr != nil { + return + } + return _hcsRevokeVmGroupAccess(_p0) +} + +func _hcsRevokeVmGroupAccess(filePath *uint16) (hr error) { + hr = procHcsRevokeVmGroupAccess.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsRevokeVmGroupAccess.Addr(), uintptr(unsafe.Pointer(filePath))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsSaveComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsSaveComputeSystem(computeSystem, operation, _p0) +} + +func _hcsSaveComputeSystem(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsSaveComputeSystem.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsSaveComputeSystem.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsSetComputeSystemCallback(computeSystem HcsSystem, callbackOptions uint32, context uintptr, callback uintptr) (hr error) { + hr = procHcsSetComputeSystemCallback.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsSetComputeSystemCallback.Addr(), uintptr(computeSystem), uintptr(callbackOptions), uintptr(context), uintptr(callback)) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsSetOperationCallback(operation HcsOperation, context uintptr, callback uintptr) (hr error) { + hr = procHcsSetOperationCallback.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsSetOperationCallback.Addr(), uintptr(operation), uintptr(context), uintptr(callback)) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsSetOperationContext(operation HcsOperation, context uintptr) (hr error) { + hr = procHcsSetOperationContext.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsSetOperationContext.Addr(), uintptr(operation), uintptr(context)) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsSetProcessCallback(process HcsProcess, callbackOptions uint32, context uintptr, callback uintptr) (hr error) { + hr = procHcsSetProcessCallback.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsSetProcessCallback.Addr(), uintptr(process), uintptr(callbackOptions), uintptr(context), uintptr(callback)) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsShutDownComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsShutDownComputeSystem(computeSystem, operation, _p0) +} + +func _hcsShutDownComputeSystem(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsShutDownComputeSystem.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsShutDownComputeSystem.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsSignalProcess(process HcsProcess, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsSignalProcess(process, operation, _p0) +} + +func _hcsSignalProcess(process HcsProcess, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsSignalProcess.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsSignalProcess.Addr(), uintptr(process), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsStartComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsStartComputeSystem(computeSystem, operation, _p0) +} + +func _hcsStartComputeSystem(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsStartComputeSystem.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsStartComputeSystem.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsStartLiveMigrationOnSource(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsStartLiveMigrationOnSource(computeSystem, operation, _p0) +} + +func _hcsStartLiveMigrationOnSource(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsStartLiveMigrationOnSource.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsStartLiveMigrationOnSource.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsStartLiveMigrationTransfer(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsStartLiveMigrationTransfer(computeSystem, operation, _p0) +} + +func _hcsStartLiveMigrationTransfer(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsStartLiveMigrationTransfer.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsStartLiveMigrationTransfer.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsSubmitWerReport(settings string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(settings) + if hr != nil { + return + } + return _hcsSubmitWerReport(_p0) +} + +func _hcsSubmitWerReport(settings *uint16) (hr error) { + hr = procHcsSubmitWerReport.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsSubmitWerReport.Addr(), uintptr(unsafe.Pointer(settings))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsTerminateComputeSystem(computeSystem HcsSystem, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsTerminateComputeSystem(computeSystem, operation, _p0) +} + +func _hcsTerminateComputeSystem(computeSystem HcsSystem, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsTerminateComputeSystem.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsTerminateComputeSystem.Addr(), uintptr(computeSystem), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsTerminateProcess(process HcsProcess, operation HcsOperation, options string) (hr error) { + var _p0 *uint16 + _p0, hr = syscall.UTF16PtrFromString(options) + if hr != nil { + return + } + return _hcsTerminateProcess(process, operation, _p0) +} + +func _hcsTerminateProcess(process HcsProcess, operation HcsOperation, options *uint16) (hr error) { + hr = procHcsTerminateProcess.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsTerminateProcess.Addr(), uintptr(process), uintptr(operation), uintptr(unsafe.Pointer(options))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsWaitForComputeSystemExit(computeSystem HcsSystem, timeoutMs uint32, result **uint16) (hr error) { + hr = procHcsWaitForComputeSystemExit.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsWaitForComputeSystemExit.Addr(), uintptr(computeSystem), uintptr(timeoutMs), uintptr(unsafe.Pointer(result))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsWaitForOperationResult(operation HcsOperation, timeoutMs uint32, resultDocument **uint16) (hr error) { + hr = procHcsWaitForOperationResult.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsWaitForOperationResult.Addr(), uintptr(operation), uintptr(timeoutMs), uintptr(unsafe.Pointer(resultDocument))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsWaitForOperationResultAndProcessInfo(operation HcsOperation, timeoutMs uint32, processInformation *HcsProcessInformation, resultDocument **uint16) (hr error) { + hr = procHcsWaitForOperationResultAndProcessInfo.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsWaitForOperationResultAndProcessInfo.Addr(), uintptr(operation), uintptr(timeoutMs), uintptr(unsafe.Pointer(processInformation)), uintptr(unsafe.Pointer(resultDocument))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +} + +func hcsWaitForProcessExit(process HcsProcess, timeoutMs uint32, result **uint16) (hr error) { + hr = procHcsWaitForProcessExit.Find() + if hr != nil { + return + } + r0, _, _ := syscall.SyscallN(procHcsWaitForProcessExit.Addr(), uintptr(process), uintptr(timeoutMs), uintptr(unsafe.Pointer(result))) + if int32(r0) < 0 { + if r0&0x1fff0000 == 0x00070000 { + r0 &= 0xffff + } + hr = syscall.Errno(r0) + } + return +}