qerror.h 8.2 KB
Newer Older
L
Luiz Capitulino 已提交
1
/*
L
Luiz Capitulino 已提交
2
 * QError Module
L
Luiz Capitulino 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15
 *
 * Copyright (C) 2009 Red Hat Inc.
 *
 * Authors:
 *  Luiz Capitulino <lcapitulino@redhat.com>
 *
 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
 * See the COPYING.LIB file in the top-level directory.
 */
#ifndef QERROR_H
#define QERROR_H

#include "qdict.h"
16
#include "qstring.h"
17
#include "qemu-error.h"
A
Anthony Liguori 已提交
18
#include "error.h"
19
#include "qapi-types.h"
L
Luiz Capitulino 已提交
20 21 22
#include <stdarg.h>

typedef struct QErrorStringTable {
23
    ErrorClass err_class;
L
Luiz Capitulino 已提交
24
    const char *error_fmt;
25
    const char *desc;
L
Luiz Capitulino 已提交
26 27 28 29 30
} QErrorStringTable;

typedef struct QError {
    QObject_HEAD;
    QDict *error;
31
    Location loc;
32
    char *err_msg;
33
    ErrorClass err_class;
L
Luiz Capitulino 已提交
34 35
} QError;

36
QString *qerror_human(const QError *qerror);
37
void qerror_report(ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
A
Anthony Liguori 已提交
38
void qerror_report_err(Error *err);
39
void assert_no_error(Error *err);
40
char *qerror_format(const char *fmt, QDict *error);
L
Luiz Capitulino 已提交
41 42 43

/*
 * QError class list
44
 * Please keep the definitions in alphabetical order.
45
 * Use scripts/check-qerror.sh to check.
L
Luiz Capitulino 已提交
46
 */
47
#define QERR_ADD_CLIENT_FAILED \
48
    -1, "{ 'class': 'AddClientFailed', 'data': {} }"
49

50
#define QERR_AMBIGUOUS_PATH \
51
    -1, "{ 'class': 'AmbiguousPath', 'data': { 'path': %s } }"
52

53
#define QERR_BAD_BUS_FOR_DEVICE \
54
    -1, "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
55

M
Marcelo Tosatti 已提交
56
#define QERR_BASE_NOT_FOUND \
57
    -1, "{ 'class': 'BaseNotFound', 'data': { 'base': %s } }"
M
Marcelo Tosatti 已提交
58

A
Anthony Liguori 已提交
59
#define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
60
    -1, "{ 'class': 'BlockFormatFeatureNotSupported', 'data': { 'format': %s, 'name': %s, 'feature': %s } }"
A
Anthony Liguori 已提交
61

62
#define QERR_BUFFER_OVERRUN \
63
    -1, "{ 'class': 'BufferOverrun', 'data': {} }"
64

65
#define QERR_BUS_NO_HOTPLUG \
66
    -1, "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
67

68
#define QERR_BUS_NOT_FOUND \
69
    -1, "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
L
Luiz Capitulino 已提交
70

71
#define QERR_COMMAND_DISABLED \
72
    -1, "{ 'class': 'CommandDisabled', 'data': { 'name': %s } }"
73

74
#define QERR_COMMAND_NOT_FOUND \
75
    -1, "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
76

77
#define QERR_DEVICE_ENCRYPTED \
78
    -1, "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s, 'filename': %s } }"
L
Luiz Capitulino 已提交
79

80
#define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \
81
    -1, "{ 'class': 'DeviceFeatureBlocksMigration', 'data': { 'device': %s, 'feature': %s } }"
82

83
#define QERR_DEVICE_HAS_NO_MEDIUM \
84
    -1, "{ 'class': 'DeviceHasNoMedium', 'data': { 'device': %s } }"
85

86
#define QERR_DEVICE_INIT_FAILED \
87
    -1, "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
88

89
#define QERR_DEVICE_IN_USE \
90
    -1, "{ 'class': 'DeviceInUse', 'data': { 'device': %s } }"
91

92
#define QERR_DEVICE_IS_READ_ONLY \
93
    -1, "{ 'class': 'DeviceIsReadOnly', 'data': { 'device': %s } }"
94

95
#define QERR_DEVICE_LOCKED \
96
    -1, "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
M
Markus Armbruster 已提交
97

98
#define QERR_DEVICE_MULTIPLE_BUSSES \
99
    -1, "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
100

101
#define QERR_DEVICE_NO_BUS \
102
    -1, "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
103 104

#define QERR_DEVICE_NO_HOTPLUG \
105
    -1, "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
106

107
#define QERR_DEVICE_NOT_ACTIVE \
108
    -1, "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
109

110
#define QERR_DEVICE_NOT_ENCRYPTED \
111
    -1, "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
112

113
#define QERR_DEVICE_NOT_FOUND \
114
    -1, "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
115

116
#define QERR_DEVICE_NOT_REMOVABLE \
117
    -1, "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
118

M
Markus Armbruster 已提交
119
#define QERR_DUPLICATE_ID \
120
    -1, "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
M
Markus Armbruster 已提交
121

M
Markus Armbruster 已提交
122
#define QERR_FD_NOT_FOUND \
123
    -1, "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
M
Markus Armbruster 已提交
124

125
#define QERR_FD_NOT_SUPPLIED \
126
    -1, "{ 'class': 'FdNotSupplied', 'data': {} }"
127

128
#define QERR_FEATURE_DISABLED \
129
    -1, "{ 'class': 'FeatureDisabled', 'data': { 'name': %s } }"
130

131
#define QERR_INVALID_BLOCK_FORMAT \
132
    -1, "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
133

134
#define QERR_INVALID_OPTION_GROUP \
135
    -1, "{ 'class': 'InvalidOptionGroup', 'data': { 'group': %s } }"
136

M
Markus Armbruster 已提交
137
#define QERR_INVALID_PARAMETER \
138
    -1, "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
M
Markus Armbruster 已提交
139

140
#define QERR_INVALID_PARAMETER_COMBINATION \
141
    -1, "{ 'class': 'InvalidParameterCombination', 'data': {} }"
142

L
Luiz Capitulino 已提交
143
#define QERR_INVALID_PARAMETER_TYPE \
144
    -1, "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
L
Luiz Capitulino 已提交
145

146
#define QERR_INVALID_PARAMETER_VALUE \
147
    -1, "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }"
148

149
#define QERR_INVALID_PASSWORD \
150
    -1, "{ 'class': 'InvalidPassword', 'data': {} }"
151

L
Luiz Capitulino 已提交
152
#define QERR_IO_ERROR \
153
    -1, "{ 'class': 'IOError', 'data': {} }"
L
Luiz Capitulino 已提交
154

155
#define QERR_JSON_PARSE_ERROR \
156
    -1, "{ 'class': 'JSONParseError', 'data': { 'message': %s } }"
157

158
#define QERR_JSON_PARSING \
159
    -1, "{ 'class': 'JSONParsing', 'data': {} }"
M
Michael Roth 已提交
160

L
Luiz Capitulino 已提交
161
#define QERR_KVM_MISSING_CAP \
162
    -1, "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
L
Luiz Capitulino 已提交
163

164
#define QERR_MIGRATION_ACTIVE \
165
    -1, "{ 'class': 'MigrationActive', 'data': {} }"
166 167

#define QERR_MIGRATION_NOT_SUPPORTED \
168
    -1, "{ 'class': 'MigrationNotSupported', 'data': {'device': %s} }"
169

170
#define QERR_MIGRATION_EXPECTED \
171
    -1, "{ 'class': 'MigrationExpected', 'data': {} }"
172

L
Luiz Capitulino 已提交
173
#define QERR_MISSING_PARAMETER \
174
    -1, "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
L
Luiz Capitulino 已提交
175

176
#define QERR_NO_BUS_FOR_DEVICE \
177
    -1, "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
178

S
Stefan Hajnoczi 已提交
179
#define QERR_NOT_SUPPORTED \
180
    -1, "{ 'class': 'NotSupported', 'data': {} }"
S
Stefan Hajnoczi 已提交
181

182
#define QERR_OPEN_FILE_FAILED \
183
    -1, "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
184

185
#define QERR_PERMISSION_DENIED \
186
    -1, "{ 'class': 'PermissionDenied', 'data': {} }"
187

188
#define QERR_PROPERTY_NOT_FOUND \
189
    -1, "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
190

191
#define QERR_PROPERTY_VALUE_BAD \
192
    -1, "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
193

194
#define QERR_PROPERTY_VALUE_IN_USE \
195
    -1, "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
196

197
#define QERR_PROPERTY_VALUE_NOT_FOUND \
198
    -1, "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
199

200
#define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \
201
    -1, "{ 'class': 'PropertyValueNotPowerOf2', 'data': { " \
202 203
    "'device': %s, 'property': %s, 'value': %"PRId64" } }"

204
#define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
205
    -1, "{ 'class': 'PropertyValueOutOfRange', 'data': { 'device': %s, 'property': %s, 'value': %"PRId64", 'min': %"PRId64", 'max': %"PRId64" } }"
206

207
#define QERR_QGA_COMMAND_FAILED \
208
    -1, "{ 'class': 'QgaCommandFailed', 'data': { 'message': %s } }"
209 210

#define QERR_QGA_LOGGING_FAILED \
211
    -1, "{ 'class': 'QgaLoggingFailed', 'data': {} }"
212

L
Luiz Capitulino 已提交
213
#define QERR_QMP_BAD_INPUT_OBJECT \
214
    -1, "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
L
Luiz Capitulino 已提交
215

216
#define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
217
    -1, "{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }"
218

219
#define QERR_QMP_EXTRA_MEMBER \
220
    -1, "{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }"
221

222
#define QERR_RESET_REQUIRED \
223
    -1, "{ 'class': 'ResetRequired', 'data': {} }"
224

225
#define QERR_SET_PASSWD_FAILED \
226
    -1, "{ 'class': 'SetPasswdFailed', 'data': {} }"
227

228
#define QERR_TOO_MANY_FILES \
229
    -1, "{ 'class': 'TooManyFiles', 'data': {} }"
230

231
#define QERR_UNDEFINED_ERROR \
232
    -1, "{ 'class': 'UndefinedError', 'data': {} }"
233

234
#define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
235
    -1, "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
236

237
#define QERR_UNSUPPORTED \
238
    -1, "{ 'class': 'Unsupported', 'data': {} }"
239

240
#define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \
241
    -1, "{ 'class': 'VirtFSFeatureBlocksMigration', 'data': { 'path': %s, 'tag': %s } }"
242

243
#define QERR_VNC_SERVER_FAILED \
244
    -1, "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
245

A
Amos Kong 已提交
246
#define QERR_SOCKET_CONNECT_FAILED \
247
    -1, "{ 'class': 'SockConnectFailed', 'data': {} }"
A
Amos Kong 已提交
248 249

#define QERR_SOCKET_LISTEN_FAILED \
250
    -1, "{ 'class': 'SockListenFailed', 'data': {} }"
A
Amos Kong 已提交
251 252

#define QERR_SOCKET_BIND_FAILED \
253
    -1, "{ 'class': 'SockBindFailed', 'data': {} }"
A
Amos Kong 已提交
254 255

#define QERR_SOCKET_CREATE_FAILED \
256
    -1, "{ 'class': 'SockCreateFailed', 'data': {} }"
A
Amos Kong 已提交
257

L
Luiz Capitulino 已提交
258
#endif /* QERROR_H */