From patchwork Tue Dec 11 14:37:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Fergeau X-Patchwork-Id: 10723919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57BB41869 for ; Tue, 11 Dec 2018 14:38:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B17529F20 for ; Tue, 11 Dec 2018 14:38:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C84B29F51; Tue, 11 Dec 2018 14:38:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BACBC29F0B for ; Tue, 11 Dec 2018 14:38:52 +0000 (UTC) Received: from localhost ([::1]:38467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWjBT-0006yq-Fn for patchwork-qemu-devel@patchwork.kernel.org; Tue, 11 Dec 2018 09:38:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWjAe-0006sj-8W for qemu-devel@nongnu.org; Tue, 11 Dec 2018 09:38:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWjAW-0004lz-KK for qemu-devel@nongnu.org; Tue, 11 Dec 2018 09:37:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:64296) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gWjAW-0004jR-Da for qemu-devel@nongnu.org; Tue, 11 Dec 2018 09:37:52 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFAD6C04BD5F for ; Tue, 11 Dec 2018 14:37:49 +0000 (UTC) Received: from natto.ory.fergeau.eu (unknown [10.48.0.207]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A0ECF105706E for ; Tue, 11 Dec 2018 14:37:49 +0000 (UTC) Received: by natto.ory.fergeau.eu (Postfix, from userid 1000) id 4886861F906; Tue, 11 Dec 2018 15:37:48 +0100 (CET) From: Christophe Fergeau To: qemu-devel@nongnu.org Date: Tue, 11 Dec 2018 15:37:45 +0100 Message-Id: <20181211143745.17342-1-cfergeau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 11 Dec 2018 14:37:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] spice: Make logging printing go through QEMU X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Christophe Fergeau --- ui/spice-core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ui/spice-core.c b/ui/spice-core.c index ebaae24643..443a2b3d32 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -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) {