...

Source file src/github.com/Microsoft/hcsshim/interface.go

Documentation: github.com/Microsoft/hcsshim

     1  //go:build windows
     2  
     3  package hcsshim
     4  
     5  import (
     6  	"io"
     7  	"time"
     8  
     9  	"github.com/Microsoft/hcsshim/internal/hcs/schema1"
    10  )
    11  
    12  // ProcessConfig is used as both the input of Container.CreateProcess
    13  // and to convert the parameters to JSON for passing onto the HCS
    14  type ProcessConfig = schema1.ProcessConfig
    15  
    16  type Layer = schema1.Layer
    17  type MappedDir = schema1.MappedDir
    18  type MappedPipe = schema1.MappedPipe
    19  type HvRuntime = schema1.HvRuntime
    20  type MappedVirtualDisk = schema1.MappedVirtualDisk
    21  
    22  // AssignedDevice represents a device that has been directly assigned to a container
    23  //
    24  // NOTE: Support added in RS5
    25  type AssignedDevice = schema1.AssignedDevice
    26  
    27  // ContainerConfig is used as both the input of CreateContainer
    28  // and to convert the parameters to JSON for passing onto the HCS
    29  type ContainerConfig = schema1.ContainerConfig
    30  
    31  type ComputeSystemQuery = schema1.ComputeSystemQuery
    32  
    33  // Container represents a created (but not necessarily running) container.
    34  type Container interface {
    35  	// Start synchronously starts the container.
    36  	Start() error
    37  
    38  	// Shutdown requests a container shutdown, but it may not actually be shutdown until Wait() succeeds.
    39  	Shutdown() error
    40  
    41  	// Terminate requests a container terminate, but it may not actually be terminated until Wait() succeeds.
    42  	Terminate() error
    43  
    44  	// Waits synchronously waits for the container to shutdown or terminate.
    45  	Wait() error
    46  
    47  	// WaitTimeout synchronously waits for the container to terminate or the duration to elapse. It
    48  	// returns false if timeout occurs.
    49  	WaitTimeout(time.Duration) error
    50  
    51  	// Pause pauses the execution of a container.
    52  	Pause() error
    53  
    54  	// Resume resumes the execution of a container.
    55  	Resume() error
    56  
    57  	// HasPendingUpdates returns true if the container has updates pending to install.
    58  	HasPendingUpdates() (bool, error)
    59  
    60  	// Statistics returns statistics for a container.
    61  	Statistics() (Statistics, error)
    62  
    63  	// ProcessList returns details for the processes in a container.
    64  	ProcessList() ([]ProcessListItem, error)
    65  
    66  	// MappedVirtualDisks returns virtual disks mapped to a utility VM, indexed by controller
    67  	MappedVirtualDisks() (map[int]MappedVirtualDiskController, error)
    68  
    69  	// CreateProcess launches a new process within the container.
    70  	CreateProcess(c *ProcessConfig) (Process, error)
    71  
    72  	// OpenProcess gets an interface to an existing process within the container.
    73  	OpenProcess(pid int) (Process, error)
    74  
    75  	// Close cleans up any state associated with the container but does not terminate or wait for it.
    76  	Close() error
    77  
    78  	// Modify the System
    79  	Modify(config *ResourceModificationRequestResponse) error
    80  }
    81  
    82  // Process represents a running or exited process.
    83  type Process interface {
    84  	// Pid returns the process ID of the process within the container.
    85  	Pid() int
    86  
    87  	// Kill signals the process to terminate but does not wait for it to finish terminating.
    88  	Kill() error
    89  
    90  	// Wait waits for the process to exit.
    91  	Wait() error
    92  
    93  	// WaitTimeout waits for the process to exit or the duration to elapse. It returns
    94  	// false if timeout occurs.
    95  	WaitTimeout(time.Duration) error
    96  
    97  	// ExitCode returns the exit code of the process. The process must have
    98  	// already terminated.
    99  	ExitCode() (int, error)
   100  
   101  	// ResizeConsole resizes the console of the process.
   102  	ResizeConsole(width, height uint16) error
   103  
   104  	// Stdio returns the stdin, stdout, and stderr pipes, respectively. Closing
   105  	// these pipes does not close the underlying pipes; it should be possible to
   106  	// call this multiple times to get multiple interfaces.
   107  	Stdio() (io.WriteCloser, io.ReadCloser, io.ReadCloser, error)
   108  
   109  	// CloseStdin closes the write side of the stdin pipe so that the process is
   110  	// notified on the read side that there is no more data in stdin.
   111  	CloseStdin() error
   112  
   113  	// Close cleans up any state associated with the process but does not kill
   114  	// or wait on it.
   115  	Close() error
   116  }
   117  

View as plain text