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

Fix back compat for monitor events API

Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
parent 832269e8
......@@ -152,6 +152,10 @@ func domainQemuMonitorEventCallback(c C.virConnectPtr, d C.virDomainPtr,
}
func (c *Connect) DomainQemuMonitorEventRegister(dom *Domain, event string, callback DomainQemuMonitorEventCallback, flags DomainQemuMonitorEventFlags) (int, error) {
if C.LIBVIR_VERSION_NUMBER < 1002003 {
return 0, GetNotImplementedError("virConnectDomainQemuMonitorEventRegister")
}
cEvent := C.CString(event)
defer C.free(unsafe.Pointer(cEvent))
goCallBackId := registerCallbackId(callback)
......@@ -174,8 +178,12 @@ func (c *Connect) DomainQemuMonitorEventRegister(dom *Domain, event string, call
}
func (c *Connect) DomainQemuEventDeregister(callbackId int) error {
if C.LIBVIR_VERSION_NUMBER < 1002003 {
return GetNotImplementedError("virConnectDomainQemuMonitorEventDeregister")
}
// Deregister the callback
if i := int(C.virConnectDomainQemuMonitorEventDeregister(c.ptr, C.int(callbackId))); i != 0 {
if i := int(C.virConnectDomainQemuMonitorEventDeregisterCompat(c.ptr, C.int(callbackId))); i != 0 {
return GetLastError()
}
return nil
......
......@@ -36,6 +36,7 @@ package libvirt
#include <libvirt/virterror.h>
#include "qemu_cfuncs.h"
#include "callbacks_cfuncs.h"
#include <assert.h>
#include <stdint.h>
......@@ -50,8 +51,12 @@ void domainQemuMonitorEventCallback_cgo(virConnectPtr c, virDomainPtr d,
int virConnectDomainQemuMonitorEventRegister_cgo(virConnectPtr c, virDomainPtr d,
const char *event, virConnectDomainQemuMonitorEventCallback cb,
long goCallbackId, unsigned int flags) {
#if LIBVIR_VERSION_NUMBER < 1002003
assert(0); // Caller should have checked version
#else
void* id = (void*)goCallbackId;
return virConnectDomainQemuMonitorEventRegister(c, d, event, cb, id, freeGoCallback_cgo, flags);
#endif
}
*/
......
/*
* 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 <libvirt/libvirt-qemu.h>
#include <assert.h>
#include "qemu_compat.h"
int virConnectDomainQemuMonitorEventDeregisterCompat(virConnectPtr conn,
int callbackID)
{
#if LIBVIR_VERSION_NUMBER < 1002003
assert(0); // Caller should have checked version
#else
return virConnectDomainQemuMonitorEventDeregister(conn, callbackID);
#endif
}
*/
import "C"
......@@ -27,6 +27,22 @@
#ifndef LIBVIRT_GO_QEMU_COMPAT_H__
#define LIBVIRT_GO_QEMU_COMPAT_H__
/* 1.2.3 */
#if LIBVIR_VERSION_NUMBER < 1002003
typedef void (*virConnectDomainQemuMonitorEventCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *event,
long long seconds,
unsigned int micros,
const char *details,
void *opaque);
#endif
int virConnectDomainQemuMonitorEventDeregisterCompat(virConnectPtr conn,
int callbackID);
/* 1.2.15 */
#ifndef VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN
......
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