Commit 7f315eea authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add compat for 1.2.7 release

Signed-off-by: default avatarDaniel P. Berrange <[email protected]>
parent 2fdcd9cb
......@@ -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.8 onwards, through conditional compilation of newer APIs.
from 1.2.7 onwards, through conditional compilation of newer APIs.
## Documentation
......
......@@ -2278,6 +2278,9 @@ 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()
}
var ret C.int
var cstats *C.virDomainStatsRecordPtr
if len(doms) > 0 {
......@@ -2286,15 +2289,15 @@ func (c *Connect) GetAllDomainStats(doms []*Domain, statsTypes DomainStatsTypes,
cdoms[i] = doms[i].ptr
}
ret = C.virDomainListGetStats(&cdoms[0], C.uint(statsTypes), &cstats, C.uint(flags))
ret = C.virDomainListGetStatsCompat(&cdoms[0], C.uint(statsTypes), &cstats, C.uint(flags))
} else {
ret = C.virConnectGetAllDomainStats(c.ptr, C.uint(statsTypes), &cstats, C.uint(flags))
ret = C.virConnectGetAllDomainStatsCompat(c.ptr, C.uint(statsTypes), &cstats, C.uint(flags))
}
if ret == -1 {
return []DomainStats{}, GetLastError()
}
defer C.virDomainStatsRecordListFree(cstats)
defer C.virDomainStatsRecordListFreeCompat(cstats)
stats := make([]DomainStats, ret)
for i := 0; i < int(ret); i++ {
......
......@@ -6,6 +6,34 @@ package libvirt
#include <assert.h>
#include "connect_compat.h"
int virConnectGetAllDomainStatsCompat(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 virDomainListGetStatsCompat(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 virDomainStatsRecordListFreeCompat(virDomainStatsRecordPtr *stats)
{
}
int virNodeAllocPagesCompat(virConnectPtr conn,
unsigned int npages,
unsigned int *pageSizes,
......
#ifndef LIBVIRT_GO_CONNECT_COMPAT_H_
#define LIBVIRT_GO_CONNECT_COMPAT_H_
/* 1.2.9 */
/* 1.2.8 */
#ifndef VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE 1 << 0
#endif
#ifndef VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_INACTIVE 1 << 1
#endif
#ifndef VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_PERSISTENT 1 << 2
#endif
#ifndef VIR_CONNECT_GET_ALL_DOMAINS_STATS_TRANSIENT
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_TRANSIENT 1 << 3
#endif
#ifndef VIR_CONNECT_GET_ALL_DOMAINS_STATS_RUNNING
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_RUNNING 1 << 4
#endif
#ifndef VIR_CONNECT_GET_ALL_DOMAINS_STATS_PAUSED
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_PAUSED 1 << 5
#endif
#ifndef VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF 1 << 6
#endif
#ifndef VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER 1 << 7
#endif
#ifndef VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS
#define VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS 1U << 31
#endif
#ifndef VIR_CONNECT_LIST_STORAGE_POOLS_ZFS
#define VIR_CONNECT_LIST_STORAGE_POOLS_ZFS 1 << 17
#endif
#if LIBVIR_VERSION_NUMBER < 1002008
typedef struct _virDomainStatsRecord virDomainStatsRecord;
typedef virDomainStatsRecord *virDomainStatsRecordPtr;
struct _virDomainStatsRecord {
virDomainPtr dom;
virTypedParameterPtr params;
int nparams;
};
#endif
int virConnectGetAllDomainStatsCompat(virConnectPtr conn,
unsigned int stats,
virDomainStatsRecordPtr **retStats,
unsigned int flags);
int virDomainListGetStatsCompat(virDomainPtr *doms,
unsigned int stats,
virDomainStatsRecordPtr **retStats,
unsigned int flags);
void virDomainStatsRecordListFreeCompat(virDomainStatsRecordPtr *stats);
/* 1.2.9 */
#ifndef VIR_NODE_ALLOC_PAGES_ADD
#define VIR_NODE_ALLOC_PAGES_ADD 0
#endif
......
......@@ -1910,6 +1910,9 @@ 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()
}
cdisk := C.CString(disk)
defer C.free(cdisk)
cdestxml := C.CString(destxml)
......@@ -1925,7 +1928,7 @@ func (d *Domain) BlockCopy(disk string, destxml string, params *DomainBlockCopyP
defer C.virTypedParamsClear((*C.virTypedParameter)(unsafe.Pointer(&(*cparams)[0])), C.int(nparams))
ret := C.virDomainBlockCopy(d.ptr, cdisk, cdestxml, (*C.virTypedParameter)(unsafe.Pointer(&(*cparams)[0])), C.int(nparams), C.uint(flags))
ret := C.virDomainBlockCopyCompat(d.ptr, cdisk, cdestxml, (*C.virTypedParameter)(unsafe.Pointer(&(*cparams)[0])), C.int(nparams), C.uint(flags))
if ret == -1 {
return GetLastError()
}
......@@ -3930,7 +3933,10 @@ func (d *Domain) OpenGraphics(idx uint, file os.File, flags DomainOpenGraphicsFl
}
func (d *Domain) OpenGraphicsFD(idx uint, flags DomainOpenGraphicsFlags) (*os.File, error) {
ret := C.virDomainOpenGraphicsFD(d.ptr, C.uint(idx), C.uint(flags))
if C.LIBVIR_VERSION_NUMBER < 1002008 {
return nil, GetNotImplementedError()
}
ret := C.virDomainOpenGraphicsFDCompat(d.ptr, C.uint(idx), C.uint(flags))
if ret == -1 {
return nil, GetLastError()
}
......
......@@ -6,6 +6,30 @@ package libvirt
#include <assert.h>
#include "domain_compat.h"
int virDomainBlockCopyCompat(virDomainPtr dom, const char *disk,
const char *destxml,
virTypedParameterPtr params,
int nparams,
unsigned int flags)
{
#if LIBVIR_VERSION_NUMBER < 1002008
assert(0); // Caller should have checked version
#else
return virDomainBlockCopy(dom, disk, destxml, params, nparams, flags);
#endif
}
int virDomainOpenGraphicsFDCompat(virDomainPtr dom,
unsigned int idx,
unsigned int flags)
{
#if LIBVIR_VERSION_NUMBER < 1002008
assert(0); // Caller should have checked version
#else
return virDomainOpenGraphicsFD(dom, idx, flags);
#endif
}
void virDomainFSInfoFreeCompat(virDomainFSInfoPtr info)
{
}
......
#ifndef LIBVIRT_GO_DOMAIN_COMPAT_H__
#define LIBVIRT_GO_ERROR_COMPAT_H__
/* 1.2.8 */
#ifndef VIR_DOMAIN_BLOCK_COPY_SHALLOW
#define VIR_DOMAIN_BLOCK_COPY_SHALLOW 1 << 0
#endif
#ifndef VIR_DOMAIN_BLOCK_COPY_REUSE_EXT
#define VIR_DOMAIN_BLOCK_COPY_REUSE_EXT 1 << 1
#endif
#ifndef VIR_DOMAIN_BLOCK_COPY_BANDWIDTH
#define VIR_DOMAIN_BLOCK_COPY_BANDWIDTH "bandwidth"
#endif
#ifndef VIR_DOMAIN_BLOCK_COPY_GRANULARITY
#define VIR_DOMAIN_BLOCK_COPY_GRANULARITY "granularity"
#endif
#ifndef VIR_DOMAIN_BLOCK_COPY_BUF_SIZE
#define VIR_DOMAIN_BLOCK_COPY_BUF_SIZE "buf-size"
#endif
#ifndef VIR_DOMAIN_STATS_STATE
#define VIR_DOMAIN_STATS_STATE 1 << 0
#endif
int virDomainBlockCopyCompat(virDomainPtr dom, const char *disk,
const char *destxml,
virTypedParameterPtr params,
int nparams,
unsigned int flags);
int virDomainOpenGraphicsFDCompat(virDomainPtr dom,
unsigned int idx,
unsigned int flags);
/* 1.2.9 */
#ifndef VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES
......
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