You are not logged in.
I have a bare bones qemu virtual machine on my private server at home. The host is a server running arch with cli only and has a UPS to power down the system in case of a power sortage wich tends to happen a lot in my part of town.
The guest is windows server 2016.
I have written a service file to start up and shut down the vm but when the host initiates shutdown the vm keeps running until i manualy log in the vm and shut it down manualy. That creates a problem of arch just killing the vm after it waits the 1 minute and 30 seconds for the service to terminate.
Here is the service file i'm using:
[Unit]
Description=Qemu-WinSrv2016 Service
After=network-target
[Service]
Type=forking
WorkingDirectory=/nas/qemu/windows/logs
User=zerostring
ExecStartPre=/usr/bin/cp /usr/share/ovmf/x64/OVMF_VARS.fd /tmp/OVMF_VARS.fd
ExecStartPre=/usr/bin/cp /usr/share/ovmf/x64/OVMF_CODE.fd /tmp/OVMF_CODE.fd
ExecStart=/usr/bin/screen -dmSL Qemu-WinSrv2016 bash -c 'qemu-system-x86_64 -enable-kvm -machine type=pc,accel=kvm \
-cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,hv_vendor_id=VM \
-smp cores=2,threads=2 \
-m 8G -mem-prealloc \
-netdev bridge,br=intel-br0,id=ndev -device virtio-net-pci,mac=52:54:00:00:38:32,id=nic0,netdev=ndev \
-vga qxl -spice port=41158,password=mypass -device virtio-serial-pci -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 -chardev spicevmc,id=spicechannel0,name=vdagent \
-soundhw hda \
-serial none \
-parallel none \
-vnc none \
-drive if=pflash,format=raw,readonly,file=/tmp/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=/tmp/OVMF_VARS.fd \
-drive format=raw,file=/nas/qemu/windows/img/windows.img \
-drive file=/nas/qemu/windows/iso/en_windows_server_2016_x64_dvd_9327751.iso,index=1,media=cdrom \
-drive file=/nas/qemu/windows/iso/virtio-win-0.1.141.iso,index=2,media=cdrom \
-usbdevice tablet \
-monitor stdio'
ExecStop=/usr/bin/screen -S Qemu-WinSrv2016 -p 0 -X eval 'stuff "system_powerdown"\015'
ExecStop=/bin/bash -c "while ps -p $MAINPID > /dev/null; do /bin/sleep 1; done"
Restart=on-failure
RestartSec=60
[Install]
WantedBy=multi-user.targetThe commands are aent to the screen but they do nothing. I have also used tried the unix socket option and the result is the same.
Any help is appreciated.
Last edited by 7thCore (2018-11-07 22:53:28)
The Linux philosophy is 'Laugh in the face of danger'. Oops. Wrong One. 'Do it yourself'. Yes, that's it.
Offline
Also the power settings for the power button are set to shutdown in the guest.
The Linux philosophy is 'Laugh in the face of danger'. Oops. Wrong One. 'Do it yourself'. Yes, that's it.
Offline
I don't think that ExecStop lines you have including that loop to wait for a process to die is how systemd expects you to manage termination of the service. I am not a Qemu user, so I can't really comment on it too much, but did you check this comment made on the Qemu Wiki: https://wiki.archlinux.org/index.php/Ta … md_in_2018.
Offline
While it showed promissing results at first it still leaves the vm running (without initiating the shutdown sequence) when the host goes through it's shutdown process and kills the vm.
Thanks for trying tho.
Last edited by 7thCore (2018-11-12 22:04:36)
The Linux philosophy is 'Laugh in the face of danger'. Oops. Wrong One. 'Do it yourself'. Yes, that's it.
Offline