Commit e9642325 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Clarify error message when a function is not implemented

The current message reported when Go code is disabled due
to libvirt missing a function is very similar to message
reported when libvirtd doesn't support a function.

Clarify it so it is clear when the missing feature is in
the Go language binding, as opposed to libvirtd.
Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
parent d2944deb
......@@ -793,7 +793,7 @@ func (c *Connect) DomainDefineXML(xmlConfig string) (*Domain, error) {
func (c *Connect) DomainDefineXMLFlags(xmlConfig string, flags DomainDefineFlags) (*Domain, error) {
if C.LIBVIR_VERSION_NUMBER < 1002012 {
return nil, GetNotImplementedError()
return nil, GetNotImplementedError("virDomainDefineXMLFlags")
}
cXml := C.CString(string(xmlConfig))
defer C.free(unsafe.Pointer(cXml))
......@@ -1446,7 +1446,7 @@ func (c *Connect) InterfaceChangeRollback(flags uint32) error {
func (c *Connect) AllocPages(pageSizes map[int]int64, startCell int, cellCount uint, flags NodeAllocPagesFlags) (int, error) {
if C.LIBVIR_VERSION_NUMBER < 1002009 {
return 0, GetNotImplementedError()
return 0, GetNotImplementedError("virNodeAllocPages")
}
cpages := make([]C.uint, len(pageSizes))
ccounts := make([]C.ulonglong, len(pageSizes))
......@@ -1573,7 +1573,7 @@ func (c *Connect) GetFreeMemory() (uint64, error) {
func (c *Connect) GetFreePages(pageSizes []uint64, startCell int, maxCells uint, flags uint32) ([]uint64, error) {
if C.LIBVIR_VERSION_NUMBER < 1002006 {
return []uint64{}, GetNotImplementedError()
return []uint64{}, GetNotImplementedError("virNodeGetFreePages")
}
cpageSizes := make([]C.uint, len(pageSizes))
ccounts := make([]C.ulonglong, len(pageSizes)*int(maxCells))
......@@ -1896,7 +1896,7 @@ func (c *Connect) GetCPUModelNames(arch string, flags uint32) ([]string, error)
func (c *Connect) GetDomainCapabilities(emulatorbin string, arch string, machine string, virttype string, flags uint32) (string, error) {
if C.LIBVIR_VERSION_NUMBER < 1002007 {
return "", GetNotImplementedError()
return "", GetNotImplementedError("virConnectGetDomainCapabilities")
}
var cemulatorbin *C.char
if emulatorbin != "" {
......@@ -2368,7 +2368,7 @@ func getDomainStatsLengthsFieldInfo(params *domainStatsLengths) map[string]typed
func (c *Connect) GetAllDomainStats(doms []*Domain, statsTypes DomainStatsTypes, flags ConnectGetAllDomainStatsFlags) ([]DomainStats, error) {
if C.LIBVIR_VERSION_NUMBER < 1002008 {
return []DomainStats{}, GetNotImplementedError()
return []DomainStats{}, GetNotImplementedError("virConnectGetAllDomainStats")
}
var ret C.int
var cstats *C.virDomainStatsRecordPtr
......
......@@ -1797,7 +1797,7 @@ type DomainInterface struct {
func (d *Domain) ListAllInterfaceAddresses(src uint) ([]DomainInterface, error) {
if C.LIBVIR_VERSION_NUMBER < 1002014 {
return []DomainInterface{}, GetNotImplementedError()
return []DomainInterface{}, GetNotImplementedError("virDomainInterfaceAddresses")
}
var cList *C.virDomainInterfacePtr
......@@ -1956,7 +1956,7 @@ func getBlockCopyParameterFieldInfo(params *DomainBlockCopyParameters) map[strin
func (d *Domain) BlockCopy(disk string, destxml string, params *DomainBlockCopyParameters, flags DomainBlockCopyFlags) error {
if C.LIBVIR_VERSION_NUMBER < 1002008 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainBlockCopy")
}
cdisk := C.CString(disk)
defer C.free(unsafe.Pointer(cdisk))
......@@ -2357,7 +2357,7 @@ func (d *Domain) MigrateSetMaxDowntime(downtime uint64, flags uint32) error {
func (d *Domain) MigrateStartPostCopy(flags uint32) error {
if C.LIBVIR_VERSION_NUMBER < 1003003 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainMigrateStartPostCopy")
}
ret := C.virDomainMigrateStartPostCopyCompat(d.ptr, C.uint(flags))
......@@ -3258,7 +3258,7 @@ func getDomainPerfEventsFieldInfo(params *DomainPerfEvents) map[string]typedPara
func (d *Domain) GetPerfEvents(flags DomainModificationImpact) (*DomainPerfEvents, error) {
if C.LIBVIR_VERSION_NUMBER < 1003003 {
return nil, GetNotImplementedError()
return nil, GetNotImplementedError("virDomainGetPerfEvents")
}
params := &DomainPerfEvents{}
......@@ -3283,7 +3283,7 @@ func (d *Domain) GetPerfEvents(flags DomainModificationImpact) (*DomainPerfEvent
func (d *Domain) SetPerfEvents(params *DomainPerfEvents, flags DomainModificationImpact) error {
if C.LIBVIR_VERSION_NUMBER < 1003003 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainSetPerfEvents")
}
info := getDomainPerfEventsFieldInfo(params)
......@@ -3568,7 +3568,7 @@ func (d *Domain) GetSecurityLabelList() ([]SecurityLabel, error) {
func (d *Domain) GetTime(flags uint32) (int64, uint, error) {
if C.LIBVIR_VERSION_NUMBER < 1002005 {
return 0, 0, GetNotImplementedError()
return 0, 0, GetNotImplementedError("virDomainGetTime")
}
var secs C.longlong
var nsecs C.uint
......@@ -3582,7 +3582,7 @@ func (d *Domain) GetTime(flags uint32) (int64, uint, error) {
func (d *Domain) SetTime(secs int64, nsecs uint, flags DomainSetTimeFlags) error {
if C.LIBVIR_VERSION_NUMBER < 1002005 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainSetTime")
}
ret := C.virDomainSetTimeCompat(d.ptr, C.longlong(secs), C.uint(nsecs), C.uint(flags))
......@@ -3595,7 +3595,7 @@ func (d *Domain) SetTime(secs int64, nsecs uint, flags DomainSetTimeFlags) error
func (d *Domain) SetUserPassword(user string, password string, flags DomainSetUserPasswordFlags) error {
if C.LIBVIR_VERSION_NUMBER < 1002015 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainSetUserPassword")
}
cuser := C.CString(user)
cpassword := C.CString(password)
......@@ -3642,7 +3642,7 @@ func (d *Domain) ManagedSaveRemove(flags uint32) error {
func (d *Domain) Rename(name string, flags uint32) error {
if C.LIBVIR_VERSION_NUMBER < 1002019 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainRename")
}
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
......@@ -3695,7 +3695,7 @@ func (d *Domain) CoreDump(to string, flags DomainCoreDumpFlags) error {
func (d *Domain) CoreDumpWithFormat(to string, format DomainCoreDumpFormat, flags DomainCoreDumpFlags) error {
if C.LIBVIR_VERSION_NUMBER < 1002003 {
GetNotImplementedError()
GetNotImplementedError("virDomainCoreDumpWithFormat")
}
cto := C.CString(to)
defer C.free(unsafe.Pointer(cto))
......@@ -3721,7 +3721,7 @@ func (d *Domain) HasCurrentSnapshot(flags uint32) (bool, error) {
func (d *Domain) FSFreeze(mounts []string, flags uint32) error {
if C.LIBVIR_VERSION_NUMBER < 1002005 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainFSFreeze")
}
cmounts := make([](*C.char), len(mounts))
......@@ -3741,7 +3741,7 @@ func (d *Domain) FSFreeze(mounts []string, flags uint32) error {
func (d *Domain) FSThaw(mounts []string, flags uint32) error {
if C.LIBVIR_VERSION_NUMBER < 1002005 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainFSThaw")
}
cmounts := make([](*C.char), len(mounts))
......@@ -3780,7 +3780,7 @@ type DomainFSInfo struct {
func (d *Domain) GetFSInfo(flags uint32) ([]DomainFSInfo, error) {
if C.LIBVIR_VERSION_NUMBER < 1002011 {
return []DomainFSInfo{}, GetNotImplementedError()
return []DomainFSInfo{}, GetNotImplementedError("virDomainGetFSInfo")
}
var cfsinfolist **C.virDomainFSInfo
......@@ -3833,7 +3833,7 @@ func (d *Domain) PMWakeup(flags uint32) error {
func (d *Domain) AddIOThread(id uint, flags DomainModificationImpact) error {
if C.LIBVIR_VERSION_NUMBER < 1002015 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainAddIOThread")
}
ret := C.virDomainAddIOThreadCompat(d.ptr, C.uint(id), C.uint(flags))
if ret == -1 {
......@@ -3845,7 +3845,7 @@ func (d *Domain) AddIOThread(id uint, flags DomainModificationImpact) error {
func (d *Domain) DelIOThread(id uint, flags DomainModificationImpact) error {
if C.LIBVIR_VERSION_NUMBER < 1002015 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainDelIOThread")
}
ret := C.virDomainDelIOThreadCompat(d.ptr, C.uint(id), C.uint(flags))
if ret == -1 {
......@@ -3887,7 +3887,7 @@ type DomainIOThreadInfo struct {
func (d *Domain) GetIOThreadInfo(flags DomainModificationImpact) ([]DomainIOThreadInfo, error) {
if C.LIBVIR_VERSION_NUMBER < 1002014 {
return []DomainIOThreadInfo{}, GetNotImplementedError()
return []DomainIOThreadInfo{}, GetNotImplementedError("virDomaingetIOThreadInfo")
}
var cinfolist **C.virDomainIOThreadInfo
......@@ -3985,7 +3985,7 @@ func (d *Domain) PinEmulator(cpumap []bool, flags DomainModificationImpact) erro
func (d *Domain) PinIOThread(iothreadid uint, cpumap []bool, flags DomainModificationImpact) error {
if C.LIBVIR_VERSION_NUMBER < 1002014 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainPinIOThread")
}
maplen := (len(cpumap) + 7) / 8
......@@ -4042,7 +4042,7 @@ func (d *Domain) OpenGraphics(idx uint, file os.File, flags DomainOpenGraphicsFl
func (d *Domain) OpenGraphicsFD(idx uint, flags DomainOpenGraphicsFlags) (*os.File, error) {
if C.LIBVIR_VERSION_NUMBER < 1002008 {
return nil, GetNotImplementedError()
return nil, GetNotImplementedError("virDomainOpenGraphicsFD")
}
ret := C.virDomainOpenGraphicsFDCompat(d.ptr, C.uint(idx), C.uint(flags))
if ret == -1 {
......@@ -4166,7 +4166,7 @@ func parseCPUString(cpumapstr string) ([]bool, error) {
func (d *Domain) GetGuestVcpus(flags uint32) (*DomainGuestVcpus, error) {
if C.LIBVIR_VERSION_NUMBER < 2000000 {
return nil, GetNotImplementedError()
return nil, GetNotImplementedError("virDomainGetGuestVcpus")
}
var VcpusSet, OnlineSet, OfflinableSet bool
......@@ -4192,7 +4192,7 @@ func (d *Domain) GetGuestVcpus(flags uint32) (*DomainGuestVcpus, error) {
func (d *Domain) SetGuestVcpus(cpus []bool, state bool, flags uint32) error {
if C.LIBVIR_VERSION_NUMBER < 2000000 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainSetGuestVcpus")
}
cpumap := ""
......@@ -4224,7 +4224,7 @@ func (d *Domain) SetGuestVcpus(cpus []bool, state bool, flags uint32) error {
func (d *Domain) SetVcpu(cpus []bool, state bool, flags uint32) error {
if C.LIBVIR_VERSION_NUMBER < 3001000 {
return GetNotImplementedError()
return GetNotImplementedError("virDomainSetVcpu")
}
cpumap := ""
......
......@@ -591,11 +591,11 @@ func GetLastError() Error {
return virErr
}
func GetNotImplementedError() Error {
func GetNotImplementedError(apiname string) Error {
return Error{
Code: ERR_NO_SUPPORT,
Domain: FROM_NONE,
Message: "Function not implemented in this libvirt build",
Message: fmt.Sprintf("Function '%s' not available in the libvirt library used during Go build", apiname),
Level: ERR_ERROR,
}
}
......@@ -272,7 +272,7 @@ func (n *Network) Update(cmd NetworkUpdateCommand, section NetworkUpdateSection,
func (n *Network) GetDHCPLeases() ([]NetworkDHCPLease, error) {
if C.LIBVIR_VERSION_NUMBER < 1002006 {
return []NetworkDHCPLease{}, GetNotImplementedError()
return []NetworkDHCPLease{}, GetNotImplementedError("virNetworkGetDHCPLeases")
}
var cLeases *C.virNetworkDHCPLeasePtr
numLeases := C.virNetworkGetDHCPLeasesCompat(n.ptr, nil, (**C.virNetworkDHCPLeasePtr)(&cLeases), C.uint(0))
......
......@@ -71,7 +71,7 @@ func networkEventLifecycleCallback(c C.virConnectPtr, n C.virNetworkPtr,
func (c *Connect) NetworkEventLifecycleRegister(net *Network, callback NetworkEventLifecycleCallback) (int, error) {
goCallBackId := registerCallbackId(callback)
if C.LIBVIR_VERSION_NUMBER < 1002001 {
return 0, GetNotImplementedError()
return 0, GetNotImplementedError("virConnectNetworkEventRegisterAny")
}
callbackPtr := unsafe.Pointer(C.networkEventLifecycleCallback_cgo)
......@@ -92,7 +92,7 @@ func (c *Connect) NetworkEventLifecycleRegister(net *Network, callback NetworkEv
func (c *Connect) NetworkEventDeregister(callbackId int) error {
if C.LIBVIR_VERSION_NUMBER < 1002001 {
return GetNotImplementedError()
return GetNotImplementedError("virConnectNetworkEventDeregisterAny")
}
// Deregister the callback
if i := int(C.virConnectNetworkEventDeregisterAnyCompat(c.ptr, C.int(callbackId))); i != 0 {
......
......@@ -87,7 +87,7 @@ func nodeDeviceEventGenericCallback(c C.virConnectPtr, d C.virNodeDevicePtr,
func (c *Connect) NodeDeviceEventLifecycleRegister(device *NodeDevice, callback NodeDeviceEventLifecycleCallback) (int, error) {
if C.LIBVIR_VERSION_NUMBER < 2002000 {
return 0, GetNotImplementedError()
return 0, GetNotImplementedError("virConnectNodeDeviceEventRegisterAny")
}
goCallBackId := registerCallbackId(callback)
......@@ -128,7 +128,7 @@ func (c *Connect) NodeDeviceEventUpdateRegister(device *NodeDevice, callback Nod
func (c *Connect) NodeDeviceEventDeregister(callbackId int) error {
if C.LIBVIR_VERSION_NUMBER < 2002000 {
return GetNotImplementedError()
return GetNotImplementedError("virConnectNodeDeviceEventDeregisterAny")
}
// Deregister the callback
if i := int(C.virConnectNodeDeviceEventDeregisterAnyCompat(c.ptr, C.int(callbackId))); i != 0 {
......
......@@ -88,7 +88,7 @@ func secretEventGenericCallback(c C.virConnectPtr, n C.virSecretPtr,
func (c *Connect) SecretEventLifecycleRegister(secret *Secret, callback SecretEventLifecycleCallback) (int, error) {
goCallBackId := registerCallbackId(callback)
if C.LIBVIR_VERSION_NUMBER < 3000000 {
return 0, GetNotImplementedError()
return 0, GetNotImplementedError("virConnectSecretEventRegisterAny")
}
callbackPtr := unsafe.Pointer(C.secretEventLifecycleCallback_cgo)
......@@ -110,7 +110,7 @@ func (c *Connect) SecretEventLifecycleRegister(secret *Secret, callback SecretEv
func (c *Connect) SecretEventValueChangedRegister(secret *Secret, callback SecretEventGenericCallback) (int, error) {
goCallBackId := registerCallbackId(callback)
if C.LIBVIR_VERSION_NUMBER < 3000000 {
return 0, GetNotImplementedError()
return 0, GetNotImplementedError("virConnectSecretEventRegisterAny")
}
callbackPtr := unsafe.Pointer(C.secretEventGenericCallback_cgo)
......@@ -131,7 +131,7 @@ func (c *Connect) SecretEventValueChangedRegister(secret *Secret, callback Secre
func (c *Connect) SecretEventDeregister(callbackId int) error {
if C.LIBVIR_VERSION_NUMBER < 3000000 {
return GetNotImplementedError()
return GetNotImplementedError("virConnectSecretEventDeregisterAny")
}
// Deregister the callback
if i := int(C.virConnectSecretEventDeregisterAnyCompat(c.ptr, C.int(callbackId))); i != 0 {
......
......@@ -87,7 +87,7 @@ func storagePoolEventGenericCallback(c C.virConnectPtr, s C.virStoragePoolPtr,
func (c *Connect) StoragePoolEventLifecycleRegister(pool *StoragePool, callback StoragePoolEventLifecycleCallback) (int, error) {
if C.LIBVIR_VERSION_NUMBER < 2000000 {
return 0, GetNotImplementedError()
return 0, GetNotImplementedError("virConnectStoragePoolEventRegisterAny")
}
goCallBackId := registerCallbackId(callback)
......@@ -110,7 +110,7 @@ func (c *Connect) StoragePoolEventLifecycleRegister(pool *StoragePool, callback
func (c *Connect) StoragePoolEventRefreshRegister(pool *StoragePool, callback StoragePoolEventGenericCallback) (int, error) {
if C.LIBVIR_VERSION_NUMBER < 2000000 {
return 0, GetNotImplementedError()
return 0, GetNotImplementedError("virConnectStoragePoolEventRegisterAny")
}
goCallBackId := registerCallbackId(callback)
......@@ -133,7 +133,7 @@ func (c *Connect) StoragePoolEventRefreshRegister(pool *StoragePool, callback St
func (c *Connect) StoragePoolEventDeregister(callbackId int) error {
if C.LIBVIR_VERSION_NUMBER < 2000000 {
return GetNotImplementedError()
return GetNotImplementedError("virConnectStoragePoolEventDeregisterAny")
}
// Deregister the callback
......
......@@ -150,7 +150,7 @@ func (v *StorageVol) GetInfo() (*StorageVolInfo, error) {
func (v *StorageVol) GetInfoFlags(flags StorageVolInfoFlags) (*StorageVolInfo, error) {
if C.LIBVIR_VERSION_NUMBER < 3000000 {
return nil, GetNotImplementedError()
return nil, GetNotImplementedError("virStorageVolGetInfoFlags")
}
var cinfo C.virStorageVolInfo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment