Ask for read-write permissions when opening files
[qemu.git] / qerror.h
blob57c5b9749b5f7e44fb859605ecaa1eb66f47e377
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 <stdarg.h>
19 typedef struct QErrorStringTable {
20 const char *desc;
21 const char *error_fmt;
22 } QErrorStringTable;
24 typedef struct QError {
25 QObject_HEAD;
26 QDict *error;
27 int linenr;
28 const char *file;
29 const char *func;
30 const QErrorStringTable *entry;
31 } QError;
33 QError *qerror_new(void);
34 QError *qerror_from_info(const char *file, int linenr, const char *func,
35 const char *fmt, va_list *va);
36 QString *qerror_human(const QError *qerror);
37 void qerror_print(const QError *qerror);
38 QError *qobject_to_qerror(const QObject *obj);
41 * QError class list
43 #define QERR_COMMAND_NOT_FOUND \
44 "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
46 #define QERR_DEVICE_ENCRYPTED \
47 "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s } }"
49 #define QERR_DEVICE_LOCKED \
50 "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
52 #define QERR_DEVICE_NOT_ACTIVE \
53 "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
55 #define QERR_DEVICE_NOT_FOUND \
56 "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
58 #define QERR_DEVICE_NOT_REMOVABLE \
59 "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
61 #define QERR_FD_NOT_FOUND \
62 "{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
64 #define QERR_FD_NOT_SUPPLIED \
65 "{ 'class': 'FdNotSupplied', 'data': {} }"
67 #define QERR_OPEN_FILE_FAILED \
68 "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
70 #define QERR_INVALID_BLOCK_FORMAT \
71 "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
73 #define QERR_INVALID_CPU_INDEX \
74 "{ 'class': 'InvalidCPUIndex', 'data': {} }"
76 #define QERR_INVALID_PARAMETER \
77 "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
79 #define QERR_INVALID_PARAMETER_TYPE \
80 "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
82 #define QERR_INVALID_PASSWORD \
83 "{ 'class': 'InvalidPassword', 'data': {} }"
85 #define QERR_JSON_PARSING \
86 "{ 'class': 'JSONParsing', 'data': {} }"
88 #define QERR_KVM_MISSING_CAP \
89 "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
91 #define QERR_MISSING_PARAMETER \
92 "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
94 #define QERR_QMP_BAD_INPUT_OBJECT \
95 "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
97 #define QERR_SET_PASSWD_FAILED \
98 "{ 'class': 'SetPasswdFailed', 'data': {} }"
100 #define QERR_UNDEFINED_ERROR \
101 "{ 'class': 'UndefinedError', 'data': {} }"
103 #define QERR_TOO_MANY_FILES \
104 "{ 'class': 'TooManyFiles', 'data': {} }"
106 #define QERR_VNC_SERVER_FAILED \
107 "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
109 #endif /* QERROR_H */