]>
Commit | Line | Data |
---|---|---|
9f9daf9a | 1 | /* |
41836a9f | 2 | * QError Module |
9f9daf9a LC |
3 | * |
4 | * Copyright (C) 2009 Red Hat Inc. | |
5 | * | |
6 | * Authors: | |
7 | * Luiz Capitulino <[email protected]> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. | |
10 | * See the COPYING.LIB file in the top-level directory. | |
11 | */ | |
12 | #ifndef QERROR_H | |
13 | #define QERROR_H | |
14 | ||
15 | #include "qdict.h" | |
77e595e7 | 16 | #include "qstring.h" |
827b0813 | 17 | #include "qemu-error.h" |
2a82d936 | 18 | #include "error.h" |
9f9daf9a LC |
19 | #include <stdarg.h> |
20 | ||
21 | typedef struct QErrorStringTable { | |
22 | const char *desc; | |
23 | const char *error_fmt; | |
24 | } QErrorStringTable; | |
25 | ||
26 | typedef struct QError { | |
27 | QObject_HEAD; | |
28 | QDict *error; | |
827b0813 | 29 | Location loc; |
9f9daf9a LC |
30 | int linenr; |
31 | const char *file; | |
32 | const char *func; | |
33 | const QErrorStringTable *entry; | |
34 | } QError; | |
35 | ||
36 | QError *qerror_new(void); | |
37 | QError *qerror_from_info(const char *file, int linenr, const char *func, | |
8b7968f7 | 38 | const char *fmt, va_list *va) GCC_FMT_ATTR(4, 0); |
77e595e7 | 39 | QString *qerror_human(const QError *qerror); |
827b0813 | 40 | void qerror_print(QError *qerror); |
0167f772 | 41 | void qerror_report_internal(const char *file, int linenr, const char *func, |
e5924d89 | 42 | const char *fmt, ...) GCC_FMT_ATTR(4, 5); |
2a82d936 | 43 | void qerror_report_err(Error *err); |
87c2f591 | 44 | QString *qerror_format(const char *fmt, QDict *error); |
0167f772 MA |
45 | #define qerror_report(fmt, ...) \ |
46 | qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__) | |
9f9daf9a LC |
47 | QError *qobject_to_qerror(const QObject *obj); |
48 | ||
49 | /* | |
50 | * QError class list | |
9d494c4b | 51 | * Please keep the definitions in alphabetical order. |
9737383b | 52 | * Use scripts/check-qerror.sh to check. |
9f9daf9a | 53 | */ |
c1303596 SH |
54 | #define QERR_ADD_CLIENT_FAILED \ |
55 | "{ 'class': 'AddClientFailed', 'data': {} }" | |
56 | ||
11e35bfd PB |
57 | #define QERR_AMBIGUOUS_PATH \ |
58 | "{ 'class': 'AmbiguousPath', 'data': { 'path': %s } }" | |
59 | ||
56e9f563 MA |
60 | #define QERR_BAD_BUS_FOR_DEVICE \ |
61 | "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }" | |
62 | ||
019b8cbf MT |
63 | #define QERR_BASE_NOT_FOUND \ |
64 | "{ 'class': 'BaseNotFound', 'data': { 'base': %s } }" | |
65 | ||
1ed520c6 AL |
66 | #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \ |
67 | "{ 'class': 'BlockFormatFeatureNotSupported', 'data': { 'format': %s, 'name': %s, 'feature': %s } }" | |
68 | ||
c1303596 SH |
69 | #define QERR_BUFFER_OVERRUN \ |
70 | "{ 'class': 'BufferOverrun', 'data': {} }" | |
7bbd8237 | 71 | |
8eae73b5 MA |
72 | #define QERR_BUS_NO_HOTPLUG \ |
73 | "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }" | |
74 | ||
c1303596 SH |
75 | #define QERR_BUS_NOT_FOUND \ |
76 | "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }" | |
4b9d4683 | 77 | |
abd6cf6d MR |
78 | #define QERR_COMMAND_DISABLED \ |
79 | "{ 'class': 'CommandDisabled', 'data': { 'name': %s } }" | |
80 | ||
c1303596 SH |
81 | #define QERR_COMMAND_NOT_FOUND \ |
82 | "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }" | |
83 | ||
0df37c41 | 84 | #define QERR_DEVICE_ENCRYPTED \ |
903a8814 | 85 | "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s, 'filename': %s } }" |
9f9daf9a | 86 | |
c1303596 SH |
87 | #define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \ |
88 | "{ 'class': 'DeviceFeatureBlocksMigration', 'data': { 'device': %s, 'feature': %s } }" | |
89 | ||
939a1cc3 SH |
90 | #define QERR_DEVICE_HAS_NO_MEDIUM \ |
91 | "{ 'class': 'DeviceHasNoMedium', 'data': { 'device': %s } }" | |
92 | ||
4d9a1a15 MA |
93 | #define QERR_DEVICE_INIT_FAILED \ |
94 | "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }" | |
95 | ||
5124eb59 MA |
96 | #define QERR_DEVICE_IN_USE \ |
97 | "{ 'class': 'DeviceInUse', 'data': { 'device': %s } }" | |
98 | ||
939a1cc3 SH |
99 | #define QERR_DEVICE_IS_READ_ONLY \ |
100 | "{ 'class': 'DeviceIsReadOnly', 'data': { 'device': %s } }" | |
101 | ||
fc5469d8 | 102 | #define QERR_DEVICE_LOCKED \ |
b0868380 MA |
103 | "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }" |
104 | ||
1ae78718 MA |
105 | #define QERR_DEVICE_MULTIPLE_BUSSES \ |
106 | "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }" | |
107 | ||
c1303596 SH |
108 | #define QERR_DEVICE_NO_BUS \ |
109 | "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }" | |
110 | ||
111 | #define QERR_DEVICE_NO_HOTPLUG \ | |
112 | "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }" | |
113 | ||
055f6122 | 114 | #define QERR_DEVICE_NOT_ACTIVE \ |
e16a1812 MA |
115 | "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }" |
116 | ||
9d494c4b MA |
117 | #define QERR_DEVICE_NOT_ENCRYPTED \ |
118 | "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }" | |
119 | ||
e16a1812 MA |
120 | #define QERR_DEVICE_NOT_FOUND \ |
121 | "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }" | |
055f6122 | 122 | |
5cfe0264 MA |
123 | #define QERR_DEVICE_NOT_REMOVABLE \ |
124 | "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }" | |
125 | ||
7bc84017 MA |
126 | #define QERR_DUPLICATE_ID \ |
127 | "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }" | |
128 | ||
c7c338c4 | 129 | #define QERR_FD_NOT_FOUND \ |
bd9d3064 | 130 | "{ 'class': 'FdNotFound', 'data': { 'name': %s } }" |
c7c338c4 | 131 | |
41471a23 | 132 | #define QERR_FD_NOT_SUPPLIED \ |
bd9d3064 | 133 | "{ 'class': 'FdNotSupplied', 'data': {} }" |
41471a23 | 134 | |
c1303596 SH |
135 | #define QERR_FEATURE_DISABLED \ |
136 | "{ 'class': 'FeatureDisabled', 'data': { 'name': %s } }" | |
137 | ||
17901e75 MA |
138 | #define QERR_INVALID_BLOCK_FORMAT \ |
139 | "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }" | |
140 | ||
7a046f5f | 141 | #define QERR_INVALID_PARAMETER \ |
bd9d3064 | 142 | "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }" |
7a046f5f | 143 | |
c1303596 SH |
144 | #define QERR_INVALID_PARAMETER_COMBINATION \ |
145 | "{ 'class': 'InvalidParameterCombination', 'data': {} }" | |
146 | ||
4b9d4683 | 147 | #define QERR_INVALID_PARAMETER_TYPE \ |
e16a1812 | 148 | "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }" |
4b9d4683 | 149 | |
985a3e52 MA |
150 | #define QERR_INVALID_PARAMETER_VALUE \ |
151 | "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }" | |
152 | ||
f6d855c5 | 153 | #define QERR_INVALID_PASSWORD \ |
e16a1812 MA |
154 | "{ 'class': 'InvalidPassword', 'data': {} }" |
155 | ||
58898873 LC |
156 | #define QERR_IO_ERROR \ |
157 | "{ 'class': 'IOError', 'data': {} }" | |
158 | ||
ef749d07 AL |
159 | #define QERR_JSON_PARSE_ERROR \ |
160 | "{ 'class': 'JSONParseError', 'data': { 'message': %s } }" | |
161 | ||
c1303596 SH |
162 | #define QERR_JSON_PARSING \ |
163 | "{ 'class': 'JSONParsing', 'data': {} }" | |
c40cc0a0 | 164 | |
82a60711 | 165 | #define QERR_KVM_MISSING_CAP \ |
e16a1812 | 166 | "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }" |
82a60711 | 167 | |
8e84865e AS |
168 | #define QERR_MIGRATION_EXPECTED \ |
169 | "{ 'class': 'MigrationExpected', 'data': {} }" | |
170 | ||
4b9d4683 | 171 | #define QERR_MISSING_PARAMETER \ |
e16a1812 | 172 | "{ 'class': 'MissingParameter', 'data': { 'name': %s } }" |
4b9d4683 | 173 | |
fab5767f MA |
174 | #define QERR_NO_BUS_FOR_DEVICE \ |
175 | "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }" | |
176 | ||
12bd451f SH |
177 | #define QERR_NOT_SUPPORTED \ |
178 | "{ 'class': 'NotSupported', 'data': {} }" | |
179 | ||
fc5469d8 MA |
180 | #define QERR_OPEN_FILE_FAILED \ |
181 | "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }" | |
182 | ||
44677ded AL |
183 | #define QERR_PERMISSION_DENIED \ |
184 | "{ 'class': 'PermissionDenied', 'data': {} }" | |
185 | ||
c58a35f8 MA |
186 | #define QERR_PROPERTY_NOT_FOUND \ |
187 | "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }" | |
188 | ||
06b4a703 MA |
189 | #define QERR_PROPERTY_VALUE_BAD \ |
190 | "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }" | |
191 | ||
9c5eff95 MA |
192 | #define QERR_PROPERTY_VALUE_IN_USE \ |
193 | "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }" | |
194 | ||
84745d68 MA |
195 | #define QERR_PROPERTY_VALUE_NOT_FOUND \ |
196 | "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }" | |
197 | ||
6aced82c PB |
198 | #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \ |
199 | "{ 'class': 'PropertyValueOutOfRange', 'data': { 'device': %s, 'property': %s, 'value': %"PRId64", 'min': %"PRId64", 'max': %"PRId64" } }" | |
200 | ||
c1303596 SH |
201 | #define QERR_QGA_COMMAND_FAILED \ |
202 | "{ 'class': 'QgaCommandFailed', 'data': { 'message': %s } }" | |
203 | ||
204 | #define QERR_QGA_LOGGING_FAILED \ | |
205 | "{ 'class': 'QgaLoggingFailed', 'data': {} }" | |
206 | ||
4b9d4683 | 207 | #define QERR_QMP_BAD_INPUT_OBJECT \ |
e16a1812 | 208 | "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }" |
4b9d4683 | 209 | |
7dfb6123 LC |
210 | #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \ |
211 | "{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }" | |
212 | ||
60d76d7b LC |
213 | #define QERR_QMP_EXTRA_MEMBER \ |
214 | "{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }" | |
215 | ||
6667b23f LC |
216 | #define QERR_RESET_REQUIRED \ |
217 | "{ 'class': 'ResetRequired', 'data': {} }" | |
218 | ||
7a84cb23 MA |
219 | #define QERR_SET_PASSWD_FAILED \ |
220 | "{ 'class': 'SetPasswdFailed', 'data': {} }" | |
221 | ||
a488be27 | 222 | #define QERR_TOO_MANY_FILES \ |
bd9d3064 | 223 | "{ 'class': 'TooManyFiles', 'data': {} }" |
a488be27 | 224 | |
fc5469d8 MA |
225 | #define QERR_UNDEFINED_ERROR \ |
226 | "{ 'class': 'UndefinedError', 'data': {} }" | |
227 | ||
f54e3641 KW |
228 | #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \ |
229 | "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }" | |
230 | ||
c1303596 SH |
231 | #define QERR_UNSUPPORTED \ |
232 | "{ 'class': 'Unsupported', 'data': {} }" | |
233 | ||
e9a0152b AK |
234 | #define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \ |
235 | "{ 'class': 'VirtFSFeatureBlocksMigration', 'data': { 'path': %s, 'tag': %s } }" | |
236 | ||
a6906e31 MA |
237 | #define QERR_VNC_SERVER_FAILED \ |
238 | "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }" | |
239 | ||
9f9daf9a | 240 | #endif /* QERROR_H */ |