domain_event.h 10.5 KB
Newer Older
1 2 3
/*
 * domain_event.h: domain event queue processing helpers
 *
4
 * Copyright (C) 2012 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17
 * 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
18
 * License along with this library.  If not, see
O
Osier Yang 已提交
19
 * <http://www.gnu.org/licenses/>.
20 21 22 23 24 25 26
 *
 * Author: Ben Guthro
 */

#include "internal.h"

#ifndef __DOMAIN_EVENT_H__
27
# define __DOMAIN_EVENT_H__
28

29
# include "domain_conf.h"
30

31 32
typedef struct _virObjectEventCallback virObjectEventCallback;
typedef virObjectEventCallback *virObjectEventCallbackPtr;
33

34 35 36 37
/**
 * Dispatching domain events that come in while
 * in a call / response rpc
 */
C
Cédric Bosdonnat 已提交
38 39 40
typedef struct _virObjectEvent virObjectEvent;
typedef virObjectEvent *virObjectEventPtr;

41 42 43
typedef struct _virDomainEvent virDomainEvent;
typedef virDomainEvent *virDomainEventPtr;

44 45
typedef struct _virObjectEventState virObjectEventState;
typedef virObjectEventState *virObjectEventStatePtr;
46

47 48 49 50 51 52 53 54 55 56 57 58 59 60
virDomainEventPtr virDomainEventLifecycleNew(int id,
                                             const char *name,
                                             const unsigned char *uuid,
                                             int type,
                                             int detail);
virDomainEventPtr virDomainEventLifecycleNewFromDom(virDomainPtr dom,
                                                    int type,
                                                    int detail);
virDomainEventPtr virDomainEventLifecycleNewFromObj(virDomainObjPtr obj,
                                                    int type,
                                                    int detail);
virDomainEventPtr virDomainEventLifecycleNewFromDef(virDomainDefPtr def,
                                                    int type,
                                                    int detail);
61

M
Matthias Bolte 已提交
62
virDomainEventPtr virDomainEventRebootNew(int id, const char *name, const unsigned char *uuid);
63 64 65
virDomainEventPtr virDomainEventRebootNewFromDom(virDomainPtr dom);
virDomainEventPtr virDomainEventRebootNewFromObj(virDomainObjPtr obj);

66 67 68
virDomainEventPtr virDomainEventRTCChangeNewFromDom(virDomainPtr dom, long long offset);
virDomainEventPtr virDomainEventRTCChangeNewFromObj(virDomainObjPtr obj, long long offset);

69 70 71
virDomainEventPtr virDomainEventWatchdogNewFromDom(virDomainPtr dom, int action);
virDomainEventPtr virDomainEventWatchdogNewFromObj(virDomainObjPtr obj, int action);

72 73 74 75 76 77 78 79
virDomainEventPtr virDomainEventIOErrorNewFromDom(virDomainPtr dom,
                                                  const char *srcPath,
                                                  const char *devAlias,
                                                  int action);
virDomainEventPtr virDomainEventIOErrorNewFromObj(virDomainObjPtr obj,
                                                  const char *srcPath,
                                                  const char *devAlias,
                                                  int action);
80 81 82 83 84 85 86 87 88 89
virDomainEventPtr virDomainEventIOErrorReasonNewFromDom(virDomainPtr dom,
                                                        const char *srcPath,
                                                        const char *devAlias,
                                                        int action,
                                                        const char *reason);
virDomainEventPtr virDomainEventIOErrorReasonNewFromObj(virDomainObjPtr obj,
                                                        const char *srcPath,
                                                        const char *devAlias,
                                                        int action,
                                                        const char *reason);
90

91
virDomainEventPtr virDomainEventGraphicsNewFromDom(virDomainPtr dom,
92 93 94 95 96
                                       int phase,
                                       virDomainEventGraphicsAddressPtr local,
                                       virDomainEventGraphicsAddressPtr remote,
                                       const char *authScheme,
                                       virDomainEventGraphicsSubjectPtr subject);
97
virDomainEventPtr virDomainEventGraphicsNewFromObj(virDomainObjPtr obj,
98 99 100 101 102
                                       int phase,
                                       virDomainEventGraphicsAddressPtr local,
                                       virDomainEventGraphicsAddressPtr remote,
                                       const char *authScheme,
                                       virDomainEventGraphicsSubjectPtr subject);
103 104
virDomainEventPtr virDomainEventControlErrorNewFromDom(virDomainPtr dom);
virDomainEventPtr virDomainEventControlErrorNewFromObj(virDomainObjPtr obj);
105

106 107 108 109 110 111 112 113
virDomainEventPtr virDomainEventBlockJobNewFromObj(virDomainObjPtr obj,
                                                    const char *path,
                                                    int type,
                                                    int status);
virDomainEventPtr virDomainEventBlockJobNewFromDom(virDomainPtr dom,
                                                    const char *path,
                                                    int type,
                                                    int status);
114

115 116 117 118 119 120 121 122 123 124
virDomainEventPtr virDomainEventDiskChangeNewFromObj(virDomainObjPtr obj,
                                                     const char *oldSrcPath,
                                                     const char *newSrcPath,
                                                     const char *devAlias,
                                                     int reason);
virDomainEventPtr virDomainEventDiskChangeNewFromDom(virDomainPtr dom,
                                                     const char *oldSrcPath,
                                                     const char *newSrcPath,
                                                     const char *devAlias,
                                                     int reason);
125 126 127 128 129 130
virDomainEventPtr virDomainEventTrayChangeNewFromObj(virDomainObjPtr obj,
                                                     const char *devAlias,
                                                     int reason);
virDomainEventPtr virDomainEventTrayChangeNewFromDom(virDomainPtr dom,
                                                     const char *devAlias,
                                                     int reason);
O
Osier Yang 已提交
131 132
virDomainEventPtr virDomainEventPMWakeupNewFromObj(virDomainObjPtr obj);
virDomainEventPtr virDomainEventPMWakeupNewFromDom(virDomainPtr dom);
O
Osier Yang 已提交
133 134
virDomainEventPtr virDomainEventPMSuspendNewFromObj(virDomainObjPtr obj);
virDomainEventPtr virDomainEventPMSuspendNewFromDom(virDomainPtr dom);
135

136 137 138
virDomainEventPtr virDomainEventBalloonChangeNewFromDom(virDomainPtr dom, unsigned long long actual);
virDomainEventPtr virDomainEventBalloonChangeNewFromObj(virDomainObjPtr obj, unsigned long long actual);

139 140 141
virDomainEventPtr virDomainEventPMSuspendDiskNewFromObj(virDomainObjPtr obj);
virDomainEventPtr virDomainEventPMSuspendDiskNewFromDom(virDomainPtr dom);

142 143 144 145 146
virDomainEventPtr virDomainEventDeviceRemovedNewFromObj(virDomainObjPtr obj,
                                                        const char *devAlias);
virDomainEventPtr virDomainEventDeviceRemovedNewFromDom(virDomainPtr dom,
                                                        const char *devAlias);

147 148 149
void virObjectEventStateFree(virObjectEventStatePtr state);
virObjectEventStatePtr
virObjectEventStateNew(void);
150

151 152 153 154 155 156 157 158 159 160 161 162 163
/*
 * virConnectObjectEventGenericCallback:
 * @conn: the connection pointer
 * @obj: the object pointer
 * @opaque: application specified data
 *
 * A generic object event callback handler. Specific events usually
 * have a customization with extra parameters
 */
typedef void (*virConnectObjectEventGenericCallback)(virConnectPtr conn,
                                                     void *obj,
                                                     void *opaque);

164
void
165
virObjectEventStateQueue(virObjectEventStatePtr state,
166 167
                         virDomainEventPtr event)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
168
int virDomainEventStateRegister(virConnectPtr conn,
169
                                virObjectEventStatePtr state,
170 171 172 173 174
                                virConnectDomainEventCallback callback,
                                void *opaque,
                                virFreeCallback freecb)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int virDomainEventStateRegisterID(virConnectPtr conn,
175
                                  virObjectEventStatePtr state,
176 177 178 179 180 181 182
                                  virDomainPtr dom,
                                  int eventID,
                                  virConnectDomainEventGenericCallback cb,
                                  void *opaque,
                                  virFreeCallback freecb,
                                  int *callbackID)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
183 184
int
virDomainEventStateDeregister(virConnectPtr conn,
185
                              virObjectEventStatePtr state,
186 187 188
                              virConnectDomainEventCallback callback)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int
189 190 191 192 193 194 195 196 197 198 199 200
virObjectEventStateRegisterID(virConnectPtr conn,
                              virObjectEventStatePtr state,
                              unsigned char *uuid,
                              const char *name,
                              int id,
                              int eventID,
                              virConnectObjectEventGenericCallback cb,
                              void *opaque,
                              virFreeCallback freecb,
                              int *callbackID)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(7);
int
201 202
virObjectEventStateDeregisterID(virConnectPtr conn,
                                virObjectEventStatePtr state,
203
                                int callbackID)
204
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
205
int
206 207
virObjectEventStateEventID(virConnectPtr conn,
                           virObjectEventStatePtr state,
208 209
                           int callbackID)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
210

211
#endif