Merge commit '924f766af9be3ff036a419fc85ed740aa01f8eac' into upstream-merge
[qemu/qemu-dev-zwu.git] / qerror.h
blob16c830d8b75917aaafb57d8428b83962cca7d18b
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 <stdarg.h>
20 typedef struct QErrorStringTable {
21 const char *desc;
22 const char *error_fmt;
23 } QErrorStringTable;
25 typedef struct QError {
26 QObject_HEAD;
27 QDict *error;
28 Location loc;
29 int linenr;
30 const char *file;
31 const char *func;
32 const QErrorStringTable *entry;
33 } QError;
35 QError *qerror_new(void);
36 QError *qerror_from_info(const char *file, int linenr, const char *func,
37 const char *fmt, va_list *va) GCC_FMT_ATTR(4, 0);
38 QString *qerror_human(const QError *qerror);
39 void qerror_print(QError *qerror);
40 void qerror_report_internal(const char *file, int linenr, const char *func,
41 const char *fmt, ...) GCC_FMT_ATTR(4, 5);
42 QString *qerror_format(const char *fmt, QDict *error);
43 #define qerror_report(fmt, ...) \
44 qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
45 QError *qobject_to_qerror(const QObject *obj);
48 * QError class list
49 * Please keep the definitions in alphabetical order.
50 * Use "grep '^#define QERR_' qerror.h | sort -c" to check.
52 #define QERR_BAD_BUS_FOR_DEVICE \
53 "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
55 #define QERR_BUS_NOT_FOUND \
56 "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
58 #define QERR_BUS_NO_HOTPLUG \
59 "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
61 #define QERR_COMMAND_NOT_FOUND \
62 "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
64 #define QERR_DEVICE_ENCRYPTED \
65 "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s } }"
67 #define QERR_DEVICE_INIT_FAILED \
68 "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
70 #define QERR_DEVICE_IN_USE \
71 "{ 'class': 'DeviceInUse', 'data': { 'device': %s } }"
73 #define QERR_DEVICE_LOCKED \
74 "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
76 #define QERR_DEVICE_MULTIPLE_BUSSES \
77 "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
79 #define QERR_DEVICE_NOT_ACTIVE \
80 "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
82 #define QERR_DEVICE_NOT_ENCRYPTED \
83 "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
85 #define QERR_DEVICE_NOT_FOUND \
86 "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
88 #define QERR_DEVICE_NOT_REMOVABLE \
89 "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
91 #define QERR_DEVICE_NO_BUS \
92 "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
94 #define QERR_DEVICE_NO_HOTPLUG \
95 "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
97 #define QERR_DUPLICATE_ID \
98 "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
100 #define QERR_FD_NOT_FOUND \
101 "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
103 #define QERR_FD_NOT_SUPPLIED \
104 "{ 'class': 'FdNotSupplied', 'data': {} }"
106 #define QERR_INVALID_BLOCK_FORMAT \
107 "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
109 #define QERR_INVALID_PARAMETER \
110 "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
112 #define QERR_INVALID_PARAMETER_TYPE \
113 "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
115 #define QERR_INVALID_PARAMETER_VALUE \
116 "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }"
118 #define QERR_INVALID_PASSWORD \
119 "{ 'class': 'InvalidPassword', 'data': {} }"
121 #define QERR_JSON_PARSING \
122 "{ 'class': 'JSONParsing', 'data': {} }"
124 #define QERR_JSON_PARSE_ERROR \
125 "{ 'class': 'JSONParseError', 'data': { 'message': %s } }"
127 #define QERR_KVM_MISSING_CAP \
128 "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
130 #define QERR_MIGRATION_EXPECTED \
131 "{ 'class': 'MigrationExpected', 'data': {} }"
133 #define QERR_MISSING_PARAMETER \
134 "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
136 #define QERR_NO_BUS_FOR_DEVICE \
137 "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
139 #define QERR_OPEN_FILE_FAILED \
140 "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
142 #define QERR_PROPERTY_NOT_FOUND \
143 "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
145 #define QERR_PROPERTY_VALUE_BAD \
146 "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
148 #define QERR_PROPERTY_VALUE_IN_USE \
149 "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
151 #define QERR_PROPERTY_VALUE_NOT_FOUND \
152 "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
154 #define QERR_QMP_BAD_INPUT_OBJECT \
155 "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
157 #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
158 "{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }"
160 #define QERR_QMP_EXTRA_MEMBER \
161 "{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }"
163 #define QERR_SET_PASSWD_FAILED \
164 "{ 'class': 'SetPasswdFailed', 'data': {} }"
166 #define QERR_TOO_MANY_FILES \
167 "{ 'class': 'TooManyFiles', 'data': {} }"
169 #define QERR_UNDEFINED_ERROR \
170 "{ 'class': 'UndefinedError', 'data': {} }"
172 #define QERR_UNSUPPORTED \
173 "{ 'class': 'Unsupported', 'data': {} }"
175 #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
176 "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
178 #define QERR_VNC_SERVER_FAILED \
179 "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
181 #define QERR_FEATURE_DISABLED \
182 "{ 'class': 'FeatureDisabled', 'data': { 'name': %s } }"
184 #endif /* QERROR_H */