2009-11-19 04:05:30 +03:00
|
|
|
/*
|
2010-05-12 23:34:42 +04:00
|
|
|
* QError Module
|
2009-11-19 04:05:30 +03:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
|
|
|
* See the COPYING.LIB file in the top-level directory.
|
|
|
|
*/
|
|
|
|
#ifndef QERROR_H
|
|
|
|
#define QERROR_H
|
|
|
|
|
|
|
|
#include "qdict.h"
|
2009-12-07 23:37:16 +03:00
|
|
|
#include "qstring.h"
|
2010-02-18 21:46:49 +03:00
|
|
|
#include "qemu-error.h"
|
2009-11-19 04:05:30 +03:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
typedef struct QErrorStringTable {
|
|
|
|
const char *desc;
|
|
|
|
const char *error_fmt;
|
|
|
|
} QErrorStringTable;
|
|
|
|
|
|
|
|
typedef struct QError {
|
|
|
|
QObject_HEAD;
|
|
|
|
QDict *error;
|
2010-02-18 21:46:49 +03:00
|
|
|
Location loc;
|
2009-11-19 04:05:30 +03:00
|
|
|
int linenr;
|
|
|
|
const char *file;
|
|
|
|
const char *func;
|
|
|
|
const QErrorStringTable *entry;
|
|
|
|
} QError;
|
|
|
|
|
|
|
|
QError *qerror_new(void);
|
|
|
|
QError *qerror_from_info(const char *file, int linenr, const char *func,
|
2010-09-23 23:28:05 +04:00
|
|
|
const char *fmt, va_list *va) GCC_FMT_ATTR(4, 0);
|
2009-12-07 23:37:16 +03:00
|
|
|
QString *qerror_human(const QError *qerror);
|
2010-02-18 21:46:49 +03:00
|
|
|
void qerror_print(QError *qerror);
|
2010-03-22 12:29:05 +03:00
|
|
|
void qerror_report_internal(const char *file, int linenr, const char *func,
|
2010-09-23 23:28:03 +04:00
|
|
|
const char *fmt, ...) GCC_FMT_ATTR(4, 5);
|
2010-03-22 12:29:05 +03:00
|
|
|
#define qerror_report(fmt, ...) \
|
|
|
|
qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
|
2009-11-19 04:05:30 +03:00
|
|
|
QError *qobject_to_qerror(const QObject *obj);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* QError class list
|
2010-03-25 19:22:30 +03:00
|
|
|
* Please keep the definitions in alphabetical order.
|
|
|
|
* Use "grep '^#define QERR_' qerror.h | sort -c" to check.
|
2009-11-19 04:05:30 +03:00
|
|
|
*/
|
2010-02-19 21:52:45 +03:00
|
|
|
#define QERR_BAD_BUS_FOR_DEVICE \
|
|
|
|
"{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
|
|
|
|
|
2010-02-19 20:05:39 +03:00
|
|
|
#define QERR_BUS_NOT_FOUND \
|
|
|
|
"{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
|
|
|
|
|
2010-02-19 21:53:36 +03:00
|
|
|
#define QERR_BUS_NO_HOTPLUG \
|
|
|
|
"{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }"
|
|
|
|
|
2009-11-27 03:58:57 +03:00
|
|
|
#define QERR_COMMAND_NOT_FOUND \
|
2009-12-07 23:37:02 +03:00
|
|
|
"{ 'class': 'CommandNotFound', 'data': { 'name': %s } }"
|
2009-11-27 03:58:57 +03:00
|
|
|
|
2009-12-07 23:36:59 +03:00
|
|
|
#define QERR_DEVICE_ENCRYPTED \
|
2009-12-07 23:37:02 +03:00
|
|
|
"{ 'class': 'DeviceEncrypted', 'data': { 'device': %s } }"
|
2009-11-19 04:05:30 +03:00
|
|
|
|
2010-02-19 21:53:54 +03:00
|
|
|
#define QERR_DEVICE_INIT_FAILED \
|
|
|
|
"{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }"
|
|
|
|
|
2010-03-25 19:22:39 +03:00
|
|
|
#define QERR_DEVICE_IN_USE \
|
|
|
|
"{ 'class': 'DeviceInUse', 'data': { 'device': %s } }"
|
|
|
|
|
2010-02-19 19:42:46 +03:00
|
|
|
#define QERR_DEVICE_LOCKED \
|
2009-12-07 23:37:03 +03:00
|
|
|
"{ 'class': 'DeviceLocked', 'data': { 'device': %s } }"
|
|
|
|
|
2010-02-19 20:05:59 +03:00
|
|
|
#define QERR_DEVICE_MULTIPLE_BUSSES \
|
|
|
|
"{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }"
|
|
|
|
|
2009-11-19 04:05:34 +03:00
|
|
|
#define QERR_DEVICE_NOT_ACTIVE \
|
2009-12-07 23:37:02 +03:00
|
|
|
"{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }"
|
|
|
|
|
2010-03-25 19:22:30 +03:00
|
|
|
#define QERR_DEVICE_NOT_ENCRYPTED \
|
|
|
|
"{ 'class': 'DeviceNotEncrypted', 'data': { 'device': %s } }"
|
|
|
|
|
2009-12-07 23:37:02 +03:00
|
|
|
#define QERR_DEVICE_NOT_FOUND \
|
|
|
|
"{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }"
|
2009-11-19 04:05:34 +03:00
|
|
|
|
2009-12-07 23:37:04 +03:00
|
|
|
#define QERR_DEVICE_NOT_REMOVABLE \
|
|
|
|
"{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }"
|
|
|
|
|
2010-02-19 20:06:18 +03:00
|
|
|
#define QERR_DEVICE_NO_BUS \
|
|
|
|
"{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
|
|
|
|
|
2011-01-06 17:14:37 +03:00
|
|
|
#define QERR_DEVICE_NO_HOTPLUG \
|
|
|
|
"{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
|
|
|
|
|
2010-03-25 19:22:31 +03:00
|
|
|
#define QERR_DUPLICATE_ID \
|
|
|
|
"{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
|
|
|
|
|
2009-12-07 23:37:10 +03:00
|
|
|
#define QERR_FD_NOT_FOUND \
|
2009-12-08 15:33:54 +03:00
|
|
|
"{ 'class': 'FdNotFound', 'data': { 'name': %s } }"
|
2009-12-07 23:37:10 +03:00
|
|
|
|
2009-12-07 23:37:12 +03:00
|
|
|
#define QERR_FD_NOT_SUPPLIED \
|
2009-12-08 15:33:54 +03:00
|
|
|
"{ 'class': 'FdNotSupplied', 'data': {} }"
|
2009-12-07 23:37:12 +03:00
|
|
|
|
2009-12-07 23:37:06 +03:00
|
|
|
#define QERR_INVALID_BLOCK_FORMAT \
|
|
|
|
"{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }"
|
|
|
|
|
2009-12-07 23:37:13 +03:00
|
|
|
#define QERR_INVALID_PARAMETER \
|
2009-12-08 15:33:54 +03:00
|
|
|
"{ 'class': 'InvalidParameter', 'data': { 'name': %s } }"
|
2009-12-07 23:37:13 +03:00
|
|
|
|
2009-11-27 03:58:57 +03:00
|
|
|
#define QERR_INVALID_PARAMETER_TYPE \
|
2009-12-07 23:37:02 +03:00
|
|
|
"{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }"
|
2009-11-27 03:58:57 +03:00
|
|
|
|
2010-03-25 19:22:33 +03:00
|
|
|
#define QERR_INVALID_PARAMETER_VALUE \
|
|
|
|
"{ 'class': 'InvalidParameterValue', 'data': { 'name': %s, 'expected': %s } }"
|
|
|
|
|
2009-12-04 20:24:08 +03:00
|
|
|
#define QERR_INVALID_PASSWORD \
|
2009-12-07 23:37:02 +03:00
|
|
|
"{ 'class': 'InvalidPassword', 'data': {} }"
|
|
|
|
|
|
|
|
#define QERR_JSON_PARSING \
|
|
|
|
"{ 'class': 'JSONParsing', 'data': {} }"
|
2009-12-04 20:24:08 +03:00
|
|
|
|
2009-11-19 04:05:35 +03:00
|
|
|
#define QERR_KVM_MISSING_CAP \
|
2009-12-07 23:37:02 +03:00
|
|
|
"{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
|
2009-11-19 04:05:35 +03:00
|
|
|
|
2010-07-27 14:19:19 +04:00
|
|
|
#define QERR_MIGRATION_EXPECTED \
|
|
|
|
"{ 'class': 'MigrationExpected', 'data': {} }"
|
|
|
|
|
2009-11-27 03:58:57 +03:00
|
|
|
#define QERR_MISSING_PARAMETER \
|
2009-12-07 23:37:02 +03:00
|
|
|
"{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
|
2009-11-27 03:58:57 +03:00
|
|
|
|
2010-02-19 21:54:06 +03:00
|
|
|
#define QERR_NO_BUS_FOR_DEVICE \
|
|
|
|
"{ 'class': 'NoBusForDevice', 'data': { 'device': %s, 'bus': %s } }"
|
|
|
|
|
2010-02-19 19:42:46 +03:00
|
|
|
#define QERR_OPEN_FILE_FAILED \
|
|
|
|
"{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
|
|
|
|
|
2010-02-19 15:11:41 +03:00
|
|
|
#define QERR_PROPERTY_NOT_FOUND \
|
|
|
|
"{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }"
|
|
|
|
|
2010-02-19 15:17:58 +03:00
|
|
|
#define QERR_PROPERTY_VALUE_BAD \
|
|
|
|
"{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
|
|
|
|
|
2010-03-16 19:40:48 +03:00
|
|
|
#define QERR_PROPERTY_VALUE_IN_USE \
|
|
|
|
"{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
|
|
|
|
|
2010-03-16 19:44:38 +03:00
|
|
|
#define QERR_PROPERTY_VALUE_NOT_FOUND \
|
|
|
|
"{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }"
|
|
|
|
|
2009-11-27 03:58:57 +03:00
|
|
|
#define QERR_QMP_BAD_INPUT_OBJECT \
|
2009-12-07 23:37:02 +03:00
|
|
|
"{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }"
|
2009-11-27 03:58:57 +03:00
|
|
|
|
2010-04-07 21:46:33 +04:00
|
|
|
#define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
|
|
|
|
"{ 'class': 'QMPBadInputObjectMember', 'data': { 'member': %s, 'expected': %s } }"
|
|
|
|
|
2010-06-01 23:15:23 +04:00
|
|
|
#define QERR_QMP_EXTRA_MEMBER \
|
|
|
|
"{ 'class': 'QMPExtraInputObjectMember', 'data': { 'member': %s } }"
|
|
|
|
|
2009-12-07 23:37:07 +03:00
|
|
|
#define QERR_SET_PASSWD_FAILED \
|
|
|
|
"{ 'class': 'SetPasswdFailed', 'data': {} }"
|
|
|
|
|
2009-12-07 23:37:14 +03:00
|
|
|
#define QERR_TOO_MANY_FILES \
|
2009-12-08 15:33:54 +03:00
|
|
|
"{ 'class': 'TooManyFiles', 'data': {} }"
|
2009-12-07 23:37:14 +03:00
|
|
|
|
2010-02-19 19:42:46 +03:00
|
|
|
#define QERR_UNDEFINED_ERROR \
|
|
|
|
"{ 'class': 'UndefinedError', 'data': {} }"
|
|
|
|
|
2009-12-07 23:37:08 +03:00
|
|
|
#define QERR_VNC_SERVER_FAILED \
|
|
|
|
"{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
|
|
|
|
|
2009-11-19 04:05:30 +03:00
|
|
|
#endif /* QERROR_H */
|