Bug 1460338 - guestfs_shutdown hangs if main process sets signal handlers
guestfs_shutdown hangs if main process sets signal handlers
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Richard W.M. Jones
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-09 14:12 EDT by Richard W.M. Jones
Modified: 2017-06-13 11:45 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-06-13 11:45:16 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
lvm_guestfs.c (1.33 KB, text/x-csrc)
2017-06-09 14:12 EDT, Richard W.M. Jones
no flags Details
Debugging output (44.70 KB, text/plain)
2017-06-09 14:12 EDT, Richard W.M. Jones
no flags Details

  None (edit)
Description Richard W.M. Jones 2017-06-09 14:12:06 EDT
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.
Comment 1 Richard W.M. Jones 2017-06-09 14:12 EDT
Created attachment 1286486 [details]
Debugging output
Comment 2 Richard W.M. Jones 2017-06-09 18:12:47 EDT
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
Comment 3 Richard W.M. Jones 2017-06-10 13:25:14 EDT
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.
Comment 4 Richard W.M. Jones 2017-06-10 13:33:38 EDT
Patch posted upstream:

https://www.redhat.com/archives/libguestfs/2017-June/msg00061.html

Note You need to log in before you can comment on or make changes to this bug.