Commit 0822ea6d authored by Daniel P. Berrange's avatar Daniel P. Berrange

Generate links to C library API docs

Signed-off-by: 's avatarDaniel P. Berrange <berrange@redhat.com>
parent e53ae544
This diff is collapsed.
This diff is collapsed.
......@@ -89,6 +89,7 @@ type DomainSnapshot struct {
ptr C.virDomainSnapshotPtr
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotFree
func (s *DomainSnapshot) Free() error {
ret := C.virDomainSnapshotFree(s.ptr)
if ret == -1 {
......@@ -97,6 +98,7 @@ func (s *DomainSnapshot) Free() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotRef
func (c *DomainSnapshot) Ref() error {
ret := C.virDomainSnapshotRef(c.ptr)
if ret == -1 {
......@@ -105,6 +107,7 @@ func (c *DomainSnapshot) Ref() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotDelete
func (s *DomainSnapshot) Delete(flags DomainSnapshotDeleteFlags) error {
result := C.virDomainSnapshotDelete(s.ptr, C.uint(flags))
if result != 0 {
......@@ -113,6 +116,7 @@ func (s *DomainSnapshot) Delete(flags DomainSnapshotDeleteFlags) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainRevertToSnapshot
func (s *DomainSnapshot) RevertToSnapshot(flags DomainSnapshotRevertFlags) error {
result := C.virDomainRevertToSnapshot(s.ptr, C.uint(flags))
if result != 0 {
......@@ -121,6 +125,7 @@ func (s *DomainSnapshot) RevertToSnapshot(flags DomainSnapshotRevertFlags) error
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotIsCurrent
func (s *DomainSnapshot) IsCurrent(flags uint32) (bool, error) {
result := C.virDomainSnapshotIsCurrent(s.ptr, C.uint(flags))
if result == -1 {
......@@ -132,6 +137,7 @@ func (s *DomainSnapshot) IsCurrent(flags uint32) (bool, error) {
return false, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotHasMetadata
func (s *DomainSnapshot) HasMetadata(flags uint32) (bool, error) {
result := C.virDomainSnapshotHasMetadata(s.ptr, C.uint(flags))
if result == -1 {
......@@ -143,6 +149,7 @@ func (s *DomainSnapshot) HasMetadata(flags uint32) (bool, error) {
return false, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotGetXMLDesc
func (s *DomainSnapshot) GetXMLDesc(flags DomainXMLFlags) (string, error) {
result := C.virDomainSnapshotGetXMLDesc(s.ptr, C.uint(flags))
if result == nil {
......@@ -153,6 +160,7 @@ func (s *DomainSnapshot) GetXMLDesc(flags DomainXMLFlags) (string, error) {
return xml, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotGetName
func (s *DomainSnapshot) GetName() (string, error) {
name := C.virDomainSnapshotGetName(s.ptr)
if name == nil {
......@@ -161,6 +169,7 @@ func (s *DomainSnapshot) GetName() (string, error) {
return C.GoString(name), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotGetParent
func (s *DomainSnapshot) GetParent(flags uint32) (*DomainSnapshot, error) {
ptr := C.virDomainSnapshotGetParent(s.ptr, C.uint(flags))
if ptr == nil {
......@@ -169,6 +178,7 @@ func (s *DomainSnapshot) GetParent(flags uint32) (*DomainSnapshot, error) {
return &DomainSnapshot{ptr: ptr}, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotNumChildren
func (s *DomainSnapshot) NumChildren(flags DomainSnapshotListFlags) (int, error) {
result := int(C.virDomainSnapshotNumChildren(s.ptr, C.uint(flags)))
if result == -1 {
......@@ -177,6 +187,7 @@ func (s *DomainSnapshot) NumChildren(flags DomainSnapshotListFlags) (int, error)
return result, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotListChildrenNames
func (s *DomainSnapshot) ListChildrenNames(flags DomainSnapshotListFlags) ([]string, error) {
const maxNames = 1024
var names [maxNames](*C.char)
......@@ -196,6 +207,7 @@ func (s *DomainSnapshot) ListChildrenNames(flags DomainSnapshotListFlags) ([]str
return goNames, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-domain-snapshot.html#virDomainSnapshotListAllChildren
func (d *DomainSnapshot) ListAllChildren(flags DomainSnapshotListFlags) ([]DomainSnapshot, error) {
var cList *C.virDomainSnapshotPtr
numVols := C.virDomainSnapshotListAllChildren(d.ptr, (**C.virDomainSnapshotPtr)(&cList), C.uint(flags))
......
......@@ -43,6 +43,7 @@ const (
EVENT_HANDLE_HANGUP = EventHandleType(C.VIR_EVENT_HANDLE_HANGUP)
)
// See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventRegisterDefaultImpl
func EventRegisterDefaultImpl() error {
if i := int(C.virEventRegisterDefaultImpl()); i != 0 {
return GetLastError()
......@@ -50,6 +51,7 @@ func EventRegisterDefaultImpl() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventRunDefaultImpl
func EventRunDefaultImpl() error {
if i := int(C.virEventRunDefaultImpl()); i != 0 {
return GetLastError()
......@@ -71,6 +73,7 @@ func eventHandleCallback(watch int, fd int, events int, callbackID int) {
callback(watch, fd, (EventHandleType)(events))
}
// See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventAddHandle
func EventAddHandle(fd int, events EventHandleType, callback EventHandleCallback) (int, error) {
callbackID := registerCallbackId(callback)
......@@ -82,10 +85,12 @@ func EventAddHandle(fd int, events EventHandleType, callback EventHandleCallback
return int(ret), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventUpdateHandle
func EventUpdateHandle(watch int, events EventHandleType) {
C.virEventUpdateHandle((C.int)(watch), (C.int)(events))
}
// See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventRemoveHandle
func EventRemoveHandle(watch int) {
C.virEventRemoveHandle((C.int)(watch))
}
......@@ -104,6 +109,7 @@ func eventTimeoutCallback(timer int, callbackID int) {
callback(timer)
}
// See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventAddTimeout
func EventAddTimeout(freq int, callback EventTimeoutCallback) (int, error) {
callbackID := registerCallbackId(callback)
......@@ -115,10 +121,12 @@ func EventAddTimeout(freq int, callback EventTimeoutCallback) (int, error) {
return int(ret), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventUpdateTimeout
func EventUpdateTimeout(timer int, freq int) {
C.virEventUpdateTimeout((C.int)(timer), (C.int)(freq))
}
// See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventRemoveTimeout
func EventRemoveTimeout(timer int) {
C.virEventRemoveTimeout((C.int)(timer))
}
......@@ -162,6 +170,7 @@ type EventLoop interface {
var eventLoopImpl EventLoop
// See also https://libvirt.org/html/libvirt-libvirt-event.html#virEventRegisterImpl
func EventRegisterImpl(impl EventLoop) {
eventLoopImpl = impl
C.virEventRegisterImpl_cgo()
......
......@@ -48,6 +48,7 @@ type Interface struct {
ptr C.virInterfacePtr
}
// See also https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreate
func (n *Interface) Create(flags uint32) error {
result := C.virInterfaceCreate(n.ptr, C.uint(flags))
if result == -1 {
......@@ -56,6 +57,7 @@ func (n *Interface) Create(flags uint32) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceDestroy
func (n *Interface) Destroy(flags uint32) error {
result := C.virInterfaceDestroy(n.ptr, C.uint(flags))
if result == -1 {
......@@ -64,6 +66,7 @@ func (n *Interface) Destroy(flags uint32) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceIsActive
func (n *Interface) IsActive() (bool, error) {
result := C.virInterfaceIsActive(n.ptr)
if result == -1 {
......@@ -75,6 +78,7 @@ func (n *Interface) IsActive() (bool, error) {
return false, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString
func (n *Interface) GetMACString() (string, error) {
result := C.virInterfaceGetMACString(n.ptr)
if result == nil {
......@@ -84,6 +88,7 @@ func (n *Interface) GetMACString() (string, error) {
return mac, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName
func (n *Interface) GetName() (string, error) {
result := C.virInterfaceGetName(n.ptr)
if result == nil {
......@@ -93,6 +98,7 @@ func (n *Interface) GetName() (string, error) {
return name, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetXMLDesc
func (n *Interface) GetXMLDesc(flags InterfaceXMLFlags) (string, error) {
result := C.virInterfaceGetXMLDesc(n.ptr, C.uint(flags))
if result == nil {
......@@ -103,6 +109,7 @@ func (n *Interface) GetXMLDesc(flags InterfaceXMLFlags) (string, error) {
return xml, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceUndefine
func (n *Interface) Undefine() error {
result := C.virInterfaceUndefine(n.ptr)
if result == -1 {
......@@ -111,6 +118,7 @@ func (n *Interface) Undefine() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceFree
func (n *Interface) Free() error {
ret := C.virInterfaceFree(n.ptr)
if ret == -1 {
......@@ -119,6 +127,7 @@ func (n *Interface) Free() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceRef
func (c *Interface) Ref() error {
ret := C.virInterfaceRef(c.ptr)
if ret == -1 {
......
......@@ -121,6 +121,7 @@ type NetworkDHCPLease struct {
Clientid string
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkFree
func (n *Network) Free() error {
ret := C.virNetworkFree(n.ptr)
if ret == -1 {
......@@ -129,6 +130,7 @@ func (n *Network) Free() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkRef
func (c *Network) Ref() error {
ret := C.virNetworkRef(c.ptr)
if ret == -1 {
......@@ -137,6 +139,7 @@ func (c *Network) Ref() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkCreate
func (n *Network) Create() error {
result := C.virNetworkCreate(n.ptr)
if result == -1 {
......@@ -145,6 +148,7 @@ func (n *Network) Create() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkDestroy
func (n *Network) Destroy() error {
result := C.virNetworkDestroy(n.ptr)
if result == -1 {
......@@ -153,6 +157,7 @@ func (n *Network) Destroy() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkIsActive
func (n *Network) IsActive() (bool, error) {
result := C.virNetworkIsActive(n.ptr)
if result == -1 {
......@@ -164,6 +169,7 @@ func (n *Network) IsActive() (bool, error) {
return false, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkIsPersistent
func (n *Network) IsPersistent() (bool, error) {
result := C.virNetworkIsPersistent(n.ptr)
if result == -1 {
......@@ -175,6 +181,7 @@ func (n *Network) IsPersistent() (bool, error) {
return false, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetAutostart
func (n *Network) GetAutostart() (bool, error) {
var out C.int
result := C.virNetworkGetAutostart(n.ptr, (*C.int)(unsafe.Pointer(&out)))
......@@ -189,6 +196,7 @@ func (n *Network) GetAutostart() (bool, error) {
}
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkSetAutostart
func (n *Network) SetAutostart(autostart bool) error {
var cAutostart C.int
switch autostart {
......@@ -204,6 +212,7 @@ func (n *Network) SetAutostart(autostart bool) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetName
func (n *Network) GetName() (string, error) {
name := C.virNetworkGetName(n.ptr)
if name == nil {
......@@ -212,6 +221,7 @@ func (n *Network) GetName() (string, error) {
return C.GoString(name), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetUUID
func (n *Network) GetUUID() ([]byte, error) {
var cUuid [C.VIR_UUID_BUFLEN](byte)
cuidPtr := unsafe.Pointer(&cUuid)
......@@ -222,6 +232,7 @@ func (n *Network) GetUUID() ([]byte, error) {
return C.GoBytes(cuidPtr, C.VIR_UUID_BUFLEN), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetUUIDString
func (n *Network) GetUUIDString() (string, error) {
var cUuid [C.VIR_UUID_STRING_BUFLEN](C.char)
cuidPtr := unsafe.Pointer(&cUuid)
......@@ -232,6 +243,7 @@ func (n *Network) GetUUIDString() (string, error) {
return C.GoString((*C.char)(cuidPtr)), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetBridgeName
func (n *Network) GetBridgeName() (string, error) {
result := C.virNetworkGetBridgeName(n.ptr)
if result == nil {
......@@ -242,6 +254,7 @@ func (n *Network) GetBridgeName() (string, error) {
return bridge, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetXMLDesc
func (n *Network) GetXMLDesc(flags NetworkXMLFlags) (string, error) {
result := C.virNetworkGetXMLDesc(n.ptr, C.uint(flags))
if result == nil {
......@@ -252,6 +265,7 @@ func (n *Network) GetXMLDesc(flags NetworkXMLFlags) (string, error) {
return xml, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkUndefine
func (n *Network) Undefine() error {
result := C.virNetworkUndefine(n.ptr)
if result == -1 {
......@@ -260,6 +274,7 @@ func (n *Network) Undefine() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkUpdate
func (n *Network) Update(cmd NetworkUpdateCommand, section NetworkUpdateSection, parentIndex int, xml string, flags NetworkUpdateFlags) error {
cxml := C.CString(xml)
defer C.free(unsafe.Pointer(cxml))
......@@ -270,6 +285,7 @@ func (n *Network) Update(cmd NetworkUpdateCommand, section NetworkUpdateSection,
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetDHCPLeases
func (n *Network) GetDHCPLeases() ([]NetworkDHCPLease, error) {
if C.LIBVIR_VERSION_NUMBER < 1002006 {
return []NetworkDHCPLease{}, GetNotImplementedError("virNetworkGetDHCPLeases")
......
......@@ -57,6 +57,7 @@ type NodeDevice struct {
ptr C.virNodeDevicePtr
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceFree
func (n *NodeDevice) Free() error {
ret := C.virNodeDeviceFree(n.ptr)
if ret == -1 {
......@@ -65,6 +66,7 @@ func (n *NodeDevice) Free() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceRef
func (c *NodeDevice) Ref() error {
ret := C.virNodeDeviceRef(c.ptr)
if ret == -1 {
......@@ -73,6 +75,7 @@ func (c *NodeDevice) Ref() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceDestroy
func (n *NodeDevice) Destroy() error {
result := C.virNodeDeviceDestroy(n.ptr)
if result == -1 {
......@@ -81,6 +84,7 @@ func (n *NodeDevice) Destroy() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceReset
func (n *NodeDevice) Reset() error {
result := C.virNodeDeviceReset(n.ptr)
if result == -1 {
......@@ -89,6 +93,7 @@ func (n *NodeDevice) Reset() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceDettach
func (n *NodeDevice) Detach() error {
result := C.virNodeDeviceDettach(n.ptr)
if result == -1 {
......@@ -97,6 +102,7 @@ func (n *NodeDevice) Detach() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceDetachFlags
func (n *NodeDevice) DetachFlags(driverName string, flags uint32) error {
cDriverName := C.CString(driverName)
defer C.free(unsafe.Pointer(cDriverName))
......@@ -107,6 +113,7 @@ func (n *NodeDevice) DetachFlags(driverName string, flags uint32) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceReAttach
func (n *NodeDevice) ReAttach() error {
result := C.virNodeDeviceReAttach(n.ptr)
if result == -1 {
......@@ -115,6 +122,7 @@ func (n *NodeDevice) ReAttach() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceGetName
func (n *NodeDevice) GetName() (string, error) {
name := C.virNodeDeviceGetName(n.ptr)
if name == nil {
......@@ -123,6 +131,7 @@ func (n *NodeDevice) GetName() (string, error) {
return C.GoString(name), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceGetXMLDesc
func (n *NodeDevice) GetXMLDesc(flags uint32) (string, error) {
result := C.virNodeDeviceGetXMLDesc(n.ptr, C.uint(flags))
if result == nil {
......@@ -133,6 +142,7 @@ func (n *NodeDevice) GetXMLDesc(flags uint32) (string, error) {
return xml, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceGetParent
func (n *NodeDevice) GetParent() (string, error) {
result := C.virNodeDeviceGetParent(n.ptr)
if result == nil {
......@@ -142,6 +152,7 @@ func (n *NodeDevice) GetParent() (string, error) {
return C.GoString(result), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceNumOfCaps
func (p *NodeDevice) NumOfCaps() (int, error) {
result := int(C.virNodeDeviceNumOfCaps(p.ptr))
if result == -1 {
......@@ -150,6 +161,7 @@ func (p *NodeDevice) NumOfCaps() (int, error) {
return result, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nodedev.html#virNodeDeviceListCaps
func (p *NodeDevice) ListCaps() ([]string, error) {
const maxCaps = 1024
var names [maxCaps](*C.char)
......
......@@ -42,6 +42,7 @@ type NWFilter struct {
ptr C.virNWFilterPtr
}
// See also https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterFree
func (f *NWFilter) Free() error {
ret := C.virNWFilterFree(f.ptr)
if ret == -1 {
......@@ -50,6 +51,7 @@ func (f *NWFilter) Free() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterRef
func (c *NWFilter) Ref() error {
ret := C.virNWFilterRef(c.ptr)
if ret == -1 {
......@@ -58,6 +60,7 @@ func (c *NWFilter) Ref() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterGetName
func (f *NWFilter) GetName() (string, error) {
name := C.virNWFilterGetName(f.ptr)
if name == nil {
......@@ -66,6 +69,7 @@ func (f *NWFilter) GetName() (string, error) {
return C.GoString(name), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterUndefine
func (f *NWFilter) Undefine() error {
result := C.virNWFilterUndefine(f.ptr)
if result == -1 {
......@@ -74,6 +78,7 @@ func (f *NWFilter) Undefine() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterGetUUID
func (f *NWFilter) GetUUID() ([]byte, error) {
var cUuid [C.VIR_UUID_BUFLEN](byte)
cuidPtr := unsafe.Pointer(&cUuid)
......@@ -84,6 +89,7 @@ func (f *NWFilter) GetUUID() ([]byte, error) {
return C.GoBytes(cuidPtr, C.VIR_UUID_BUFLEN), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterGetUUIDString
func (f *NWFilter) GetUUIDString() (string, error) {
var cUuid [C.VIR_UUID_STRING_BUFLEN](C.char)
cuidPtr := unsafe.Pointer(&cUuid)
......@@ -94,6 +100,7 @@ func (f *NWFilter) GetUUIDString() (string, error) {
return C.GoString((*C.char)(cuidPtr)), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virNWFilterGetXMLDesc
func (f *NWFilter) GetXMLDesc(flags uint32) (string, error) {
result := C.virNWFilterGetXMLDesc(f.ptr, C.uint(flags))
if result == nil {
......
......@@ -67,6 +67,7 @@ type Secret struct {
ptr C.virSecretPtr
}
// See also https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretFree
func (s *Secret) Free() error {
ret := C.virSecretFree(s.ptr)
if ret == -1 {
......@@ -75,6 +76,7 @@ func (s *Secret) Free() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretRef
func (c *Secret) Ref() error {
ret := C.virSecretRef(c.ptr)
if ret == -1 {
......@@ -83,6 +85,7 @@ func (c *Secret) Ref() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretUndefine
func (s *Secret) Undefine() error {
result := C.virSecretUndefine(s.ptr)
if result == -1 {
......@@ -91,6 +94,7 @@ func (s *Secret) Undefine() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetUUID
func (s *Secret) GetUUID() ([]byte, error) {
var cUuid [C.VIR_UUID_BUFLEN](byte)
cuidPtr := unsafe.Pointer(&cUuid)
......@@ -101,6 +105,7 @@ func (s *Secret) GetUUID() ([]byte, error) {
return C.GoBytes(cuidPtr, C.VIR_UUID_BUFLEN), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetUUIDString
func (s *Secret) GetUUIDString() (string, error) {
var cUuid [C.VIR_UUID_STRING_BUFLEN](C.char)
cuidPtr := unsafe.Pointer(&cUuid)
......@@ -111,6 +116,7 @@ func (s *Secret) GetUUIDString() (string, error) {
return C.GoString((*C.char)(cuidPtr)), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetUsageID
func (s *Secret) GetUsageID() (string, error) {
result := C.virSecretGetUsageID(s.ptr)
if result == nil {
......@@ -119,6 +125,7 @@ func (s *Secret) GetUsageID() (string, error) {
return C.GoString(result), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetUsageType
func (s *Secret) GetUsageType() (SecretUsageType, error) {
result := SecretUsageType(C.virSecretGetUsageType(s.ptr))
if result == -1 {
......@@ -127,6 +134,7 @@ func (s *Secret) GetUsageType() (SecretUsageType, error) {
return result, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetXMLDesc
func (s *Secret) GetXMLDesc(flags uint32) (string, error) {
result := C.virSecretGetXMLDesc(s.ptr, C.uint(flags))
if result == nil {
......@@ -137,6 +145,7 @@ func (s *Secret) GetXMLDesc(flags uint32) (string, error) {
return xml, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretGetValue
func (s *Secret) GetValue(flags uint32) ([]byte, error) {
var cvalue_size C.size_t
......@@ -149,6 +158,7 @@ func (s *Secret) GetValue(flags uint32) ([]byte, error) {
return ret, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretSetValue
func (s *Secret) SetValue(value []byte, flags uint32) error {
cvalue := make([]C.uchar, len(value))
......
......@@ -103,6 +103,7 @@ type StoragePoolInfo struct {
Available uint64
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolBuild
func (p *StoragePool) Build(flags StoragePoolBuildFlags) error {
result := C.virStoragePoolBuild(p.ptr, C.uint(flags))
if result == -1 {
......@@ -111,6 +112,7 @@ func (p *StoragePool) Build(flags StoragePoolBuildFlags) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolCreate
func (p *StoragePool) Create(flags StoragePoolCreateFlags) error {
result := C.virStoragePoolCreate(p.ptr, C.uint(flags))
if result == -1 {
......@@ -119,6 +121,7 @@ func (p *StoragePool) Create(flags StoragePoolCreateFlags) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDelete
func (p *StoragePool) Delete(flags StoragePoolDeleteFlags) error {
result := C.virStoragePoolDelete(p.ptr, C.uint(flags))
if result == -1 {
......@@ -127,6 +130,7 @@ func (p *StoragePool) Delete(flags StoragePoolDeleteFlags) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolDestroy
func (p *StoragePool) Destroy() error {
result := C.virStoragePoolDestroy(p.ptr)
if result == -1 {
......@@ -135,6 +139,7 @@ func (p *StoragePool) Destroy() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolFree
func (p *StoragePool) Free() error {
ret := C.virStoragePoolFree(p.ptr)
if ret == -1 {
......@@ -143,6 +148,7 @@ func (p *StoragePool) Free() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolRef
func (c *StoragePool) Ref() error {
ret := C.virStoragePoolRef(c.ptr)
if ret == -1 {
......@@ -151,6 +157,7 @@ func (c *StoragePool) Ref() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetAutostart
func (p *StoragePool) GetAutostart() (bool, error) {
var out C.int
result := C.virStoragePoolGetAutostart(p.ptr, (*C.int)(unsafe.Pointer(&out)))
......@@ -165,6 +172,7 @@ func (p *StoragePool) GetAutostart() (bool, error) {
}
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetInfo
func (p *StoragePool) GetInfo() (*StoragePoolInfo, error) {
var cinfo C.virStoragePoolInfo
result := C.virStoragePoolGetInfo(p.ptr, &cinfo)
......@@ -179,6 +187,7 @@ func (p *StoragePool) GetInfo() (*StoragePoolInfo, error) {
}, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetName
func (p *StoragePool) GetName() (string, error) {
name := C.virStoragePoolGetName(p.ptr)
if name == nil {
......@@ -187,6 +196,7 @@ func (p *StoragePool) GetName() (string, error) {
return C.GoString(name), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetUUID
func (p *StoragePool) GetUUID() ([]byte, error) {
var cUuid [C.VIR_UUID_BUFLEN](byte)
cuidPtr := unsafe.Pointer(&cUuid)
......@@ -197,6 +207,7 @@ func (p *StoragePool) GetUUID() ([]byte, error) {
return C.GoBytes(cuidPtr, C.VIR_UUID_BUFLEN), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetUUIDString
func (p *StoragePool) GetUUIDString() (string, error) {
var cUuid [C.VIR_UUID_STRING_BUFLEN](C.char)
cuidPtr := unsafe.Pointer(&cUuid)
......@@ -207,6 +218,7 @@ func (p *StoragePool) GetUUIDString() (string, error) {
return C.GoString((*C.char)(cuidPtr)), nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolGetXMLDesc
func (p *StoragePool) GetXMLDesc(flags StorageXMLFlags) (string, error) {
result := C.virStoragePoolGetXMLDesc(p.ptr, C.uint(flags))
if result == nil {
......@@ -217,6 +229,7 @@ func (p *StoragePool) GetXMLDesc(flags StorageXMLFlags) (string, error) {
return xml, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolIsActive
func (p *StoragePool) IsActive() (bool, error) {
result := C.virStoragePoolIsActive(p.ptr)
if result == -1 {
......@@ -228,6 +241,7 @@ func (p *StoragePool) IsActive() (bool, error) {
return false, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolIsPersistent
func (p *StoragePool) IsPersistent() (bool, error) {
result := C.virStoragePoolIsPersistent(p.ptr)
if result == -1 {
......@@ -239,6 +253,7 @@ func (p *StoragePool) IsPersistent() (bool, error) {
return false, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolSetAutostart
func (p *StoragePool) SetAutostart(autostart bool) error {
var cAutostart C.int
switch autostart {
......@@ -254,6 +269,7 @@ func (p *StoragePool) SetAutostart(autostart bool) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolRefresh
func (p *StoragePool) Refresh(flags uint32) error {
result := C.virStoragePoolRefresh(p.ptr, C.uint(flags))
if result == -1 {
......@@ -262,6 +278,7 @@ func (p *StoragePool) Refresh(flags uint32) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolUndefine
func (p *StoragePool) Undefine() error {
result := C.virStoragePoolUndefine(p.ptr)
if result == -1 {
......@@ -270,6 +287,7 @@ func (p *StoragePool) Undefine() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolCreateXML
func (p *StoragePool) StorageVolCreateXML(xmlConfig string, flags StorageVolCreateFlags) (*StorageVol, error) {
cXml := C.CString(string(xmlConfig))
defer C.free(unsafe.Pointer(cXml))
......@@ -280,6 +298,7 @@ func (p *StoragePool) StorageVolCreateXML(xmlConfig string, flags StorageVolCrea
return &StorageVol{ptr: ptr}, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolCreateXMLFrom
func (p *StoragePool) StorageVolCreateXMLFrom(xmlConfig string, clonevol *StorageVol, flags StorageVolCreateFlags) (*StorageVol, error) {
cXml := C.CString(string(xmlConfig))
defer C.free(unsafe.Pointer(cXml))
......@@ -290,6 +309,7 @@ func (p *StoragePool) StorageVolCreateXMLFrom(xmlConfig string, clonevol *Storag
return &StorageVol{ptr: ptr}, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolLookupByName
func (p *StoragePool) LookupStorageVolByName(name string) (*StorageVol, error) {
cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))
......@@ -300,6 +320,7 @@ func (p *StoragePool) LookupStorageVolByName(name string) (*StorageVol, error) {
return &StorageVol{ptr: ptr}, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolNumOfVolumes
func (p *StoragePool) NumOfStorageVolumes() (int, error) {
result := int(C.virStoragePoolNumOfVolumes(p.ptr))
if result == -1 {
......@@ -308,6 +329,7 @@ func (p *StoragePool) NumOfStorageVolumes() (int, error) {
return result, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolListVolumes
func (p *StoragePool) ListStorageVolumes() ([]string, error) {
const maxVols = 1024
var names [maxVols](*C.char)
......@@ -327,6 +349,7 @@ func (p *StoragePool) ListStorageVolumes() ([]string, error) {
return goNames, nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolListAllVolumes
func (p *StoragePool) ListAllStorageVolumes(flags uint32) ([]StorageVol, error) {
var cList *C.virStorageVolPtr
numVols := C.virStoragePoolListAllVolumes(p.ptr, (**C.virStorageVolPtr)(&cList), C.uint(flags))
......
......@@ -123,6 +123,7 @@ type StorageVolInfo struct {
Allocation uint64
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolDelete
func (v *StorageVol) Delete(flags StorageVolDeleteFlags) error {
result := C.virStorageVolDelete(v.ptr, C.uint(flags))
if result == -1 {
......@@ -131,6 +132,7 @@ func (v *StorageVol) Delete(flags StorageVolDeleteFlags) error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolFree
func (v *StorageVol) Free() error {
ret := C.virStorageVolFree(v.ptr)
if ret == -1 {
......@@ -139,6 +141,7 @@ func (v *StorageVol) Free() error {
return nil
}
// See also https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolRef
func (c *StorageVol) Ref() error {