diff mbox series

[1/5] log: Add logs for vm start and destroy

Message ID 20200806093720.2355692-2-liangpeng10@huawei.com
State New
Headers show
Series log: Add logs for some modules | expand

Commit Message

Peng Liang Aug. 6, 2020, 9:37 a.m. UTC
Add logs for vm start and destroy.

Signed-off-by: Peng Liang <liangpeng10@huawei.com>
---
 hw/acpi/core.c  | 3 +++
 hw/core/reset.c | 2 ++
 softmmu/vl.c    | 8 ++++++++
 3 files changed, 13 insertions(+)

Comments

Thomas Huth Aug. 6, 2020, 10:07 a.m. UTC | #1
On 06/08/2020 11.37, Peng Liang wrote:
> Add logs for vm start and destroy.
> 
> Signed-off-by: Peng Liang <liangpeng10@huawei.com>
> ---
>  hw/acpi/core.c  | 3 +++
>  hw/core/reset.c | 2 ++
>  softmmu/vl.c    | 8 ++++++++
>  3 files changed, 13 insertions(+)
> 
> diff --git a/hw/acpi/core.c b/hw/acpi/core.c
> index ac06db3450..0a24f018cf 100644
> --- a/hw/acpi/core.c
> +++ b/hw/acpi/core.c
> @@ -560,13 +560,16 @@ static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)
>          uint16_t sus_typ = (val >> 10) & 7;
>          switch(sus_typ) {
>          case 0: /* soft power off */
> +            info_report("VM will be soft power off");
>              qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
>              break;
>          case 1:
> +            info_report("VM will be suspend state");
>              qemu_system_suspend_request();
>              break;
>          default:
>              if (sus_typ == ar->pm1.cnt.s4_val) { /* S4 request */
> +                info_report("VM will be S4 state");
>                  qapi_event_send_suspend_disk();
>                  qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
>              }

There is already a trace point in qemu_system_shutdown_request(), so
this can already be used instead.

 Thomas
diff mbox series

Patch

diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index ac06db3450..0a24f018cf 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -560,13 +560,16 @@  static void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)
         uint16_t sus_typ = (val >> 10) & 7;
         switch(sus_typ) {
         case 0: /* soft power off */
+            info_report("VM will be soft power off");
             qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
             break;
         case 1:
+            info_report("VM will be suspend state");
             qemu_system_suspend_request();
             break;
         default:
             if (sus_typ == ar->pm1.cnt.s4_val) { /* S4 request */
+                info_report("VM will be S4 state");
                 qapi_event_send_suspend_disk();
                 qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
             }
diff --git a/hw/core/reset.c b/hw/core/reset.c
index 9c477f2bf5..bd583c77ac 100644
--- a/hw/core/reset.c
+++ b/hw/core/reset.c
@@ -26,6 +26,7 @@ 
 #include "qemu/osdep.h"
 #include "qemu/queue.h"
 #include "sysemu/reset.h"
+#include "qemu/error-report.h"
 
 /* reset/shutdown handler */
 
@@ -64,6 +65,7 @@  void qemu_devices_reset(void)
 {
     QEMUResetEntry *re, *nre;
 
+    info_report("reset all devices");
     /* reset all devices */
     QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) {
         re->func(re->opaque);
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 4eb9d1f7fd..a9f06111b3 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -1657,9 +1657,11 @@  static bool main_loop_should_exit(void)
     }
     if (qemu_powerdown_requested()) {
         qemu_system_powerdown();
+        info_report("domain is power down by outside operation");
     }
     if (qemu_vmstop_requested(&r)) {
         vm_stop(r);
+        info_report("domain is stopped by outside operation");
     }
     return false;
 }
@@ -1669,6 +1671,7 @@  void qemu_main_loop(void)
 #ifdef CONFIG_PROFILER
     int64_t ti;
 #endif
+    info_report("qemu enter main_loop");
     while (!main_loop_should_exit()) {
 #ifdef CONFIG_PROFILER
         ti = profile_getclock();
@@ -2941,6 +2944,7 @@  void qemu_init(int argc, char **argv, char **envp)
 
     autostart = 1;
 
+    info_report("qemu pid is %d, options parsing start", getpid());
     /* first pass of option parsing */
     optind = 1;
     while (optind < argc) {
@@ -3154,6 +3158,7 @@  void qemu_init(int argc, char **argv, char **envp)
                 exit(0);
                 break;
             case QEMU_OPTION_m:
+                info_report("memory options parse start");
                 opts = qemu_opts_parse_noisily(qemu_find_opts("memory"),
                                                optarg, true);
                 if (!opts) {
@@ -4152,6 +4157,7 @@  void qemu_init(int argc, char **argv, char **envp)
     current_machine->maxram_size = maxram_size;
     current_machine->ram_slots = ram_slots;
 
+    info_report("configure accelerator %s start", machine_class->name);
     /*
      * Note: uses machine properties such as kernel-irqchip, must run
      * after machine_set_property().
@@ -4300,6 +4306,7 @@  void qemu_init(int argc, char **argv, char **envp)
     replay_checkpoint(CHECKPOINT_INIT);
     qdev_machine_init();
 
+    info_report("machine init start");
     current_machine->boot_order = boot_order;
 
     /* parse features once if machine provides default cpu_type */
@@ -4379,6 +4386,7 @@  void qemu_init(int argc, char **argv, char **envp)
             exit(1);
     }
 
+    info_report("device init start");
     /* init generic devices */
     rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
     qemu_opts_foreach(qemu_find_opts("device"),