]> git.proxmox.com Git - qemu.git/blame - qerror.h
monitor: convert do_device_del() to QObject, QError
[qemu.git] / qerror.h
CommitLineData
9f9daf9a
LC
1/*
2 * QError header file.
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"
9f9daf9a
LC
18#include <stdarg.h>
19
20typedef struct QErrorStringTable {
21 const char *desc;
22 const char *error_fmt;
23} QErrorStringTable;
24
25typedef struct QError {
26 QObject_HEAD;
27 QDict *error;
827b0813 28 Location loc;
9f9daf9a
LC
29 int linenr;
30 const char *file;
31 const char *func;
32 const QErrorStringTable *entry;
33} QError;
34
35QError *qerror_new(void);
36QError *qerror_from_info(const char *file, int linenr, const char *func,
37 const char *fmt, va_list *va);
77e595e7 38QString *qerror_human(const QError *qerror);
827b0813 39void qerror_print(QError *qerror);
0167f772
MA
40void 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__)
9f9daf9a
LC
45QError *qobject_to_qerror(const QObject *obj);
46
47/*
48 * QError class list
49 */
56e9f563
MA
50#define QERR_BAD_BUS_FOR_DEVICE \
51 "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
52
7bbd8237
MA
53#define QERR_BUS_NOT_FOUND \
54 "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
55
8eae73b5
MA
56#define QERR_BUS_NO_HOTPLUG \
57 "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
58
4b9d4683 59#define QERR_COMMAND_NOT_FOUND \
e16a1812 60 "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
4b9d4683 61
0df37c41 62#define QERR_DEVICE_ENCRYPTED \
e16a1812 63 "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s } }"
9f9daf9a 64
25b28f01
SH
65#define QERR_DEVICE_NOT_ENCRYPTED \
66 "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
67
4d9a1a15
MA
68#define QERR_DEVICE_INIT_FAILED \
69 "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
70
fc5469d8 71#define QERR_DEVICE_LOCKED \
b0868380
MA
72 "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
73
1ae78718
MA
74#define QERR_DEVICE_MULTIPLE_BUSSES \
75 "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
76
055f6122 77#define QERR_DEVICE_NOT_ACTIVE \
e16a1812
MA
78 "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
79
80#define QERR_DEVICE_NOT_FOUND \
81 "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
055f6122 82
5cfe0264
MA
83#define QERR_DEVICE_NOT_REMOVABLE \
84 "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
85
07574baf
MA
86#define QERR_DEVICE_NO_BUS \
87 "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
88
c7c338c4 89#define QERR_FD_NOT_FOUND \
bd9d3064 90 "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
c7c338c4 91
41471a23 92#define QERR_FD_NOT_SUPPLIED \
bd9d3064 93 "{ 'class': 'FdNotSupplied', 'data': {} }"
41471a23 94
17901e75
MA
95#define QERR_INVALID_BLOCK_FORMAT \
96 "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
97
7a046f5f 98#define QERR_INVALID_PARAMETER \
bd9d3064 99 "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
7a046f5f 100
4b9d4683 101#define QERR_INVALID_PARAMETER_TYPE \
e16a1812 102 "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
4b9d4683 103
f6d855c5 104#define QERR_INVALID_PASSWORD \
e16a1812
MA
105 "{ 'class': 'InvalidPassword', 'data': {} }"
106
107#define QERR_JSON_PARSING \
108 "{ 'class': 'JSONParsing', 'data': {} }"
f6d855c5 109
82a60711 110#define QERR_KVM_MISSING_CAP \
e16a1812 111 "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
82a60711 112
4b9d4683 113#define QERR_MISSING_PARAMETER \
e16a1812 114 "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
4b9d4683 115
fab5767f
MA
116#define QERR_NO_BUS_FOR_DEVICE \
117 "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
118
fc5469d8
MA
119#define QERR_OPEN_FILE_FAILED \
120 "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
121
c58a35f8
MA
122#define QERR_PROPERTY_NOT_FOUND \
123 "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
124
06b4a703
MA
125#define QERR_PROPERTY_VALUE_BAD \
126 "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
127
9c5eff95
MA
128#define QERR_PROPERTY_VALUE_IN_USE \
129 "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
130
84745d68
MA
131#define QERR_PROPERTY_VALUE_NOT_FOUND \
132 "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
133
4b9d4683 134#define QERR_QMP_BAD_INPUT_OBJECT \
e16a1812 135 "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
4b9d4683 136
7a84cb23
MA
137#define QERR_SET_PASSWD_FAILED \
138 "{ 'class': 'SetPasswdFailed', 'data': {} }"
139
a488be27 140#define QERR_TOO_MANY_FILES \
bd9d3064 141 "{ 'class': 'TooManyFiles', 'data': {} }"
a488be27 142
fc5469d8
MA
143#define QERR_UNDEFINED_ERROR \
144 "{ 'class': 'UndefinedError', 'data': {} }"
145
a6906e31
MA
146#define QERR_VNC_SERVER_FAILED \
147 "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
148
9f9daf9a 149#endif /* QERROR_H */