On 23.09.25 12:09, Markus Armbruster wrote:
VFU_OBJECT_ERROR() reports the error with error_setg(&error_abort,
...) when auto-shutdown is enabled, else with error_report().
Issues:
1. The error is serious enough to warrant aborting the process when
auto-shutdown is enabled, yet harmless enough to permit carrying on
when it's disabled. This makes no sense to me.
2. Like assert(), &error_abort is strictly for programming errors. Is
this one?
Brief look at the code make me think that, no it isn't.
Or should we exit(1) instead?
3. qapi/error.h advises "don't error_setg(&error_abort, ...), use
assert()."
This patch addresses just 3.
Cc: Jagannathan Raman <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
---
hw/remote/vfio-user-obj.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c
index ea6165ebdc..eb96982a3a 100644
--- a/hw/remote/vfio-user-obj.c
+++ b/hw/remote/vfio-user-obj.c
@@ -75,12 +75,9 @@ OBJECT_DECLARE_TYPE(VfuObject, VfuObjectClass, VFU_OBJECT)
*/
#define VFU_OBJECT_ERROR(o, fmt, ...) \
{ \
- if (vfu_object_auto_shutdown()) { \
- error_setg(&error_abort, (fmt), ## __VA_ARGS__); \
- } else { \
- error_report((fmt), ## __VA_ARGS__); \
- } \
- } \
+ error_report((fmt), ## __VA_ARGS__); \
+ assert(!vfu_object_auto_shutdown()); \
Probably, it's only my feeling, but for me, assert() is really strictly bound
to programming errors, more than abort(). Using abort() for errors which are
not programming, but we can't handle them looks less confusing, i.e.
if (vfu_object_auto_shutdown()) {
abort();
}
Not really matter. Anyway:
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
+ }
struct VfuObjectClass {
ObjectClass parent_class;
--
Best regards,
Vladimir