Commit 16be403b authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add compat for 1.2.0 release

Signed-off-by: default avatarDaniel P. Berrange <[email protected]>
parent d75a56fc
......@@ -7,7 +7,7 @@ Make sure to have `libvirt-dev` package (or the development files otherwise some
## Version Support
The libvirt go package provides API coverage for libvirt versions
from 1.2.1 onwards, through conditional compilation of newer APIs.
from 1.2.0 onwards, through conditional compilation of newer APIs.
## Documentation
......
#ifndef LIBVIRT_GO_CONNECT_COMPAT_H_
#define LIBVIRT_GO_CONNECT_COMPAT_H_
/* 1.2.1 */
#ifndef VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER
#define VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER 1 << 16
#endif
/* 1.2.2 */
#ifndef VIR_NODE_CPU_STATS_INTR
......
......@@ -6,6 +6,16 @@ package libvirt
#include <assert.h>
#include "network_compat.h"
int virConnectNetworkEventDeregisterAnyCompat(virConnectPtr conn,
int callbackID)
{
#if LIBVIR_VERSION_NUMBER < 1002001
assert(0); // Caller should have checked version
#else
return virConnectNetworkEventDeregisterAny(conn, callbackID);
#endif
}
void virNetworkDHCPLeaseFreeCompat(virNetworkDHCPLeasePtr lease)
{
}
......
#ifndef LIBVIRT_GO_NETWORK_COMPAT_H__
#define LIBVIRT_GO_NETWORK_COMPAT_H__
/* 1.2.1 */
#ifndef VIR_NETWORK_EVENT_DEFINED
#define VIR_NETWORK_EVENT_DEFINED 0
#endif
#ifndef VIR_NETWORK_EVENT_UNDEFINED
#define VIR_NETWORK_EVENT_UNDEFINED 1
#endif
#ifndef VIR_NETWORK_EVENT_STARTED
#define VIR_NETWORK_EVENT_STARTED 2
#endif
#ifndef VIR_NETWORK_EVENT_STOPPED
#define VIR_NETWORK_EVENT_STOPPED 3
#endif
#ifndef VIR_NETWORK_EVENT_ID_LIFECYCLE
#define VIR_NETWORK_EVENT_ID_LIFECYCLE 0
#endif
#if LIBVIR_VERSION_NUMBER < 1002001
typedef void (*virConnectNetworkEventGenericCallback)(virConnectPtr conn,
virNetworkPtr net,
void *opaque);
#endif
int virConnectNetworkEventDeregisterAnyCompat(virConnectPtr conn,
int callbackID);
/* 1.2.5 */
......
......@@ -8,6 +8,7 @@ import (
/*
#cgo pkg-config: libvirt
#include <libvirt/libvirt.h>
#include "network_compat.h"
#include "network_events_cfuncs.h"
*/
import "C"
......@@ -43,6 +44,9 @@ 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()
}
callbackPtr := unsafe.Pointer(C.networkEventLifecycleCallback_cgo)
var cnet C.virNetworkPtr
......@@ -61,8 +65,11 @@ func (c *Connect) NetworkEventLifecycleRegister(net *Network, callback NetworkEv
}
func (c *Connect) NetworkEventDeregister(callbackId int) error {
if C.LIBVIR_VERSION_NUMBER < 1002001 {
return GetNotImplementedError()
}
// Deregister the callback
if i := int(C.virConnectNetworkEventDeregisterAny(c.ptr, C.int(callbackId))); i != 0 {
if i := int(C.virConnectNetworkEventDeregisterAnyCompat(c.ptr, C.int(callbackId))); i != 0 {
return GetLastError()
}
return nil
......
......@@ -4,6 +4,8 @@ package libvirt
#cgo pkg-config: libvirt
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
#include <assert.h>
#include "network_compat.h"
#include "network_events_cfuncs.h"
#include "callbacks_cfuncs.h"
#include <stdint.h>
......@@ -19,7 +21,11 @@ int virConnectNetworkEventRegisterAny_cgo(virConnectPtr c, virNetworkPtr d,
int eventID, virConnectNetworkEventGenericCallback cb,
long goCallbackId) {
void* id = (void*)goCallbackId;
#if LIBVIR_VERSION_NUMBER < 1002001
assert(0); // Caller should have checked version
#else
return virConnectNetworkEventRegisterAny(c, d, eventID, cb, id, freeGoCallback_cgo);
#endif
}
*/
......
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