Commit 9d5f61ec authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add compat for 1.2.4 release

Signed-off-by: default avatarDaniel P. Berrange <[email protected]>
parent b72bd8ef
......@@ -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.5 onwards, through conditional compilation of newer APIs.
from 1.2.4 onwards, through conditional compilation of newer APIs.
## Documentation
......
......@@ -3478,9 +3478,12 @@ 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()
}
var secs C.longlong
var nsecs C.uint
ret := C.virDomainGetTime(d.ptr, &secs, &nsecs, C.uint(flags))
ret := C.virDomainGetTimeCompat(d.ptr, &secs, &nsecs, C.uint(flags))
if ret == -1 {
return 0, 0, GetLastError()
}
......@@ -3489,8 +3492,11 @@ func (d *Domain) GetTime(flags uint32) (int64, uint, error) {
}
func (d *Domain) SetTime(secs int64, nsecs uint, flags uint32) error {
if C.LIBVIR_VERSION_NUMBER < 1002005 {
return GetNotImplementedError()
}
ret := C.virDomainSetTime(d.ptr, C.longlong(secs), C.uint(nsecs), C.uint(flags))
ret := C.virDomainSetTimeCompat(d.ptr, C.longlong(secs), C.uint(nsecs), C.uint(flags))
if ret == -1 {
return GetLastError()
}
......@@ -3622,6 +3628,9 @@ 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()
}
cmounts := make([](*C.char), len(mounts))
for i := 0; i < len(mounts); i++ {
......@@ -3630,7 +3639,7 @@ func (d *Domain) FSFreeze(mounts []string, flags uint32) error {
}
nmounts := len(mounts)
ret := C.virDomainFSFreeze(d.ptr, (**C.char)(unsafe.Pointer(&cmounts[0])), C.uint(nmounts), C.uint(flags))
ret := C.virDomainFSFreezeCompat(d.ptr, (**C.char)(unsafe.Pointer(&cmounts[0])), C.uint(nmounts), C.uint(flags))
if ret == -1 {
return GetLastError()
}
......@@ -3639,6 +3648,9 @@ 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()
}
cmounts := make([](*C.char), len(mounts))
for i := 0; i < len(mounts); i++ {
......@@ -3647,7 +3659,7 @@ func (d *Domain) FSThaw(mounts []string, flags uint32) error {
}
nmounts := len(mounts)
ret := C.virDomainFSThaw(d.ptr, (**C.char)(unsafe.Pointer(&cmounts[0])), C.uint(nmounts), C.uint(flags))
ret := C.virDomainFSThawCompat(d.ptr, (**C.char)(unsafe.Pointer(&cmounts[0])), C.uint(nmounts), C.uint(flags))
if ret == -1 {
return GetLastError()
}
......
......@@ -6,6 +6,54 @@ package libvirt
#include <assert.h>
#include "domain_compat.h"
int virDomainGetTimeCompat(virDomainPtr dom,
long long *seconds,
unsigned int *nseconds,
unsigned int flags)
{
#if LIBVIR_VERSION_NUMBER < 1002005
assert(0); // Caller should have checked version
#else
return virDomainGetTime(dom, seconds, nseconds, flags);
#endif
}
int virDomainSetTimeCompat(virDomainPtr dom,
long long seconds,
unsigned int nseconds,
unsigned int flags)
{
#if LIBVIR_VERSION_NUMBER < 1002005
assert(0); // Caller should have checked version
#else
return virDomainSetTime(dom, seconds, nseconds, flags);
#endif
}
int virDomainFSFreezeCompat(virDomainPtr dom,
const char **mountpoints,
unsigned int nmountpoints,
unsigned int flags)
{
#if LIBVIR_VERSION_NUMBER < 1002005
assert(0); // Caller should have checked version
#else
return virDomainFSFreeze(dom, mountpoints, nmountpoints, flags);
#endif
}
int virDomainFSThawCompat(virDomainPtr dom,
const char **mountpoints,
unsigned int nmountpoints,
unsigned int flags)
{
#if LIBVIR_VERSION_NUMBER < 1002005
assert(0); // Caller should have checked version
#else
return virDomainFSThaw(dom, mountpoints, nmountpoints, flags);
#endif
}
int virDomainBlockCopyCompat(virDomainPtr dom, const char *disk,
const char *destxml,
virTypedParameterPtr params,
......
#ifndef LIBVIRT_GO_DOMAIN_COMPAT_H__
#define LIBVIRT_GO_ERROR_COMPAT_H__
/* 1.2.5 */
#ifndef VIR_DOMAIN_REBOOT_PARAVIRT
#define VIR_DOMAIN_REBOOT_PARAVIRT 1 << 4
#endif
#ifndef VIR_DOMAIN_SHUTDOWN_PARAVIRT
#define VIR_DOMAIN_SHUTDOWN_PARAVIRT 1 << 4
#endif
#ifndef VIR_DOMAIN_TIME_SYNC
#define VIR_DOMAIN_TIME_SYNC 1 << 0
#endif
int virDomainGetTimeCompat(virDomainPtr dom,
long long *seconds,
unsigned int *nseconds,
unsigned int flags);
int virDomainSetTimeCompat(virDomainPtr dom,
long long seconds,
unsigned int nseconds,
unsigned int flags);
int virDomainFSFreezeCompat(virDomainPtr dom,
const char **mountpoints,
unsigned int nmountpoints,
unsigned int flags);
int virDomainFSThawCompat(virDomainPtr dom,
const char **mountpoints,
unsigned int nmountpoints,
unsigned int flags);
/* 1.2.6 */
#ifndef VIR_DOMAIN_BLOCK_COMMIT_ACTIVE
......
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