kvmadm icon indicating copy to clipboard operation
kvmadm copied to clipboard

Shutting down Windows VM leaves svc in maintenance

Open gbulfon opened this issue 5 years ago • 4 comments

Hi, is there any reason why a Windows VM shutting down from within Windows leaves the specific svc in maintenance state? I always need to disable the specific svc to enable it again.

Gabriele

gbulfon avatar Jan 02 '20 13:01 gbulfon

This usually means that the qemu process did not stop before the stop method timed out (set to 300 seconds). Can you check that the windows VM is acutally shutting down? If so, and it takes longer than 300 seconds you might want to increase the timeout property of the stop method in SMF.

edit: sorry just realised that you are shutting down from within the VM. Well yes that will leave the the specific FMRI in maintenance state. As from SFM's point of view the qemu process just "disappeared".

hadfl avatar Jan 02 '20 20:01 hadfl

I understand what you mean. But from the point of view of an admin interface, if you look for example at VMware or Proxmox, shutting down the machine from within the VM shows the machine as stopped, as expected by an admin user. If I ever want to create an admin interface for this, how can I determine that this is not actually "maintenance" but normal system shutdown? Is there any way that the svc can see that qemu disappeared normally and not abnormally, then show a normal "disabled" state?

gbulfon avatar Jan 05 '20 17:01 gbulfon

I don't think there is a mechanism in SMF for that. But if you are aware of one, let me know.

For the behaviour you expect you are probably better off using branded zones (like e.g. kvm/bhyve branded zones on OmniOS) instead of services

hadfl avatar Jan 06 '20 19:01 hadfl

Usually, old style start/stop scripts would check for a known pid file. If the process is absent and there is no pid file, that has clearly shutdown and deleted it for known reasons, so the service should be "disabled". If the process is absent and there is stilla a pid file, this is an abnormal state, and should be "maintenance".

I don't know if qemu cmd has any flag to drop its pid file somewhere and remove it on clean shutdown. If not, this may be implemented with a wrapper starting qemu, keeping the pid number and saving it in a known place, then join qemu process and check for errno on exit, to decide if the pid file should be deleted or not (clean exit, or not).

Just my 2 cents ;)

Gabriele

gbulfon avatar Jan 08 '20 08:01 gbulfon