I can perform a virsh # shutdown <vmname>, and watch the client gracefully shut down through the VM console. Without actually rebooting/shutting down the server, I can MANUALLY run what libvirt-guests.shutdown does on ExecStop: /usr/lib/libvirt/libvirt-guests.sh stop This lets me watch the client gracefully shut down through the VM console. But, if I actually reboot or shut down the server, systemd acts as if the VM is gracefully being shut down, when it more appears the VM is forcefully being shut down. Unless https://bugzilla.redhat.com/show_bug.cgi?id=1252201 is implemented (allowing watching a vm console, until libvirt-guests is complete) I can't see for sure. But, whereas manually running libvirt-guests.sh stop gives my guest VM a clean shutdown in its logs, the guest sees a crash if I shutdown/reboot the host. Using libvirt 1.2.18 (-1 Arch) and QEMU git-master (2.4.0.r40384.2d69736). pm-utils 1.4.1-6. acpid 2.0.23-4 Installed using Q35 chipset. I can perform virsh # shutdown <vmname>, and watching the client VM console see a graceful shutdown. On host: ===== # systemctl reboot {{{ client VM console immediately blanks out - I do NOT see a graceful shutdown }}} libvirt-guests.sh: Running guests on default URI: <vmname> libvirt-guests.sh: Shuitting down guests on default URI... libvirt-guests.sh: Starting shutdown on guest: <vmname> libvirt-guests.sh: Waiting for 1 guests to shut down, 300 seconds left A stop job is running for Suspend Active Libvirt Guests... libvirt-guests.sh: Waiting for 1 guests to shut down ===== In about 85 seconds, it moves past this, but guest was not suspended or gracefully shutdown. Guest's "last" shows a crash. And, watching on the VM console, the second systemctl restart runs on the host, the VM console disconnects. ===== # systemctl status libvirt-guests ● libvirt-guests.service - Suspend Active Libvirt Guests Loaded: loaded (/usr/lib/systemd/system/libvirt-guests.service; enabled; vendor preset: disabled) Active: active (exited) since Mon 2015-08-10 20:27:57 EDT; 6s ago Docs: man:libvirtd(8) http://libvirt.org Process: 751 ExecStart=/usr/lib/libvirt/libvirt-guests.sh start (code=exited, status=0/SUCCESS) Main PID: 751 (code=exited, status=0/SUCCESS) ===== $ cat /etc/conf.d/libvirt-guests BYPASS_CACHE=0 CONNECT_RETRIES=10 ON_BOOT=start ON_SHUTDOWN=shutdown PARALLEL_SHUTDOWN=4 RETRIES_SLEEP=1 SHUTDOWN_TIMEOUT=300 START_DELAY=0 URIS=default ===== A virsh # shutdown <vmname> or an in-guest systemctl poweroff takes a few seconds (3-5?) ===== {{{ libvirt-guests.service is: }}} [Unit] Description=Suspend Active Libvirt Guests After=network.target libvirtd.service time-sync.target Documentation=man:libvirtd(8) Documentation=http://libvirt.org [Service] EnvironmentFile=-/etc/conf.d/libvirt-guests # Hack just call traditional service until we factor # out the code ExecStart=/usr/lib/libvirt/libvirt-guests.sh start ExecStop=/usr/lib/libvirt/libvirt-guests.sh stop Type=oneshot RemainAfterExit=yes StandardOutput=journal+console [Install] WantedBy=multi-user.target ===== Strangely, manually running "/usr/lib/libvirt/libvirt-guests.sh stop" lets me see a graceful shutdown on the VM console and shows (executing in a few seconds): Running guests on default URI: servo Shutting down guests on default URI... Starting shutdown on guest: servo Waiting for 1 guests to shut down, 300 seconds left Shutdown of guest servo complete. =====
By "libvirt-guests.service doesn't work", I mean to properly run during a shutdown, since that's what it's intended to do... Not do anything while the machine is up and running. systemctl stop libvirt-guests does the same thing as manually running libvirt-guests.sh. My gut tells me this is related to https://bugzilla.redhat.com/show_bug.cgi?id=1252201 That perhaps part of libvirt (not necessarily meaning its systemd service, but something else needed for libvirtd) starts shutting down before libvirt-guests, it can never gracefully shut down.
libvirt-guests has a timeout, it could be hitting that. But if you can't physically sit in front of the machine, you'll need to get more logging out of systemd somehow to see how long everything is taking and what order it's calling services in
Since there's no response, closing as DEFERRED. But if anyone is still affected with newer libvirt versions, please re-open and we can triage from there
Hi, I have similar problem. When I'm running more than 1 VM only the first one is stoped on host shutdown. If I'm not wrong problem occurs until: https://github.com/libvirt/libvirt/commit/fff4682965e41f36b8c486c6f4e55eab5f45fa86#diff-c201dad6e9ea420304b36ef82497dff9R264 File /var/lib/libvirt/libvirt-guests has wrong format. It contains newline after first VM uuid for given URI and next line don't have URI but only uuid. In my case /var/lib/libvirt/libvirt-guests is like this: ===== default 93ca0a98-a77f-4d0e-aafd-29f3eadce3fe e6f48a2d-afda-458d-8510-9085f03c7593 3549b202-dd05-4f17-a124-7c5a95ccf0b6 756ec146-7491-4f28-a22a-cb855976dcd3 fda953f3-cd37-4fe3-8da6-3d4ca3b19f7b ===== But I think it should look like that: ===== default 93ca0a98-a77f-4d0e-aafd-29f3eadce3fe e6f48a2d-afda-458d-8510-9085f03c7593 3549b202-dd05-4f17-a124-7c5a95ccf0b6 756ec146-7491-4f28-a22a-cb855976dcd3 fda953f3-cd37-4fe3-8da6-3d4ca3b19f7b ===== when I remove quotation when echoing list then script work properly. Here is my patch: diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in index 7f74b85..7380b4b 100644 --- a/tools/libvirt-guests.sh.in +++ b/tools/libvirt-guests.sh.in @@ -499,7 +499,7 @@ stop() { fi if [ -n "$list" ]; then - echo "$uri" "$list" >>"$LISTFILE" + echo "$uri" $list >>"$LISTFILE" fi done set +f
I found that my problem is for ubuntu: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1591695