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