libnbd

package module
v1.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: LGPL-2.1 Imports: 6 Imported by: 1

README

Libnbd Go binding

This module provides access to Network Block Device (NBD) servers from the Go programming language, using the libnbd library.

Please see the manual to learn how to use this module: https://libguestfs.org/libnbd-golang.3.html

This is part of libnbd, please check the project at: https://gitlab.com/nbdkit/libnbd

License

The software is Copyright Red Hat and licensed under the GNU Lesser General Public License version 2 or above (LGPLv2+). See the file LICENSE for details.

Documentation

Index

Constants

View Source
const (
	TLS_DISABLE = Tls(0)
	TLS_ALLOW   = Tls(1)
	TLS_REQUIRE = Tls(2)
)
View Source
const (
	SIZE_MINIMUM   = Size(0)
	SIZE_PREFERRED = Size(1)
	SIZE_MAXIMUM   = Size(2)
	SIZE_PAYLOAD   = Size(3)
)
View Source
const (
	CMD_FLAG_FUA         = CmdFlag(0x01)
	CMD_FLAG_NO_HOLE     = CmdFlag(0x02)
	CMD_FLAG_DF          = CmdFlag(0x04)
	CMD_FLAG_REQ_ONE     = CmdFlag(0x08)
	CMD_FLAG_FAST_ZERO   = CmdFlag(0x10)
	CMD_FLAG_PAYLOAD_LEN = CmdFlag(0x20)
	CMD_FLAG_MASK        = CmdFlag(0x3f)
)
View Source
const (
	HANDSHAKE_FLAG_FIXED_NEWSTYLE = HandshakeFlag(0x01)
	HANDSHAKE_FLAG_NO_ZEROES      = HandshakeFlag(0x02)
	HANDSHAKE_FLAG_MASK           = HandshakeFlag(0x03)
)
View Source
const (
	STRICT_COMMANDS  = Strict(0x01)
	STRICT_FLAGS     = Strict(0x02)
	STRICT_BOUNDS    = Strict(0x04)
	STRICT_ZERO_SIZE = Strict(0x08)
	STRICT_ALIGN     = Strict(0x10)
	STRICT_PAYLOAD   = Strict(0x20)
	STRICT_AUTO_FLAG = Strict(0x40)
	STRICT_MASK      = Strict(0x7f)
)
View Source
const (
	ALLOW_TRANSPORT_TCP   = AllowTransport(0x01)
	ALLOW_TRANSPORT_UNIX  = AllowTransport(0x02)
	ALLOW_TRANSPORT_VSOCK = AllowTransport(0x04)
	ALLOW_TRANSPORT_MASK  = AllowTransport(0x07)
)
View Source
const (
	SHUTDOWN_ABANDON_PENDING = Shutdown(0x10000)
	SHUTDOWN_MASK            = Shutdown(0x10000)
)
View Source
const (
	AIO_DIRECTION_READ  uint32 = 1
	AIO_DIRECTION_WRITE uint32 = 2
	AIO_DIRECTION_BOTH  uint32 = 3
	READ_DATA           uint32 = 1
	READ_HOLE           uint32 = 2
	READ_ERROR          uint32 = 3
	/* Meta-context namespace "base" */
	NAMESPACE_BASE          = "base:"
	CONTEXT_BASE_ALLOCATION = "base:allocation"
	/* Defined bits in "base:allocation" */
	STATE_HOLE uint32 = 1
	STATE_ZERO uint32 = 2
	/* Meta-context namespace "qemu" */
	NAMESPACE_QEMU            = "qemu:"
	CONTEXT_QEMU_DIRTY_BITMAP = "qemu:dirty-bitmap:"
	/* Defined bits in "qemu:dirty-bitmap:" */
	STATE_DIRTY                   uint32 = 1
	CONTEXT_QEMU_ALLOCATION_DEPTH        = "qemu:allocation-depth"
)

Constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type AioBlockStatus64Optargs added in v1.18.0

type AioBlockStatus64Optargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioBlockStatus64.

type AioBlockStatusFilterOptargs added in v1.18.0

type AioBlockStatusFilterOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioBlockStatusFilter.

type AioBlockStatusOptargs

type AioBlockStatusOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioBlockStatus.

type AioBuffer

type AioBuffer struct {
	P    unsafe.Pointer
	Size uint
}

Asynchronous I/O buffer.

func FromBytes

func FromBytes(buf []byte) AioBuffer

FromBytes makes a new buffer backed by a C allocated array, initialized by copying the given Go slice.

func MakeAioBuffer

func MakeAioBuffer(size uint) AioBuffer

MakeAioBuffer makes a new buffer backed by an uninitialized C allocated array.

func MakeAioBufferZero added in v1.12.0

func MakeAioBufferZero(size uint) AioBuffer

MakeAioBuffer makes a new buffer backed by a C allocated array. The underlying buffer is set to zero.

func (*AioBuffer) Bytes

func (b *AioBuffer) Bytes() []byte

Bytes copies the underlying C array to Go allocated memory and return a slice. Modifying the returned slice does not modify the underlying buffer backing array.

func (*AioBuffer) Free

func (b *AioBuffer) Free()

Free deallocates the underlying C allocated array. Using the buffer after Free() will panic.

func (*AioBuffer) Get

func (b *AioBuffer) Get(i uint) *byte

Get returns a pointer to a byte in the underlying C array. The pointer can be used to modify the underlying array. The pointer must not be used after calling Free().

func (*AioBuffer) Slice added in v1.12.0

func (b *AioBuffer) Slice() []byte

Slice creates a slice backed by the underlying C array. The slice can be used to access or modify the contents of the underlying array. The slice must not be used after caling Free().

type AioCacheOptargs

type AioCacheOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioCache.

type AioDisconnectOptargs

type AioDisconnectOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioDisconnect.

type AioFlushOptargs

type AioFlushOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioFlush.

type AioOptExtendedHeadersOptargs added in v1.18.0

type AioOptExtendedHeadersOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
}

Struct carrying optional arguments for AioOptExtendedHeaders.

type AioOptGoOptargs

type AioOptGoOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
}

Struct carrying optional arguments for AioOptGo.

type AioOptInfoOptargs

type AioOptInfoOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
}

Struct carrying optional arguments for AioOptInfo.

type AioOptListMetaContextOptargs

type AioOptListMetaContextOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
}

Struct carrying optional arguments for AioOptListMetaContext.

type AioOptListMetaContextQueriesOptargs added in v1.18.0

type AioOptListMetaContextQueriesOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
}

Struct carrying optional arguments for AioOptListMetaContextQueries.

type AioOptListOptargs

type AioOptListOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
}

Struct carrying optional arguments for AioOptList.

type AioOptSetMetaContextOptargs added in v1.18.0

type AioOptSetMetaContextOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
}

Struct carrying optional arguments for AioOptSetMetaContext.

type AioOptSetMetaContextQueriesOptargs added in v1.18.0

type AioOptSetMetaContextQueriesOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
}

Struct carrying optional arguments for AioOptSetMetaContextQueries.

type AioOptStarttlsOptargs added in v1.18.0

type AioOptStarttlsOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
}

Struct carrying optional arguments for AioOptStarttls.

type AioOptStructuredReplyOptargs added in v1.18.0

type AioOptStructuredReplyOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
}

Struct carrying optional arguments for AioOptStructuredReply.

type AioPreadOptargs

type AioPreadOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioPread.

type AioPreadStructuredOptargs

type AioPreadStructuredOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioPreadStructured.

type AioPwriteOptargs

type AioPwriteOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioPwrite.

type AioTrimOptargs

type AioTrimOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioTrim.

type AioZeroOptargs

type AioZeroOptargs struct {
	/* CompletionCallback field is ignored unless CompletionCallbackSet == true. */
	CompletionCallbackSet bool
	CompletionCallback    CompletionCallback
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for AioZero.

type AllowTransport

type AllowTransport uint32

type BlockStatus64Optargs added in v1.18.0

type BlockStatus64Optargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for BlockStatus64.

type BlockStatusFilterOptargs added in v1.18.0

type BlockStatusFilterOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for BlockStatusFilter.

type BlockStatusOptargs

type BlockStatusOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for BlockStatus.

type CacheOptargs

type CacheOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for Cache.

type ChunkCallback

type ChunkCallback func(subbuf []byte, offset uint64, status uint, error *int) int

type CmdFlag

type CmdFlag uint32

Flags.

type CompletionCallback

type CompletionCallback func(error *int) int

type ContextCallback

type ContextCallback func(name string) int

type DebugCallback

type DebugCallback func(context string, msg string) int

type Extent64Callback added in v1.18.0

type Extent64Callback func(metacontext string, offset uint64, entries []LibnbdExtent, error *int) int

type ExtentCallback

type ExtentCallback func(metacontext string, offset uint64, entries []uint32, error *int) int

type FlushOptargs

type FlushOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for Flush.

type HandshakeFlag

type HandshakeFlag uint32

type Libnbd

type Libnbd struct {
	// contains filtered or unexported fields
}

Handle.

func Create

func Create() (*Libnbd, error)

Create a new handle.

func (*Libnbd) AddMetaContext

func (h *Libnbd) AddMetaContext(name string) error

AddMetaContext: ask server to negotiate metadata context

func (*Libnbd) AioBlockStatus

func (h *Libnbd) AioBlockStatus(count uint64, offset uint64, extent ExtentCallback, optargs *AioBlockStatusOptargs) (uint64, error)

AioBlockStatus: send block status command, with 32-bit callback

func (*Libnbd) AioBlockStatus64 added in v1.18.0

func (h *Libnbd) AioBlockStatus64(count uint64, offset uint64, extent64 Extent64Callback, optargs *AioBlockStatus64Optargs) (uint64, error)

AioBlockStatus64: send block status command, with 64-bit callback

func (*Libnbd) AioBlockStatusFilter added in v1.18.0

func (h *Libnbd) AioBlockStatusFilter(count uint64, offset uint64, contexts []string, extent64 Extent64Callback, optargs *AioBlockStatusFilterOptargs) (uint64, error)

AioBlockStatusFilter: send filtered block status command to the NBD server

func (*Libnbd) AioCache

func (h *Libnbd) AioCache(count uint64, offset uint64, optargs *AioCacheOptargs) (uint64, error)

AioCache: send cache (prefetch) command to the NBD server

func (*Libnbd) AioCommandCompleted

func (h *Libnbd) AioCommandCompleted(cookie uint64) (bool, error)

AioCommandCompleted: check if the command completed

func (*Libnbd) AioConnect

func (h *Libnbd) AioConnect(addr string) error

AioConnect: connect to the NBD server

func (*Libnbd) AioConnectCommand

func (h *Libnbd) AioConnectCommand(argv []string) error

AioConnectCommand: connect to the NBD server

func (*Libnbd) AioConnectSocket

func (h *Libnbd) AioConnectSocket(sock int) error

AioConnectSocket: connect directly to a connected socket

func (*Libnbd) AioConnectSystemdSocketActivation

func (h *Libnbd) AioConnectSystemdSocketActivation(argv []string) error

AioConnectSystemdSocketActivation: connect using systemd socket activation

func (*Libnbd) AioConnectTcp

func (h *Libnbd) AioConnectTcp(hostname string, port string) error

AioConnectTcp: connect to the NBD server over a TCP port

func (*Libnbd) AioConnectUnix

func (h *Libnbd) AioConnectUnix(unixsocket string) error

AioConnectUnix: connect to the NBD server over a Unix domain socket

func (*Libnbd) AioConnectUri

func (h *Libnbd) AioConnectUri(uri string) error

AioConnectUri: connect to an NBD URI

func (*Libnbd) AioConnectVsock

func (h *Libnbd) AioConnectVsock(cid uint32, port uint32) error

AioConnectVsock: connect to the NBD server over AF_VSOCK socket

func (*Libnbd) AioDisconnect

func (h *Libnbd) AioDisconnect(optargs *AioDisconnectOptargs) error

AioDisconnect: disconnect from the NBD server

func (*Libnbd) AioFlush

func (h *Libnbd) AioFlush(optargs *AioFlushOptargs) (uint64, error)

AioFlush: send flush command to the NBD server

func (*Libnbd) AioGetDirection

func (h *Libnbd) AioGetDirection() (uint, error)

AioGetDirection: return the read or write direction

func (*Libnbd) AioGetFd

func (h *Libnbd) AioGetFd() (int, error)

AioGetFd: return file descriptor associated with this connection

func (*Libnbd) AioInFlight

func (h *Libnbd) AioInFlight() (uint, error)

AioInFlight: check how many aio commands are still in flight

func (*Libnbd) AioIsClosed

func (h *Libnbd) AioIsClosed() (bool, error)

AioIsClosed: check if the connection is closed

func (*Libnbd) AioIsConnecting

func (h *Libnbd) AioIsConnecting() (bool, error)

AioIsConnecting: check if the connection is connecting or handshaking

func (*Libnbd) AioIsCreated

func (h *Libnbd) AioIsCreated() (bool, error)

AioIsCreated: check if the connection has just been created

func (*Libnbd) AioIsDead

func (h *Libnbd) AioIsDead() (bool, error)

AioIsDead: check if the connection is dead

func (*Libnbd) AioIsNegotiating

func (h *Libnbd) AioIsNegotiating() (bool, error)

AioIsNegotiating: check if connection is ready to send handshake option

func (*Libnbd) AioIsProcessing

func (h *Libnbd) AioIsProcessing() (bool, error)

AioIsProcessing: check if the connection is processing a command

func (*Libnbd) AioIsReady

func (h *Libnbd) AioIsReady() (bool, error)

AioIsReady: check if the connection is in the ready state

func (*Libnbd) AioNotifyRead

func (h *Libnbd) AioNotifyRead() error

AioNotifyRead: notify that the connection is readable

func (*Libnbd) AioNotifyWrite

func (h *Libnbd) AioNotifyWrite() error

AioNotifyWrite: notify that the connection is writable

func (*Libnbd) AioOptAbort

func (h *Libnbd) AioOptAbort() error

AioOptAbort: end negotiation and close the connection

func (*Libnbd) AioOptExtendedHeaders added in v1.18.0

func (h *Libnbd) AioOptExtendedHeaders(optargs *AioOptExtendedHeadersOptargs) error

AioOptExtendedHeaders: request the server to enable extended headers

func (*Libnbd) AioOptGo

func (h *Libnbd) AioOptGo(optargs *AioOptGoOptargs) error

AioOptGo: end negotiation and move on to using an export

func (*Libnbd) AioOptInfo

func (h *Libnbd) AioOptInfo(optargs *AioOptInfoOptargs) error

AioOptInfo: request the server for information about an export

func (*Libnbd) AioOptList

func (h *Libnbd) AioOptList(list ListCallback, optargs *AioOptListOptargs) error

AioOptList: request the server to list all exports during negotiation

func (*Libnbd) AioOptListMetaContext

func (h *Libnbd) AioOptListMetaContext(context ContextCallback, optargs *AioOptListMetaContextOptargs) (uint, error)

AioOptListMetaContext: request list of available meta contexts, using implicit query

func (*Libnbd) AioOptListMetaContextQueries added in v1.18.0

func (h *Libnbd) AioOptListMetaContextQueries(queries []string, context ContextCallback, optargs *AioOptListMetaContextQueriesOptargs) (uint, error)

AioOptListMetaContextQueries: request list of available meta contexts, using explicit query

func (*Libnbd) AioOptSetMetaContext added in v1.18.0

func (h *Libnbd) AioOptSetMetaContext(context ContextCallback, optargs *AioOptSetMetaContextOptargs) (uint, error)

AioOptSetMetaContext: select specific meta contexts, with implicit query list

func (*Libnbd) AioOptSetMetaContextQueries added in v1.18.0

func (h *Libnbd) AioOptSetMetaContextQueries(queries []string, context ContextCallback, optargs *AioOptSetMetaContextQueriesOptargs) (uint, error)

AioOptSetMetaContextQueries: select specific meta contexts, with explicit query list

func (*Libnbd) AioOptStarttls added in v1.18.0

func (h *Libnbd) AioOptStarttls(optargs *AioOptStarttlsOptargs) error

AioOptStarttls: request the server to initiate TLS

func (*Libnbd) AioOptStructuredReply added in v1.18.0

func (h *Libnbd) AioOptStructuredReply(optargs *AioOptStructuredReplyOptargs) error

AioOptStructuredReply: request the server to enable structured replies

func (*Libnbd) AioPeekCommandCompleted

func (h *Libnbd) AioPeekCommandCompleted() (uint64, error)

AioPeekCommandCompleted: check if any command has completed

func (*Libnbd) AioPread

func (h *Libnbd) AioPread(buf AioBuffer, offset uint64, optargs *AioPreadOptargs) (uint64, error)

AioPread: read from the NBD server

func (*Libnbd) AioPreadStructured

func (h *Libnbd) AioPreadStructured(buf AioBuffer, offset uint64, chunk ChunkCallback, optargs *AioPreadStructuredOptargs) (uint64, error)

AioPreadStructured: read from the NBD server

func (*Libnbd) AioPwrite

func (h *Libnbd) AioPwrite(buf AioBuffer, offset uint64, optargs *AioPwriteOptargs) (uint64, error)

AioPwrite: write to the NBD server

func (*Libnbd) AioTrim

func (h *Libnbd) AioTrim(count uint64, offset uint64, optargs *AioTrimOptargs) (uint64, error)

AioTrim: send trim command to the NBD server

func (*Libnbd) AioZero

func (h *Libnbd) AioZero(count uint64, offset uint64, optargs *AioZeroOptargs) (uint64, error)

AioZero: send write zeroes command to the NBD server

func (*Libnbd) BlockStatus

func (h *Libnbd) BlockStatus(count uint64, offset uint64, extent ExtentCallback, optargs *BlockStatusOptargs) error

BlockStatus: send block status command, with 32-bit callback

func (*Libnbd) BlockStatus64 added in v1.18.0

func (h *Libnbd) BlockStatus64(count uint64, offset uint64, extent64 Extent64Callback, optargs *BlockStatus64Optargs) error

BlockStatus64: send block status command, with 64-bit callback

func (*Libnbd) BlockStatusFilter added in v1.18.0

func (h *Libnbd) BlockStatusFilter(count uint64, offset uint64, contexts []string, extent64 Extent64Callback, optargs *BlockStatusFilterOptargs) error

BlockStatusFilter: send filtered block status command, with 64-bit callback

func (*Libnbd) Cache

func (h *Libnbd) Cache(count uint64, offset uint64, optargs *CacheOptargs) error

Cache: send cache (prefetch) command to the NBD server

func (*Libnbd) CanBlockStatusPayload added in v1.18.0

func (h *Libnbd) CanBlockStatusPayload() (bool, error)

CanBlockStatusPayload: does the server support the block status payload flag?

func (*Libnbd) CanCache

func (h *Libnbd) CanCache() (bool, error)

CanCache: does the server support the cache command?

func (*Libnbd) CanDf

func (h *Libnbd) CanDf() (bool, error)

CanDf: does the server support the don't fragment flag to pread?

func (*Libnbd) CanFastZero

func (h *Libnbd) CanFastZero() (bool, error)

CanFastZero: does the server support the fast zero flag?

func (*Libnbd) CanFlush

func (h *Libnbd) CanFlush() (bool, error)

CanFlush: does the server support the flush command?

func (*Libnbd) CanFua

func (h *Libnbd) CanFua() (bool, error)

CanFua: does the server support the FUA flag?

func (*Libnbd) CanMetaContext

func (h *Libnbd) CanMetaContext(metacontext string) (bool, error)

CanMetaContext: does the server support a specific meta context?

func (*Libnbd) CanMultiConn

func (h *Libnbd) CanMultiConn() (bool, error)

CanMultiConn: does the server support multi-conn?

func (*Libnbd) CanTrim

func (h *Libnbd) CanTrim() (bool, error)

CanTrim: does the server support the trim command?

func (*Libnbd) CanZero

func (h *Libnbd) CanZero() (bool, error)

CanZero: does the server support the zero command?

func (*Libnbd) ClearDebugCallback

func (h *Libnbd) ClearDebugCallback() error

ClearDebugCallback: clear the debug callback

func (*Libnbd) ClearMetaContexts

func (h *Libnbd) ClearMetaContexts() error

ClearMetaContexts: reset the list of requested meta contexts

func (*Libnbd) Close

func (h *Libnbd) Close() *LibnbdError

Close the handle.

func (*Libnbd) ConnectCommand

func (h *Libnbd) ConnectCommand(argv []string) error

ConnectCommand: connect to NBD server command

func (*Libnbd) ConnectSocket

func (h *Libnbd) ConnectSocket(sock int) error

ConnectSocket: connect directly to a connected socket

func (*Libnbd) ConnectSystemdSocketActivation

func (h *Libnbd) ConnectSystemdSocketActivation(argv []string) error

ConnectSystemdSocketActivation: connect using systemd socket activation

func (*Libnbd) ConnectTcp

func (h *Libnbd) ConnectTcp(hostname string, port string) error

ConnectTcp: connect to NBD server over a TCP port

func (*Libnbd) ConnectUnix

func (h *Libnbd) ConnectUnix(unixsocket string) error

ConnectUnix: connect to NBD server over a Unix domain socket

func (*Libnbd) ConnectUri

func (h *Libnbd) ConnectUri(uri string) error

ConnectUri: connect to NBD URI

func (*Libnbd) ConnectVsock

func (h *Libnbd) ConnectVsock(cid uint32, port uint32) error

ConnectVsock: connect to NBD server over AF_VSOCK protocol

func (*Libnbd) ConnectionState

func (h *Libnbd) ConnectionState() (*string, error)

ConnectionState: return string describing the state of the connection

func (*Libnbd) Flush

func (h *Libnbd) Flush(optargs *FlushOptargs) error

Flush: send flush command to the NBD server

func (*Libnbd) GetBlockSize

func (h *Libnbd) GetBlockSize(size_type Size) (uint64, error)

GetBlockSize: return a specific server block size constraint

func (*Libnbd) GetCanonicalExportName

func (h *Libnbd) GetCanonicalExportName() (*string, error)

GetCanonicalExportName: return the canonical export name, if the server has one

func (*Libnbd) GetDebug

func (h *Libnbd) GetDebug() (bool, error)

GetDebug: return the state of the debug flag

func (*Libnbd) GetExportDescription

func (h *Libnbd) GetExportDescription() (*string, error)

GetExportDescription: return the export description, if the server has one

func (*Libnbd) GetExportName

func (h *Libnbd) GetExportName() (*string, error)

GetExportName: get the export name

func (*Libnbd) GetExtendedHeadersNegotiated added in v1.18.0

func (h *Libnbd) GetExtendedHeadersNegotiated() (bool, error)

GetExtendedHeadersNegotiated: see if extended headers are in use

func (*Libnbd) GetFullInfo

func (h *Libnbd) GetFullInfo() (bool, error)

GetFullInfo: see if NBD_OPT_GO requests extra details

func (*Libnbd) GetHandleName

func (h *Libnbd) GetHandleName() (*string, error)

GetHandleName: get the handle name

func (*Libnbd) GetHandshakeFlags

func (h *Libnbd) GetHandshakeFlags() (HandshakeFlag, error)

GetHandshakeFlags: see which handshake flags are supported

func (*Libnbd) GetMetaContext

func (h *Libnbd) GetMetaContext(i int) (*string, error)

GetMetaContext: return the i'th meta context request

func (*Libnbd) GetNrMetaContexts

func (h *Libnbd) GetNrMetaContexts() (uint, error)

GetNrMetaContexts: return the current number of requested meta contexts

func (*Libnbd) GetOptMode

func (h *Libnbd) GetOptMode() (bool, error)

GetOptMode: return whether option mode was enabled

func (*Libnbd) GetPackageName

func (h *Libnbd) GetPackageName() (*string, error)

GetPackageName: return the name of the library

func (*Libnbd) GetPreadInitialize added in v1.12.0

func (h *Libnbd) GetPreadInitialize() (bool, error)

GetPreadInitialize: see whether libnbd pre-initializes read buffers

func (*Libnbd) GetPrivateData

func (h *Libnbd) GetPrivateData() (uint, error)

GetPrivateData: get the per-handle private data

func (*Libnbd) GetProtocol

func (h *Libnbd) GetProtocol() (*string, error)

GetProtocol: return the NBD protocol variant

func (*Libnbd) GetRequestBlockSize added in v1.12.0

func (h *Libnbd) GetRequestBlockSize() (bool, error)

GetRequestBlockSize: see if NBD_OPT_GO requests block size

func (*Libnbd) GetRequestExtendedHeaders added in v1.18.0

func (h *Libnbd) GetRequestExtendedHeaders() (bool, error)

GetRequestExtendedHeaders: see if extended headers are attempted

func (*Libnbd) GetRequestMetaContext added in v1.18.0

func (h *Libnbd) GetRequestMetaContext() (bool, error)

GetRequestMetaContext: see if connect automatically requests meta contexts

func (*Libnbd) GetRequestStructuredReplies

func (h *Libnbd) GetRequestStructuredReplies() (bool, error)

GetRequestStructuredReplies: see if structured replies are attempted

func (*Libnbd) GetSize

func (h *Libnbd) GetSize() (uint64, error)

GetSize: return the export size

func (*Libnbd) GetSocketActivationName added in v1.18.0

func (h *Libnbd) GetSocketActivationName() (*string, error)

GetSocketActivationName: get the socket activation name

func (*Libnbd) GetStrictMode

func (h *Libnbd) GetStrictMode() (Strict, error)

GetStrictMode: see which strictness flags are in effect

func (*Libnbd) GetStructuredRepliesNegotiated

func (h *Libnbd) GetStructuredRepliesNegotiated() (bool, error)

GetStructuredRepliesNegotiated: see if structured replies are in use

func (*Libnbd) GetTls

func (h *Libnbd) GetTls() (Tls, error)

GetTls: get the TLS request setting

func (*Libnbd) GetTlsNegotiated

func (h *Libnbd) GetTlsNegotiated() (bool, error)

GetTlsNegotiated: find out if TLS was negotiated on a connection

func (*Libnbd) GetTlsUsername

func (h *Libnbd) GetTlsUsername() (*string, error)

GetTlsUsername: get the current TLS username

func (*Libnbd) GetTlsVerifyPeer

func (h *Libnbd) GetTlsVerifyPeer() (bool, error)

GetTlsVerifyPeer: get whether we verify the identity of the server

func (*Libnbd) GetUri

func (h *Libnbd) GetUri() (*string, error)

GetUri: construct an NBD URI for a connection

func (*Libnbd) GetVersion

func (h *Libnbd) GetVersion() (*string, error)

GetVersion: return the version of the library

func (*Libnbd) IsReadOnly

func (h *Libnbd) IsReadOnly() (bool, error)

IsReadOnly: is the NBD export read-only?

func (*Libnbd) IsRotational

func (h *Libnbd) IsRotational() (bool, error)

IsRotational: is the NBD disk rotational (like a disk)?

func (*Libnbd) KillSubprocess

func (h *Libnbd) KillSubprocess(signum int) error

KillSubprocess: kill server running as a subprocess

func (*Libnbd) OptAbort

func (h *Libnbd) OptAbort() error

OptAbort: end negotiation and close the connection

func (*Libnbd) OptExtendedHeaders added in v1.18.0

func (h *Libnbd) OptExtendedHeaders() (bool, error)

OptExtendedHeaders: request the server to enable extended headers

func (*Libnbd) OptGo

func (h *Libnbd) OptGo() error

OptGo: end negotiation and move on to using an export

func (*Libnbd) OptInfo

func (h *Libnbd) OptInfo() error

OptInfo: request the server for information about an export

func (*Libnbd) OptList

func (h *Libnbd) OptList(list ListCallback) (uint, error)

OptList: request the server to list all exports during negotiation

func (*Libnbd) OptListMetaContext

func (h *Libnbd) OptListMetaContext(context ContextCallback) (uint, error)

OptListMetaContext: list available meta contexts, using implicit query list

func (*Libnbd) OptListMetaContextQueries added in v1.18.0

func (h *Libnbd) OptListMetaContextQueries(queries []string, context ContextCallback) (uint, error)

OptListMetaContextQueries: list available meta contexts, using explicit query list

func (*Libnbd) OptSetMetaContext added in v1.18.0

func (h *Libnbd) OptSetMetaContext(context ContextCallback) (uint, error)

OptSetMetaContext: select specific meta contexts, using implicit query list

func (*Libnbd) OptSetMetaContextQueries added in v1.18.0

func (h *Libnbd) OptSetMetaContextQueries(queries []string, context ContextCallback) (uint, error)

OptSetMetaContextQueries: select specific meta contexts, using explicit query list

func (*Libnbd) OptStarttls added in v1.18.0

func (h *Libnbd) OptStarttls() (bool, error)

OptStarttls: request the server to initiate TLS

func (*Libnbd) OptStructuredReply added in v1.18.0

func (h *Libnbd) OptStructuredReply() (bool, error)

OptStructuredReply: request the server to enable structured replies

func (*Libnbd) Poll

func (h *Libnbd) Poll(timeout int) (uint, error)

Poll: poll the handle once

func (*Libnbd) Poll2 added in v1.18.0

func (h *Libnbd) Poll2(fd int, timeout int) (uint, error)

Poll2: poll the handle once, with fd

func (*Libnbd) Pread

func (h *Libnbd) Pread(buf []byte, offset uint64, optargs *PreadOptargs) error

Pread: read from the NBD server

func (*Libnbd) PreadStructured

func (h *Libnbd) PreadStructured(buf []byte, offset uint64, chunk ChunkCallback, optargs *PreadStructuredOptargs) error

PreadStructured: read from the NBD server

func (*Libnbd) Pwrite

func (h *Libnbd) Pwrite(buf []byte, offset uint64, optargs *PwriteOptargs) error

Pwrite: write to the NBD server

func (*Libnbd) SetDebug

func (h *Libnbd) SetDebug(debug bool) error

SetDebug: set or clear the debug flag

func (*Libnbd) SetDebugCallback

func (h *Libnbd) SetDebugCallback(debug DebugCallback) error

SetDebugCallback: set the debug callback

func (*Libnbd) SetExportName

func (h *Libnbd) SetExportName(export_name string) error

SetExportName: set the export name

func (*Libnbd) SetFullInfo

func (h *Libnbd) SetFullInfo(request bool) error

SetFullInfo: control whether NBD_OPT_GO requests extra details

func (*Libnbd) SetHandleName

func (h *Libnbd) SetHandleName(handle_name string) error

SetHandleName: set the handle name

func (*Libnbd) SetHandshakeFlags

func (h *Libnbd) SetHandshakeFlags(flags HandshakeFlag) error

SetHandshakeFlags: control use of handshake flags

func (*Libnbd) SetOptMode

func (h *Libnbd) SetOptMode(enable bool) error

SetOptMode: control option mode, for pausing during option negotiation

func (*Libnbd) SetPreadInitialize added in v1.12.0

func (h *Libnbd) SetPreadInitialize(request bool) error

SetPreadInitialize: control whether libnbd pre-initializes read buffers

func (*Libnbd) SetPrivateData

func (h *Libnbd) SetPrivateData(private_data uint) (uint, error)

SetPrivateData: set the per-handle private data

func (*Libnbd) SetRequestBlockSize added in v1.12.0

func (h *Libnbd) SetRequestBlockSize(request bool) error

SetRequestBlockSize: control whether NBD_OPT_GO requests block size

func (*Libnbd) SetRequestExtendedHeaders added in v1.18.0

func (h *Libnbd) SetRequestExtendedHeaders(request bool) error

SetRequestExtendedHeaders: control use of extended headers

func (*Libnbd) SetRequestMetaContext added in v1.18.0

func (h *Libnbd) SetRequestMetaContext(request bool) error

SetRequestMetaContext: control whether connect automatically requests meta contexts

func (*Libnbd) SetRequestStructuredReplies

func (h *Libnbd) SetRequestStructuredReplies(request bool) error

SetRequestStructuredReplies: control use of structured replies

func (*Libnbd) SetSocketActivationName added in v1.18.0

func (h *Libnbd) SetSocketActivationName(socket_name string) error

SetSocketActivationName: set the socket activation name

func (*Libnbd) SetStrictMode

func (h *Libnbd) SetStrictMode(flags Strict) error

SetStrictMode: control how strictly to follow NBD protocol

func (*Libnbd) SetTls

func (h *Libnbd) SetTls(tls Tls) error

SetTls: enable or require TLS (authentication and encryption)

func (*Libnbd) SetTlsCertificates

func (h *Libnbd) SetTlsCertificates(dir string) error

SetTlsCertificates: set the path to the TLS certificates directory

func (*Libnbd) SetTlsPskFile

func (h *Libnbd) SetTlsPskFile(filename string) error

SetTlsPskFile: set the TLS Pre-Shared Keys (PSK) filename

func (*Libnbd) SetTlsUsername

func (h *Libnbd) SetTlsUsername(username string) error

SetTlsUsername: set the TLS username

func (*Libnbd) SetTlsVerifyPeer

func (h *Libnbd) SetTlsVerifyPeer(verify bool) error

SetTlsVerifyPeer: set whether we verify the identity of the server

func (*Libnbd) SetUriAllowLocalFile

func (h *Libnbd) SetUriAllowLocalFile(allow bool) error

SetUriAllowLocalFile: set the allowed transports in NBD URIs

func (*Libnbd) SetUriAllowTls

func (h *Libnbd) SetUriAllowTls(tls Tls) error

SetUriAllowTls: set the allowed TLS settings in NBD URIs

func (*Libnbd) SetUriAllowTransports

func (h *Libnbd) SetUriAllowTransports(mask AllowTransport) error

SetUriAllowTransports: set the allowed transports in NBD URIs

func (*Libnbd) Shutdown

func (h *Libnbd) Shutdown(optargs *ShutdownOptargs) error

Shutdown: disconnect from the NBD server

func (*Libnbd) StatsBytesReceived added in v1.18.0

func (h *Libnbd) StatsBytesReceived() (uint64, error)

StatsBytesReceived: statistics of bytes received over connection so far

func (*Libnbd) StatsBytesSent added in v1.18.0

func (h *Libnbd) StatsBytesSent() (uint64, error)

StatsBytesSent: statistics of bytes sent over connection so far

func (*Libnbd) StatsChunksReceived added in v1.18.0

func (h *Libnbd) StatsChunksReceived() (uint64, error)

StatsChunksReceived: statistics of chunks received over connection so far

func (*Libnbd) StatsChunksSent added in v1.18.0

func (h *Libnbd) StatsChunksSent() (uint64, error)

StatsChunksSent: statistics of chunks sent over connection so far

func (*Libnbd) String

func (h *Libnbd) String() string

Convert handle to string (just for debugging).

func (*Libnbd) SupportsTls

func (h *Libnbd) SupportsTls() (bool, error)

SupportsTls: true if libnbd was compiled with support for TLS

func (*Libnbd) SupportsUri

func (h *Libnbd) SupportsUri() (bool, error)

SupportsUri: true if libnbd was compiled with support for NBD URIs

func (*Libnbd) SupportsVsock added in v1.18.0

func (h *Libnbd) SupportsVsock() (bool, error)

SupportsVsock: true if libnbd was compiled with support for AF_VSOCK

func (*Libnbd) Trim

func (h *Libnbd) Trim(count uint64, offset uint64, optargs *TrimOptargs) error

Trim: send trim command to the NBD server

func (*Libnbd) Zero

func (h *Libnbd) Zero(count uint64, offset uint64, optargs *ZeroOptargs) error

Zero: send write zeroes command to the NBD server

type LibnbdError

type LibnbdError struct {
	Op     string        // operation which failed
	Errmsg string        // string (nbd_get_error)
	Errno  syscall.Errno // errno (nbd_get_errno)
}

All functions (except Close) return ([result,] LibnbdError).

func (*LibnbdError) Error

func (e *LibnbdError) Error() string

Implement the error interface

func (*LibnbdError) String

func (e *LibnbdError) String() string

type LibnbdExtent added in v1.18.0

type LibnbdExtent struct {
	Length uint64 // length of the extent
	Flags  uint64 // flags describing properties of the extent
}

Used for block status callback.

type ListCallback

type ListCallback func(name string, description string) int

type PreadOptargs

type PreadOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for Pread.

type PreadStructuredOptargs

type PreadStructuredOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for PreadStructured.

type PwriteOptargs

type PwriteOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for Pwrite.

type Shutdown

type Shutdown uint32

type ShutdownOptargs

type ShutdownOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    Shutdown
}

Struct carrying optional arguments for Shutdown.

type Size

type Size int

type Strict

type Strict uint32

type Tls

type Tls int

Enums.

type TrimOptargs

type TrimOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for Trim.

type ZeroOptargs

type ZeroOptargs struct {
	/* Flags field is ignored unless FlagsSet == true. */
	FlagsSet bool
	Flags    CmdFlag
}

Struct carrying optional arguments for Zero.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL