From 070514d4498845d190a93acad7afdf06619c6f9c Mon Sep 17 00:00:00 2001 From: Chase Covello <54591271+chasecovello@users.noreply.github.com> Date: Tue, 27 Aug 2024 02:37:21 -0700 Subject: [PATCH] Fix: set RTC to localtime only for Windows/ReactOS/DOS and UTC for all others (#1429) * Set RTC to localtime only for Windows/ReactOS/DOS and UTC for all other OS Windows/ReactOS/DOS conventionally set the system RTC to local time, but Linux/UNIX/macOS use UTC. Guest systems that expect UTC and have the time zone set to local time will have the wrong system clock time at startup until they set the clock with NTP. This is especially an issue for disk images imported from or shared with another VM configuration that uses UTC for non-Windows guests. * Removed RTC driftfix option for non-Windows/ReactOS/DOS guests According to the QEMU man page: Enable driftfix (i386 targets only) if you experience time drift problems, specifically with Windows' ACPI HAL. This option will try to figure out how many timer interrupts were not processed by the Windows guest and will re-inject them. This option thus seems unnecessary for other systems and may cause performance or timekeeping issues, so enable only for Windows/ReactOS/DOS. --- quickemu | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/quickemu b/quickemu index 3c49a08..2ded9d7 100755 --- a/quickemu +++ b/quickemu @@ -1191,9 +1191,16 @@ function vm_boot() { args+=(-machine ${MACHINE_TYPE},smm=${SMM},vmport=off,accel=${QEMU_ACCEL} ${GUEST_TWEAKS} ${CPU} ${SMP} -m ${RAM_VM} ${BALLOON} - -rtc base=localtime,clock=host,driftfix=slew -pidfile "${VMDIR}/${VMNAME}.pid") + if [ "${guest_os}" == "windows" ] || [ "${guest_os}" == "windows-server" ] || [ "${guest_os}" == "reactos" ] || [ "${guest_os}" == "freedos" ]; then + # shellcheck disable=SC2054 + args+=(-rtc base=localtime,clock=host,driftfix=slew) + else + # shellcheck disable=SC2054 + args+=(-rtc base=utc,clock=host) + fi + # shellcheck disable=SC2206 args+=(${VIDEO} -display ${DISPLAY_RENDER}) # Only enable SPICE is using SPICE display