You are not logged in.
Pages: 1
I am running few virtual machines on kvm/qemu/libvirt. Some are Windows 7, some are Linux. My Windows guests have qemu-agent installed (from https://fedoraproject.org/wiki/Windows_ … t_download), which allows for robust and graceful shutdown, like this:
virsh shutdown --mode=agent gdyniaHowever when I started using libvirt-guests I noticed that it does not use --mode=agent. Which means that my virtual machines won't shutdown gracefully. To allewiate this I made the following change in PKGBUILD of libvirt (in my own repo)
--- a/libvirt/trunk/PKGBUILD
+++ b/libvirt/trunk/PKGBUILD
@@ -87,6 +87,12 @@ prepare() {
sed -i 's|/usr/libexec/qemu-bridge-helper|/usr/lib/qemu/qemu-bridge-helper|g' \
src/qemu/qemu{.conf,_conf.c} \
src/qemu/test_libvirtd_qemu.aug.in
+
+ # support for virsh shutdown mode=agent
+ sed -i 's#run_virsh "$uri" shutdown "$guest"#run_virsh "$uri" shutdown --mode=agent "$guest" >/dev/null 2>\&1 ||\\\
+ run_virsh "$uri" shutdown --mode=acpi "$guest" >/dev/null 2>\&1 ||\\\
+ run_virsh "$uri" shutdown "$guest"#g' \
+ tools/libvirt-guests.sh.in
}
build() {This works reasonably also for Linux virtual machine, except that at shutdown a global error state is set inside retval by one of the shutdown attempts and, as a result, the following is reported:
. . .
Jul 26 17:23:49 gdansk libvirt-guests.sh[11330]: Waiting for 1 guests to shut down, 290 seconds left
Jul 26 17:23:49 gdansk libvirt-guests.sh[11330]: Shutdown of guest gdynia complete.
Jul 26 17:23:49 gdansk systemd[1]: libvirt-guests.service: Control process exited, code=exited status=1
Jul 26 17:23:49 gdansk systemd[1]: Stopped Suspend Active Libvirt Guests.
Jul 26 17:23:49 gdansk systemd[1]: libvirt-guests.service: Unit entered failed state.
Jul 26 17:23:49 gdansk systemd[1]: libvirt-guests.service: Failed with result 'exit-code'.Obviously my scriping skills are not there yet, I was hoping that "||" that I added would suppress error code from all but last failed shutdown attempt. Any idea how to further improve this?
Another thing I added, since host is also a fileserver for guests, is this:
--- a/libvirt/trunk/PKGBUILD
+++ b/libvirt/trunk/PKGBUILD
@@ -93,6 +93,10 @@ prepare() {
run_virsh "$uri" shutdown --mode=acpi "$guest" >/dev/null 2>\&1 ||\\\
run_virsh "$uri" shutdown "$guest"#g' \
tools/libvirt-guests.sh.in
+
+ # dependency on smbd (and indirectly winbindd)
+ sed -i 's|libvirtd.service time-sync.target|libvirtd.service smbd.service time-sync.target|g' \
+ tools/libvirt-guests.service.in
}
build() {Last edited by Bronek (2015-07-26 17:28:49)
Offline
Pages: 1