2008-11-04 23:33:57 +00:00
|
|
|
/*
|
|
|
|
* domain_event.h: domain event queue processing helpers
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 VirtualIron
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Author: Ben Guthro
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
#ifndef __DOMAIN_EVENT_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __DOMAIN_EVENT_H__
|
2008-11-04 23:33:57 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "domain_conf.h"
|
2008-12-04 21:09:20 +00:00
|
|
|
|
2008-11-04 23:33:57 +00:00
|
|
|
typedef struct _virDomainEventCallback virDomainEventCallback;
|
|
|
|
typedef virDomainEventCallback *virDomainEventCallbackPtr;
|
|
|
|
|
|
|
|
struct _virDomainEventCallbackList {
|
2010-03-18 14:06:09 +00:00
|
|
|
unsigned int nextID;
|
2008-11-04 23:33:57 +00:00
|
|
|
unsigned int count;
|
|
|
|
virDomainEventCallbackPtr *callbacks;
|
|
|
|
};
|
|
|
|
typedef struct _virDomainEventCallbackList virDomainEventCallbackList;
|
|
|
|
typedef virDomainEventCallbackList *virDomainEventCallbackListPtr;
|
|
|
|
|
|
|
|
void virDomainEventCallbackListFree(virDomainEventCallbackListPtr list);
|
|
|
|
|
|
|
|
int virDomainEventCallbackListAdd(virConnectPtr conn,
|
|
|
|
virDomainEventCallbackListPtr cbList,
|
|
|
|
virConnectDomainEventCallback callback,
|
2008-11-19 15:25:24 +00:00
|
|
|
void *opaque,
|
2010-02-10 13:19:17 +00:00
|
|
|
virFreeCallback freecb)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
2010-03-18 14:20:53 +00:00
|
|
|
int virDomainEventCallbackListAddID(virConnectPtr conn,
|
|
|
|
virDomainEventCallbackListPtr cbList,
|
|
|
|
virDomainPtr dom,
|
|
|
|
int eventID,
|
|
|
|
virConnectDomainEventGenericCallback cb,
|
|
|
|
void *opaque,
|
|
|
|
virFreeCallback freecb)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(5);
|
|
|
|
|
2008-11-04 23:33:57 +00:00
|
|
|
|
|
|
|
int virDomainEventCallbackListRemove(virConnectPtr conn,
|
|
|
|
virDomainEventCallbackListPtr cbList,
|
2010-02-10 13:19:17 +00:00
|
|
|
virConnectDomainEventCallback callback)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
2010-03-18 14:20:53 +00:00
|
|
|
int virDomainEventCallbackListRemoveID(virConnectPtr conn,
|
|
|
|
virDomainEventCallbackListPtr cbList,
|
|
|
|
int callbackID)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
2008-11-21 10:17:22 +00:00
|
|
|
int virDomainEventCallbackListRemoveConn(virConnectPtr conn,
|
2010-02-10 13:19:17 +00:00
|
|
|
virDomainEventCallbackListPtr cbList)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
2008-11-21 10:17:22 +00:00
|
|
|
|
2010-03-18 14:20:53 +00:00
|
|
|
|
2008-12-04 21:09:20 +00:00
|
|
|
int virDomainEventCallbackListMarkDelete(virConnectPtr conn,
|
|
|
|
virDomainEventCallbackListPtr cbList,
|
2010-02-10 13:19:17 +00:00
|
|
|
virConnectDomainEventCallback callback)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
2010-03-18 14:20:53 +00:00
|
|
|
int virDomainEventCallbackListMarkDeleteID(virConnectPtr conn,
|
|
|
|
virDomainEventCallbackListPtr cbList,
|
|
|
|
int callbackID)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
|
|
|
|
2010-02-10 13:19:17 +00:00
|
|
|
|
2008-12-04 21:09:20 +00:00
|
|
|
int virDomainEventCallbackListPurgeMarked(virDomainEventCallbackListPtr cbList);
|
|
|
|
|
2010-03-18 13:17:14 +00:00
|
|
|
int virDomainEventCallbackListCount(virDomainEventCallbackListPtr cbList);
|
2010-03-18 14:20:53 +00:00
|
|
|
int virDomainEventCallbackListCountID(virConnectPtr conn,
|
|
|
|
virDomainEventCallbackListPtr cbList,
|
|
|
|
int eventID)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
|
|
|
int virDomainEventCallbackListEventID(virConnectPtr conn,
|
|
|
|
virDomainEventCallbackListPtr cbList,
|
|
|
|
int callbackID)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
2010-03-18 13:17:14 +00:00
|
|
|
|
2008-11-04 23:33:57 +00:00
|
|
|
/**
|
|
|
|
* Dispatching domain events that come in while
|
|
|
|
* in a call / response rpc
|
|
|
|
*/
|
|
|
|
typedef struct _virDomainEvent virDomainEvent;
|
|
|
|
typedef virDomainEvent *virDomainEventPtr;
|
|
|
|
|
|
|
|
struct _virDomainEventQueue {
|
|
|
|
unsigned int count;
|
|
|
|
virDomainEventPtr *events;
|
|
|
|
};
|
|
|
|
typedef struct _virDomainEventQueue virDomainEventQueue;
|
|
|
|
typedef virDomainEventQueue *virDomainEventQueuePtr;
|
|
|
|
|
2008-12-04 21:09:20 +00:00
|
|
|
virDomainEventQueuePtr virDomainEventQueueNew(void);
|
|
|
|
|
|
|
|
virDomainEventPtr virDomainEventNew(int id, const char *name, const unsigned char *uuid, int type, int detail);
|
|
|
|
virDomainEventPtr virDomainEventNewFromDom(virDomainPtr dom, int type, int detail);
|
|
|
|
virDomainEventPtr virDomainEventNewFromObj(virDomainObjPtr obj, int type, int detail);
|
|
|
|
virDomainEventPtr virDomainEventNewFromDef(virDomainDefPtr def, int type, int detail);
|
|
|
|
|
2010-03-18 15:25:38 +00:00
|
|
|
virDomainEventPtr virDomainEventRebootNewFromDom(virDomainPtr dom);
|
|
|
|
virDomainEventPtr virDomainEventRebootNewFromObj(virDomainObjPtr obj);
|
|
|
|
|
2010-03-18 18:28:15 +00:00
|
|
|
virDomainEventPtr virDomainEventRTCChangeNewFromDom(virDomainPtr dom, long long offset);
|
|
|
|
virDomainEventPtr virDomainEventRTCChangeNewFromObj(virDomainObjPtr obj, long long offset);
|
|
|
|
|
Add support for an explicit watchdog event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_WATCHDOG
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_WATCHDOG_NONE = 0,
VIR_DOMAIN_EVENT_WATCHDOG_PAUSE,
VIR_DOMAIN_EVENT_WATCHDOG_RESET,
VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF,
VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN,
VIR_DOMAIN_EVENT_WATCHDOG_DEBUG,
} virDomainEventWatchdogAction;
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventWatchdogCallback)(virConnectPtr conn,
virDomainPtr dom,
int action,
void *opaque);
* daemon/remote.c: Dispatch watchdog events to client
* examples/domain-events/events-c/event-test.c: Watch for
watchdog events
* include/libvirt/libvirt.h.in: Define new watchdg event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle watchdog events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for watchdogs and emit a libvirt watchdog event
* src/remote/remote_driver.c: Receive and dispatch watchdog
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
watchdog events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for WATCHDOG event
from QEMU monitor
2010-03-18 19:07:48 +00:00
|
|
|
virDomainEventPtr virDomainEventWatchdogNewFromDom(virDomainPtr dom, int action);
|
|
|
|
virDomainEventPtr virDomainEventWatchdogNewFromObj(virDomainObjPtr obj, int action);
|
|
|
|
|
Add support for an explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR
This event includes the action that is about to be taken
as a result of the watchdog triggering
typedef enum {
VIR_DOMAIN_EVENT_IO_ERROR_NONE = 0,
VIR_DOMAIN_EVENT_IO_ERROR_PAUSE,
VIR_DOMAIN_EVENT_IO_ERROR_REPORT,
} virDomainEventIOErrorAction;
In addition it has the source path of the disk that had the
error and its unique device alias. It does not include the
target device name (/dev/sda), since this would preclude
triggering IO errors from other file backed devices (eg
serial ports connected to a file)
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
virDomainEventPtr virDomainEventIOErrorNewFromDom(virDomainPtr dom,
|
|
|
|
const char *srcPath,
|
|
|
|
const char *devAlias,
|
|
|
|
int action);
|
|
|
|
virDomainEventPtr virDomainEventIOErrorNewFromObj(virDomainObjPtr obj,
|
|
|
|
const char *srcPath,
|
|
|
|
const char *devAlias,
|
|
|
|
int action);
|
|
|
|
|
2008-12-04 21:09:20 +00:00
|
|
|
int virDomainEventQueuePush(virDomainEventQueuePtr evtQueue,
|
|
|
|
virDomainEventPtr event);
|
2008-11-04 23:33:57 +00:00
|
|
|
|
|
|
|
virDomainEventPtr
|
2008-12-04 21:09:20 +00:00
|
|
|
virDomainEventQueuePop(virDomainEventQueuePtr evtQueue);
|
2008-11-04 23:33:57 +00:00
|
|
|
|
2008-12-04 21:09:20 +00:00
|
|
|
void virDomainEventFree(virDomainEventPtr event);
|
2008-11-04 23:33:57 +00:00
|
|
|
void virDomainEventQueueFree(virDomainEventQueuePtr queue);
|
|
|
|
|
2008-12-04 21:09:20 +00:00
|
|
|
typedef void (*virDomainEventDispatchFunc)(virConnectPtr conn,
|
|
|
|
virDomainEventPtr event,
|
2010-03-18 14:06:09 +00:00
|
|
|
virConnectDomainEventGenericCallback cb,
|
2008-12-04 21:09:20 +00:00
|
|
|
void *cbopaque,
|
|
|
|
void *opaque);
|
|
|
|
void virDomainEventDispatchDefaultFunc(virConnectPtr conn,
|
|
|
|
virDomainEventPtr event,
|
2010-03-18 14:06:09 +00:00
|
|
|
virConnectDomainEventGenericCallback cb,
|
2008-12-04 21:09:20 +00:00
|
|
|
void *cbopaque,
|
|
|
|
void *opaque);
|
|
|
|
|
|
|
|
void virDomainEventDispatch(virDomainEventPtr event,
|
|
|
|
virDomainEventCallbackListPtr cbs,
|
|
|
|
virDomainEventDispatchFunc dispatch,
|
|
|
|
void *opaque);
|
|
|
|
void virDomainEventQueueDispatch(virDomainEventQueuePtr queue,
|
|
|
|
virDomainEventCallbackListPtr cbs,
|
|
|
|
virDomainEventDispatchFunc dispatch,
|
|
|
|
void *opaque);
|
2008-11-04 23:33:57 +00:00
|
|
|
|
|
|
|
#endif
|