interface.go 3.6 KB

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