package process
import "github.com/vmware/govmomi/toolbox/process"
Index ¶
- Variables
- type Error
- type File
- func (a *File) IsDir() bool
- func (a *File) ModTime() time.Time
- func (a *File) Mode() os.FileMode
- func (a *File) Name() string
- func (a *File) Size() int64
- func (a *File) Sys() interface{}
- type IO
- type Manager
- func NewManager() *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
- func New() *Process
- func NewFunc(run func(ctx context.Context, args string) error) *Process
- func NewRoundTrip() *Process
- func (p *Process) WithIO() *Process
- type State
Variables ¶
var FuncIO = struct { key int64 }{vix.CommandMagicWord}
FuncIO is the Context key to access optional ProcessIO
Types ¶
type Error ¶
Error can be returned by the Process.Wait function to propagate ExitCode to process State.
func (*Error) Error ¶
type File ¶
File implements the os.FileInfo interface to enable toolbox interaction with virtual files.
func (*File) IsDir ¶
IsDir implementation of the os.FileInfo interface method.
func (*File) ModTime ¶
ModTime implementation of the os.FileInfo interface method.
func (*File) Mode ¶
Mode implementation of the os.FileInfo interface method.
func (*File) Name ¶
Name implementation of the os.FileInfo interface method.
func (*File) Size ¶
Size implementation of the os.FileInfo interface method.
func (*File) Sys ¶
func (a *File) Sys() interface{}
Sys implementation of the os.FileInfo interface method.
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 NewManager ¶
func NewManager() *Manager
NewManager creates a new process Manager instance.
func (*Manager) Kill ¶
Kill cancels the Process Context. Returns true if pid exists in the process table, false otherwise.
func (*Manager) List ¶
List the process State for the given pids.
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) Open ¶
Open implements hgfs.FileHandler.Open
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.
func (*Manager) Stat ¶
Stat implements hgfs.FileHandler.Stat
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
func (*Process) WithIO ¶
WithIO enables toolbox Process IO without file system disk IO.
type State ¶
type State struct { StartTime int64 // (keep first to ensure 64-bit alignment) EndTime int64 // (keep first to ensure 64-bit alignment) Name string Args string Owner string Pid int64 ExitCode int32 IO *IO }
State is the toolbox representation of the GuestProcessInfo type
Source Files ¶
- Version
- v0.48.1 (latest)
- Published
- Feb 11, 2025
- Platform
- linux/amd64
- Imports
- 18 packages
- Last checked
- 2 months ago –
Tools for package owners.