spice: Make logging printing go through QEMU
PATCH 1/1 spice: Make logging printing go through QEMU
Since spice 0.14.1, it's possible to use g_log_set_default_handler() to use a custom function to print spice-server's logs, which gives more consistent log output.
With older spice versions, this is not going to work as expected, but will not have any ill effect, so this call is not conditional on spice version.
Since this added g_log_set_default_handler() will bridge glib logging and QEMU logging, the call might fit better in a more generic place.
--- ui/spice-core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
ui/spice-core.c +25 -0
@@ -632,6 +632,30 @@ static void vm_change_state_handler(void *opaque, int running, } } +static void qemu_log_func (const gchar *log_domain, +GLogLevelFlags log_level, +const gchar *message, +gpointer user_data) +{ +switch (log_level &G_LOG_LEVEL_MASK ) { +case G_LOG_LEVEL_DEBUG : +break ; +case G_LOG_LEVEL_INFO : +/* Fall through */ +case G_LOG_LEVEL_MESSAGE : +info_report ("%s" , message); +break ; +case G_LOG_LEVEL_WARNING : +/* Fall through */ +case G_LOG_LEVEL_CRITICAL : +warn_report ("%s" , message); +break ; +case G_LOG_LEVEL_ERROR : +error_report ("%s" , message); +break ; + } +} +void qemu_spice_init (void ) {QemuOpts *opts =QTAILQ_FIRST (&qemu_spice_opts.head);
@@ -647,6 +671,7 @@ void qemu_spice_init(void)spice_wan_compression_t wan_compr;bool seamless_migration; +g_log_set_default_handler (qemu_log_func,NULL );qemu_thread_get_self (&me);if (!opts) {
Signature · 1 line
2.19.2
Quoted 10 lines · Christophe Fergeau
Since spice 0.14.1, it's possible to use
g_log_set_default_handler()to use a custom function to print spice-server's logs, which gives more consistent log output.With older spice versions, this is not going to work as expected, but will not have any ill effect, so this call is not conditional on spice version.
Since this added
g_log_set_default_handler()will bridge glib logging and QEMU logging, the call might fit better in a more generic place.
Yeah, I think this is the kind of thing that could go early in the main() method.
It might also be relevant to integrate it into unit tests and other tools (qemu-img/nbd/io/etc).
Quoted 21 lines
Signed-off-by Christophe Fergeau <[email protected]>--- ui/spice-core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)ui/spice-core.c +7
-0@@ -632,6 +632,30 @@ static void vm_change_state_handler(void *opaque, int running, } } +static void qemu_log_func (const gchar *log_domain, +GLogLevelFlags log_level, +const gchar *message, +gpointer user_data) +{ +switch (log_level &G_LOG_LEVEL_MASK ) { +case G_LOG_LEVEL_DEBUG :
ui/spice-core.c static void vm_change_state_handler(void *opaque, int running, · line 651
Quoted 10 lines
ui/spice-core.c +10
-0+break ; +case G_LOG_LEVEL_INFO : +/* Fall through */ +case G_LOG_LEVEL_MESSAGE : +info_report ("%s" , message); +break ; +case G_LOG_LEVEL_WARNING : +/* Fall through */ +case G_LOG_LEVEL_CRITICAL : +warn_report ("%s" , message);
IIUC, CRITICAL & ERROR are both reporting errors, the only difference is that LEVEL_ERROR results in the process being terminated immediately.
Anyway, I think this means G_LOG_LEVEL_CRITICAL should use erorr_report too. Only G_LOG_LEVEL_WARNING should use warn_report
ui/spice-core.c static void vm_change_state_handler(void *opaque, int running, · line 657
Quoted 6 lines
ui/spice-core.c +6
-0+break ; +case G_LOG_LEVEL_ERROR : +error_report ("%s" , message); +break ; + } +}
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 :|
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH] spice: Make logging printing go through QEMU
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
eba6c0d spice: Make logging printing go through QEMU
=== OUTPUT BEGIN ===
Checking PATCH 1/1: spice: Make logging printing go through QEMU...
ERROR: switch and case should be at the same indent
#33: FILE: ui/spice-core.c:640:
+ switch (log_level & G_LOG_LEVEL_MASK) {
+ case G_LOG_LEVEL_DEBUG:
[...]
+ case G_LOG_LEVEL_INFO:
[...]
+ case G_LOG_LEVEL_MESSAGE:
[...]
+ case G_LOG_LEVEL_WARNING:
[...]
+ case G_LOG_LEVEL_CRITICAL:
[...]
+ case G_LOG_LEVEL_ERROR:
total: 1 errors, 0 warnings, 37 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]