]> Git Repo - qemu.git/blob - qerror.h
qerror: don't delay error message construction
[qemu.git] / qerror.h
1 /*
2  * QError Module
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"
16 #include "qstring.h"
17 #include "qemu-error.h"
18 #include "error.h"
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;
29     Location loc;
30     char *err_msg;
31 } QError;
32
33 QString *qerror_human(const QError *qerror);
34 void qerror_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
35 void qerror_report_err(Error *err);
36 void assert_no_error(Error *err);
37 char *qerror_format(const char *fmt, QDict *error);
38
39 /*
40  * QError class list
41  * Please keep the definitions in alphabetical order.
42  * Use scripts/check-qerror.sh to check.
43  */
44 #define QERR_ADD_CLIENT_FAILED \
45     "{ 'class': 'AddClientFailed', 'data': {} }"
46
47 #define QERR_AMBIGUOUS_PATH \
48     "{ 'class': 'AmbiguousPath', 'data': { 'path': %s } }"
49
50 #define QERR_BAD_BUS_FOR_DEVICE \
51     "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
52
53 #define QERR_BASE_NOT_FOUND \
54     "{ 'class': 'BaseNotFound', 'data': { 'base': %s } }"
55
56 #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
57     "{ 'class': 'BlockFormatFeatureNotSupported', 'data': { 'format': %s, 'name': %s, 'feature': %s } }"
58
59 #define QERR_BUFFER_OVERRUN \
60     "{ 'class': 'BufferOverrun', 'data': {} }"
61
62 #define QERR_BUS_NO_HOTPLUG \
63     "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
64
65 #define QERR_BUS_NOT_FOUND \
66     "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
67
68 #define QERR_COMMAND_DISABLED \
69     "{ 'class': 'CommandDisabled', 'data': { 'name': %s } }"
70
71 #define QERR_COMMAND_NOT_FOUND \
72     "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
73
74 #define QERR_DEVICE_ENCRYPTED \
75     "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s, 'filename': %s } }"
76
77 #define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \
78     "{ 'class': 'DeviceFeatureBlocksMigration', 'data': { 'device': %s, 'feature': %s } }"
79
80 #define QERR_DEVICE_HAS_NO_MEDIUM \
81     "{ 'class': 'DeviceHasNoMedium', 'data': { 'device': %s } }"
82
83 #define QERR_DEVICE_INIT_FAILED \
84     "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
85
86 #define QERR_DEVICE_IN_USE \
87     "{ 'class': 'DeviceInUse', 'data': { 'device': %s } }"
88
89 #define QERR_DEVICE_IS_READ_ONLY \
90     "{ 'class': 'DeviceIsReadOnly', 'data': { 'device': %s } }"
91
92 #define QERR_DEVICE_LOCKED \
93     "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
94
95 #define QERR_DEVICE_MULTIPLE_BUSSES \
96     "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
97
98 #define QERR_DEVICE_NO_BUS \
99     "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
100
101 #define QERR_DEVICE_NO_HOTPLUG \
102     "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
103
104 #define QERR_DEVICE_NOT_ACTIVE \
105     "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
106
107 #define QERR_DEVICE_NOT_ENCRYPTED \
108     "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
109
110 #define QERR_DEVICE_NOT_FOUND \
111     "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
112
113 #define QERR_DEVICE_NOT_REMOVABLE \
114     "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
115
116 #define QERR_DUPLICATE_ID \
117     "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
118
119 #define QERR_FD_NOT_FOUND \
120     "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
121
122 #define QERR_FD_NOT_SUPPLIED \
123     "{ 'class': 'FdNotSupplied', 'data': {} }"
124
125 #define QERR_FEATURE_DISABLED \
126     "{ 'class': 'FeatureDisabled', 'data': { 'name': %s } }"
127
128 #define QERR_INVALID_BLOCK_FORMAT \
129     "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
130
131 #define QERR_INVALID_OPTION_GROUP \
132     "{ 'class': 'InvalidOptionGroup', 'data': { 'group': %s } }"
133
134 #define QERR_INVALID_PARAMETER \
135     "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
136
137 #define QERR_INVALID_PARAMETER_COMBINATION \
138     "{ 'class': 'InvalidParameterCombination', 'data': {} }"
139
140 #define QERR_INVALID_PARAMETER_TYPE \
141     "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
142
143 #define QERR_INVALID_PARAMETER_VALUE \
144     "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }"
145
146 #define QERR_INVALID_PASSWORD \
147     "{ 'class': 'InvalidPassword', 'data': {} }"
148
149 #define QERR_IO_ERROR \
150     "{ 'class': 'IOError', 'data': {} }"
151
152 #define QERR_JSON_PARSE_ERROR \
153     "{ 'class': 'JSONParseError', 'data': { 'message': %s } }"
154
155 #define QERR_JSON_PARSING \
156     "{ 'class': 'JSONParsing', 'data': {} }"
157
158 #define QERR_KVM_MISSING_CAP \
159     "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
160
161 #define QERR_MIGRATION_ACTIVE \
162     "{ 'class': 'MigrationActive', 'data': {} }"
163
164 #define QERR_MIGRATION_NOT_SUPPORTED \
165     "{ 'class': 'MigrationNotSupported', 'data': {'device': %s} }"
166
167 #define QERR_MIGRATION_EXPECTED \
168     "{ 'class': 'MigrationExpected', 'data': {} }"
169
170 #define QERR_MISSING_PARAMETER \
171     "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
172
173 #define QERR_NO_BUS_FOR_DEVICE \
174     "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
175
176 #define QERR_NOT_SUPPORTED \
177     "{ 'class': 'NotSupported', 'data': {} }"
178
179 #define QERR_OPEN_FILE_FAILED \
180     "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
181
182 #define QERR_PERMISSION_DENIED \
183     "{ 'class': 'PermissionDenied', 'data': {} }"
184
185 #define QERR_PROPERTY_NOT_FOUND \
186     "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
187
188 #define QERR_PROPERTY_VALUE_BAD \
189     "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
190
191 #define QERR_PROPERTY_VALUE_IN_USE \
192     "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
193
194 #define QERR_PROPERTY_VALUE_NOT_FOUND \
195     "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
196
197 #define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \
198     "{ 'class': 'PropertyValueNotPowerOf2', 'data': { " \
199     "'device': %s, 'property': %s, 'value': %"PRId64" } }"
200
201 #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
202     "{ 'class': 'PropertyValueOutOfRange', 'data': { 'device': %s, 'property': %s, 'value': %"PRId64", 'min': %"PRId64", 'max': %"PRId64" } }"
203
204 #define QERR_QGA_COMMAND_FAILED \
205     "{ 'class': 'QgaCommandFailed', 'data': { 'message': %s } }"
206
207 #define QERR_QGA_LOGGING_FAILED \
208     "{ 'class': 'QgaLoggingFailed', 'data': {} }"
209
210 #define QERR_QMP_BAD_INPUT_OBJECT \
211     "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
212
213 #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
214     "{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }"
215
216 #define QERR_QMP_EXTRA_MEMBER \
217     "{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }"
218
219 #define QERR_RESET_REQUIRED \
220     "{ 'class': 'ResetRequired', 'data': {} }"
221
222 #define QERR_SET_PASSWD_FAILED \
223     "{ 'class': 'SetPasswdFailed', 'data': {} }"
224
225 #define QERR_TOO_MANY_FILES \
226     "{ 'class': 'TooManyFiles', 'data': {} }"
227
228 #define QERR_UNDEFINED_ERROR \
229     "{ 'class': 'UndefinedError', 'data': {} }"
230
231 #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
232     "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
233
234 #define QERR_UNSUPPORTED \
235     "{ 'class': 'Unsupported', 'data': {} }"
236
237 #define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \
238     "{ 'class': 'VirtFSFeatureBlocksMigration', 'data': { 'path': %s, 'tag': %s } }"
239
240 #define QERR_VNC_SERVER_FAILED \
241     "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
242
243 #define QERR_SOCKET_CONNECT_IN_PROGRESS \
244     "{ 'class': 'SockConnectInprogress', 'data': {} }"
245
246 #define QERR_SOCKET_CONNECT_FAILED \
247     "{ 'class': 'SockConnectFailed', 'data': {} }"
248
249 #define QERR_SOCKET_LISTEN_FAILED \
250     "{ 'class': 'SockListenFailed', 'data': {} }"
251
252 #define QERR_SOCKET_BIND_FAILED \
253     "{ 'class': 'SockBindFailed', 'data': {} }"
254
255 #define QERR_SOCKET_CREATE_FAILED \
256     "{ 'class': 'SockCreateFailed', 'data': {} }"
257
258 #endif /* QERROR_H */
This page took 0.033616 seconds and 4 git commands to generate.