copy / v86

x86 PC emulator and x86-to-wasm JIT, running in the browser
https://copy.sh/v86/
BSD 2-Clause "Simplified" License
19.67k stars 1.38k forks source link

Feature Request- ACPI Wakeup Call upon initializing VM from saved image state #1075

Open evonox opened 3 months ago

evonox commented 3 months ago

I have the following use case. When I load the OS Linux from the saved image, it contains incorrect date and time. I would like to detect in the hosted OS that the image was woken up and synchronize time from the V86 emulator, for instance using a Bash script. Could the OS Linux receive from ACPI subsystem for instance signal or interrupt that it was awaken from hibernation to automatically synch the clock with the valid value?

SuperMaxusa commented 3 months ago

I would like to detect in the hosted OS that the image was woken up and synchronize time from the V86 emulator, for instance using a Bash script.

You can run hwclock -s (#754) to synchronize time and date from RTC clock.

Could the OS Linux receive from ACPI subsystem for instance signal or interrupt that it was awaken from hibernation to automatically synch the clock with the valid value?

Load from state is not like a hibernation, it's just restore from file your RAM state, some device state and other settings, so I don' t think that ACPI sends any signal after restoring.

Maybe you can run this command (emulator.serial0_send() or emulator.keyboard_send_text()) automatically on emulator-ready or emulator-started events (or if something else is found for #1065).

If it will be helpful, you can run

(( sleep 20 ; hwclock -s ) & ) && clear 

and save state when screen is cleared.

(explanation: this script runs a small task for updating time on background with timeout 20 second (you can choose any value), and clears screen in same time)