Documentation ¶
Index ¶
- Variables
- func DecodeXDR(buf []byte, val interface{}) error
- func DefaultIP() string
- func DefaultStartCommand(m *ProcessManager, r *vix.StartProgramRequest) (int64, error)
- func EncodeXDR(val interface{}) ([]byte, error)
- func GuestInfoCommand(kind int, req []byte) []byte
- func GuestInfoNicInfoRequest() ([]byte, error)
- func Halt() error
- func Reboot() error
- type Channel
- type ChannelOut
- type CommandHandler
- type CommandServer
- func (c *CommandServer) CreateDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) CreateTemporaryDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) CreateTemporaryFile(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) DeleteDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) DeleteFile(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) Dispatch(data []byte) ([]byte, error)
- func (c *CommandServer) GetToolsState(_ vix.CommandRequestHeader, _ []byte) ([]byte, error)
- func (c *CommandServer) InitiateFileTransferFromGuest(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) InitiateFileTransferToGuest(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) KillProcess(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) ListFiles(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) ListProcesses(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) MoveDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) MoveFile(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) ProcessHgfsPacket(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) ReadEnvironmentVariables(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) RegisterHandler(op uint32, handler CommandHandler)
- func (c *CommandServer) SetGuestFileAttributes(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- func (c *CommandServer) StartCommand(header vix.CommandRequestHeader, data []byte) ([]byte, error)
- type DNSConfigInfo
- type DhcpConfigInfo
- type GuestNicInfo
- type GuestNicV3
- type Handler
- type IPAddressEntry
- type InetCidrRouteEntry
- type NicInfoV3
- type PowerCommand
- type PowerCommandHandler
- type Process
- type ProcessError
- type ProcessFile
- type ProcessIO
- type ProcessManager
- func (m *ProcessManager) Kill(pid int64) bool
- func (m *ProcessManager) ListProcesses(pids []int64) []byte
- func (m *ProcessManager) Open(u *url.URL, mode int32) (hgfs.File, error)
- func (m *ProcessManager) Start(r *vix.StartProgramRequest, p *Process) (int64, error)
- func (m *ProcessManager) Stat(u *url.URL) (os.FileInfo, error)
- type ProcessState
- type Service
- func (s *Service) CapabilitiesRegister([]byte) ([]byte, error)
- func (s *Service) Dispatch(request []byte) []byte
- func (s *Service) Ping([]byte) ([]byte, error)
- func (s *Service) RegisterHandler(name string, handler Handler)
- func (s *Service) Reset([]byte) ([]byte, error)
- func (s *Service) SendGuestInfo()
- func (s *Service) SetOption(args []byte) ([]byte, error)
- func (s *Service) Start() error
- func (s *Service) Stop()
- func (s *Service) Wait()
- type TraceChannel
- type TypedIPAddress
- type WinsConfigInfo
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotVirtualWorld = errors.New("not in a virtual world")
)
var ProcessFuncIO = struct { key int64 }{vix.CommandMagicWord}
ProcessFuncIO is the Context key to access optional ProcessIO
var (
Trace = false
)
Functions ¶
func DefaultIP ¶
func DefaultIP() string
DefaultIP is used by default when responding to a Set_Option broadcastIP request It can be overridden with the Service.PrimaryIP field
func DefaultStartCommand ¶
func DefaultStartCommand(m *ProcessManager, r *vix.StartProgramRequest) (int64, error)
func GuestInfoCommand ¶
func GuestInfoNicInfoRequest ¶
Types ¶
type Channel ¶
Channel abstracts the guest<->vmx RPC transport
func NewBackdoorChannelIn ¶
func NewBackdoorChannelIn() Channel
NewBackdoorChannelIn creates a Channel for use with the TCLO protocol
func NewBackdoorChannelOut ¶
func NewBackdoorChannelOut() Channel
NewBackdoorChannelOut creates a Channel for use with the RPCI protocol
func NewTraceChannel ¶
type ChannelOut ¶
type ChannelOut struct {
Channel
}
ChannelOut extends Channel to provide RPCI protocol helpers
type CommandHandler ¶
type CommandHandler func(vix.CommandRequestHeader, []byte) ([]byte, error)
type CommandServer ¶
type CommandServer struct { Out *ChannelOut ProcessManager *ProcessManager Authenticate func(vix.CommandRequestHeader, []byte) error ProcessStartCommand func(*ProcessManager, *vix.StartProgramRequest) (int64, error) FileServer *hgfs.Server // contains filtered or unexported fields }
func (*CommandServer) CreateDirectory ¶
func (c *CommandServer) CreateDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) CreateTemporaryDirectory ¶
func (c *CommandServer) CreateTemporaryDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) CreateTemporaryFile ¶
func (c *CommandServer) CreateTemporaryFile(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) DeleteDirectory ¶
func (c *CommandServer) DeleteDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) DeleteFile ¶
func (c *CommandServer) DeleteFile(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) GetToolsState ¶
func (c *CommandServer) GetToolsState(_ vix.CommandRequestHeader, _ []byte) ([]byte, error)
func (*CommandServer) InitiateFileTransferFromGuest ¶
func (c *CommandServer) InitiateFileTransferFromGuest(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) InitiateFileTransferToGuest ¶
func (c *CommandServer) InitiateFileTransferToGuest(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) KillProcess ¶
func (c *CommandServer) KillProcess(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) ListFiles ¶
func (c *CommandServer) ListFiles(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) ListProcesses ¶
func (c *CommandServer) ListProcesses(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) MoveDirectory ¶
func (c *CommandServer) MoveDirectory(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) MoveFile ¶
func (c *CommandServer) MoveFile(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) ProcessHgfsPacket ¶
func (c *CommandServer) ProcessHgfsPacket(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) ReadEnvironmentVariables ¶
func (c *CommandServer) ReadEnvironmentVariables(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) RegisterHandler ¶
func (c *CommandServer) RegisterHandler(op uint32, handler CommandHandler)
func (*CommandServer) SetGuestFileAttributes ¶
func (c *CommandServer) SetGuestFileAttributes(header vix.CommandRequestHeader, data []byte) ([]byte, error)
func (*CommandServer) StartCommand ¶
func (c *CommandServer) StartCommand(header vix.CommandRequestHeader, data []byte) ([]byte, error)
type DNSConfigInfo ¶
type DNSConfigInfo struct { HostName *string `xdr:"optional"` DomainName *string `xdr:"optional"` Servers []TypedIPAddress Search *string `xdr:"optional"` }
type DhcpConfigInfo ¶
type GuestNicInfo ¶
func DefaultGuestNicInfo ¶
func DefaultGuestNicInfo() *GuestNicInfo
func NewGuestNicInfo ¶
func NewGuestNicInfo() *GuestNicInfo
type GuestNicV3 ¶
type GuestNicV3 struct { MacAddress string IPs []IPAddressEntry DNSConfigInfo *DNSConfigInfo `xdr:"optional"` WinsConfigInfo *WinsConfigInfo `xdr:"optional"` DhcpConfigInfov4 *DhcpConfigInfo `xdr:"optional"` DhcpConfigInfov6 *DhcpConfigInfo `xdr:"optional"` }
func (*GuestNicV3) AddIP ¶
func (nic *GuestNicV3) AddIP(addr net.Addr)
type IPAddressEntry ¶
type IPAddressEntry struct { Address TypedIPAddress PrefixLength uint32 Origin *int32 `xdr:"optional"` Status *int32 `xdr:"optional"` }
type InetCidrRouteEntry ¶
type InetCidrRouteEntry struct { Dest TypedIPAddress PrefixLength uint32 NextHop *TypedIPAddress `xdr:"optional"` IfIndex uint32 Type int32 Metric uint32 }
type NicInfoV3 ¶
type NicInfoV3 struct { Nics []GuestNicV3 Routes []InetCidrRouteEntry DNSConfigInfo *DNSConfigInfo `xdr:"optional"` WinsConfigInfo *WinsConfigInfo `xdr:"optional"` DhcpConfigInfov4 *DhcpConfigInfo `xdr:"optional"` DhcpConfigInfov6 *DhcpConfigInfo `xdr:"optional"` }
type PowerCommand ¶
type PowerCommand struct { Handler func() error // contains filtered or unexported fields }
type PowerCommandHandler ¶
type PowerCommandHandler struct { Halt PowerCommand Reboot PowerCommand PowerOn PowerCommand Resume PowerCommand Suspend PowerCommand }
type Process ¶
type Process struct { ProcessState Start func(*Process, *vix.StartProgramRequest) (int64, error) Wait func() error Kill context.CancelFunc // contains filtered or unexported fields }
Process managed by the ProcessManager.
func NewProcess ¶
func NewProcess() *Process
NewProcess 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 ProcessState.ExitCode, if error is of type exec.ExitError. The ctx param may be used to kill the process via the ProcessManager.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 NewProcessFunc ¶
NewProcessFunc 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 ProcessManager.Kill method. The run args command is that of the VixMsgStartProgramRequest.Arguments field.
func NewProcessRoundTrip ¶
func NewProcessRoundTrip() *Process
NewProcessRoundTrip starts a Go function to implement a toolbox backed http.RoundTripper
type ProcessError ¶
ProcessError can be returned by the Process.Wait function to propagate ExitCode to ProcessState.
func (*ProcessError) Error ¶
func (e *ProcessError) Error() string
type ProcessFile ¶
ProcessFile implements the os.FileInfo interface to enable toolbox interaction with virtual files.
func (*ProcessFile) IsDir ¶
func (a *ProcessFile) IsDir() bool
IsDir implementation of the os.FileInfo interface method.
func (*ProcessFile) ModTime ¶
func (a *ProcessFile) ModTime() time.Time
ModTime implementation of the os.FileInfo interface method.
func (*ProcessFile) Mode ¶
func (a *ProcessFile) Mode() os.FileMode
Mode implementation of the os.FileInfo interface method.
func (*ProcessFile) Name ¶
func (a *ProcessFile) Name() string
Name implementation of the os.FileInfo interface method.
func (*ProcessFile) Size ¶
func (a *ProcessFile) Size() int64
Size implementation of the os.FileInfo interface method.
func (*ProcessFile) Sys ¶
func (a *ProcessFile) Sys() interface{}
Sys implementation of the os.FileInfo interface method.
type ProcessIO ¶
type ProcessIO 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 }
ProcessIO encapsulates IO for Go functions and OS commands such that they can interact via the OperationsManager without file system disk IO.
type ProcessManager ¶
type ProcessManager struct {
// contains filtered or unexported fields
}
ProcessManager manages processes within the guest. See: http://pubs.vmware.com/vsphere-60/topic/com.vmware.wssdk.apiref.doc/vim.vm.guest.ProcessManager.html
func NewProcessManager ¶
func NewProcessManager() *ProcessManager
NewProcessManager creates a new ProcessManager instance.
func (*ProcessManager) Kill ¶
func (m *ProcessManager) Kill(pid int64) bool
Kill cancels the Process Context. Returns true if pid exists in the process table, false otherwise.
func (*ProcessManager) ListProcesses ¶
func (m *ProcessManager) ListProcesses(pids []int64) []byte
ListProcesses marshals the ProcessState 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 (*ProcessManager) Start ¶
func (m *ProcessManager) Start(r *vix.StartProgramRequest, p *Process) (int64, error)
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 ProcessState EndTime and ExitCode fields are set. The process state can be queried via ListProcessesInGuest until it is removed, 5 minutes after Wait returns.
type ProcessState ¶
type ProcessState 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 *ProcessIO }
ProcessState is the toolbox representation of the GuestProcessInfo type
type Service ¶
type Service struct { Command *CommandServer Power *PowerCommandHandler PrimaryIP func() string // contains filtered or unexported fields }
Service receives and dispatches incoming RPC requests from the vmx
func NewService ¶
NewService initializes a Service instance
func (*Service) CapabilitiesRegister ¶
func (*Service) RegisterHandler ¶
RegisterHandler for the given RPC name
func (*Service) SendGuestInfo ¶
func (s *Service) SendGuestInfo()
func (*Service) Start ¶
Start initializes the RPC channels and starts a goroutine to listen for incoming RPC requests
type TraceChannel ¶
type TraceChannel struct { Channel // contains filtered or unexported fields }
func (*TraceChannel) Receive ¶
func (d *TraceChannel) Receive() ([]byte, error)
func (*TraceChannel) Send ¶
func (d *TraceChannel) Send(buf []byte) error
func (*TraceChannel) Start ¶
func (d *TraceChannel) Start() error
func (*TraceChannel) Stop ¶
func (d *TraceChannel) Stop() error
type TypedIPAddress ¶
type WinsConfigInfo ¶
type WinsConfigInfo struct { Primary TypedIPAddress Secondary TypedIPAddress }