Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
connect_compat.go | 206 ---------------------------------------------
connect_compat.h | 81 ------------------
connect_wrapper.go | 172 +++++++++++++++++++++++++++++++++++++
connect_wrapper.h | 75 +++++++++++++++++
4 files changed, 247 insertions(+), 287 deletions(-)
delete mode 100644 connect_compat.go
diff --git a/connect_compat.go b/connect_compat.go
deleted file mode 100644
index 1ecbef2..0000000
--- a/connect_compat.go
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * This file is part of the libvirt-go project
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * Copyright (c) 2013 Alex Zorin
- * Copyright (C) 2016 Red Hat, Inc.
- *
- */
-
-package libvirt
-
-/*
-#cgo pkg-config: libvirt
-#include <libvirt/libvirt.h>
-#include <assert.h>
-#include "connect_compat.h"
-
-int virNodeGetFreePagesWrapper(virConnectPtr conn,
- unsigned int npages,
- unsigned int *pages,
- int startcell,
- unsigned int cellcount,
- unsigned long long *counts,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 1002006
- assert(0); // Caller should have checked version
-#else
- return virNodeGetFreePages(conn, npages, pages, startcell, cellcount, counts,
flags);
-#endif
-}
-
-char * virConnectGetDomainCapabilitiesWrapper(virConnectPtr conn,
- const char *emulatorbin,
- const char *arch,
- const char *machine,
- const char *virttype,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 1002007
- assert(0); // Caller should have checked version
-#else
- return virConnectGetDomainCapabilities(conn, emulatorbin, arch, machine, virttype,
flags);
-#endif
-}
-
-int virConnectGetAllDomainStatsWrapper(virConnectPtr conn,
- unsigned int stats,
- virDomainStatsRecordPtr **retStats,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 1002008
- assert(0); // Caller should have checked version
-#else
- return virConnectGetAllDomainStats(conn, stats, retStats, flags);
-#endif
-}
-
-int virDomainListGetStatsWrapper(virDomainPtr *doms,
- unsigned int stats,
- virDomainStatsRecordPtr **retStats,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 1002008
- assert(0); // Caller should have checked version
-#else
- return virDomainListGetStats(doms, stats, retStats, flags);
-#endif
-}
-
-void virDomainStatsRecordListFreeWrapper(virDomainStatsRecordPtr *stats)
-{
-}
-
-int virNodeAllocPagesWrapper(virConnectPtr conn,
- unsigned int npages,
- unsigned int *pageSizes,
- unsigned long long *pageCounts,
- int startCell,
- unsigned int cellCount,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 1002009
- assert(0); // Caller should have checked version
-#else
- return virNodeAllocPages(conn, npages, pageSizes, pageCounts, startCell, cellCount,
flags);
-#endif
-}
-
-
-virDomainPtr virDomainDefineXMLFlagsWrapper(virConnectPtr conn,
- const char *xml,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 1002012
- assert(0); // Caller should have checked version
-#else
- return virDomainDefineXMLFlags(conn, xml, flags);
-#endif
-}
-
-virStoragePoolPtr virStoragePoolLookupByTargetPathWrapper(virConnectPtr conn,
- const char *path)
-{
-#if LIBVIR_VERSION_NUMBER < 4001000
- assert(0); // Caller should have checked version
-#else
- return virStoragePoolLookupByTargetPath(conn, path);
-#endif
-}
-
-char *virConnectBaselineHypervisorCPUWrapper(virConnectPtr conn,
- const char *emulator,
- const char *arch,
- const char *machine,
- const char *virttype,
- const char **xmlCPUs,
- unsigned int ncpus,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 4004000
- assert(0); // Caller should have checked version
-#else
- return virConnectBaselineHypervisorCPU(conn, emulator, arch, machine, virttype,
xmlCPUs, ncpus, flags);
-#endif
-}
-
-int virConnectCompareHypervisorCPUWrapper(virConnectPtr conn,
- const char *emulator,
- const char *arch,
- const char *machine,
- const char *virttype,
- const char *xmlCPU,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 4004000
- assert(0); // Caller should have checked version
-#else
- return virConnectCompareHypervisorCPU(conn, emulator, arch, machine, virttype,
xmlCPU, flags);
-#endif
-}
-
-int virNodeGetSEVInfoWrapper(virConnectPtr conn,
- virTypedParameterPtr *params,
- int *nparams,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 4005000
- assert(0); // Caller should have checked version
-#else
- return virNodeGetSEVInfo(conn, params, nparams, flags);
-#endif
-}
-
-int virConnectListAllNWFilterBindingsWrapper(virConnectPtr conn,
- virNWFilterBindingPtr **bindings,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 4005000
- assert(0); // Caller should have checked version
-#else
- return virConnectListAllNWFilterBindings(conn, bindings, flags);
-#endif
-}
-
-virNWFilterBindingPtr virNWFilterBindingCreateXMLWrapper(virConnectPtr conn,
- const char *xml,
- unsigned int flags)
-{
-#if LIBVIR_VERSION_NUMBER < 4005000
- assert(0); // Caller should have checked version
-#else
- return virNWFilterBindingCreateXML(conn, xml, flags);
-#endif
-}
-
-virNWFilterBindingPtr virNWFilterBindingLookupByPortDevWrapper(virConnectPtr conn,
- const char *portdev)
-{
-#if LIBVIR_VERSION_NUMBER < 4005000
- assert(0); // Caller should have checked version
-#else
- return virNWFilterBindingLookupByPortDev(conn, portdev);
-#endif
-}
-
-
-*/
-import "C"
diff --git a/connect_compat.h b/connect_compat.h
index 09cbe22..924b07d 100644
--- a/connect_compat.h
+++ b/connect_compat.h
@@ -47,24 +47,6 @@
#define VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE 1 << 0
#endif
-int virNodeGetFreePagesWrapper(virConnectPtr conn,
- unsigned int npages,
- unsigned int *pages,
- int startcell,
- unsigned int cellcount,
- unsigned long long *counts,
- unsigned int flags);
-
-
-/* 1.2.7 */
-
-char * virConnectGetDomainCapabilitiesWrapper(virConnectPtr conn,
- const char *emulatorbin,
- const char *arch,
- const char *machine,
- const char *virttype,
- unsigned int flags);
-
/* 1.2.8 */
@@ -118,18 +100,6 @@ struct _virDomainStatsRecord {
};
#endif
-int virConnectGetAllDomainStatsWrapper(virConnectPtr conn,
- unsigned int stats,
- virDomainStatsRecordPtr **retStats,
- unsigned int flags);
-
-int virDomainListGetStatsWrapper(virDomainPtr *doms,
- unsigned int stats,
- virDomainStatsRecordPtr **retStats,
- unsigned int flags);
-
-void virDomainStatsRecordListFreeWrapper(virDomainStatsRecordPtr *stats);
-
/* 1.2.9 */
#ifndef VIR_NODE_ALLOC_PAGES_ADD
@@ -140,14 +110,6 @@ void virDomainStatsRecordListFreeWrapper(virDomainStatsRecordPtr
*stats);
#define VIR_NODE_ALLOC_PAGES_SET 1 << 0
#endif
-int virNodeAllocPagesWrapper(virConnectPtr conn,
- unsigned int npages,
- unsigned int *pageSizes,
- unsigned long long *pageCounts,
- int startCell,
- unsigned int cellCount,
- unsigned int flags);
-
/* 1.2.11 */
@@ -178,10 +140,6 @@ int virNodeAllocPagesWrapper(virConnectPtr conn,
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING 1 << 30
#endif
-virDomainPtr virDomainDefineXMLFlagsWrapper(virConnectPtr conn,
- const char *xml,
- unsigned int flags);
-
/* 1.2.14 */
#ifndef VIR_CONNECT_BASELINE_CPU_MIGRATABLE
@@ -212,37 +170,9 @@ virDomainPtr virDomainDefineXMLFlagsWrapper(virConnectPtr conn,
#define VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV 1 << 15
#endif
-/* 4.1.0 */
-
-virStoragePoolPtr virStoragePoolLookupByTargetPathWrapper(virConnectPtr conn,
- const char *path);
-
-/* 4.4.0 */
-
-char *virConnectBaselineHypervisorCPUWrapper(virConnectPtr conn,
- const char *emulator,
- const char *arch,
- const char *machine,
- const char *virttype,
- const char **xmlCPUs,
- unsigned int ncpus,
- unsigned int flags);
-
-int virConnectCompareHypervisorCPUWrapper(virConnectPtr conn,
- const char *emulator,
- const char *arch,
- const char *machine,
- const char *virttype,
- const char *xmlCPU,
- unsigned int flags);
/* 4.5.0 */
-int virNodeGetSEVInfoWrapper(virConnectPtr conn,
- virTypedParameterPtr *params,
- int *nparams,
- unsigned int flags);
-
#ifndef VIR_NODE_SEV_CBITPOS
#define VIR_NODE_SEV_CBITPOS "cbitpos"
#endif
@@ -263,17 +193,6 @@ int virNodeGetSEVInfoWrapper(virConnectPtr conn,
typedef struct _virNWFilterBinding *virNWFilterBindingPtr;
#endif
-int virConnectListAllNWFilterBindingsWrapper(virConnectPtr conn,
- virNWFilterBindingPtr **bindings,
- unsigned int flags);
-
-virNWFilterBindingPtr virNWFilterBindingCreateXMLWrapper(virConnectPtr conn,
- const char *xml,
- unsigned int flags);
-
-virNWFilterBindingPtr virNWFilterBindingLookupByPortDevWrapper(virConnectPtr conn,
- const char *portdev);
-
#ifndef VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT 1 << 29
#endif
diff --git a/connect_wrapper.go b/connect_wrapper.go
index ec2da69..cbafc53 100644
--- a/connect_wrapper.go
+++ b/connect_wrapper.go
@@ -30,6 +30,7 @@ package libvirt
#cgo pkg-config: libvirt
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
+#include <assert.h>
#include "connect_wrapper.h"
#include "callbacks_wrapper.h"
@@ -67,5 +68,176 @@ virConnectPtr virConnectOpenAuthWrap(const char *name, int *credtype,
uint ncred
return virConnectOpenAuth(name, &auth, flags);
}
+
+int virNodeGetFreePagesWrapper(virConnectPtr conn,
+ unsigned int npages,
+ unsigned int *pages,
+ int startcell,
+ unsigned int cellcount,
+ unsigned long long *counts,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 1002006
+ assert(0); // Caller should have checked version
+#else
+ return virNodeGetFreePages(conn, npages, pages, startcell, cellcount, counts,
flags);
+#endif
+}
+
+char * virConnectGetDomainCapabilitiesWrapper(virConnectPtr conn,
+ const char *emulatorbin,
+ const char *arch,
+ const char *machine,
+ const char *virttype,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 1002007
+ assert(0); // Caller should have checked version
+#else
+ return virConnectGetDomainCapabilities(conn, emulatorbin, arch, machine, virttype,
flags);
+#endif
+}
+
+int virConnectGetAllDomainStatsWrapper(virConnectPtr conn,
+ unsigned int stats,
+ virDomainStatsRecordPtr **retStats,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 1002008
+ assert(0); // Caller should have checked version
+#else
+ return virConnectGetAllDomainStats(conn, stats, retStats, flags);
+#endif
+}
+
+int virDomainListGetStatsWrapper(virDomainPtr *doms,
+ unsigned int stats,
+ virDomainStatsRecordPtr **retStats,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 1002008
+ assert(0); // Caller should have checked version
+#else
+ return virDomainListGetStats(doms, stats, retStats, flags);
+#endif
+}
+
+void virDomainStatsRecordListFreeWrapper(virDomainStatsRecordPtr *stats)
+{
+}
+
+int virNodeAllocPagesWrapper(virConnectPtr conn,
+ unsigned int npages,
+ unsigned int *pageSizes,
+ unsigned long long *pageCounts,
+ int startCell,
+ unsigned int cellCount,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 1002009
+ assert(0); // Caller should have checked version
+#else
+ return virNodeAllocPages(conn, npages, pageSizes, pageCounts, startCell, cellCount,
flags);
+#endif
+}
+
+
+virDomainPtr virDomainDefineXMLFlagsWrapper(virConnectPtr conn,
+ const char *xml,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 1002012
+ assert(0); // Caller should have checked version
+#else
+ return virDomainDefineXMLFlags(conn, xml, flags);
+#endif
+}
+
+virStoragePoolPtr virStoragePoolLookupByTargetPathWrapper(virConnectPtr conn,
+ const char *path)
+{
+#if LIBVIR_VERSION_NUMBER < 4001000
+ assert(0); // Caller should have checked version
+#else
+ return virStoragePoolLookupByTargetPath(conn, path);
+#endif
+}
+
+char *virConnectBaselineHypervisorCPUWrapper(virConnectPtr conn,
+ const char *emulator,
+ const char *arch,
+ const char *machine,
+ const char *virttype,
+ const char **xmlCPUs,
+ unsigned int ncpus,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 4004000
+ assert(0); // Caller should have checked version
+#else
+ return virConnectBaselineHypervisorCPU(conn, emulator, arch, machine, virttype,
xmlCPUs, ncpus, flags);
+#endif
+}
+
+int virConnectCompareHypervisorCPUWrapper(virConnectPtr conn,
+ const char *emulator,
+ const char *arch,
+ const char *machine,
+ const char *virttype,
+ const char *xmlCPU,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 4004000
+ assert(0); // Caller should have checked version
+#else
+ return virConnectCompareHypervisorCPU(conn, emulator, arch, machine, virttype,
xmlCPU, flags);
+#endif
+}
+
+int virNodeGetSEVInfoWrapper(virConnectPtr conn,
+ virTypedParameterPtr *params,
+ int *nparams,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 4005000
+ assert(0); // Caller should have checked version
+#else
+ return virNodeGetSEVInfo(conn, params, nparams, flags);
+#endif
+}
+
+int virConnectListAllNWFilterBindingsWrapper(virConnectPtr conn,
+ virNWFilterBindingPtr **bindings,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 4005000
+ assert(0); // Caller should have checked version
+#else
+ return virConnectListAllNWFilterBindings(conn, bindings, flags);
+#endif
+}
+
+virNWFilterBindingPtr virNWFilterBindingCreateXMLWrapper(virConnectPtr conn,
+ const char *xml,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 4005000
+ assert(0); // Caller should have checked version
+#else
+ return virNWFilterBindingCreateXML(conn, xml, flags);
+#endif
+}
+
+virNWFilterBindingPtr virNWFilterBindingLookupByPortDevWrapper(virConnectPtr conn,
+ const char *portdev)
+{
+#if LIBVIR_VERSION_NUMBER < 4005000
+ assert(0); // Caller should have checked version
+#else
+ return virNWFilterBindingLookupByPortDev(conn, portdev);
+#endif
+}
+
+
*/
import "C"
diff --git a/connect_wrapper.h b/connect_wrapper.h
index 60374c7..7af88f1 100644
--- a/connect_wrapper.h
+++ b/connect_wrapper.h
@@ -31,4 +31,79 @@ int virConnectRegisterCloseCallbackHelper(virConnectPtr c,
virConnectCloseFunc c
virConnectPtr virConnectOpenAuthWrap(const char *name, int *credtype, uint ncredtype, int
callbackID, unsigned int flags);
+int virNodeGetFreePagesWrapper(virConnectPtr conn,
+ unsigned int npages,
+ unsigned int *pages,
+ int startcell,
+ unsigned int cellcount,
+ unsigned long long *counts,
+ unsigned int flags);
+
+char * virConnectGetDomainCapabilitiesWrapper(virConnectPtr conn,
+ const char *emulatorbin,
+ const char *arch,
+ const char *machine,
+ const char *virttype,
+ unsigned int flags);
+
+int virConnectGetAllDomainStatsWrapper(virConnectPtr conn,
+ unsigned int stats,
+ virDomainStatsRecordPtr **retStats,
+ unsigned int flags);
+
+int virDomainListGetStatsWrapper(virDomainPtr *doms,
+ unsigned int stats,
+ virDomainStatsRecordPtr **retStats,
+ unsigned int flags);
+
+void virDomainStatsRecordListFreeWrapper(virDomainStatsRecordPtr *stats);
+
+int virNodeAllocPagesWrapper(virConnectPtr conn,
+ unsigned int npages,
+ unsigned int *pageSizes,
+ unsigned long long *pageCounts,
+ int startCell,
+ unsigned int cellCount,
+ unsigned int flags);
+
+virDomainPtr virDomainDefineXMLFlagsWrapper(virConnectPtr conn,
+ const char *xml,
+ unsigned int flags);
+
+virStoragePoolPtr virStoragePoolLookupByTargetPathWrapper(virConnectPtr conn,
+ const char *path);
+
+char *virConnectBaselineHypervisorCPUWrapper(virConnectPtr conn,
+ const char *emulator,
+ const char *arch,
+ const char *machine,
+ const char *virttype,
+ const char **xmlCPUs,
+ unsigned int ncpus,
+ unsigned int flags);
+
+int virConnectCompareHypervisorCPUWrapper(virConnectPtr conn,
+ const char *emulator,
+ const char *arch,
+ const char *machine,
+ const char *virttype,
+ const char *xmlCPU,
+ unsigned int flags);
+
+int virNodeGetSEVInfoWrapper(virConnectPtr conn,
+ virTypedParameterPtr *params,
+ int *nparams,
+ unsigned int flags);
+
+int virConnectListAllNWFilterBindingsWrapper(virConnectPtr conn,
+ virNWFilterBindingPtr **bindings,
+ unsigned int flags);
+
+virNWFilterBindingPtr virNWFilterBindingCreateXMLWrapper(virConnectPtr conn,
+ const char *xml,
+ unsigned int flags);
+
+virNWFilterBindingPtr virNWFilterBindingLookupByPortDevWrapper(virConnectPtr conn,
+ const char *portdev);
+
#endif /* LIBVIRT_GO_CONNECT_WRAPPER_H__ */
--
2.17.1