Documentation ¶
Index ¶
- Variables
- type Error
- type File
- type IO
- type Manager
- func (m *Manager) Kill(pid int64) bool
- func (m *Manager) List(pids []int64) []State
- func (m *Manager) ListProcesses(pids []int64) []byte
- func (m *Manager) Open(u *url.URL, mode int32) (hgfs.File, error)
- func (m *Manager) Start(r *vix.StartProgramRequest, p *Process) (int64, error)
- func (m *Manager) Stat(u *url.URL) (os.FileInfo, error)
- type Process
- type State
Constants ¶
This section is empty.
Variables ¶
var (
EscapeXML *strings.Replacer
)
var FuncIO = struct { key int64 }{vix.CommandMagicWord}
FuncIO is the Context key to access optional ProcessIO
Functions ¶
This section is empty.
Types ¶
type Error ¶
Error can be returned by the Process.Wait function to propagate ExitCode to process State.
type File ¶
File implements the os.FileInfo interface to enable toolbox interaction with virtual files.
type IO ¶
type IO struct { In struct { io.Writer io.Reader io.Closer // Closer for the write side of the pipe, can be closed via hgfs ops (FileTranfserToGuest) } Out *bytes.Buffer Err *bytes.Buffer }
IO encapsulates IO for Go functions and OS commands such that they can interact via the OperationsManager without file system disk IO.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages processes within the guest. See: http://pubs.vmware.com/vsphere-60/topic/com.vmware.wssdk.apiref.doc/vim.vm.guest.Manager.html
func (*Manager) Kill ¶
Kill cancels the Process Context. Returns true if pid exists in the process table, false otherwise.
func (*Manager) ListProcesses ¶
ListProcesses marshals the process State for the given pids. If no pids are specified, all current processes are included. The return value can be used for responding to a VixMsgListProcessesExRequest.
func (*Manager) Start ¶
Start calls the Process.Start function, returning the pid on success or an error. A goroutine is started that calls the Process.Wait function. After Process.Wait has returned, the process State EndTime and ExitCode fields are set. The process state can be queried via ListProcessesInGuest until it is removed, 5 minutes after Wait returns.
type Process ¶
type Process struct { State Start func(*Process, *vix.StartProgramRequest) (int64, error) Wait func() error Kill context.CancelFunc // contains filtered or unexported fields }
Process managed by the process Manager.
func New ¶
func New() *Process
New creates a new Process, where the Start function use exec.CommandContext to create and start the process. The Wait function waits for the process to finish and returns the error returned by exec.Cmd.Wait(). Prior to Wait returning, the exec.Cmd.Wait() error is used to set the Process.ExitCode, if error is of type exec.ExitError. The ctx param may be used to kill the process via the process Manager.Kill method. The VixMsgStartProgramRequest param fields are mapped to the exec.Cmd counterpart fields. Processes are started within a sub-shell, allowing for i/o redirection, just as with the C version of vmware-tools.
func NewFunc ¶
NewFunc creates a new Process, where the Start function calls the given run function within a goroutine. The Wait function waits for the goroutine to finish and returns the error returned by run. The run ctx param may be used to return early via the process Manager.Kill method. The run args command is that of the VixMsgStartProgramRequest.Arguments field.
func NewRoundTrip ¶
func NewRoundTrip() *Process
NewRoundTrip starts a Go function to implement a toolbox backed http.RoundTripper