ide/ahci: Use universal DMA helper functions
[qemu/opensuse.git] / qerror.h
blobb4c8758f400948592e10b963118250f635cd9a19
1 /*
2 * QError Module
4 * Copyright (C) 2009 Red Hat Inc.
6 * Authors:
7 * Luiz Capitulino <lcapitulino@redhat.com>
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.
12 #ifndef QERROR_H
13 #define QERROR_H
15 #include "qdict.h"
16 #include "qstring.h"
17 #include "qemu-error.h"
18 #include "error.h"
19 #include <stdarg.h>
21 typedef struct QErrorStringTable {
22 const char *desc;
23 const char *error_fmt;
24 } QErrorStringTable;
26 typedef struct QError {
27 QObject_HEAD;
28 QDict *error;
29 Location loc;
30 int linenr;
31 const char *file;
32 const char *func;
33 const QErrorStringTable *entry;
34 } QError;
36 QError *qerror_new(void);
37 QError *qerror_from_info(const char *file, int linenr, const char *func,
38 const char *fmt, va_list *va) GCC_FMT_ATTR(4, 0);
39 QString *qerror_human(const QError *qerror);
40 void qerror_print(QError *qerror);
41 void qerror_report_internal(const char *file, int linenr, const char *func,
42 const char *fmt, ...) GCC_FMT_ATTR(4, 5);
43 void qerror_report_err(Error *err);
44 void assert_no_error(Error *err);
45 QString *qerror_format(const char *fmt, QDict *error);
46 #define qerror_report(fmt, ...) \
47 qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
48 QError *qobject_to_qerror(const QObject *obj);
51 * QError class list
52 * Please keep the definitions in alphabetical order.
53 * Use scripts/check-qerror.sh to check.
55 #define QERR_ADD_CLIENT_FAILED \
56 "{ 'class': 'AddClientFailed', 'data': {} }"
58 #define QERR_AMBIGUOUS_PATH \
59 "{ 'class': 'AmbiguousPath', 'data': { 'path': %s } }"
61 #define QERR_BAD_BUS_FOR_DEVICE \
62 "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
64 #define QERR_BASE_NOT_FOUND \
65 "{ 'class': 'BaseNotFound', 'data': { 'base': %s } }"
67 #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
68 "{ 'class': 'BlockFormatFeatureNotSupported', 'data': { 'format': %s, 'name': %s, 'feature': %s } }"
70 #define QERR_BUFFER_OVERRUN \
71 "{ 'class': 'BufferOverrun', 'data': {} }"
73 #define QERR_BUS_NO_HOTPLUG \
74 "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
76 #define QERR_BUS_NOT_FOUND \
77 "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
79 #define QERR_COMMAND_DISABLED \
80 "{ 'class': 'CommandDisabled', 'data': { 'name': %s } }"
82 #define QERR_COMMAND_NOT_FOUND \
83 "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
85 #define QERR_DEVICE_ENCRYPTED \
86 "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s, 'filename': %s } }"
88 #define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \
89 "{ 'class': 'DeviceFeatureBlocksMigration', 'data': { 'device': %s, 'feature': %s } }"
91 #define QERR_DEVICE_HAS_NO_MEDIUM \
92 "{ 'class': 'DeviceHasNoMedium', 'data': { 'device': %s } }"
94 #define QERR_DEVICE_INIT_FAILED \
95 "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
97 #define QERR_DEVICE_IN_USE \
98 "{ 'class': 'DeviceInUse', 'data': { 'device': %s } }"
100 #define QERR_DEVICE_IS_READ_ONLY \
101 "{ 'class': 'DeviceIsReadOnly', 'data': { 'device': %s } }"
103 #define QERR_DEVICE_LOCKED \
104 "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
106 #define QERR_DEVICE_MULTIPLE_BUSSES \
107 "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
109 #define QERR_DEVICE_NO_BUS \
110 "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
112 #define QERR_DEVICE_NO_HOTPLUG \
113 "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
115 #define QERR_DEVICE_NOT_ACTIVE \
116 "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
118 #define QERR_DEVICE_NOT_ENCRYPTED \
119 "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
121 #define QERR_DEVICE_NOT_FOUND \
122 "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
124 #define QERR_DEVICE_NOT_REMOVABLE \
125 "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
127 #define QERR_DUPLICATE_ID \
128 "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
130 #define QERR_FD_NOT_FOUND \
131 "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
133 #define QERR_FD_NOT_SUPPLIED \
134 "{ 'class': 'FdNotSupplied', 'data': {} }"
136 #define QERR_FEATURE_DISABLED \
137 "{ 'class': 'FeatureDisabled', 'data': { 'name': %s } }"
139 #define QERR_INVALID_BLOCK_FORMAT \
140 "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
142 #define QERR_INVALID_OPTION_GROUP \
143 "{ 'class': 'InvalidOptionGroup', 'data': { 'group': %s } }"
145 #define QERR_INVALID_PARAMETER \
146 "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
148 #define QERR_INVALID_PARAMETER_COMBINATION \
149 "{ 'class': 'InvalidParameterCombination', 'data': {} }"
151 #define QERR_INVALID_PARAMETER_TYPE \
152 "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
154 #define QERR_INVALID_PARAMETER_VALUE \
155 "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }"
157 #define QERR_INVALID_PASSWORD \
158 "{ 'class': 'InvalidPassword', 'data': {} }"
160 #define QERR_IO_ERROR \
161 "{ 'class': 'IOError', 'data': {} }"
163 #define QERR_JSON_PARSE_ERROR \
164 "{ 'class': 'JSONParseError', 'data': { 'message': %s } }"
166 #define QERR_JSON_PARSING \
167 "{ 'class': 'JSONParsing', 'data': {} }"
169 #define QERR_KVM_MISSING_CAP \
170 "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
172 #define QERR_MIGRATION_ACTIVE \
173 "{ 'class': 'MigrationActive', 'data': {} }"
175 #define QERR_MIGRATION_NOT_SUPPORTED \
176 "{ 'class': 'MigrationNotSupported', 'data': {'device': %s} }"
178 #define QERR_MIGRATION_EXPECTED \
179 "{ 'class': 'MigrationExpected', 'data': {} }"
181 #define QERR_MISSING_PARAMETER \
182 "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
184 #define QERR_NO_BUS_FOR_DEVICE \
185 "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
187 #define QERR_NOT_SUPPORTED \
188 "{ 'class': 'NotSupported', 'data': {} }"
190 #define QERR_OPEN_FILE_FAILED \
191 "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
193 #define QERR_PERMISSION_DENIED \
194 "{ 'class': 'PermissionDenied', 'data': {} }"
196 #define QERR_PROPERTY_NOT_FOUND \
197 "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
199 #define QERR_PROPERTY_VALUE_BAD \
200 "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
202 #define QERR_PROPERTY_VALUE_IN_USE \
203 "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
205 #define QERR_PROPERTY_VALUE_NOT_FOUND \
206 "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
208 #define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \
209 "{ 'class': 'PropertyValueNotPowerOf2', 'data': { " \
210 "'device': %s, 'property': %s, 'value': %"PRId64" } }"
212 #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
213 "{ 'class': 'PropertyValueOutOfRange', 'data': { 'device': %s, 'property': %s, 'value': %"PRId64", 'min': %"PRId64", 'max': %"PRId64" } }"
215 #define QERR_QGA_COMMAND_FAILED \
216 "{ 'class': 'QgaCommandFailed', 'data': { 'message': %s } }"
218 #define QERR_QGA_LOGGING_FAILED \
219 "{ 'class': 'QgaLoggingFailed', 'data': {} }"
221 #define QERR_QMP_BAD_INPUT_OBJECT \
222 "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
224 #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
225 "{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }"
227 #define QERR_QMP_EXTRA_MEMBER \
228 "{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }"
230 #define QERR_RESET_REQUIRED \
231 "{ 'class': 'ResetRequired', 'data': {} }"
233 #define QERR_SET_PASSWD_FAILED \
234 "{ 'class': 'SetPasswdFailed', 'data': {} }"
236 #define QERR_TOO_MANY_FILES \
237 "{ 'class': 'TooManyFiles', 'data': {} }"
239 #define QERR_UNDEFINED_ERROR \
240 "{ 'class': 'UndefinedError', 'data': {} }"
242 #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
243 "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
245 #define QERR_UNSUPPORTED \
246 "{ 'class': 'Unsupported', 'data': {} }"
248 #define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \
249 "{ 'class': 'VirtFSFeatureBlocksMigration', 'data': { 'path': %s, 'tag': %s } }"
251 #define QERR_VNC_SERVER_FAILED \
252 "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
254 #define QERR_SOCKET_CONNECT_IN_PROGRESS \
255 "{ 'class': 'SockConnectInprogress', 'data': {} }"
257 #define QERR_SOCKET_CONNECT_FAILED \
258 "{ 'class': 'SockConnectFailed', 'data': {} }"
260 #define QERR_SOCKET_LISTEN_FAILED \
261 "{ 'class': 'SockListenFailed', 'data': {} }"
263 #define QERR_SOCKET_BIND_FAILED \
264 "{ 'class': 'SockBindFailed', 'data': {} }"
266 #define QERR_SOCKET_CREATE_FAILED \
267 "{ 'class': 'SockCreateFailed', 'data': {} }"
269 #endif /* QERROR_H */