Statistics
| Branch: | Revision:

root / qerror.h @ 0167f772

History | View | Annotate | Download (4.5 kB)

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"
16
#include "qstring.h"
17
#include "qemu-error.h"
18
#include <stdarg.h>
19

    
20
typedef struct QErrorStringTable {
21
    const char *desc;
22
    const char *error_fmt;
23
} QErrorStringTable;
24

    
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;
34

    
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);
46

    
47
/*
48
 * QError class list
49
 */
50
#define QERR_BAD_BUS_FOR_DEVICE \
51
    "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
52

    
53
#define QERR_BUS_NOT_FOUND \
54
    "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
55

    
56
#define QERR_BUS_NO_HOTPLUG \
57
    "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
58

    
59
#define QERR_COMMAND_NOT_FOUND \
60
    "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
61

    
62
#define QERR_DEVICE_ENCRYPTED \
63
    "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s } }"
64

    
65
#define QERR_DEVICE_NOT_ENCRYPTED \
66
    "{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
67

    
68
#define QERR_DEVICE_INIT_FAILED \
69
    "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
70

    
71
#define QERR_DEVICE_LOCKED \
72
    "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
73

    
74
#define QERR_DEVICE_MULTIPLE_BUSSES \
75
    "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
76

    
77
#define QERR_DEVICE_NOT_ACTIVE \
78
    "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
79

    
80
#define QERR_DEVICE_NOT_FOUND \
81
    "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
82

    
83
#define QERR_DEVICE_NOT_REMOVABLE \
84
    "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
85

    
86
#define QERR_DEVICE_NO_BUS \
87
    "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
88

    
89
#define QERR_FD_NOT_FOUND \
90
    "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
91

    
92
#define QERR_FD_NOT_SUPPLIED \
93
    "{ 'class': 'FdNotSupplied', 'data': {} }"
94

    
95
#define QERR_INVALID_BLOCK_FORMAT \
96
    "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
97

    
98
#define QERR_INVALID_PARAMETER \
99
    "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
100

    
101
#define QERR_INVALID_PARAMETER_TYPE \
102
    "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
103

    
104
#define QERR_INVALID_PASSWORD \
105
    "{ 'class': 'InvalidPassword', 'data': {} }"
106

    
107
#define QERR_JSON_PARSING \
108
    "{ 'class': 'JSONParsing', 'data': {} }"
109

    
110
#define QERR_KVM_MISSING_CAP \
111
    "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
112

    
113
#define QERR_MISSING_PARAMETER \
114
    "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
115

    
116
#define QERR_NO_BUS_FOR_DEVICE \
117
    "{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
118

    
119
#define QERR_OPEN_FILE_FAILED \
120
    "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
121

    
122
#define QERR_PROPERTY_NOT_FOUND \
123
    "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
124

    
125
#define QERR_PROPERTY_VALUE_BAD \
126
    "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
127

    
128
#define QERR_PROPERTY_VALUE_IN_USE \
129
    "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
130

    
131
#define QERR_PROPERTY_VALUE_NOT_FOUND \
132
    "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
133

    
134
#define QERR_QMP_BAD_INPUT_OBJECT \
135
    "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
136

    
137
#define QERR_SET_PASSWD_FAILED \
138
    "{ 'class': 'SetPasswdFailed', 'data': {} }"
139

    
140
#define QERR_TOO_MANY_FILES \
141
    "{ 'class': 'TooManyFiles', 'data': {} }"
142

    
143
#define QERR_UNDEFINED_ERROR \
144
    "{ 'class': 'UndefinedError', 'data': {} }"
145

    
146
#define QERR_VNC_SERVER_FAILED \
147
    "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
148

    
149
#endif /* QERROR_H */