interface.go 3.7 KB

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