Skip to contentSkip to conversation

xen/passthrough: add missing error-report include

PATCH In review Adam Williamson 5 participants 10 messages Jul 17, 2025 – Jul 28, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/passthrough: add missing error-report include

In cfcacba an error_report was added to this file, but the corresponding include of qemu/error-report.h was missed. This only becomes apparent when building against Xen 4.20+.

---
 hw/xen/xen_pt.c | 1 +
 1 file changed, 1 insertion(+)
hw/xen/xen_pt.c +1 -0
index 9d16644d82..006b5b55f2 100644
@@ -54,6 +54,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include <sys/ioctl.h>
 
 #include "hw/pci/pci.h"
Signature · 1 line
2.50.1
#1 lore raw
Quoted 14 lines · Adam Williamson

In cfcacba an error_report was added to this file, but the corresponding include of qemu/error-report.h was missed. This only becomes apparent when building against Xen 4.20+.

---
 hw/xen/xen_pt.c | 1 +
 1 file changed, 1 insertion(+)
hw/xen/xen_pt.c +0 -0
index 9d16644d82..006b5b55f2 100644

hw/xen/xen_pt.c line 60

Quoted 7 lines
hw/xen/xen_pt.c +1 -0
@@ -54,6 +54,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include <sys/ioctl.h>
 
 #include "hw/pci/pci.h"

Uh, error-report.h is included without this for me. To see, build with -H:

. /work/armbru/qemu/hw/xen/xen_pt.h
.. /work/armbru/qemu/include/hw/xen/xen_native.h ... /work/armbru/qemu/hw/xen/trace.h
.... ./trace/trace-hw_xen.h
..... /work/armbru/qemu/include/qemu/error-report.h

Code smell: header in include/... includes header from hw/. Not this patch's concern.

Reviewed-by
#2 lore raw
Quoted 27 lines · Markus Armbruster
Quoted 14 lines · Adam Williamson

In cfcacba an error_report was added to this file, but the corresponding include of qemu/error-report.h was missed. This only becomes apparent when building against Xen 4.20+.

---
 hw/xen/xen_pt.c | 1 +
 1 file changed, 1 insertion(+)
hw/xen/xen_pt.c +0 -0
index 9d16644d82..006b5b55f2 100644

hw/xen/xen_pt.c line 60

Quoted 7 lines
hw/xen/xen_pt.c +1 -0
@@ -54,6 +54,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include <sys/ioctl.h>
 
 #include "hw/pci/pci.h"

Uh, error-report.h is included without this for me. To see, build with -H:

Quoted 5 lines

. /work/armbru/qemu/hw/xen/xen_pt.h
.. /work/armbru/qemu/include/hw/xen/xen_native.h ... /work/armbru/qemu/hw/xen/trace.h
.... ./trace/trace-hw_xen.h
..... /work/armbru/qemu/include/qemu/error-report.h

Just remembered: the generated trace header includes error-report.h only when trace's log backend is enabled.

Suggested commit message:

In commit cfcacba an error_report was added to this file, but the corresponding include of qemu/error-report.h was missed. This only becomes apparent when building against Xen 4.20+ with trace backend log disabled.

Fixes cfcacbab38e4 (xen/passthrough: use gsi to map pirq when dom0 is PVH)

With something like that

Quoted 2 lines

Code smell: header in include/... includes header from hw/. Not this patch's concern.

#3 lore raw
Quoted 29 lines · Markus Armbruster
Quoted 27 lines · Markus Armbruster
Quoted 14 lines · Adam Williamson

In cfcacba an error_report was added to this file, but the corresponding include of qemu/error-report.h was missed. This only becomes apparent when building against Xen 4.20+.

---
 hw/xen/xen_pt.c | 1 +
 1 file changed, 1 insertion(+)
hw/xen/xen_pt.c +0 -0
index 9d16644d82..006b5b55f2 100644

hw/xen/xen_pt.c line 60

Quoted 7 lines
hw/xen/xen_pt.c +1 -0
@@ -54,6 +54,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include <sys/ioctl.h>
 
 #include "hw/pci/pci.h"

Uh, error-report.h is included without this for me. To see, build with -H:

Quoted 8 lines
Quoted 5 lines

. /work/armbru/qemu/hw/xen/xen_pt.h
.. /work/armbru/qemu/include/hw/xen/xen_native.h ... /work/armbru/qemu/hw/xen/trace.h
.... ./trace/trace-hw_xen.h
..... /work/armbru/qemu/include/qemu/error-report.h

Just remembered: the generated trace header includes error-report.h only when trace's log backend is enabled.

Hmm, that's rather an unfortunate trap-door :-( Given that 'log' is enabled by default when building from git we'll never see missing error-report.h problems in daily work.

Looking at the log backend it appears that originally it would unconditionally include the timestamp when calling qemu_log, but then changed that to opt-in with

commit 418ed14268f797a5142b60cd557cd598eb548c66
Author: Stefan Hajnoczi <[email protected]>
Date: Mon Jan 25 11:35:07 2021 +0000

trace: make the 'log' backend timestamp configurable

requiring -msg timestamp=on, which was a pre-existing flag that already did a similar toggle for the 'error_report' function. The goal makes sense, but it introduced the error-report.h trap door

When I see that I also question why the 'log' backend should be a special case user of qemu_log() ? Why shouldn't we emit timestamps for all usage of qemu_log() ?

If we changed the qemu_log impl to honour the timestamp toggle, then all users of qemu_log benefit. We then eliminate error-report.h usage in trace.h headers, and also cut the code size for trace points significantly

static inline void _nocheck__trace_object_dynamic_cast_assert(const char * type, const char * target, const char * file, int line, const char * func)

{
    if (trace_event_get_state(TRACE_OBJECT_DYNAMIC_CAST_ASSERT) && qemu_loglevel_mask(LOG_TRACE)) {
        if (message_with_timestamp) {
            struct timeval _now;
            gettimeofday(&_now, NULL);
            qemu_log("%d@%zu.%06zu:object_dynamic_cast_assert " "%s->%s (%s:%d:%s)" "\n",
                     qemu_get_thread_id(),
                     (size_t)_now.tv_sec, (size_t)_now.tv_usec
                     , type, target, file, line, func);
        } else {
            qemu_log("object_dynamic_cast_assert " "%s->%s (%s:%d:%s)" "\n", type, target, file, line, func);
        }
    }
}

down to

static inline void _nocheck__trace_object_dynamic_cast_assert(const char * type, const char * target, const char * file, int line, const char * func)

{
    if (trace_event_get_state(TRACE_OBJECT_DYNAMIC_CAST_ASSERT) && qemu_loglevel_mask(LOG_TRACE)) {
            qemu_log("object_dynamic_cast_assert " "%s->%s (%s:%d:%s)" "\n", type, target, file, line, func);
    }
}

which feels more in keeping with the kind of level of complexity you should want to be inlined in trace callers.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw
Quoted 36 lines · Daniel P. Berrangé
Quoted 35 lines · Markus Armbruster
Quoted 32 lines · Markus Armbruster
Quoted 14 lines · Adam Williamson

In cfcacba an error_report was added to this file, but the corresponding include of qemu/error-report.h was missed. This only becomes apparent when building against Xen 4.20+.

---
 hw/xen/xen_pt.c | 1 +
 1 file changed, 1 insertion(+)
hw/xen/xen_pt.c +0 -0
index 9d16644d82..006b5b55f2 100644

hw/xen/xen_pt.c line 60

Quoted 7 lines
hw/xen/xen_pt.c +1 -0
@@ -54,6 +54,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include <sys/ioctl.h>
 
 #include "hw/pci/pci.h"

Uh, error-report.h is included without this for me. To see, build with -H:

. /work/armbru/qemu/hw/xen/xen_pt.h
.. /work/armbru/qemu/include/hw/xen/xen_native.h ... /work/armbru/qemu/hw/xen/trace.h
.... ./trace/trace-hw_xen.h
..... /work/armbru/qemu/include/qemu/error-report.h

Quoted 6 lines
Quoted 2 lines

Just remembered: the generated trace header includes error-report.h only when trace's log backend is enabled.

Hmm, that's rather an unfortunate trap-door :-( Given that 'log' is enabled by default when building from git we'll never see missing error-report.h problems in daily work.

Correct.

Quoted 44 lines

Looking at the log backend it appears that originally it would unconditionally include the timestamp when calling qemu_log, but then changed that to opt-in with

commit 418ed14268f797a5142b60cd557cd598eb548c66
Author: Stefan Hajnoczi <[email protected]>
Date: Mon Jan 25 11:35:07 2021 +0000

trace: make the 'log' backend timestamp configurable

requiring -msg timestamp=on, which was a pre-existing flag that already did a similar toggle for the 'error_report' function. The goal makes sense, but it introduced the error-report.h trap door

When I see that I also question why the 'log' backend should be a special case user of qemu_log() ? Why shouldn't we emit timestamps for all usage of qemu_log() ?

If we changed the qemu_log impl to honour the timestamp toggle, then all users of qemu_log benefit. We then eliminate error-report.h usage in trace.h headers, and also cut the code size for trace points significantly

static inline void _nocheck__trace_object_dynamic_cast_assert(const char * type, const char * target, const char * file, int line, const char * func)

{
    if (trace_event_get_state(TRACE_OBJECT_DYNAMIC_CAST_ASSERT) && qemu_loglevel_mask(LOG_TRACE)) {
        if (message_with_timestamp) {
            struct timeval _now;
            gettimeofday(&_now, NULL);
            qemu_log("%d@%zu.%06zu:object_dynamic_cast_assert " "%s->%s (%s:%d:%s)" "\n",
                     qemu_get_thread_id(),
                     (size_t)_now.tv_sec, (size_t)_now.tv_usec
                     , type, target, file, line, func);
        } else {
            qemu_log("object_dynamic_cast_assert " "%s->%s (%s:%d:%s)" "\n", type, target, file, line, func);
        }
    }
}

down to

static inline void _nocheck__trace_object_dynamic_cast_assert(const char * type, const char * target, const char * file, int line, const char * func)

Quoted 8 lines
{
    if (trace_event_get_state(TRACE_OBJECT_DYNAMIC_CAST_ASSERT) && qemu_loglevel_mask(LOG_TRACE)) {
            qemu_log("object_dynamic_cast_assert " "%s->%s (%s:%d:%s)" "\n", type, target, file, line, func);
    }
}

which feels more in keeping with the kind of level of complexity you should want to be inlined in trace callers.

Oh yes. We should do this even if we find a reason for keeping qemu_log() as it is. The obvious way would be a new function qemu_log_with_timestamp().

#5 lore raw
Quoted 97 lines · Markus Armbruster
Quoted 36 lines · Daniel P. Berrangé
Quoted 35 lines · Markus Armbruster
Quoted 32 lines · Markus Armbruster
Quoted 14 lines · Adam Williamson

In cfcacba an error_report was added to this file, but the corresponding include of qemu/error-report.h was missed. This only becomes apparent when building against Xen 4.20+.

---
 hw/xen/xen_pt.c | 1 +
 1 file changed, 1 insertion(+)
hw/xen/xen_pt.c +0 -0
index 9d16644d82..006b5b55f2 100644

hw/xen/xen_pt.c line 60

Quoted 7 lines
hw/xen/xen_pt.c +1 -0
@@ -54,6 +54,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include <sys/ioctl.h>
 
 #include "hw/pci/pci.h"

Uh, error-report.h is included without this for me. To see, build with -H:

. /work/armbru/qemu/hw/xen/xen_pt.h
.. /work/armbru/qemu/include/hw/xen/xen_native.h ... /work/armbru/qemu/hw/xen/trace.h
.... ./trace/trace-hw_xen.h
..... /work/armbru/qemu/include/qemu/error-report.h

Quoted 6 lines
Quoted 2 lines

Just remembered: the generated trace header includes error-report.h only when trace's log backend is enabled.

Hmm, that's rather an unfortunate trap-door :-( Given that 'log' is enabled by default when building from git we'll never see missing error-report.h problems in daily work.

Correct.

Quoted 50 lines

Looking at the log backend it appears that originally it would unconditionally include the timestamp when calling qemu_log, but then changed that to opt-in with

commit 418ed14268f797a5142b60cd557cd598eb548c66
Author: Stefan Hajnoczi <[email protected]>
Date: Mon Jan 25 11:35:07 2021 +0000

trace: make the 'log' backend timestamp configurable

requiring -msg timestamp=on, which was a pre-existing flag that already did a similar toggle for the 'error_report' function. The goal makes sense, but it introduced the error-report.h trap door

When I see that I also question why the 'log' backend should be a special case user of qemu_log() ? Why shouldn't we emit timestamps for all usage of qemu_log() ?

If we changed the qemu_log impl to honour the timestamp toggle, then all users of qemu_log benefit. We then eliminate error-report.h usage in trace.h headers, and also cut the code size for trace points significantly

static inline void _nocheck__trace_object_dynamic_cast_assert(const char * type, const char * target, const char * file, int line, const char * func)

{
    if (trace_event_get_state(TRACE_OBJECT_DYNAMIC_CAST_ASSERT) && qemu_loglevel_mask(LOG_TRACE)) {
        if (message_with_timestamp) {
            struct timeval _now;
            gettimeofday(&_now, NULL);
            qemu_log("%d@%zu.%06zu:object_dynamic_cast_assert " "%s->%s (%s:%d:%s)" "\n",
                     qemu_get_thread_id(),
                     (size_t)_now.tv_sec, (size_t)_now.tv_usec
                     , type, target, file, line, func);
        } else {
            qemu_log("object_dynamic_cast_assert " "%s->%s (%s:%d:%s)" "\n", type, target, file, line, func);
        }
    }
}

down to

static inline void _nocheck__trace_object_dynamic_cast_assert(const char * type, const char * target, const char * file, int line, const char * func)

{
    if (trace_event_get_state(TRACE_OBJECT_DYNAMIC_CAST_ASSERT) && qemu_loglevel_mask(LOG_TRACE)) {
            qemu_log("object_dynamic_cast_assert " "%s->%s (%s:%d:%s)" "\n", type, target, file, line, func);
    }
}
Quoted 6 lines
Quoted 2 lines

which feels more in keeping with the kind of level of complexity you should want to be inlined in trace callers.

Oh yes. We should do this even if we find a reason for keeping qemu_log() as it is. The obvious way would be a new function qemu_log_with_timestamp().

Now proposed at:

https://lists.nongnu.org/archive/html/qemu-devel/2025-07/msg05234.html

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#6 lore raw
In reply to Markus Armbruster
Quoted 3 lines · Markus Armbruster
Quoted 1 line · Adam Williamson

In cfcacba an error_report was added to this file, but the

In commit cfcacbab38e ("xen/passthrough: use gsi to map pirq when dom0 is PVH") an error_report was added to this file, but the

Quoted 24 lines
Quoted 13 lines

corresponding include of qemu/error-report.h was missed. This only becomes apparent when building against Xen 4.20+.

---
  hw/xen/xen_pt.c | 1 +
  1 file changed, 1 insertion(+)
hw/xen/xen_pt.c +0 -0
index 9d16644d82..006b5b55f2 100644

hw/xen/xen_pt.c line 60

Quoted 7 lines
hw/xen/xen_pt.c +1 -0
@@ -54,6 +54,7 @@
 
  #include "qemu/osdep.h"
  #include "qapi/error.h"
+#include "qemu/error-report.h"
  #include <sys/ioctl.h>
 
  #include "hw/pci/pci.h"

Uh, error-report.h is included without this for me. To see, build with -H:

Quoted 8 lines

. /work/armbru/qemu/hw/xen/xen_pt.h
.. /work/armbru/qemu/include/hw/xen/xen_native.h ... /work/armbru/qemu/hw/xen/trace.h
.... ./trace/trace-hw_xen.h
..... /work/armbru/qemu/include/qemu/error-report.h

Code smell: header in include/... includes header from hw/. Not this patch's concern.

Lucky side effect of including "trace.h" a include/ file due to trace event being called in inlined function. Bad pattern indeed.

Back to this patch:

#7 lore raw
Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Markus Armbruster
Quoted 1 line · Adam Williamson

In cfcacba an error_report was added to this file, but the

   In commit cfcacbab38e ("xen/passthrough: use gsi to map pirq when dom0 is PVH") an error_report was added to this file, but the

Quoted 27 lines
Quoted 13 lines

corresponding include of qemu/error-report.h was missed. This only becomes apparent when building against Xen 4.20+.

---
  hw/xen/xen_pt.c | 1 +

  1 file changed, 1 insertion(+)
hw/xen/xen_pt.c +0 -0
index 9d16644d82..006b5b55f2 100644

hw/xen/xen_pt.c line 58

Quoted 5 lines
hw/xen/xen_pt.c +1 -0
@@ -54,6 +54,7 @@
   #include "qemu/osdep.h"
   #include "qapi/error.h"
+#include "qemu/error-report.h"
   #include <sys/ioctl.h>
   #include "hw/pci/pci.h"

Uh, error-report.h is included without this for me.  To see, build with -H:

. /work/armbru/qemu/hw/xen/xen_pt.h
.. /work/armbru/qemu/include/hw/xen/xen_native.h ... /work/armbru/qemu/hw/xen/trace.h
.... ./trace/trace-hw_xen.h
..... /work/armbru/qemu/include/qemu/error-report.h

FYI "qemu/error-report.h" was added in commit 418ed14268f ("trace:
make the 'log' backend timestamp configurable") to access the message_with_timestamp declaration.

Quoted 11 lines
Quoted 3 lines

Code smell: header in include/... includes header from hw/.  Not this patch's concern.

Lucky side effect of including "trace.h" a include/ file due to trace event being called in inlined function. Bad pattern indeed.

Back to this patch:

Reviewed-by on v1 1/1
#8 lore raw
In reply to Adam Williamson

Am 17. Juli 2025 22:02:07 UTC schrieb Adam Williamson <[email protected]>:

Quoted 14 lines

In cfcacba an error_report was added to this file, but the corresponding include of qemu/error-report.h was missed. This only becomes apparent when building against Xen 4.20+.

---
hw/xen/xen_pt.c | 1 +

1 file changed, 1 insertion(+)
hw/xen/xen_pt.c +0 -0
index 9d16644d82..006b5b55f2 100644

hw/xen/xen_pt.c line 60

Quoted 7 lines
hw/xen/xen_pt.c +1 -0
@@ -54,6 +54,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include <sys/ioctl.h>
 
 #include "hw/pci/pci.h"