How to find the best "Host shutdown timeout" for a VM?

Problem description

I was debugging a problem in a HomeAssistant app. I noticed it is apparently related to IncusOS system update (in my case at 3am) and it is a problem that the VM did not properly shut-down.

I tried to trace it down in the logs, but I did not even find the log entry for when it started trying to stop the VM hmm? :thinking:

Shutdown done at 3:02:

05. Okt., 03:02:28 7a1f891b-64ac-00eb-8188-bba1bb8fc781 systemd-logind[630]: The system will reboot now!
05. Okt., 03:02:28 7a1f891b-64ac-00eb-8188-bba1bb8fc781 systemd-logind[630]: System is rebooting.

And here it confirms the shutdown was not graceful:

05. Okt., 03:02:05 7a1f891b-64ac-00eb-8188-bba1bb8fc781 systemd[1]: Reloading finished in 645 ms.
05. Okt., 03:02:25 7a1f891b-64ac-00eb-8188-bba1bb8fc781 incusd[1103]: time="2026-10-05T03:02:25+02:00" level=warning msg="Failed shutting down instance, forcefully stopping" err="Failed shutting down instance, status is \"Running\": context deadline exceeded" instance=HAOS project=default
05. Okt., 03:02:26 7a1f891b-64ac-00eb-8188-bba1bb8fc781 kernel: enp2s0f0: port 4(tap98345ad8) entered disabled state
05. Okt., 03:02:26 7a1f891b-64ac-00eb-8188-bba1bb8fc781 systemd-networkd[794]: tap98345ad8: Lost carrier
05. Okt., 03:02:26 7a1f891b-64ac-00eb-8188-bba1bb8fc781 incusd[1103]: time="2026-10-05T03:02:26+02:00" level=warning msg="QMP monitor read failed" err="read unix @->/proc/self/fd/5/qemu.monitor: read: connection reset by peer"
05. Okt., 03:02:26 7a1f891b-64ac-00eb-8188-bba1bb8fc781 kernel: usb 1-6: reset full-speed USB device number 3 using xhci_hcd
05. Okt., 03:02:26 7a1f891b-64ac-00eb-8188-bba1bb8fc781 kernel: cdc_acm 1-6:1.0: ttyACM0: USB ACM device
05. Okt., 03:02:26 7a1f891b-64ac-00eb-8188-bba1bb8fc781 kernel: cdc_acm 1-6:1.2: ttyACM1: USB ACM device
05. Okt., 03:02:26 7a1f891b-64ac-00eb-8188-bba1bb8fc781 55-scsi-sg3_id.rules[436860]: WARNING: SCSI device zd0 has no device ID, consider changing .SCSI_ID_SERIAL_SRC in 00-scsi-sg3_config.rules
05. Okt., 03:02:27 7a1f891b-64ac-00eb-8188-bba1bb8fc781 systemd[1]: var-lib-incus-devices-HAOS-config.mount.mount: Deactivated successfully.

The shutdown timeout was the default 30 seconds. That said, I’ve heard of timeouts up to 1m 45s, which is maybe too much but not totally unexpected in HAOS due to them also gracefully shutting down all dependencies.

Idea

Unfortunately nothing in Incus or IncusOS makes me aware of that problem. Could not it e.g. yield a “Warning” at the next reboot like: “Instance XY did not gracefully shut down in XY minutes. Please adjust the shutdown timeout if needed”?

Or maybe generally show/expose that information in the IncusOS web UI?

Questions

  • Is there a way I am missing or how should I deal with that?
  • Can I somehow see or measure the shutdown time a VM needs?

For the measurement question, I’d separate guest shutdown time from the host’s deadline. Incus documents boot.host_shutdown_timeout as seconds to wait before force-stopping the instance, with a default of 30. It isn’t a measurement of how long HAOS needs.

A read-only first check is:

incus config show HAOS --expanded

Check boot.host_shutdown_timeout and boot.host_shutdown_action there, including anything supplied by profiles.

To measure your particular VM, I’d use a planned maintenance window: start HAOS’s normal host shutdown from inside the guest, note the time, and watch incus list HAOS until its state becomes STOPPED, keeping the guest’s shutdown logs for comparison. Make sure you can start the VM again afterward. This interrupts Home Assistant, so I wouldn’t do it while automations are needed or during a host update. Measure more than one clean shutdown before choosing a timeout with some margin, rather than treating another user’s 1m45s as your VM’s limit.

Your quoted warning already records that this attempt exceeded the deadline and was force-stopped. I don’t know whether IncusOS can surface that warning in the UI after reboot; that part still needs an IncusOS maintainer’s answer. I haven’t reproduced this on HAOS myself.

It only lists:

boot.host_shutdown_timeout: "120"

I did increase that before already to 2min, so that is correct.


Also note yeah your idea of manually noting times was not really appealing to me. That said, when researching I found out the incus wait command, which is exactly what we want, which makes this trivial to automate:

$ time (incus stop HAOS && incus wait HAOS status=stopped)
incus stop HAOS  0,09s user 0,04s system 0% cpu 1:27,23 total

In my experience the incus stop already did wait until the instance was shut down, so maybe you can skip the last part, but anyway, better to be safe.

So it does take 1m 27s for me.

Your experience fits the incus stop manpage: its --timeout flag is documented as the time to wait for the instance to shut down cleanly (default -1), so the extra incus wait is a safety net rather than a requirement.

One thing your measurement is good for: 1m27s against your 120 s setting leaves about 33 s of headroom. Shutdown time is not necessarily constant, so I’d keep a generous margin instead of tuning the timeout close to a single measured run, and re-measure now and then. incus wait makes that easy to repeat.