qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/1] log hmp/qmp command


From: Denis V. Lunev
Subject: Re: [Qemu-devel] [PATCH 1/1] log hmp/qmp command
Date: Mon, 12 Oct 2015 16:58:20 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 10/12/2015 04:49 PM, Eric Blake wrote:
On 10/12/2015 02:41 AM, Denis V. Lunev wrote:
From: Pavel Butsykin <address@hidden>

This log would be very welcome for long-term diagnostics of the system
in the production. This log is at least necessary to understand what
has been happened on the system and to identify issues at higher-level
subsystems (libvirt, etc).

Signed-off-by: Pavel Butsykin <address@hidden>
Signed-off-by: Denis V. Lunev <address@hidden>
CC: Markus Armbruster <address@hidden>
CC: Luiz Capitulino <address@hidden>
CC: Eric Blake <address@hidden>
---
@@ -3822,6 +3824,8 @@ static void handle_qmp_command(JSONMessageParser *parser, 
QList *tokens)
          error_setg(&local_err, QERR_JSON_PARSING);
          goto err_out;
      }
+    qemu_log_mask(LOG_CMD, "qmp \"%s\" requested\n",
+                  qobject_to_json(obj)->string);
In addition to the leak already pointed out, qobject_to_json() can be
expensive, and it looks like we are doing that work unconditionally even
if the logging is not turned on. Is there a way to optimize so that the
conversion is only done when logging is enabled?

this seems quite reasonable.

Will it be good if we'll change logging implementation to
use macros, something like

#define qemu_log_mask(int mask, const char *ftp, ...) \
do { \
va_list ap; \
  \
if (!(qemu_loglevel & mask) || !qemu_logfile) {\
      break;\
  }\
  qemu_log(ftp, __VA_ARGS__); \
} while (0)

This IMHO makes sense even out of the scope of this patch.

Den



reply via email to

[Prev in Thread] Current Thread [Next in Thread]