On 25/9/25 11:44, Daniel P. Berrangé wrote:
The error_report function can include the guest name in any
messages it prints. The qemu_log function has no equivalent
behaviour.
This introduces support for a "workload name" in the new
messages API, which in the case of system emulators will
be the guest name. The possibility of defining a workload
name for other binaries is left as an exercise for the
future.
This change has no impact on the output of the error_report
function, but will change the qemu_log function. This can
be easily seen with the 'log' trace backend, and how it is
now more closely matching error_report output.
Before:
# qemu-system-x86_64 -msg guest-name=on -name blah -object
tls-creds-x509,id=t0,dir=fish -d 'trace:qcrypto*'
qcrypto_tls_creds_x509_load TLS creds x509 load creds=0x55b3af3fd870 dir=fish
qcrypto_tls_creds_get_path TLS creds path creds=0x55b3af3fd870
filename=ca-cert.pem path=<none>
blah qemu-system-x86_64: Unable to access credentials fish/ca-cert.pem: No
such file or directory
After:
# qemu-system-x86_64 -msg guest-name=on -name blah -object
tls-creds-x509,id=t0,dir=fish -d 'trace:qcrypto*'
blah qcrypto_tls_creds_x509_load TLS creds x509 load creds=0x55b3af3fd870
dir=fish
blah qcrypto_tls_creds_get_path TLS creds path creds=0x55b3af3fd870
filename=ca-cert.pem path=<none>
blah qemu-system-x86_64: Unable to access credentials fish/ca-cert.pem: No
such file or directory
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
Signed-off-by: Daniel P. Berrangé <berra...@redhat.com>
---
include/qemu/error-report.h | 3 ---
include/qemu/message.h | 10 ++++++++++
system/vl.c | 6 ++++--
util/error-report.c | 7 -------
util/message.c | 11 +++++++++++
5 files changed, 25 insertions(+), 12 deletions(-)
void qmessage_context_print(FILE *fp)
{
if (message_format & QMESSAGE_FORMAT_TIMESTAMP) {
@@ -19,4 +25,9 @@ void qmessage_context_print(FILE *fp)
g_autofree char *timestr = g_date_time_format_iso8601(dt);
fprintf(fp, "%s ", timestr);
}
+
+ if ((message_format & QMESSAGE_FORMAT_WORKLOAD_NAME) &&
+ message_workloadname) {
+ fprintf(fp, "%s ", message_workloadname);
Here also no formatting used; use fputs + fputc?
+ }
}