qerror.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. #include "qdict.h"
  15. #include "qstring.h"
  16. #include "qemu-error.h"
  17. #include "error.h"
  18. #include "qapi-types.h"
  19. #include <stdarg.h>
  20. typedef struct QError {
  21. QObject_HEAD;
  22. Location loc;
  23. char *err_msg;
  24. ErrorClass err_class;
  25. } QError;
  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. void assert_no_error(Error *err);
  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_ADD_CLIENT_FAILED \
  36. ERROR_CLASS_GENERIC_ERROR, "Could not add client"
  37. #define QERR_AMBIGUOUS_PATH \
  38. ERROR_CLASS_GENERIC_ERROR, "Path '%s' does not uniquely identify an object"
  39. #define QERR_BAD_BUS_FOR_DEVICE \
  40. ERROR_CLASS_GENERIC_ERROR, "Device '%s' can't go on a %s bus"
  41. #define QERR_BASE_NOT_FOUND \
  42. ERROR_CLASS_GENERIC_ERROR, "Base '%s' not found"
  43. #define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
  44. ERROR_CLASS_GENERIC_ERROR, "Block format '%s' used by device '%s' does not support feature '%s'"
  45. #define QERR_BUFFER_OVERRUN \
  46. ERROR_CLASS_GENERIC_ERROR, "An internal buffer overran"
  47. #define QERR_BUS_NO_HOTPLUG \
  48. ERROR_CLASS_GENERIC_ERROR, "Bus '%s' does not support hotplugging"
  49. #define QERR_BUS_NOT_FOUND \
  50. ERROR_CLASS_GENERIC_ERROR, "Bus '%s' not found"
  51. #define QERR_COMMAND_DISABLED \
  52. ERROR_CLASS_GENERIC_ERROR, "The command %s has been disabled for this instance"
  53. #define QERR_COMMAND_NOT_FOUND \
  54. ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found"
  55. #define QERR_DEVICE_ENCRYPTED \
  56. ERROR_CLASS_DEVICE_ENCRYPTED, "'%s' (%s) is encrypted"
  57. #define QERR_DEVICE_FEATURE_BLOCKS_MIGRATION \
  58. ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when using feature '%s' in device '%s'"
  59. #define QERR_DEVICE_HAS_NO_MEDIUM \
  60. ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no medium"
  61. #define QERR_DEVICE_INIT_FAILED \
  62. ERROR_CLASS_GENERIC_ERROR, "Device '%s' could not be initialized"
  63. #define QERR_DEVICE_IN_USE \
  64. ERROR_CLASS_GENERIC_ERROR, "Device '%s' is in use"
  65. #define QERR_DEVICE_IS_READ_ONLY \
  66. ERROR_CLASS_GENERIC_ERROR, "Device '%s' is read only"
  67. #define QERR_DEVICE_LOCKED \
  68. ERROR_CLASS_GENERIC_ERROR, "Device '%s' is locked"
  69. #define QERR_DEVICE_MULTIPLE_BUSSES \
  70. ERROR_CLASS_GENERIC_ERROR, "Device '%s' has multiple child busses"
  71. #define QERR_DEVICE_NO_BUS \
  72. ERROR_CLASS_GENERIC_ERROR, "Device '%s' has no child bus"
  73. #define QERR_DEVICE_NO_HOTPLUG \
  74. ERROR_CLASS_GENERIC_ERROR, "Device '%s' does not support hotplugging"
  75. #define QERR_DEVICE_NOT_ACTIVE \
  76. ERROR_CLASS_DEVICE_NOT_ACTIVE, "Device '%s' has not been activated"
  77. #define QERR_DEVICE_NOT_ENCRYPTED \
  78. ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not encrypted"
  79. #define QERR_DEVICE_NOT_FOUND \
  80. ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found"
  81. #define QERR_DEVICE_NOT_REMOVABLE \
  82. ERROR_CLASS_GENERIC_ERROR, "Device '%s' is not removable"
  83. #define QERR_DUPLICATE_ID \
  84. ERROR_CLASS_GENERIC_ERROR, "Duplicate ID '%s' for %s"
  85. #define QERR_FD_NOT_FOUND \
  86. ERROR_CLASS_GENERIC_ERROR, "File descriptor named '%s' not found"
  87. #define QERR_FD_NOT_SUPPLIED \
  88. ERROR_CLASS_GENERIC_ERROR, "No file descriptor supplied via SCM_RIGHTS"
  89. #define QERR_FEATURE_DISABLED \
  90. ERROR_CLASS_GENERIC_ERROR, "The feature '%s' is not enabled"
  91. #define QERR_INVALID_BLOCK_FORMAT \
  92. ERROR_CLASS_GENERIC_ERROR, "Invalid block format '%s'"
  93. #define QERR_INVALID_OPTION_GROUP \
  94. ERROR_CLASS_GENERIC_ERROR, "There is no option group '%s'"
  95. #define QERR_INVALID_PARAMETER \
  96. ERROR_CLASS_GENERIC_ERROR, "Invalid parameter '%s'"
  97. #define QERR_INVALID_PARAMETER_COMBINATION \
  98. ERROR_CLASS_GENERIC_ERROR, "Invalid parameter combination"
  99. #define QERR_INVALID_PARAMETER_TYPE \
  100. ERROR_CLASS_GENERIC_ERROR, "Invalid parameter type for '%s', expected: %s"
  101. #define QERR_INVALID_PARAMETER_VALUE \
  102. ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' expects %s"
  103. #define QERR_INVALID_PASSWORD \
  104. ERROR_CLASS_GENERIC_ERROR, "Password incorrect"
  105. #define QERR_IO_ERROR \
  106. ERROR_CLASS_GENERIC_ERROR, "An IO error has occurred"
  107. #define QERR_JSON_PARSE_ERROR \
  108. ERROR_CLASS_GENERIC_ERROR, "JSON parse error, %s"
  109. #define QERR_JSON_PARSING \
  110. ERROR_CLASS_GENERIC_ERROR, "Invalid JSON syntax"
  111. #define QERR_KVM_MISSING_CAP \
  112. ERROR_CLASS_K_V_M_MISSING_CAP, "Using KVM without %s, %s unavailable"
  113. #define QERR_MIGRATION_ACTIVE \
  114. ERROR_CLASS_GENERIC_ERROR, "There's a migration process in progress"
  115. #define QERR_MIGRATION_NOT_SUPPORTED \
  116. ERROR_CLASS_GENERIC_ERROR, "State blocked by non-migratable device '%s'"
  117. #define QERR_MIGRATION_EXPECTED \
  118. ERROR_CLASS_MIGRATION_EXPECTED, "An incoming migration is expected before this command can be executed"
  119. #define QERR_MISSING_PARAMETER \
  120. ERROR_CLASS_GENERIC_ERROR, "Parameter '%s' is missing"
  121. #define QERR_NO_BUS_FOR_DEVICE \
  122. ERROR_CLASS_GENERIC_ERROR, "No '%s' bus found for device '%s'"
  123. #define QERR_NOT_SUPPORTED \
  124. ERROR_CLASS_GENERIC_ERROR, "Not supported"
  125. #define QERR_OPEN_FILE_FAILED \
  126. ERROR_CLASS_GENERIC_ERROR, "Could not open '%s'"
  127. #define QERR_PERMISSION_DENIED \
  128. ERROR_CLASS_GENERIC_ERROR, "Insufficient permission to perform this operation"
  129. #define QERR_PROPERTY_NOT_FOUND \
  130. ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' not found"
  131. #define QERR_PROPERTY_VALUE_BAD \
  132. ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' doesn't take value '%s'"
  133. #define QERR_PROPERTY_VALUE_IN_USE \
  134. ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't take value '%s', it's in use"
  135. #define QERR_PROPERTY_VALUE_NOT_FOUND \
  136. ERROR_CLASS_GENERIC_ERROR, "Property '%s.%s' can't find value '%s'"
  137. #define QERR_PROPERTY_VALUE_NOT_POWER_OF_2 \
  138. ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2"
  139. #define QERR_PROPERTY_VALUE_OUT_OF_RANGE \
  140. ERROR_CLASS_GENERIC_ERROR, "Property %s.%s doesn't take value %" PRId64 " (minimum: %" PRId64 ", maximum: %" PRId64 ")"
  141. #define QERR_QGA_COMMAND_FAILED \
  142. ERROR_CLASS_GENERIC_ERROR, "Guest agent command failed, error was '%s'"
  143. #define QERR_QGA_LOGGING_FAILED \
  144. ERROR_CLASS_GENERIC_ERROR, "Guest agent failed to log non-optional log statement"
  145. #define QERR_QMP_BAD_INPUT_OBJECT \
  146. ERROR_CLASS_GENERIC_ERROR, "Expected '%s' in QMP input"
  147. #define QERR_QMP_BAD_INPUT_OBJECT_MEMBER \
  148. ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' expects '%s'"
  149. #define QERR_QMP_EXTRA_MEMBER \
  150. ERROR_CLASS_GENERIC_ERROR, "QMP input object member '%s' is unexpected"
  151. #define QERR_RESET_REQUIRED \
  152. ERROR_CLASS_GENERIC_ERROR, "Resetting the Virtual Machine is required"
  153. #define QERR_SET_PASSWD_FAILED \
  154. ERROR_CLASS_GENERIC_ERROR, "Could not set password"
  155. #define QERR_TOO_MANY_FILES \
  156. ERROR_CLASS_GENERIC_ERROR, "Too many open files"
  157. #define QERR_UNDEFINED_ERROR \
  158. ERROR_CLASS_GENERIC_ERROR, "An undefined error has occurred"
  159. #define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
  160. ERROR_CLASS_GENERIC_ERROR, "'%s' uses a %s feature which is not supported by this qemu version: %s"
  161. #define QERR_UNSUPPORTED \
  162. ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported"
  163. #define QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION \
  164. ERROR_CLASS_GENERIC_ERROR, "Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'"
  165. #define QERR_VNC_SERVER_FAILED \
  166. ERROR_CLASS_GENERIC_ERROR, "Could not start VNC server on %s"
  167. #define QERR_SOCKET_CONNECT_FAILED \
  168. ERROR_CLASS_GENERIC_ERROR, "Failed to connect to socket"
  169. #define QERR_SOCKET_LISTEN_FAILED \
  170. ERROR_CLASS_GENERIC_ERROR, "Failed to set socket to listening mode"
  171. #define QERR_SOCKET_BIND_FAILED \
  172. ERROR_CLASS_GENERIC_ERROR, "Failed to bind socket"
  173. #define QERR_SOCKET_CREATE_FAILED \
  174. ERROR_CLASS_GENERIC_ERROR, "Failed to create socket"
  175. #endif /* QERROR_H */