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