使用qemu来学习Linux的休眠和唤醒

发布时间 2023-09-22 20:48:20作者: 摩斯电码

休眠

在虚拟机中执行下面的命令:

# echo mem > /sys/power/state

唤醒

进入monitor模式:ctrl+a c

(qemu) system_wakeup

查看日志

查看虚拟机的内核日志:

[   63.878427] PM: suspend entry (deep)
[   63.880758] Filesystems sync: 0.002 seconds
[   63.905165] Freezing user space processes
[   63.918547] Freezing user space processes completed (elapsed 0.013 seconds)
[   63.918600] OOM killer disabled.
[   63.918604] Freezing remaining freezable tasks
[   63.933581] Freezing remaining freezable tasks completed (elapsed 0.014 seconds)
[   63.933956] printk: Suspending console(s) (use no_console_suspend to debug)
[   64.157554] ACPI: PM: Preparing to enter system sleep state S3
[   64.157873] ACPI: PM: Saving platform NVS memory
[   64.158183] Disabling non-boot CPUs ...
[   64.177614] smpboot: CPU 1 is now offline
[   64.190154] smpboot: CPU 2 is now offline
[   64.200412] smpboot: CPU 3 is now offline
[   64.209810] smpboot: CPU 4 is now offline
[   64.218578] smpboot: CPU 5 is now offline
[   64.225909] smpboot: CPU 6 is now offline
[   64.231571] smpboot: CPU 7 is now offline
[  109.246110] ACPI: PM: Low-level resume complete
[  109.246717] ACPI: PM: Restoring platform NVS memory
[  109.264354] Enabling non-boot CPUs ...
[  109.267436] x86: Booting SMP configuration:
[  109.267448] smpboot: Booting Node 0 Processor 1 APIC 0x1
[  109.309331] CPU1 is up
[  109.310011] smpboot: Booting Node 1 Processor 2 APIC 0x2
[  109.335256] CPU2 is up
[  109.336082] smpboot: Booting Node 1 Processor 3 APIC 0x3
[  109.360920] CPU3 is up
[  109.361831] smpboot: Booting Node 2 Processor 4 APIC 0x4
[  109.389742] CPU4 is up
[  109.390474] smpboot: Booting Node 2 Processor 5 APIC 0x5
[  109.417438] CPU5 is up
[  109.418530] smpboot: Booting Node 3 Processor 6 APIC 0x6
[  109.450698] CPU6 is up
[  109.451443] smpboot: Booting Node 3 Processor 7 APIC 0x7
[  109.480943] CPU7 is up
[  109.495593] ACPI: PM: Waking up from system sleep state S3
[  109.509932] pci 0000:00:01.0: PIIX3: Enabling Passive Release
[  109.516706] virtio_blk virtio2: 8/0/0 default/read/poll queues
[  109.539719] OOM killer enabled.
[  109.539724] Restarting tasks ... done.
[  109.544564] random: crng reseeded on system resumption
[  109.568101] PM: suspend exit