]> git.proxmox.com Git - qemu.git/blame - qerror.h
error: drop error_get_qobject()/error_set_qobject()
[qemu.git] / qerror.h
CommitLineData
9f9daf9a 1/*
41836a9f 2 * QError Module
9f9daf9a
LC
3 *
4 * Copyright (C) 2009 Red Hat Inc.
5 *
6 * Authors:
7 * Luiz Capitulino <lcapitulino@redhat.com>
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"
13f59ae8 19#include "qapi-types.h"
9f9daf9a
LC
20#include <stdarg.h>
21
22typedef struct QErrorStringTable {
13f59ae8 23 ErrorClass err_class;
9f9daf9a 24 const char *error_fmt;
85465051 25 const char *desc;
9f9daf9a
LC
26} QErrorStringTable;
27
28typedef struct QError {
29 QObject_HEAD;
30 QDict *error;
827b0813 31 Location loc;
18da7c0f 32 char *err_msg;
13f59ae8 33 ErrorClass err_class;
9f9daf9a
LC
34} QError;
35
77e595e7 36QString *qerror_human(const QError *qerror);
13f59ae8 37void qerror_report(ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
2a82d936 38void qerror_report_err(Error *err);
59f971d4 39void assert_no_error(Error *err);
2b38cf2e 40char *qerror_format(const char *fmt, QDict *error);
9f9daf9a
LC
41
42/*
43 * QError class list
9d494c4b 44 * Please keep the definitions in alphabetical order.
9737383b 45 * Use scripts/check-qerror.sh to check.
9f9daf9a 46 */
c1303596 47#define QERR_ADD_CLIENT_FAILED \
0f32cf6a 48 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'AddClientFailed', 'data': {} }"
c1303596 49
11e35bfd 50#define QERR_AMBIGUOUS_PATH \
0f32cf6a 51 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'AmbiguousPath', 'data': { 'path': %s } }"
11e35bfd 52
56e9f563 53#define QERR_BAD_BUS_FOR_DEVICE \
0f32cf6a 54 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
56e9f563 55
019b8cbf 56#define QERR_BASE_NOT_FOUND \
0f32cf6a 57 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BaseNotFound', 'data': { 'base': %s } }"
019b8cbf 58
1ed520c6 59#define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
0f32cf6a 60 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BlockFormatFeatureNotSupported', 'data': { 'format': %s, 'name': %s, 'feature': %s } }"
1ed520c6 61
c1303596 62#define QERR_BUFFER_OVERRUN \
0f32cf6a 63 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BufferOverrun', 'data': {} }"
7bbd8237 64
8eae73b5 65#define QERR_BUS_NO_HOTPLUG \
0f32cf6a 66 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
8eae73b5 67
c1303596 68#define QERR_BUS_NOT_FOUND \
0f32cf6a 69 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
4b9d4683 70
abd6cf6d 71#define QERR_COMMAND_DISABLED \
0f32cf6a 72 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'CommandDisabled', 'data': { 'name': %s } }"
abd6cf6d 73
c1303596 74#define QERR_COMMAND_NOT_FOUND \
0f32cf6a 75 ERROR_CLASS_COMMAND_NOT_FOUND, "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
c1303596 76
0df37c41 77#define QERR_DEVICE_ENCRYPTED \
0f32cf6a 78 ERROR_CLASS_DEVICE_ENCRYPTED, "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s, 'filename': %s } }"
9f9daf9a 79
c1303596 80#define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \
0f32cf6a 81 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceFeatureBlocksMigration', 'data': { 'device': %s, 'feature': %s } }"
c1303596 82
939a1cc3 83#define QERR_DEVICE_HAS_NO_MEDIUM \
0f32cf6a 84 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceHasNoMedium', 'data': { 'device': %s } }"
939a1cc3 85
4d9a1a15 86#define QERR_DEVICE_INIT_FAILED \
0f32cf6a 87 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
4d9a1a15 88
5124eb59 89#define QERR_DEVICE_IN_USE \
0f32cf6a 90 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceInUse', 'data': { 'device': %s } }"
5124eb59 91
939a1cc3 92#define QERR_DEVICE_IS_READ_ONLY \
0f32cf6a 93 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceIsReadOnly', 'data': { 'device': %s } }"
939a1cc3 94
fc5469d8 95#define QERR_DEVICE_LOCKED \
0f32cf6a 96 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
b0868380 97
1ae78718 98#define QERR_DEVICE_MULTIPLE_BUSSES \
0f32cf6a 99 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
1ae78718 100
c1303596 101#define QERR_DEVICE_NO_BUS \
0f32cf6a 102 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
c1303596
SH
103
104#define QERR_DEVICE_NO_HOTPLUG \
0f32cf6a 105 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
c1303596 106
055f6122 107#define QERR_DEVICE_NOT_ACTIVE \
0f32cf6a 108 ERROR_CLASS_DEVICE_NOT_ACTIVE, "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
e16a1812 109
9d494c4b 110#define QERR_DEVICE_NOT_ENCRYPTED \
0f32cf6a 111 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
9d494c4b 112
e16a1812 113#define QERR_DEVICE_NOT_FOUND \
0f32cf6a 114 ERROR_CLASS_DEVICE_NOT_FOUND, "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
055f6122 115
5cfe0264 116#define QERR_DEVICE_NOT_REMOVABLE \
0f32cf6a 117 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
5cfe0264 118
7bc84017 119#define QERR_DUPLICATE_ID \
0f32cf6a 120 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
7bc84017 121
c7c338c4 122#define QERR_FD_NOT_FOUND \
0f32cf6a 123 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
c7c338c4 124
41471a23 125#define QERR_FD_NOT_SUPPLIED \
0f32cf6a 126 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FdNotSupplied', 'data': {} }"
41471a23 127
c1303596 128#define QERR_FEATURE_DISABLED \
0f32cf6a 129 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'FeatureDisabled', 'data': { 'name': %s } }"
c1303596 130
17901e75 131#define QERR_INVALID_BLOCK_FORMAT \
0f32cf6a 132 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
17901e75 133
8ff15d4a 134#define QERR_INVALID_OPTION_GROUP \
0f32cf6a 135 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidOptionGroup', 'data': { 'group': %s } }"
8ff15d4a 136
7a046f5f 137#define QERR_INVALID_PARAMETER \
0f32cf6a 138 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
7a046f5f 139
c1303596 140#define QERR_INVALID_PARAMETER_COMBINATION \
0f32cf6a 141 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterCombination', 'data': {} }"
c1303596 142
4b9d4683 143#define QERR_INVALID_PARAMETER_TYPE \
0f32cf6a 144 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
4b9d4683 145
985a3e52 146#define QERR_INVALID_PARAMETER_VALUE \
0f32cf6a 147 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }"
985a3e52 148
f6d855c5 149#define QERR_INVALID_PASSWORD \
0f32cf6a 150 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'InvalidPassword', 'data': {} }"
e16a1812 151
58898873 152#define QERR_IO_ERROR \
0f32cf6a 153 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'IOError', 'data': {} }"
58898873 154
ef749d07 155#define QERR_JSON_PARSE_ERROR \
0f32cf6a 156 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'JSONParseError', 'data': { 'message': %s } }"
ef749d07 157
c1303596 158#define QERR_JSON_PARSING \
0f32cf6a 159 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'JSONParsing', 'data': {} }"
c40cc0a0 160
82a60711 161#define QERR_KVM_MISSING_CAP \
0f32cf6a 162 ERROR_CLASS_K_V_M_MISSING_CAP, "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
82a60711 163
a4acc064 164#define QERR_MIGRATION_ACTIVE \
0f32cf6a 165 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MigrationActive', 'data': {} }"
a4acc064
LC
166
167#define QERR_MIGRATION_NOT_SUPPORTED \
0f32cf6a 168 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MigrationNotSupported', 'data': {'device': %s} }"
a4acc064 169
8e84865e 170#define QERR_MIGRATION_EXPECTED \
0f32cf6a 171 ERROR_CLASS_MIGRATION_EXPECTED, "{ 'class': 'MigrationExpected', 'data': {} }"
8e84865e 172
4b9d4683 173#define QERR_MISSING_PARAMETER \
0f32cf6a 174 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
4b9d4683 175
fab5767f 176#define QERR_NO_BUS_FOR_DEVICE \
0f32cf6a 177 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
fab5767f 178
12bd451f 179#define QERR_NOT_SUPPORTED \
0f32cf6a 180 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'NotSupported', 'data': {} }"
12bd451f 181
fc5469d8 182#define QERR_OPEN_FILE_FAILED \
0f32cf6a 183 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
fc5469d8 184
44677ded 185#define QERR_PERMISSION_DENIED \
0f32cf6a 186 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PermissionDenied', 'data': {} }"
44677ded 187
c58a35f8 188#define QERR_PROPERTY_NOT_FOUND \
0f32cf6a 189 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
c58a35f8 190
06b4a703 191#define QERR_PROPERTY_VALUE_BAD \
0f32cf6a 192 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
06b4a703 193
9c5eff95 194#define QERR_PROPERTY_VALUE_IN_USE \
0f32cf6a 195 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
9c5eff95 196
84745d68 197#define QERR_PROPERTY_VALUE_NOT_FOUND \
0f32cf6a 198 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
84745d68 199
02fda01c 200#define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \
0f32cf6a 201 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueNotPowerOf2', 'data': { " \
02fda01c
SH
202 "'device': %s, 'property': %s, 'value': %"PRId64" } }"
203
6aced82c 204#define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
0f32cf6a 205 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'PropertyValueOutOfRange', 'data': { 'device': %s, 'property': %s, 'value': %"PRId64", 'min': %"PRId64", 'max': %"PRId64" } }"
6aced82c 206
c1303596 207#define QERR_QGA_COMMAND_FAILED \
0f32cf6a 208 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QgaCommandFailed', 'data': { 'message': %s } }"
c1303596
SH
209
210#define QERR_QGA_LOGGING_FAILED \
0f32cf6a 211 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QgaLoggingFailed', 'data': {} }"
c1303596 212
4b9d4683 213#define QERR_QMP_BAD_INPUT_OBJECT \
0f32cf6a 214 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
4b9d4683 215
7dfb6123 216#define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
0f32cf6a 217 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }"
7dfb6123 218
60d76d7b 219#define QERR_QMP_EXTRA_MEMBER \
0f32cf6a 220 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }"
60d76d7b 221
6667b23f 222#define QERR_RESET_REQUIRED \
0f32cf6a 223 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'ResetRequired', 'data': {} }"
6667b23f 224
7a84cb23 225#define QERR_SET_PASSWD_FAILED \
0f32cf6a 226 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SetPasswdFailed', 'data': {} }"
7a84cb23 227
a488be27 228#define QERR_TOO_MANY_FILES \
0f32cf6a 229 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'TooManyFiles', 'data': {} }"
a488be27 230
fc5469d8 231#define QERR_UNDEFINED_ERROR \
0f32cf6a 232 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'UndefinedError', 'data': {} }"
fc5469d8 233
f54e3641 234#define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
0f32cf6a 235 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
f54e3641 236
c1303596 237#define QERR_UNSUPPORTED \
0f32cf6a 238 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'Unsupported', 'data': {} }"
c1303596 239
e9a0152b 240#define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \
0f32cf6a 241 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'VirtFSFeatureBlocksMigration', 'data': { 'path': %s, 'tag': %s } }"
e9a0152b 242
a6906e31 243#define QERR_VNC_SERVER_FAILED \
0f32cf6a 244 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
a6906e31 245
aed3d11d 246#define QERR_SOCKET_CONNECT_FAILED \
0f32cf6a 247 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockConnectFailed', 'data': {} }"
aed3d11d
AK
248
249#define QERR_SOCKET_LISTEN_FAILED \
0f32cf6a 250 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockListenFailed', 'data': {} }"
aed3d11d
AK
251
252#define QERR_SOCKET_BIND_FAILED \
0f32cf6a 253 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockBindFailed', 'data': {} }"
aed3d11d
AK
254
255#define QERR_SOCKET_CREATE_FAILED \
0f32cf6a 256 ERROR_CLASS_GENERIC_ERROR, "{ 'class': 'SockCreateFailed', 'data': {} }"
aed3d11d 257
9f9daf9a 258#endif /* QERROR_H */