root / qerror.c @ 9dd69d65
History | View | Annotate | Download (16.8 kB)
1 | 9f9daf9a | Luiz Capitulino | /*
|
---|---|---|---|
2 | 41836a9f | Luiz Capitulino | * QError Module
|
3 | 9f9daf9a | Luiz Capitulino | *
|
4 | 9f9daf9a | Luiz Capitulino | * Copyright (C) 2009 Red Hat Inc.
|
5 | 9f9daf9a | Luiz Capitulino | *
|
6 | 9f9daf9a | Luiz Capitulino | * Authors:
|
7 | 9f9daf9a | Luiz Capitulino | * Luiz Capitulino <lcapitulino@redhat.com>
|
8 | 9f9daf9a | Luiz Capitulino | *
|
9 | 9f9daf9a | Luiz Capitulino | * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
10 | 9f9daf9a | Luiz Capitulino | * See the COPYING.LIB file in the top-level directory.
|
11 | 9f9daf9a | Luiz Capitulino | */
|
12 | 0167f772 | Markus Armbruster | |
13 | 0167f772 | Markus Armbruster | #include "monitor.h" |
14 | 9f9daf9a | Luiz Capitulino | #include "qjson.h" |
15 | 9f9daf9a | Luiz Capitulino | #include "qerror.h" |
16 | 9f9daf9a | Luiz Capitulino | #include "qemu-common.h" |
17 | 9f9daf9a | Luiz Capitulino | |
18 | 9f9daf9a | Luiz Capitulino | static void qerror_destroy_obj(QObject *obj); |
19 | 9f9daf9a | Luiz Capitulino | |
20 | 9f9daf9a | Luiz Capitulino | static const QType qerror_type = { |
21 | 9f9daf9a | Luiz Capitulino | .code = QTYPE_QERROR, |
22 | 9f9daf9a | Luiz Capitulino | .destroy = qerror_destroy_obj, |
23 | 9f9daf9a | Luiz Capitulino | }; |
24 | 9f9daf9a | Luiz Capitulino | |
25 | 9f9daf9a | Luiz Capitulino | /**
|
26 | 9f9daf9a | Luiz Capitulino | * The 'desc' parameter is a printf-like string, the format of the format
|
27 | 9f9daf9a | Luiz Capitulino | * string is:
|
28 | 9f9daf9a | Luiz Capitulino | *
|
29 | 9f9daf9a | Luiz Capitulino | * %(KEY)
|
30 | 9f9daf9a | Luiz Capitulino | *
|
31 | 9f9daf9a | Luiz Capitulino | * Where KEY is a QDict key, which has to be passed to qerror_from_info().
|
32 | 9f9daf9a | Luiz Capitulino | *
|
33 | 9f9daf9a | Luiz Capitulino | * Example:
|
34 | 9f9daf9a | Luiz Capitulino | *
|
35 | 9f9daf9a | Luiz Capitulino | * "foo error on device: %(device) slot: %(slot_nr)"
|
36 | 9f9daf9a | Luiz Capitulino | *
|
37 | 9f9daf9a | Luiz Capitulino | * A single percent sign can be printed if followed by a second one,
|
38 | 9f9daf9a | Luiz Capitulino | * for example:
|
39 | 9f9daf9a | Luiz Capitulino | *
|
40 | 9f9daf9a | Luiz Capitulino | * "running out of foo: %(foo)%%"
|
41 | 9d494c4b | Markus Armbruster | *
|
42 | 9d494c4b | Markus Armbruster | * Please keep the entries in alphabetical order.
|
43 | 9737383b | Stefan Hajnoczi | * Use scripts/check-qerror.sh to check.
|
44 | 9f9daf9a | Luiz Capitulino | */
|
45 | d05ac8fa | Blue Swirl | static const QErrorStringTable qerror_table[] = { |
46 | 357b6156 | Luiz Capitulino | { |
47 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_ADD_CLIENT_FAILED, |
48 | c1303596 | Stefan Hajnoczi | .desc = "Could not add client",
|
49 | c1303596 | Stefan Hajnoczi | }, |
50 | c1303596 | Stefan Hajnoczi | { |
51 | 11e35bfd | Paolo Bonzini | .error_fmt = QERR_AMBIGUOUS_PATH, |
52 | 11e35bfd | Paolo Bonzini | .desc = "Path '%(path)' does not uniquely identify a %(object)"
|
53 | 11e35bfd | Paolo Bonzini | }, |
54 | 11e35bfd | Paolo Bonzini | { |
55 | 56e9f563 | Markus Armbruster | .error_fmt = QERR_BAD_BUS_FOR_DEVICE, |
56 | 56e9f563 | Markus Armbruster | .desc = "Device '%(device)' can't go on a %(bad_bus_type) bus",
|
57 | 56e9f563 | Markus Armbruster | }, |
58 | 56e9f563 | Markus Armbruster | { |
59 | 019b8cbf | Marcelo Tosatti | .error_fmt = QERR_BASE_NOT_FOUND, |
60 | 019b8cbf | Marcelo Tosatti | .desc = "Base '%(base)' not found",
|
61 | 019b8cbf | Marcelo Tosatti | }, |
62 | 019b8cbf | Marcelo Tosatti | { |
63 | 1ed520c6 | Anthony Liguori | .error_fmt = QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, |
64 | 1ed520c6 | Anthony Liguori | .desc = "Block format '%(format)' used by device '%(name)' does not support feature '%(feature)'",
|
65 | 1ed520c6 | Anthony Liguori | }, |
66 | 1ed520c6 | Anthony Liguori | { |
67 | 8eae73b5 | Markus Armbruster | .error_fmt = QERR_BUS_NO_HOTPLUG, |
68 | 8eae73b5 | Markus Armbruster | .desc = "Bus '%(bus)' does not support hotplugging",
|
69 | 8eae73b5 | Markus Armbruster | }, |
70 | 8eae73b5 | Markus Armbruster | { |
71 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_BUS_NOT_FOUND, |
72 | c1303596 | Stefan Hajnoczi | .desc = "Bus '%(bus)' not found",
|
73 | 4b9d4683 | Luiz Capitulino | }, |
74 | 4b9d4683 | Luiz Capitulino | { |
75 | abd6cf6d | Michael Roth | .error_fmt = QERR_COMMAND_DISABLED, |
76 | abd6cf6d | Michael Roth | .desc = "The command %(name) has been disabled for this instance",
|
77 | abd6cf6d | Michael Roth | }, |
78 | abd6cf6d | Michael Roth | { |
79 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_COMMAND_NOT_FOUND, |
80 | c1303596 | Stefan Hajnoczi | .desc = "The command %(name) has not been found",
|
81 | c1303596 | Stefan Hajnoczi | }, |
82 | c1303596 | Stefan Hajnoczi | { |
83 | 0df37c41 | Luiz Capitulino | .error_fmt = QERR_DEVICE_ENCRYPTED, |
84 | fc5469d8 | Markus Armbruster | .desc = "Device '%(device)' is encrypted",
|
85 | 0df37c41 | Luiz Capitulino | }, |
86 | 0df37c41 | Luiz Capitulino | { |
87 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_DEVICE_FEATURE_BLOCKS_MIGRATION, |
88 | c1303596 | Stefan Hajnoczi | .desc = "Migration is disabled when using feature '%(feature)' in device '%(device)'",
|
89 | c1303596 | Stefan Hajnoczi | }, |
90 | c1303596 | Stefan Hajnoczi | { |
91 | 939a1cc3 | Stefan Hajnoczi | .error_fmt = QERR_DEVICE_HAS_NO_MEDIUM, |
92 | 939a1cc3 | Stefan Hajnoczi | .desc = "Device '%(device)' has no medium",
|
93 | 939a1cc3 | Stefan Hajnoczi | }, |
94 | 939a1cc3 | Stefan Hajnoczi | { |
95 | 4d9a1a15 | Markus Armbruster | .error_fmt = QERR_DEVICE_INIT_FAILED, |
96 | 4d9a1a15 | Markus Armbruster | .desc = "Device '%(device)' could not be initialized",
|
97 | 4d9a1a15 | Markus Armbruster | }, |
98 | 4d9a1a15 | Markus Armbruster | { |
99 | 5124eb59 | Markus Armbruster | .error_fmt = QERR_DEVICE_IN_USE, |
100 | 5124eb59 | Markus Armbruster | .desc = "Device '%(device)' is in use",
|
101 | 5124eb59 | Markus Armbruster | }, |
102 | 5124eb59 | Markus Armbruster | { |
103 | 939a1cc3 | Stefan Hajnoczi | .error_fmt = QERR_DEVICE_IS_READ_ONLY, |
104 | 939a1cc3 | Stefan Hajnoczi | .desc = "Device '%(device)' is read only",
|
105 | 939a1cc3 | Stefan Hajnoczi | }, |
106 | 939a1cc3 | Stefan Hajnoczi | { |
107 | b0868380 | Markus Armbruster | .error_fmt = QERR_DEVICE_LOCKED, |
108 | fc5469d8 | Markus Armbruster | .desc = "Device '%(device)' is locked",
|
109 | b0868380 | Markus Armbruster | }, |
110 | 1ae78718 | Markus Armbruster | { |
111 | 1ae78718 | Markus Armbruster | .error_fmt = QERR_DEVICE_MULTIPLE_BUSSES, |
112 | 1ae78718 | Markus Armbruster | .desc = "Device '%(device)' has multiple child busses",
|
113 | 1ae78718 | Markus Armbruster | }, |
114 | b0868380 | Markus Armbruster | { |
115 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_DEVICE_NO_BUS, |
116 | c1303596 | Stefan Hajnoczi | .desc = "Device '%(device)' has no child bus",
|
117 | c1303596 | Stefan Hajnoczi | }, |
118 | c1303596 | Stefan Hajnoczi | { |
119 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_DEVICE_NO_HOTPLUG, |
120 | c1303596 | Stefan Hajnoczi | .desc = "Device '%(device)' does not support hotplugging",
|
121 | c1303596 | Stefan Hajnoczi | }, |
122 | c1303596 | Stefan Hajnoczi | { |
123 | e16a1812 | Markus Armbruster | .error_fmt = QERR_DEVICE_NOT_ACTIVE, |
124 | 8754c81e | Luiz Capitulino | .desc = "Device '%(device)' has not been activated",
|
125 | e16a1812 | Markus Armbruster | }, |
126 | e16a1812 | Markus Armbruster | { |
127 | 9d494c4b | Markus Armbruster | .error_fmt = QERR_DEVICE_NOT_ENCRYPTED, |
128 | 9d494c4b | Markus Armbruster | .desc = "Device '%(device)' is not encrypted",
|
129 | 9d494c4b | Markus Armbruster | }, |
130 | 9d494c4b | Markus Armbruster | { |
131 | 357b6156 | Luiz Capitulino | .error_fmt = QERR_DEVICE_NOT_FOUND, |
132 | fc5469d8 | Markus Armbruster | .desc = "Device '%(device)' not found",
|
133 | 357b6156 | Luiz Capitulino | }, |
134 | 055f6122 | Luiz Capitulino | { |
135 | 5cfe0264 | Markus Armbruster | .error_fmt = QERR_DEVICE_NOT_REMOVABLE, |
136 | fc5469d8 | Markus Armbruster | .desc = "Device '%(device)' is not removable",
|
137 | 5cfe0264 | Markus Armbruster | }, |
138 | 5cfe0264 | Markus Armbruster | { |
139 | 7bc84017 | Markus Armbruster | .error_fmt = QERR_DUPLICATE_ID, |
140 | 7bc84017 | Markus Armbruster | .desc = "Duplicate ID '%(id)' for %(object)",
|
141 | 7bc84017 | Markus Armbruster | }, |
142 | 7bc84017 | Markus Armbruster | { |
143 | c7c338c4 | Markus Armbruster | .error_fmt = QERR_FD_NOT_FOUND, |
144 | fc5469d8 | Markus Armbruster | .desc = "File descriptor named '%(name)' not found",
|
145 | c7c338c4 | Markus Armbruster | }, |
146 | c7c338c4 | Markus Armbruster | { |
147 | 41471a23 | Markus Armbruster | .error_fmt = QERR_FD_NOT_SUPPLIED, |
148 | 41471a23 | Markus Armbruster | .desc = "No file descriptor supplied via SCM_RIGHTS",
|
149 | 41471a23 | Markus Armbruster | }, |
150 | 41471a23 | Markus Armbruster | { |
151 | bf826328 | Luiz Capitulino | .error_fmt = QERR_FEATURE_DISABLED, |
152 | bf826328 | Luiz Capitulino | .desc = "The feature '%(name)' is not enabled",
|
153 | bf826328 | Luiz Capitulino | }, |
154 | bf826328 | Luiz Capitulino | { |
155 | 17901e75 | Markus Armbruster | .error_fmt = QERR_INVALID_BLOCK_FORMAT, |
156 | fc5469d8 | Markus Armbruster | .desc = "Invalid block format '%(name)'",
|
157 | 17901e75 | Markus Armbruster | }, |
158 | 17901e75 | Markus Armbruster | { |
159 | 8ff15d4a | Luiz Capitulino | .error_fmt = QERR_INVALID_OPTION_GROUP, |
160 | 8ff15d4a | Luiz Capitulino | .desc = "There is no option group '%(group)'",
|
161 | 8ff15d4a | Luiz Capitulino | }, |
162 | 8ff15d4a | Luiz Capitulino | { |
163 | 7a046f5f | Markus Armbruster | .error_fmt = QERR_INVALID_PARAMETER, |
164 | fc5469d8 | Markus Armbruster | .desc = "Invalid parameter '%(name)'",
|
165 | 7a046f5f | Markus Armbruster | }, |
166 | 7a046f5f | Markus Armbruster | { |
167 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_INVALID_PARAMETER_COMBINATION, |
168 | c1303596 | Stefan Hajnoczi | .desc = "Invalid parameter combination",
|
169 | c1303596 | Stefan Hajnoczi | }, |
170 | c1303596 | Stefan Hajnoczi | { |
171 | e16a1812 | Markus Armbruster | .error_fmt = QERR_INVALID_PARAMETER_TYPE, |
172 | 5eeee3fa | Anthony Liguori | .desc = "Invalid parameter type for '%(name)', expected: %(expected)",
|
173 | 055f6122 | Luiz Capitulino | }, |
174 | 82a60711 | Luiz Capitulino | { |
175 | 985a3e52 | Markus Armbruster | .error_fmt = QERR_INVALID_PARAMETER_VALUE, |
176 | 985a3e52 | Markus Armbruster | .desc = "Parameter '%(name)' expects %(expected)",
|
177 | 985a3e52 | Markus Armbruster | }, |
178 | 985a3e52 | Markus Armbruster | { |
179 | e16a1812 | Markus Armbruster | .error_fmt = QERR_INVALID_PASSWORD, |
180 | fc5469d8 | Markus Armbruster | .desc = "Password incorrect",
|
181 | 4b9d4683 | Luiz Capitulino | }, |
182 | 4b9d4683 | Luiz Capitulino | { |
183 | 58898873 | Luiz Capitulino | .error_fmt = QERR_IO_ERROR, |
184 | 58898873 | Luiz Capitulino | .desc = "An IO error has occurred",
|
185 | 58898873 | Luiz Capitulino | }, |
186 | 58898873 | Luiz Capitulino | { |
187 | ac32c780 | Michael Roth | .error_fmt = QERR_JSON_PARSE_ERROR, |
188 | ac32c780 | Michael Roth | .desc = "JSON parse error, %(message)",
|
189 | ac32c780 | Michael Roth | |
190 | ac32c780 | Michael Roth | }, |
191 | ac32c780 | Michael Roth | { |
192 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_JSON_PARSING, |
193 | c1303596 | Stefan Hajnoczi | .desc = "Invalid JSON syntax",
|
194 | c1303596 | Stefan Hajnoczi | }, |
195 | c1303596 | Stefan Hajnoczi | { |
196 | 82a60711 | Luiz Capitulino | .error_fmt = QERR_KVM_MISSING_CAP, |
197 | 82a60711 | Luiz Capitulino | .desc = "Using KVM without %(capability), %(feature) unavailable",
|
198 | 82a60711 | Luiz Capitulino | }, |
199 | 4b9d4683 | Luiz Capitulino | { |
200 | a4acc064 | Luiz Capitulino | .error_fmt = QERR_MIGRATION_ACTIVE, |
201 | a4acc064 | Luiz Capitulino | .desc = "There's a migration process in progress",
|
202 | a4acc064 | Luiz Capitulino | }, |
203 | a4acc064 | Luiz Capitulino | { |
204 | a4acc064 | Luiz Capitulino | .error_fmt = QERR_MIGRATION_NOT_SUPPORTED, |
205 | a4acc064 | Luiz Capitulino | .desc = "State blocked by non-migratable device '%(device)'",
|
206 | a4acc064 | Luiz Capitulino | }, |
207 | a4acc064 | Luiz Capitulino | { |
208 | 8e84865e | Amit Shah | .error_fmt = QERR_MIGRATION_EXPECTED, |
209 | 8e84865e | Amit Shah | .desc = "An incoming migration is expected before this command can be executed",
|
210 | 8e84865e | Amit Shah | }, |
211 | 8e84865e | Amit Shah | { |
212 | 4b9d4683 | Luiz Capitulino | .error_fmt = QERR_MISSING_PARAMETER, |
213 | fc5469d8 | Markus Armbruster | .desc = "Parameter '%(name)' is missing",
|
214 | fc5469d8 | Markus Armbruster | }, |
215 | fc5469d8 | Markus Armbruster | { |
216 | fab5767f | Markus Armbruster | .error_fmt = QERR_NO_BUS_FOR_DEVICE, |
217 | fab5767f | Markus Armbruster | .desc = "No '%(bus)' bus found for device '%(device)'",
|
218 | fab5767f | Markus Armbruster | }, |
219 | fab5767f | Markus Armbruster | { |
220 | 12bd451f | Stefan Hajnoczi | .error_fmt = QERR_NOT_SUPPORTED, |
221 | 12bd451f | Stefan Hajnoczi | .desc = "Not supported",
|
222 | 12bd451f | Stefan Hajnoczi | }, |
223 | 12bd451f | Stefan Hajnoczi | { |
224 | fc5469d8 | Markus Armbruster | .error_fmt = QERR_OPEN_FILE_FAILED, |
225 | fc5469d8 | Markus Armbruster | .desc = "Could not open '%(filename)'",
|
226 | 4b9d4683 | Luiz Capitulino | }, |
227 | 4b9d4683 | Luiz Capitulino | { |
228 | 44677ded | Anthony Liguori | .error_fmt = QERR_PERMISSION_DENIED, |
229 | 44677ded | Anthony Liguori | .desc = "Insufficient permission to perform this operation",
|
230 | 44677ded | Anthony Liguori | }, |
231 | 44677ded | Anthony Liguori | { |
232 | c58a35f8 | Markus Armbruster | .error_fmt = QERR_PROPERTY_NOT_FOUND, |
233 | c58a35f8 | Markus Armbruster | .desc = "Property '%(device).%(property)' not found",
|
234 | c58a35f8 | Markus Armbruster | }, |
235 | c58a35f8 | Markus Armbruster | { |
236 | 06b4a703 | Markus Armbruster | .error_fmt = QERR_PROPERTY_VALUE_BAD, |
237 | 06b4a703 | Markus Armbruster | .desc = "Property '%(device).%(property)' doesn't take value '%(value)'",
|
238 | 06b4a703 | Markus Armbruster | }, |
239 | 06b4a703 | Markus Armbruster | { |
240 | 9c5eff95 | Markus Armbruster | .error_fmt = QERR_PROPERTY_VALUE_IN_USE, |
241 | 9c5eff95 | Markus Armbruster | .desc = "Property '%(device).%(property)' can't take value '%(value)', it's in use",
|
242 | 9c5eff95 | Markus Armbruster | }, |
243 | 9c5eff95 | Markus Armbruster | { |
244 | 84745d68 | Markus Armbruster | .error_fmt = QERR_PROPERTY_VALUE_NOT_FOUND, |
245 | 84745d68 | Markus Armbruster | .desc = "Property '%(device).%(property)' can't find value '%(value)'",
|
246 | 84745d68 | Markus Armbruster | }, |
247 | 84745d68 | Markus Armbruster | { |
248 | 02fda01c | Stefan Hajnoczi | .error_fmt = QERR_PROPERTY_VALUE_NOT_POWER_OF_2, |
249 | 02fda01c | Stefan Hajnoczi | .desc = "Property '%(device).%(property)' doesn't take "
|
250 | 02fda01c | Stefan Hajnoczi | "value '%(value)', it's not a power of 2",
|
251 | 02fda01c | Stefan Hajnoczi | }, |
252 | 02fda01c | Stefan Hajnoczi | { |
253 | 6aced82c | Paolo Bonzini | .error_fmt = QERR_PROPERTY_VALUE_OUT_OF_RANGE, |
254 | 6aced82c | Paolo Bonzini | .desc = "Property '%(device).%(property)' doesn't take "
|
255 | 41453412 | Stefan Hajnoczi | "value %(value) (minimum: %(min), maximum: %(max))",
|
256 | 6aced82c | Paolo Bonzini | }, |
257 | 6aced82c | Paolo Bonzini | { |
258 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_QGA_COMMAND_FAILED, |
259 | c1303596 | Stefan Hajnoczi | .desc = "Guest agent command failed, error was '%(message)'",
|
260 | c1303596 | Stefan Hajnoczi | }, |
261 | c1303596 | Stefan Hajnoczi | { |
262 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_QGA_LOGGING_FAILED, |
263 | c1303596 | Stefan Hajnoczi | .desc = "Guest agent failed to log non-optional log statement",
|
264 | c1303596 | Stefan Hajnoczi | }, |
265 | c1303596 | Stefan Hajnoczi | { |
266 | 4b9d4683 | Luiz Capitulino | .error_fmt = QERR_QMP_BAD_INPUT_OBJECT, |
267 | abaf2f52 | Luiz Capitulino | .desc = "Expected '%(expected)' in QMP input",
|
268 | 4b9d4683 | Luiz Capitulino | }, |
269 | 4b9d4683 | Luiz Capitulino | { |
270 | 7dfb6123 | Luiz Capitulino | .error_fmt = QERR_QMP_BAD_INPUT_OBJECT_MEMBER, |
271 | 7dfb6123 | Luiz Capitulino | .desc = "QMP input object member '%(member)' expects '%(expected)'",
|
272 | 7dfb6123 | Luiz Capitulino | }, |
273 | 7dfb6123 | Luiz Capitulino | { |
274 | 60d76d7b | Luiz Capitulino | .error_fmt = QERR_QMP_EXTRA_MEMBER, |
275 | 60d76d7b | Luiz Capitulino | .desc = "QMP input object member '%(member)' is unexpected",
|
276 | 60d76d7b | Luiz Capitulino | }, |
277 | 60d76d7b | Luiz Capitulino | { |
278 | 6667b23f | Luiz Capitulino | .error_fmt = QERR_RESET_REQUIRED, |
279 | 6667b23f | Luiz Capitulino | .desc = "Resetting the Virtual Machine is required",
|
280 | 6667b23f | Luiz Capitulino | }, |
281 | 6667b23f | Luiz Capitulino | { |
282 | 7a84cb23 | Markus Armbruster | .error_fmt = QERR_SET_PASSWD_FAILED, |
283 | 7a84cb23 | Markus Armbruster | .desc = "Could not set password",
|
284 | 7a84cb23 | Markus Armbruster | }, |
285 | 7a84cb23 | Markus Armbruster | { |
286 | a488be27 | Markus Armbruster | .error_fmt = QERR_TOO_MANY_FILES, |
287 | a488be27 | Markus Armbruster | .desc = "Too many open files",
|
288 | a488be27 | Markus Armbruster | }, |
289 | a488be27 | Markus Armbruster | { |
290 | e16a1812 | Markus Armbruster | .error_fmt = QERR_UNDEFINED_ERROR, |
291 | 07f35073 | Dong Xu Wang | .desc = "An undefined error has occurred",
|
292 | 4b9d4683 | Luiz Capitulino | }, |
293 | a6906e31 | Markus Armbruster | { |
294 | f54e3641 | Kevin Wolf | .error_fmt = QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, |
295 | f54e3641 | Kevin Wolf | .desc = "'%(device)' uses a %(format) feature which is not "
|
296 | f54e3641 | Kevin Wolf | "supported by this qemu version: %(feature)",
|
297 | f54e3641 | Kevin Wolf | }, |
298 | f54e3641 | Kevin Wolf | { |
299 | c1303596 | Stefan Hajnoczi | .error_fmt = QERR_UNSUPPORTED, |
300 | c1303596 | Stefan Hajnoczi | .desc = "this feature or command is not currently supported",
|
301 | c1303596 | Stefan Hajnoczi | }, |
302 | c1303596 | Stefan Hajnoczi | { |
303 | e9a0152b | Aneesh Kumar K.V | .error_fmt = QERR_VIRTFS_FEATURE_BLOCKS_MIGRATION, |
304 | e9a0152b | Aneesh Kumar K.V | .desc = "Migration is disabled when VirtFS export path '%(path)' "
|
305 | e9a0152b | Aneesh Kumar K.V | "is mounted in the guest using mount_tag '%(tag)'",
|
306 | e9a0152b | Aneesh Kumar K.V | }, |
307 | e9a0152b | Aneesh Kumar K.V | { |
308 | a6906e31 | Markus Armbruster | .error_fmt = QERR_VNC_SERVER_FAILED, |
309 | a6906e31 | Markus Armbruster | .desc = "Could not start VNC server on %(target)",
|
310 | a6906e31 | Markus Armbruster | }, |
311 | aed3d11d | Amos Kong | { |
312 | aed3d11d | Amos Kong | .error_fmt = QERR_SOCKET_CONNECT_IN_PROGRESS, |
313 | aed3d11d | Amos Kong | .desc = "Connection can not be completed immediately",
|
314 | aed3d11d | Amos Kong | }, |
315 | aed3d11d | Amos Kong | { |
316 | aed3d11d | Amos Kong | .error_fmt = QERR_SOCKET_CONNECT_FAILED, |
317 | aed3d11d | Amos Kong | .desc = "Failed to connect to socket",
|
318 | aed3d11d | Amos Kong | }, |
319 | aed3d11d | Amos Kong | { |
320 | aed3d11d | Amos Kong | .error_fmt = QERR_SOCKET_LISTEN_FAILED, |
321 | aed3d11d | Amos Kong | .desc = "Failed to set socket to listening mode",
|
322 | aed3d11d | Amos Kong | }, |
323 | aed3d11d | Amos Kong | { |
324 | aed3d11d | Amos Kong | .error_fmt = QERR_SOCKET_BIND_FAILED, |
325 | aed3d11d | Amos Kong | .desc = "Failed to bind socket",
|
326 | aed3d11d | Amos Kong | }, |
327 | aed3d11d | Amos Kong | { |
328 | aed3d11d | Amos Kong | .error_fmt = QERR_SOCKET_CREATE_FAILED, |
329 | aed3d11d | Amos Kong | .desc = "Failed to create socket",
|
330 | aed3d11d | Amos Kong | }, |
331 | 9f9daf9a | Luiz Capitulino | {} |
332 | 9f9daf9a | Luiz Capitulino | }; |
333 | 9f9daf9a | Luiz Capitulino | |
334 | 9f9daf9a | Luiz Capitulino | /**
|
335 | 9f9daf9a | Luiz Capitulino | * qerror_new(): Create a new QError
|
336 | 9f9daf9a | Luiz Capitulino | *
|
337 | 9f9daf9a | Luiz Capitulino | * Return strong reference.
|
338 | 9f9daf9a | Luiz Capitulino | */
|
339 | 9f9daf9a | Luiz Capitulino | QError *qerror_new(void)
|
340 | 9f9daf9a | Luiz Capitulino | { |
341 | 9f9daf9a | Luiz Capitulino | QError *qerr; |
342 | 9f9daf9a | Luiz Capitulino | |
343 | 7267c094 | Anthony Liguori | qerr = g_malloc0(sizeof(*qerr));
|
344 | 9f9daf9a | Luiz Capitulino | QOBJECT_INIT(qerr, &qerror_type); |
345 | 9f9daf9a | Luiz Capitulino | |
346 | 9f9daf9a | Luiz Capitulino | return qerr;
|
347 | 9f9daf9a | Luiz Capitulino | } |
348 | 9f9daf9a | Luiz Capitulino | |
349 | 8b7968f7 | Stefan Weil | static void GCC_FMT_ATTR(2, 3) qerror_abort(const QError *qerr, |
350 | 8b7968f7 | Stefan Weil | const char *fmt, ...) |
351 | 9f9daf9a | Luiz Capitulino | { |
352 | 9f9daf9a | Luiz Capitulino | va_list ap; |
353 | 9f9daf9a | Luiz Capitulino | |
354 | 9f9daf9a | Luiz Capitulino | fprintf(stderr, "qerror: bad call in function '%s':\n", qerr->func);
|
355 | 9f9daf9a | Luiz Capitulino | fprintf(stderr, "qerror: -> ");
|
356 | 9f9daf9a | Luiz Capitulino | |
357 | 9f9daf9a | Luiz Capitulino | va_start(ap, fmt); |
358 | 9f9daf9a | Luiz Capitulino | vfprintf(stderr, fmt, ap); |
359 | 9f9daf9a | Luiz Capitulino | va_end(ap); |
360 | 9f9daf9a | Luiz Capitulino | |
361 | 9f9daf9a | Luiz Capitulino | fprintf(stderr, "\nqerror: call at %s:%d\n", qerr->file, qerr->linenr);
|
362 | 9f9daf9a | Luiz Capitulino | abort(); |
363 | 9f9daf9a | Luiz Capitulino | } |
364 | 9f9daf9a | Luiz Capitulino | |
365 | 8b7968f7 | Stefan Weil | static void GCC_FMT_ATTR(2, 0) qerror_set_data(QError *qerr, |
366 | 8b7968f7 | Stefan Weil | const char *fmt, va_list *va) |
367 | 9f9daf9a | Luiz Capitulino | { |
368 | 9f9daf9a | Luiz Capitulino | QObject *obj; |
369 | 9f9daf9a | Luiz Capitulino | |
370 | 9f9daf9a | Luiz Capitulino | obj = qobject_from_jsonv(fmt, va); |
371 | 9f9daf9a | Luiz Capitulino | if (!obj) {
|
372 | 9f9daf9a | Luiz Capitulino | qerror_abort(qerr, "invalid format '%s'", fmt);
|
373 | 9f9daf9a | Luiz Capitulino | } |
374 | 9f9daf9a | Luiz Capitulino | if (qobject_type(obj) != QTYPE_QDICT) {
|
375 | 9f9daf9a | Luiz Capitulino | qerror_abort(qerr, "error format is not a QDict '%s'", fmt);
|
376 | 9f9daf9a | Luiz Capitulino | } |
377 | 9f9daf9a | Luiz Capitulino | |
378 | 9f9daf9a | Luiz Capitulino | qerr->error = qobject_to_qdict(obj); |
379 | 9f9daf9a | Luiz Capitulino | |
380 | 9f9daf9a | Luiz Capitulino | obj = qdict_get(qerr->error, "class");
|
381 | 9f9daf9a | Luiz Capitulino | if (!obj) {
|
382 | 9f9daf9a | Luiz Capitulino | qerror_abort(qerr, "missing 'class' key in '%s'", fmt);
|
383 | 9f9daf9a | Luiz Capitulino | } |
384 | 9f9daf9a | Luiz Capitulino | if (qobject_type(obj) != QTYPE_QSTRING) {
|
385 | 9f9daf9a | Luiz Capitulino | qerror_abort(qerr, "'class' key value should be a QString");
|
386 | 9f9daf9a | Luiz Capitulino | } |
387 | 9f9daf9a | Luiz Capitulino | |
388 | 9f9daf9a | Luiz Capitulino | obj = qdict_get(qerr->error, "data");
|
389 | 9f9daf9a | Luiz Capitulino | if (!obj) {
|
390 | 9f9daf9a | Luiz Capitulino | qerror_abort(qerr, "missing 'data' key in '%s'", fmt);
|
391 | 9f9daf9a | Luiz Capitulino | } |
392 | 9f9daf9a | Luiz Capitulino | if (qobject_type(obj) != QTYPE_QDICT) {
|
393 | 9f9daf9a | Luiz Capitulino | qerror_abort(qerr, "'data' key value should be a QDICT");
|
394 | 9f9daf9a | Luiz Capitulino | } |
395 | 9f9daf9a | Luiz Capitulino | } |
396 | 9f9daf9a | Luiz Capitulino | |
397 | 9f9daf9a | Luiz Capitulino | static void qerror_set_desc(QError *qerr, const char *fmt) |
398 | 9f9daf9a | Luiz Capitulino | { |
399 | 9f9daf9a | Luiz Capitulino | int i;
|
400 | 9f9daf9a | Luiz Capitulino | |
401 | 9f9daf9a | Luiz Capitulino | // FIXME: inefficient loop
|
402 | 9f9daf9a | Luiz Capitulino | |
403 | 9f9daf9a | Luiz Capitulino | for (i = 0; qerror_table[i].error_fmt; i++) { |
404 | 9f9daf9a | Luiz Capitulino | if (strcmp(qerror_table[i].error_fmt, fmt) == 0) { |
405 | 9f9daf9a | Luiz Capitulino | qerr->entry = &qerror_table[i]; |
406 | 9f9daf9a | Luiz Capitulino | return;
|
407 | 9f9daf9a | Luiz Capitulino | } |
408 | 9f9daf9a | Luiz Capitulino | } |
409 | 9f9daf9a | Luiz Capitulino | |
410 | 9f9daf9a | Luiz Capitulino | qerror_abort(qerr, "error format '%s' not found", fmt);
|
411 | 9f9daf9a | Luiz Capitulino | } |
412 | 9f9daf9a | Luiz Capitulino | |
413 | 9f9daf9a | Luiz Capitulino | /**
|
414 | 9f9daf9a | Luiz Capitulino | * qerror_from_info(): Create a new QError from error information
|
415 | 9f9daf9a | Luiz Capitulino | *
|
416 | 9f9daf9a | Luiz Capitulino | * The information consists of:
|
417 | 9f9daf9a | Luiz Capitulino | *
|
418 | 9f9daf9a | Luiz Capitulino | * - file the file name of where the error occurred
|
419 | 9f9daf9a | Luiz Capitulino | * - linenr the line number of where the error occurred
|
420 | 9f9daf9a | Luiz Capitulino | * - func the function name of where the error occurred
|
421 | 9f9daf9a | Luiz Capitulino | * - fmt JSON printf-like dictionary, there must exist keys 'class' and
|
422 | 9f9daf9a | Luiz Capitulino | * 'data'
|
423 | 9f9daf9a | Luiz Capitulino | * - va va_list of all arguments specified by fmt
|
424 | 9f9daf9a | Luiz Capitulino | *
|
425 | 9f9daf9a | Luiz Capitulino | * Return strong reference.
|
426 | 9f9daf9a | Luiz Capitulino | */
|
427 | 9f9daf9a | Luiz Capitulino | QError *qerror_from_info(const char *file, int linenr, const char *func, |
428 | 9f9daf9a | Luiz Capitulino | const char *fmt, va_list *va) |
429 | 9f9daf9a | Luiz Capitulino | { |
430 | 9f9daf9a | Luiz Capitulino | QError *qerr; |
431 | 9f9daf9a | Luiz Capitulino | |
432 | 9f9daf9a | Luiz Capitulino | qerr = qerror_new(); |
433 | 827b0813 | Markus Armbruster | loc_save(&qerr->loc); |
434 | 9f9daf9a | Luiz Capitulino | qerr->linenr = linenr; |
435 | 9f9daf9a | Luiz Capitulino | qerr->file = file; |
436 | 9f9daf9a | Luiz Capitulino | qerr->func = func; |
437 | 9f9daf9a | Luiz Capitulino | |
438 | 9f9daf9a | Luiz Capitulino | if (!fmt) {
|
439 | 9f9daf9a | Luiz Capitulino | qerror_abort(qerr, "QDict not specified");
|
440 | 9f9daf9a | Luiz Capitulino | } |
441 | 9f9daf9a | Luiz Capitulino | |
442 | 9f9daf9a | Luiz Capitulino | qerror_set_data(qerr, fmt, va); |
443 | 9f9daf9a | Luiz Capitulino | qerror_set_desc(qerr, fmt); |
444 | 9f9daf9a | Luiz Capitulino | |
445 | 9f9daf9a | Luiz Capitulino | return qerr;
|
446 | 9f9daf9a | Luiz Capitulino | } |
447 | 9f9daf9a | Luiz Capitulino | |
448 | a12eeaaa | Luiz Capitulino | static void parse_error(const QErrorStringTable *entry, int c) |
449 | 9f9daf9a | Luiz Capitulino | { |
450 | a12eeaaa | Luiz Capitulino | fprintf(stderr, "expected '%c' in '%s'", c, entry->desc);
|
451 | a12eeaaa | Luiz Capitulino | abort(); |
452 | 9f9daf9a | Luiz Capitulino | } |
453 | 9f9daf9a | Luiz Capitulino | |
454 | a12eeaaa | Luiz Capitulino | static const char *append_field(QDict *error, QString *outstr, |
455 | a12eeaaa | Luiz Capitulino | const QErrorStringTable *entry,
|
456 | 9f9daf9a | Luiz Capitulino | const char *start) |
457 | 9f9daf9a | Luiz Capitulino | { |
458 | 9f9daf9a | Luiz Capitulino | QObject *obj; |
459 | 9f9daf9a | Luiz Capitulino | QDict *qdict; |
460 | 9f9daf9a | Luiz Capitulino | QString *key_qs; |
461 | 9f9daf9a | Luiz Capitulino | const char *end, *key; |
462 | 9f9daf9a | Luiz Capitulino | |
463 | 9f9daf9a | Luiz Capitulino | if (*start != '%') |
464 | a12eeaaa | Luiz Capitulino | parse_error(entry, '%');
|
465 | 9f9daf9a | Luiz Capitulino | start++; |
466 | 9f9daf9a | Luiz Capitulino | if (*start != '(') |
467 | a12eeaaa | Luiz Capitulino | parse_error(entry, '(');
|
468 | 9f9daf9a | Luiz Capitulino | start++; |
469 | 9f9daf9a | Luiz Capitulino | |
470 | 9f9daf9a | Luiz Capitulino | end = strchr(start, ')');
|
471 | 9f9daf9a | Luiz Capitulino | if (!end)
|
472 | a12eeaaa | Luiz Capitulino | parse_error(entry, ')');
|
473 | 9f9daf9a | Luiz Capitulino | |
474 | 9f9daf9a | Luiz Capitulino | key_qs = qstring_from_substr(start, 0, end - start - 1); |
475 | 9f9daf9a | Luiz Capitulino | key = qstring_get_str(key_qs); |
476 | 9f9daf9a | Luiz Capitulino | |
477 | a12eeaaa | Luiz Capitulino | qdict = qobject_to_qdict(qdict_get(error, "data"));
|
478 | 9f9daf9a | Luiz Capitulino | obj = qdict_get(qdict, key); |
479 | 9f9daf9a | Luiz Capitulino | if (!obj) {
|
480 | a12eeaaa | Luiz Capitulino | abort(); |
481 | 9f9daf9a | Luiz Capitulino | } |
482 | 9f9daf9a | Luiz Capitulino | |
483 | 9f9daf9a | Luiz Capitulino | switch (qobject_type(obj)) {
|
484 | 9f9daf9a | Luiz Capitulino | case QTYPE_QSTRING:
|
485 | 9f9daf9a | Luiz Capitulino | qstring_append(outstr, qdict_get_str(qdict, key)); |
486 | 9f9daf9a | Luiz Capitulino | break;
|
487 | 9f9daf9a | Luiz Capitulino | case QTYPE_QINT:
|
488 | 9f9daf9a | Luiz Capitulino | qstring_append_int(outstr, qdict_get_int(qdict, key)); |
489 | 9f9daf9a | Luiz Capitulino | break;
|
490 | 9f9daf9a | Luiz Capitulino | default:
|
491 | a12eeaaa | Luiz Capitulino | abort(); |
492 | 9f9daf9a | Luiz Capitulino | } |
493 | 9f9daf9a | Luiz Capitulino | |
494 | 9f9daf9a | Luiz Capitulino | QDECREF(key_qs); |
495 | 9f9daf9a | Luiz Capitulino | return ++end;
|
496 | 9f9daf9a | Luiz Capitulino | } |
497 | 9f9daf9a | Luiz Capitulino | |
498 | a12eeaaa | Luiz Capitulino | static QString *qerror_format_desc(QDict *error,
|
499 | a12eeaaa | Luiz Capitulino | const QErrorStringTable *entry)
|
500 | 9f9daf9a | Luiz Capitulino | { |
501 | 9f9daf9a | Luiz Capitulino | QString *qstring; |
502 | a12eeaaa | Luiz Capitulino | const char *p; |
503 | 9f9daf9a | Luiz Capitulino | |
504 | a12eeaaa | Luiz Capitulino | assert(entry != NULL);
|
505 | 9f9daf9a | Luiz Capitulino | |
506 | 9f9daf9a | Luiz Capitulino | qstring = qstring_new(); |
507 | 9f9daf9a | Luiz Capitulino | |
508 | a12eeaaa | Luiz Capitulino | for (p = entry->desc; *p != '\0';) { |
509 | 9f9daf9a | Luiz Capitulino | if (*p != '%') { |
510 | 9f9daf9a | Luiz Capitulino | qstring_append_chr(qstring, *p++); |
511 | 9f9daf9a | Luiz Capitulino | } else if (*(p + 1) == '%') { |
512 | 9f9daf9a | Luiz Capitulino | qstring_append_chr(qstring, '%');
|
513 | 9f9daf9a | Luiz Capitulino | p += 2;
|
514 | 9f9daf9a | Luiz Capitulino | } else {
|
515 | a12eeaaa | Luiz Capitulino | p = append_field(error, qstring, entry, p); |
516 | 9f9daf9a | Luiz Capitulino | } |
517 | 9f9daf9a | Luiz Capitulino | } |
518 | 9f9daf9a | Luiz Capitulino | |
519 | 77e595e7 | Markus Armbruster | return qstring;
|
520 | 77e595e7 | Markus Armbruster | } |
521 | 77e595e7 | Markus Armbruster | |
522 | 87c2f591 | Luiz Capitulino | QString *qerror_format(const char *fmt, QDict *error) |
523 | 87c2f591 | Luiz Capitulino | { |
524 | 87c2f591 | Luiz Capitulino | const QErrorStringTable *entry = NULL; |
525 | 87c2f591 | Luiz Capitulino | int i;
|
526 | 87c2f591 | Luiz Capitulino | |
527 | 87c2f591 | Luiz Capitulino | for (i = 0; qerror_table[i].error_fmt; i++) { |
528 | 87c2f591 | Luiz Capitulino | if (strcmp(qerror_table[i].error_fmt, fmt) == 0) { |
529 | 87c2f591 | Luiz Capitulino | entry = &qerror_table[i]; |
530 | 87c2f591 | Luiz Capitulino | break;
|
531 | 87c2f591 | Luiz Capitulino | } |
532 | 87c2f591 | Luiz Capitulino | } |
533 | 87c2f591 | Luiz Capitulino | |
534 | 87c2f591 | Luiz Capitulino | return qerror_format_desc(error, entry);
|
535 | 87c2f591 | Luiz Capitulino | } |
536 | 87c2f591 | Luiz Capitulino | |
537 | 77e595e7 | Markus Armbruster | /**
|
538 | a12eeaaa | Luiz Capitulino | * qerror_human(): Format QError data into human-readable string.
|
539 | a12eeaaa | Luiz Capitulino | */
|
540 | a12eeaaa | Luiz Capitulino | QString *qerror_human(const QError *qerror)
|
541 | a12eeaaa | Luiz Capitulino | { |
542 | a12eeaaa | Luiz Capitulino | return qerror_format_desc(qerror->error, qerror->entry);
|
543 | a12eeaaa | Luiz Capitulino | } |
544 | a12eeaaa | Luiz Capitulino | |
545 | a12eeaaa | Luiz Capitulino | /**
|
546 | 77e595e7 | Markus Armbruster | * qerror_print(): Print QError data
|
547 | 77e595e7 | Markus Armbruster | *
|
548 | 77e595e7 | Markus Armbruster | * This function will print the member 'desc' of the specified QError object,
|
549 | 1ecda02b | Markus Armbruster | * it uses error_report() for this, so that the output is routed to the right
|
550 | 77e595e7 | Markus Armbruster | * place (ie. stderr or Monitor's device).
|
551 | 77e595e7 | Markus Armbruster | */
|
552 | 827b0813 | Markus Armbruster | void qerror_print(QError *qerror)
|
553 | 77e595e7 | Markus Armbruster | { |
554 | 77e595e7 | Markus Armbruster | QString *qstring = qerror_human(qerror); |
555 | 827b0813 | Markus Armbruster | loc_push_restore(&qerror->loc); |
556 | 1ecda02b | Markus Armbruster | error_report("%s", qstring_get_str(qstring));
|
557 | 827b0813 | Markus Armbruster | loc_pop(&qerror->loc); |
558 | 9f9daf9a | Luiz Capitulino | QDECREF(qstring); |
559 | 9f9daf9a | Luiz Capitulino | } |
560 | 9f9daf9a | Luiz Capitulino | |
561 | 0167f772 | Markus Armbruster | void qerror_report_internal(const char *file, int linenr, const char *func, |
562 | 0167f772 | Markus Armbruster | const char *fmt, ...) |
563 | 0167f772 | Markus Armbruster | { |
564 | 0167f772 | Markus Armbruster | va_list va; |
565 | 0167f772 | Markus Armbruster | QError *qerror; |
566 | 0167f772 | Markus Armbruster | |
567 | 0167f772 | Markus Armbruster | va_start(va, fmt); |
568 | 0167f772 | Markus Armbruster | qerror = qerror_from_info(file, linenr, func, fmt, &va); |
569 | 0167f772 | Markus Armbruster | va_end(va); |
570 | 0167f772 | Markus Armbruster | |
571 | 0167f772 | Markus Armbruster | if (monitor_cur_is_qmp()) {
|
572 | 0167f772 | Markus Armbruster | monitor_set_error(cur_mon, qerror); |
573 | 0167f772 | Markus Armbruster | } else {
|
574 | 0167f772 | Markus Armbruster | qerror_print(qerror); |
575 | 0167f772 | Markus Armbruster | QDECREF(qerror); |
576 | 0167f772 | Markus Armbruster | } |
577 | 0167f772 | Markus Armbruster | } |
578 | 0167f772 | Markus Armbruster | |
579 | 2a82d936 | Anthony Liguori | /* Evil... */
|
580 | 2a82d936 | Anthony Liguori | struct Error
|
581 | 2a82d936 | Anthony Liguori | { |
582 | 2a82d936 | Anthony Liguori | QDict *obj; |
583 | 2a82d936 | Anthony Liguori | const char *fmt; |
584 | 2a82d936 | Anthony Liguori | char *msg;
|
585 | 2a82d936 | Anthony Liguori | }; |
586 | 2a82d936 | Anthony Liguori | |
587 | 2a82d936 | Anthony Liguori | void qerror_report_err(Error *err)
|
588 | 2a82d936 | Anthony Liguori | { |
589 | 2a82d936 | Anthony Liguori | QError *qerr; |
590 | 2a82d936 | Anthony Liguori | int i;
|
591 | 2a82d936 | Anthony Liguori | |
592 | 2a82d936 | Anthony Liguori | qerr = qerror_new(); |
593 | 2a82d936 | Anthony Liguori | loc_save(&qerr->loc); |
594 | 2a82d936 | Anthony Liguori | QINCREF(err->obj); |
595 | 2a82d936 | Anthony Liguori | qerr->error = err->obj; |
596 | 2a82d936 | Anthony Liguori | |
597 | 2a82d936 | Anthony Liguori | for (i = 0; qerror_table[i].error_fmt; i++) { |
598 | 2a82d936 | Anthony Liguori | if (strcmp(qerror_table[i].error_fmt, err->fmt) == 0) { |
599 | 2a82d936 | Anthony Liguori | qerr->entry = &qerror_table[i]; |
600 | 2a82d936 | Anthony Liguori | break;
|
601 | 2a82d936 | Anthony Liguori | } |
602 | 2a82d936 | Anthony Liguori | } |
603 | 2a82d936 | Anthony Liguori | |
604 | 2a82d936 | Anthony Liguori | if (monitor_cur_is_qmp()) {
|
605 | 2a82d936 | Anthony Liguori | monitor_set_error(cur_mon, qerr); |
606 | 2a82d936 | Anthony Liguori | } else {
|
607 | 2a82d936 | Anthony Liguori | qerror_print(qerr); |
608 | 2a82d936 | Anthony Liguori | QDECREF(qerr); |
609 | 2a82d936 | Anthony Liguori | } |
610 | 2a82d936 | Anthony Liguori | } |
611 | 2a82d936 | Anthony Liguori | |
612 | 59f971d4 | Paolo Bonzini | void assert_no_error(Error *err)
|
613 | 59f971d4 | Paolo Bonzini | { |
614 | 59f971d4 | Paolo Bonzini | if (err) {
|
615 | 59f971d4 | Paolo Bonzini | qerror_report_err(err); |
616 | 59f971d4 | Paolo Bonzini | abort(); |
617 | 59f971d4 | Paolo Bonzini | } |
618 | 59f971d4 | Paolo Bonzini | } |
619 | 59f971d4 | Paolo Bonzini | |
620 | 9f9daf9a | Luiz Capitulino | /**
|
621 | 9f9daf9a | Luiz Capitulino | * qobject_to_qerror(): Convert a QObject into a QError
|
622 | 9f9daf9a | Luiz Capitulino | */
|
623 | 9f9daf9a | Luiz Capitulino | QError *qobject_to_qerror(const QObject *obj)
|
624 | 9f9daf9a | Luiz Capitulino | { |
625 | 9f9daf9a | Luiz Capitulino | if (qobject_type(obj) != QTYPE_QERROR) {
|
626 | 9f9daf9a | Luiz Capitulino | return NULL; |
627 | 9f9daf9a | Luiz Capitulino | } |
628 | 9f9daf9a | Luiz Capitulino | |
629 | 9f9daf9a | Luiz Capitulino | return container_of(obj, QError, base);
|
630 | 9f9daf9a | Luiz Capitulino | } |
631 | 9f9daf9a | Luiz Capitulino | |
632 | 9f9daf9a | Luiz Capitulino | /**
|
633 | 9f9daf9a | Luiz Capitulino | * qerror_destroy_obj(): Free all memory allocated by a QError
|
634 | 9f9daf9a | Luiz Capitulino | */
|
635 | 9f9daf9a | Luiz Capitulino | static void qerror_destroy_obj(QObject *obj) |
636 | 9f9daf9a | Luiz Capitulino | { |
637 | 9f9daf9a | Luiz Capitulino | QError *qerr; |
638 | 9f9daf9a | Luiz Capitulino | |
639 | 9f9daf9a | Luiz Capitulino | assert(obj != NULL);
|
640 | 9f9daf9a | Luiz Capitulino | qerr = qobject_to_qerror(obj); |
641 | 9f9daf9a | Luiz Capitulino | |
642 | 9f9daf9a | Luiz Capitulino | QDECREF(qerr->error); |
643 | 7267c094 | Anthony Liguori | g_free(qerr); |
644 | 9f9daf9a | Luiz Capitulino | } |