opnsense / plugins

OPNsense plugin collection
https://opnsense.org/
BSD 2-Clause "Simplified" License
835 stars 625 forks source link

emulators/qemu-guest-agent: qemu-ga will not launch thaw operation #4148

Open deajan opened 1 month ago

deajan commented 1 month ago

Important notices Before you add a new report, we ask you kindly to acknowledge the following:

Describe the bug I'm trying to make a fsfreeze-hook script for OPNSense to have quiesce when backing up on KVM hosts. I've noticed that qemu-ga will launch the fsfreeze-hook with freeze argument, but won't run it again with thaw argument until a new snapshot is made, hence rendering the script useless.

To Reproduce Steps to reproduce the behavior:

  1. Create the following file in /usr/local/etc/qemu/fsfreeze-hook
    
    #!/bin/sh

case "$1" in "freeze") echo "FREEZE" >> /tmp/fsfreze ;; "thaw") echo "THAW" >> /tmp/fsfreze ;; esac

3. Make the file executable
4. Stop qemu-guest-agent service
5. Run it manually in order to add `-F` option which will call the above script, eg run `/usr/local/bin/qemu-ga -F -d -v -l /var/log/qemu-ga.log`
6. On the KVM host, run `virsh snapshot-create <domain> --disk-only --atomic --quiesce`
7. Look into file `/tmp/fsfreeze`, it will contain `FREEZE`
8. Run the snapshot command again on KVM host
9. libvirt will complain with `error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': filesystems have already frozen`
10. Look into file `tmp/fsfreeze`, it will contain

FREEZE FREEZE THAW



**Expected behavior**
At the end of the snapshot process, qemu-ga should call `fsfreeze-hook` script with `thaw` argument.
But it runs it only on second (failed) attempt.

Running the freeze/thaw hooks on other guests work.

**Environment**
OPNsense 24.7_9 (amd64)
qemu-guest-agent 9.0.1

Host:
AlmaLinux 9.4
libvirt-daemon-kvm 10.0.0-6.6
qemu-kvm 8.2.0-11
fraenki commented 1 month ago

Not sure whether this is a bug in qemu-ga or the FreeBSD port. It may make sense to report the bug to FreeBSD: https://bugs.freebsd.org/bugzilla/enter_bug.cgi?component=Individual%20Port%28s%29&product=Ports%20%26%20Packages&short_desc=emulators%2Fqemu The maintainer of the FreeBSD port may have further information available.

When this issue is solved, I'll gladly integrate your fsfreeze-hook script in OPNsense.

deajan commented 1 month ago

Bug created as https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=280615