Add a missing #include for FreeBSD hosts
[qemu.git] / qerror.h
blobdd298d4777a050803fec188988e8c46acf6edea7
1 /*
2 * QError header file.
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);
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, ...)
42 __attribute__ ((format(printf, 4, 5)));
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
50 #define QERR_BAD_BUS_FOR_DEVICE \
51 "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
53 #define QERR_BUS_NOT_FOUND \
54 "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
56 #define QERR_BUS_NO_HOTPLUG \
57 "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
59 #define QERR_COMMAND_NOT_FOUND \
60 "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
62 #define QERR_DEVICE_ENCRYPTED \
63 "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s } }"
65 #define QERR_DEVICE_NOT_ENCRYPTED \
66 "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
68 #define QERR_DEVICE_INIT_FAILED \
69 "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
71 #define QERR_DEVICE_LOCKED \
72 "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
74 #define QERR_DEVICE_MULTIPLE_BUSSES \
75 "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
77 #define QERR_DEVICE_NOT_ACTIVE \
78 "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
80 #define QERR_DEVICE_NOT_FOUND \
81 "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
83 #define QERR_DEVICE_NOT_REMOVABLE \
84 "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
86 #define QERR_DEVICE_NO_BUS \
87 "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
89 #define QERR_FD_NOT_FOUND \
90 "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
92 #define QERR_FD_NOT_SUPPLIED \
93 "{ 'class': 'FdNotSupplied', 'data': {} }"
95 #define QERR_INVALID_BLOCK_FORMAT \
96 "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
98 #define QERR_INVALID_PARAMETER \
99 "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
101 #define QERR_INVALID_PARAMETER_TYPE \
102 "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
104 #define QERR_INVALID_PASSWORD \
105 "{ 'class': 'InvalidPassword', 'data': {} }"
107 #define QERR_JSON_PARSING \
108 "{ 'class': 'JSONParsing', 'data': {} }"
110 #define QERR_KVM_MISSING_CAP \
111 "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
113 #define QERR_MISSING_PARAMETER \
114 "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
116 #define QERR_NO_BUS_FOR_DEVICE \
117 "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
119 #define QERR_OPEN_FILE_FAILED \
120 "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
122 #define QERR_PROPERTY_NOT_FOUND \
123 "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
125 #define QERR_PROPERTY_VALUE_BAD \
126 "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
128 #define QERR_PROPERTY_VALUE_IN_USE \
129 "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
131 #define QERR_PROPERTY_VALUE_NOT_FOUND \
132 "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
134 #define QERR_QMP_BAD_INPUT_OBJECT \
135 "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
137 #define QERR_SET_PASSWD_FAILED \
138 "{ 'class': 'SetPasswdFailed', 'data': {} }"
140 #define QERR_TOO_MANY_FILES \
141 "{ 'class': 'TooManyFiles', 'data': {} }"
143 #define QERR_UNDEFINED_ERROR \
144 "{ 'class': 'UndefinedError', 'data': {} }"
146 #define QERR_VNC_SERVER_FAILED \
147 "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
149 #endif /* QERROR_H */