[7/9] log: report HMP command and event
diff mbox

Message ID 1457954501-26528-8-git-send-email-den@openvz.org
State New
Headers show

Commit Message

Denis V. Lunev March 14, 2016, 11:21 a.m. UTC
From: Pavel Butsykin <pbutsykin@virtuozzo.com>

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Stefan Hajnoczi <stefanha@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Luiz Capitulino <lcapitulino@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: Eric Blake <eblake@redhat.com>
---
 include/qemu/log.h | 1 +
 monitor.c          | 4 ++++
 util/log.c         | 2 ++
 3 files changed, 7 insertions(+)

Comments

Paolo Bonzini March 14, 2016, 2:36 p.m. UTC | #1
On 14/03/2016 12:21, Denis V. Lunev wrote:
> From: Pavel Butsykin <pbutsykin@virtuozzo.com>

Please explain the usecase here.  Is it for debugging the hypervisor or
for something else?

Paolo

> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Luiz Capitulino <lcapitulino@redhat.com>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Eric Blake <eblake@redhat.com>
> ---
>  include/qemu/log.h | 1 +
>  monitor.c          | 4 ++++
>  util/log.c         | 2 ++
>  3 files changed, 7 insertions(+)
> 
> diff --git a/include/qemu/log.h b/include/qemu/log.h
> index 55bceae..9264bbf 100644
> --- a/include/qemu/log.h
> +++ b/include/qemu/log.h
> @@ -43,6 +43,7 @@ static inline bool qemu_log_separate(void)
>  #define CPU_LOG_PAGE       (1 << 14)
>  #define LOG_TRACE          (1 << 15)
>  #define LOG_QMP            (1 << 16)
> +#define LOG_HMP            (1 << 17)
>  
>  /* Returns true if a bit is set in the current loglevel mask
>   */
> diff --git a/monitor.c b/monitor.c
> index eec4e58..4bf4f31 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -2893,6 +2893,8 @@ static void handle_hmp_command(Monitor *mon, const char *cmdline)
>      QDict *qdict;
>      const mon_cmd_t *cmd;
>  
> +    qemu_log_mask(LOG_HMP, "HMP command: %s\n", cmdline);
> +
>      cmd = monitor_parse_command(mon, &cmdline, mon->cmd_table);
>      if (!cmd) {
>          return;
> @@ -4053,11 +4055,13 @@ static void monitor_event(void *opaque, int event)
>          }
>          mon->reset_seen = 1;
>          mon_refcount++;
> +        qemu_log_mask(LOG_HMP, "HMP: new connection established\n");
>          break;
>  
>      case CHR_EVENT_CLOSED:
>          mon_refcount--;
>          monitor_fdsets_cleanup();
> +        qemu_log_mask(LOG_HMP, "HMP: connection closed\n");
>          break;
>      }
>  }
> diff --git a/util/log.c b/util/log.c
> index 5fc517b..795aaea 100644
> --- a/util/log.c
> +++ b/util/log.c
> @@ -133,6 +133,8 @@ const QEMULogItem qemu_log_items[] = {
>        "complete traces" },
>      { LOG_QMP, "qmp",
>        "log the QMP commands and events" },
> +    { LOG_HMP, "hmp",
> +      "log the HMP commands and events" },
>      { 0, NULL, NULL },
>  };
>  
>
Denis V. Lunev March 14, 2016, 3:08 p.m. UTC | #2
On 03/14/2016 05:36 PM, Paolo Bonzini wrote:
> On 14/03/2016 12:21, Denis V. Lunev wrote:
>> From: Pavel Butsykin <pbutsykin@virtuozzo.com>
> Please explain the usecase here.  Is it for debugging the hypervisor or
> for something else?
>
> Paolo
yes. There are important HMP-only commands like switch to snapshot,
which should be logged. The rest is the same as I have answered to
Daniel to patch 6.

Den
Paolo Bonzini March 14, 2016, 4:35 p.m. UTC | #3
On 14/03/2016 16:08, Denis V. Lunev wrote:
>> Please explain the usecase here.  Is it for debugging the hypervisor or
>> for something else?
>
> yes. There are important HMP-only commands like switch to snapshot,
> which should be logged. The rest is the same as I have answered to
> Daniel to patch 6.

Wouldn't they be logged through the human-monitor-command QMP command?

Paolo

Patch
diff mbox

diff --git a/include/qemu/log.h b/include/qemu/log.h
index 55bceae..9264bbf 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -43,6 +43,7 @@  static inline bool qemu_log_separate(void)
 #define CPU_LOG_PAGE       (1 << 14)
 #define LOG_TRACE          (1 << 15)
 #define LOG_QMP            (1 << 16)
+#define LOG_HMP            (1 << 17)
 
 /* Returns true if a bit is set in the current loglevel mask
  */
diff --git a/monitor.c b/monitor.c
index eec4e58..4bf4f31 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2893,6 +2893,8 @@  static void handle_hmp_command(Monitor *mon, const char *cmdline)
     QDict *qdict;
     const mon_cmd_t *cmd;
 
+    qemu_log_mask(LOG_HMP, "HMP command: %s\n", cmdline);
+
     cmd = monitor_parse_command(mon, &cmdline, mon->cmd_table);
     if (!cmd) {
         return;
@@ -4053,11 +4055,13 @@  static void monitor_event(void *opaque, int event)
         }
         mon->reset_seen = 1;
         mon_refcount++;
+        qemu_log_mask(LOG_HMP, "HMP: new connection established\n");
         break;
 
     case CHR_EVENT_CLOSED:
         mon_refcount--;
         monitor_fdsets_cleanup();
+        qemu_log_mask(LOG_HMP, "HMP: connection closed\n");
         break;
     }
 }
diff --git a/util/log.c b/util/log.c
index 5fc517b..795aaea 100644
--- a/util/log.c
+++ b/util/log.c
@@ -133,6 +133,8 @@  const QEMULogItem qemu_log_items[] = {
       "complete traces" },
     { LOG_QMP, "qmp",
       "log the QMP commands and events" },
+    { LOG_HMP, "hmp",
+      "log the HMP commands and events" },
     { 0, NULL, NULL },
 };