Documentation
¶
Index ¶
- Constants
- Variables
- func ControlDomain() bool
- func Error(s string) error
- func JoinXenStorePath(paths ...string) string
- func RequestID() uint32
- func UnixSocketPath() string
- func ValidPath(path string) bool
- func ValidPermissions(permissions ...string) bool
- func ValidWatchPath(path string) bool
- func XenBusPath() string
- type Client
- func (c *Client) Close() error
- func (c *Client) Error() error
- func (c *Client) GetDomainPath(domid int) (string, error)
- func (c *Client) GetPermissions(path string) (string, error)
- func (c *Client) List(path string) ([]string, error)
- func (c *Client) Read(path string) (string, error)
- func (c *Client) Remove(path string) (string, error)
- func (c *Client) SetPermissions(path string, perms []string) (string, error)
- func (c *Client) UnWatch(path, token string) error
- func (c *Client) Watch(path, token string) (chan *Packet, error)
- func (c *Client) Write(path, value string) (string, error)
- type Event
- type Packet
- type PacketHeader
- type ReadWriteTransport
- type Router
- type Transport
- type UnixSocketTransport
- type XenBusTransport
Constants ¶
const ( XsDebug xenStoreOperation = iota XsDirectory XsRead XsGetPermissions XsWatch XsUnWatch XsStartTransaction XsEndTransaction XsIntroduce XsRelease XsGetDomainPath XsWrite XsMkdir XsRm XsSetPermissions XsWatchEvent XsError XsIsDomainIntroduced XsResume XsSetTarget XsRestrict XsResetWatches XsInvalid xenStoreOperation = 0xffff // XenStorePathSeparator is the separator between paths in XenStore. Parts of any path sent // to/received from XenStore should be joined with exactly 1 instance of this string. This is // not platform dependent. XenStorePathSeparator = "/" )
const PacketHeaderSize = unsafe.Sizeof(PacketHeader{})
Variables ¶
var (
NUL byte = 0x0
)
Functions ¶
func ControlDomain ¶
func ControlDomain() bool
ControlDomain checks whether the current Xen domain has the 'control_d' capability (will be true on Domain-0).
func JoinXenStorePath ¶
JoinXenStorePath concatenates parts of a path together with the XenStorePathSeparator, ensuring that exactly 1 instance of the XenStorePathSeparator is used.
func RequestID ¶
func RequestID() uint32
RequestID returns the next unique (for this session) request ID to use when contacting XenStore. RequestID synchronises access to the counter and is therefore safe to call across multiple goroutines.
func UnixSocketPath ¶
func UnixSocketPath() string
UnixSocketPath gets the current path to the XenStore unix socket on this system
func ValidPath ¶
ValidPath returns a bool representing whether the provided string is a valid XenStore path.
func ValidPermissions ¶
ValidPermissions checks if a set of permission specifications for validity & returns true only if all are valid.
func ValidWatchPath ¶
ValidWatchPath returns a bool representing whether the provided string is a valid watch path - a special case of XenStore paths.
func XenBusPath ¶
func XenBusPath() string
XenBusPath returns the path to the XenBus device on this system
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper which allows easier communication with XenStore by providing methods which allow performing normal XenStore functions with minimal effort.
func NewClient ¶
NewClient creates a new connected Client and starts the internal Router so that packets can be sent and received correctly by the Client.
func NewUnixSocketClient ¶
NewUnixSocketClient creates a new Client which will be connected to an underlying UnixSocket.
func NewXenBusClient ¶
NewXenBusClient creates a new Client which will be connected to an underlying XenBus device.
func (*Client) GetDomainPath ¶
GetDomainPath
func (*Client) GetPermissions ¶
GetPermissions returns the currently stored permissions for a XenStore path.
func (*Client) SetPermissions ¶
SetPermissions sets the permissions for a path in XenStore.
type Packet ¶
type Packet struct { Header *PacketHeader Payload []byte }
func (*Packet) Check ¶
Checks whether the current Packet contains an error response & returns a Go error if so
func (*Packet) String ¶
String returns a JSON representation of the packet with the payload split into all of the constituent parts.
type PacketHeader ¶
type PacketHeader struct { Op xenStoreOperation `struc:"uint32,little"` RqId uint32 `struc:"uint32,little"` TxId uint32 `struc:"uint32,little"` Length uint32 `struc:"uint32,little"` }
type ReadWriteTransport ¶
type ReadWriteTransport struct {
// contains filtered or unexported fields
}
ReadWriteTransport is an implementation of the Transport interface which works for any io.ReadWriteCloser..
func (*ReadWriteTransport) Close ¶
func (r *ReadWriteTransport) Close() error
func (*ReadWriteTransport) IsOpen ¶
func (r *ReadWriteTransport) IsOpen() bool
Check if the underlying io.ReadWriteCloser has been closed yet.
func (*ReadWriteTransport) Receive ¶
func (r *ReadWriteTransport) Receive() (*Packet, error)
func (*ReadWriteTransport) Send ¶
func (r *ReadWriteTransport) Send(p *Packet) error
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router provides a way of sending a Packet and receiving the reply in return. It does ths by intercepting all packets over a Transport and forwarding them to listeners over channels.
func NewRouter ¶
NewRouter creates a new instance of the Router struct for Transport t with all of the correct defaults set.
func (*Router) Send ¶
Send sends a Packet to XenStore and returns a channel which the response Packet will be sent over when it is received.
type Transport ¶
type Transport interface { // Send a packet to the XenStore backend. Send(*Packet) error // Receive a packet from the XenStore backend. Receive() (*Packet, error) // Close if required by the underlying implementation. Close() error }
Transport is an interface for sending and receiving data from XenStore.
type UnixSocketTransport ¶
type UnixSocketTransport struct { *ReadWriteTransport Path string }
UnixSocketTransport is an implementation of Transport which sends/receives data from XenStore using a unix socket.
func NewUnixSocketTransport ¶
func NewUnixSocketTransport(path string) (*UnixSocketTransport, error)
NewUnixSocketTransport creates a new connected UnixSocketTransport.
type XenBusTransport ¶
type XenBusTransport struct { *ReadWriteTransport Path string }
XenBusTransport is an implementation of Transport which sends/receives data from XenStore using the special XenBus device on Linux (and possibly other Unix operating systems)
func NewXenBusTransport ¶
func NewXenBusTransport(path string) (*XenBusTransport, error)
Create a new connected XenBusTransport.