1 /* 2 * QError Module 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 "qapi/qmp/qstring.h" 16 #include "qapi/error.h" 17 #include "qapi-types.h" 18 #include <stdarg.h> 19 20 typedef struct QError { 21 QObject_HEAD; 22 char *err_msg; 23 ErrorClass err_class; 24 } QError; 25 26 QString *qerror_human(const QError *qerror); 27 void qerror_report(ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(2, 3); 28 void qerror_report_err(Error *err); 29 30 /* 31 * QError class list 32 * Please keep the definitions in alphabetical order. 33 * Use scripts/check-qerror.sh to check. 34 */ 35 #define QERR_BASE_NOT_FOUND \ 36 ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found" 37 38 #define QERR_BLOCK_JOB_NOT_ACTIVE \ 39 ERROR_CLASS_DEVICE_NOT_ACTIVE, "No active block job on device '%s'" 40 41 #define QERR_BLOCK_JOB_NOT_READY \ 42 ERROR_CLASS_GENERIC_ERROR, "The active block job for device '%s' cannot be completed" 43 44 #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \ 45 ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by device '%s' does not support feature '%s'" 46 47 #define QERR_BUS_NO_HOTPLUG \ 48 ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging" 49 50 #define QERR_BUS_NOT_FOUND \ 51 ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found" 52 53 #define QERR_COMMAND_NOT_FOUND \ 54 ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found" 55 56 #define QERR_DEVICE_ENCRYPTED \ 57 ERROR_CLASS_DEVICE_ENCRYPTED, "'%s' (%s) is encrypted" 58 59 #define QERR_DEVICE_HAS_NO_MEDIUM \ 60 ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium" 61 62 #define QERR_DEVICE_INIT_FAILED \ 63 ERROR_CLASS_GENERIC_ERROR, "Device '%s' could not be initialized" 64 65 #define QERR_DEVICE_IN_USE \ 66 ERROR_CLASS_GENERIC_ERROR, "Device '%s' is in use" 67 68 #define QERR_DEVICE_IS_READ_ONLY \ 69 ERROR_CLASS_GENERIC_ERROR, "Device '%s' is read only" 70 71 #define QERR_DEVICE_NO_HOTPLUG \ 72 ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging" 73 74 #define QERR_DEVICE_NOT_ACTIVE \ 75 ERROR_CLASS_DEVICE_NOT_ACTIVE, "No %s device has been activated" 76 77 #define QERR_DEVICE_NOT_ENCRYPTED \ 78 ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not encrypted" 79 80 #define QERR_DEVICE_NOT_FOUND \ 81 ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found" 82 83 #define QERR_FD_NOT_FOUND \ 84 ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found" 85 86 #define QERR_FD_NOT_SUPPLIED \ 87 ERROR_CLASS_GENERIC_ERROR, "No file descriptor supplied via SCM_RIGHTS" 88 89 #define QERR_FEATURE_DISABLED \ 90 ERROR_CLASS_GENERIC_ERROR, "The feature '%s' is not enabled" 91 92 #define QERR_INVALID_BLOCK_FORMAT \ 93 ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'" 94 95 #define QERR_INVALID_PARAMETER \ 96 ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'" 97 98 #define QERR_INVALID_PARAMETER_TYPE \ 99 ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s" 100 101 #define QERR_INVALID_PARAMETER_VALUE \ 102 ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' expects %s" 103 104 #define QERR_INVALID_PASSWORD \ 105 ERROR_CLASS_GENERIC_ERROR, "Password incorrect" 106 107 #define QERR_IO_ERROR \ 108 ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred" 109 110 #define QERR_JSON_PARSING \ 111 ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax" 112 113 #define QERR_KVM_MISSING_CAP \ 114 ERROR_CLASS_KVM_MISSING_CAP, "Using KVM without %s, %s unavailable" 115 116 #define QERR_MIGRATION_ACTIVE \ 117 ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress" 118 119 #define QERR_MISSING_PARAMETER \ 120 ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing" 121 122 #define QERR_PERMISSION_DENIED \ 123 ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation" 124 125 #define QERR_PROPERTY_VALUE_BAD \ 126 ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'" 127 128 #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \ 129 ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")" 130 131 #define QERR_QGA_COMMAND_FAILED \ 132 ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'" 133 134 #define QERR_QMP_BAD_INPUT_OBJECT \ 135 ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input" 136 137 #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \ 138 ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' expects '%s'" 139 140 #define QERR_QMP_EXTRA_MEMBER \ 141 ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected" 142 143 #define QERR_SET_PASSWD_FAILED \ 144 ERROR_CLASS_GENERIC_ERROR, "Could not set password" 145 146 #define QERR_UNDEFINED_ERROR \ 147 ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred" 148 149 #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \ 150 ERROR_CLASS_GENERIC_ERROR, "'%s' uses a %s feature which is not supported by this qemu version: %s" 151 152 #define QERR_UNSUPPORTED \ 153 ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported" 154 155 #endif /* QERROR_H */ 156