Created attachment 1286485 [details] lvm_guestfs.c Description of problem: (Reported by wtfuzz on IRC) The attached program fails, but only when an LVM volume group is open in the main process (using lvm2app). It seems as if lvm2app fiddles with signal handlers, and those are inherited by the forked qemu process, preventing it from seeing the SIGTERM signal that we later send. So guestfs_shutdown hangs. See attached example code and debug. Version-Release number of selected component (if applicable): libguestfs 1.32.7 (from Debian) How reproducible: 100% when lvm_vg_open has been called in the main process.
Created attachment 1286486 [details] Debugging output
From the reporter: 21:25 < wtfuzz> rwmjones: I can confirm that setting up SIGTERM in a sigset_t, and doing a sigprocmask(SIG_UNBLOCK, &mask, NULL) after lvm_vg_open() fixes my issue
I was able to reproduce this easily with upstream by adjusting one of the example programs to include this code in main(): guestfs_set_backend (g, "direct"); sigemptyset (&set); sigaddset (&set, SIGTERM); sigprocmask (SIG_BLOCK, &set, NULL); Note this only affects the 'direct' backend.
Patch posted upstream: https://www.redhat.com/archives/libguestfs/2017-June/msg00061.html
Fixed upstream in: https://github.com/libguestfs/libguestfs/commit/1f1cd11cf0f5a6652c1571fd01a4cce2c7e411ae https://github.com/libguestfs/libguestfs/commit/db8fdfd8d61873b2c5129870014b4af6d2ad6602 In libguestfs >= 1.37.15.