Bug 801286

Summary: qemu-kvm is terminated when interrupt a guestfish command
Product: Red Hat Enterprise Linux 6 Reporter: Qixiang Wan <qwan>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: leiwang, moli, qguan
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-08 10:31:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Qixiang Wan 2012-03-08 07:50:57 UTC
Description of problem:
When pgroup is set to "false", users can interrupt a guestfish command by pressing "Ctrl-C", but the qemu-kvm could also be terminated.

Version-Release number of selected component (if applicable):
libguestfs-1.16.8-1.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Launch the guestfish with pgroup set to "false"
2. Run a command which can take a few seconds to finish, like "compress-device-out", then interrupt it by "^C" while it's running.
  
Actual results:
The qemu-kvm process also be terminated

Expected results:
Only the command should be cancelled and qemu-kvm process should keep running well.

Additional info:

verbose log:

$ guestfish -a /images/guest.img -v
><fs> set-pgroup 0
><fs> run
libguestfs: [00000ms] febootstrap-supermin-helper --verbose -f checksum '/usr/lib64/guestfs/supermin.d' x86_64
[...]
libguestfs: recv_from_daemon: received GUESTFS_LAUNCH_FLAG
libguestfs: [03763ms] appliance is up
><fs> compress-device-out gzip /dev/vda vda.zip
libguestfs: send_to_daemon: 68 bytes: 00 00 00 40 | 20 00 f5 f5 | 00 00 00 04 | 00 00 01 24 | 00 00 00 00 | ...
guestfsd: main_loop: proc 7 (list_devices) took 0.00 seconds
guestfsd: main_loop: new request, len 0x40
gzip -c < /dev/vda
libguestfs: recv_from_daemon: 40 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 01 24 | 00 00 00 01 | 00 12 34 01 | ...
libguestfs: recv_from_daemon: 8200 bytes: 00 00 00 00 | 00 00 20 00 | 1f 8b 08 00 | e3 aa 58 4f | 00 03 ec dc | ...
libguestfs: recv_from_daemon: 8200 bytes: 00 00 00 00 | 00 00 20 00 | 00 00 00 00 | 00 00 00 00 | 00 00 00 00 | ...
^Cqemu: terminating on signal 2
libguestfs: error: unexpected end of file when reading from daemon.
See earlier debug messages.
Or you can run 'libguestfs-test-tool' and post the complete output into
a bug report or message to the libguestfs mailing list.
libguestfs: child_cleanup: 0x27cb370: child process died
libguestfs: error: receive_file_data: parse error in reply callback
libguestfs: error: vda.zip: error in chunked encoding
><fs> ping-daemon 
libguestfs: error: ping_daemon: call launch before using this function
(in guestfish, don't forget to use the 'run' command)
><fs>

Comment 2 Qixiang Wan 2012-03-08 07:55:07 UTC
But we're not very sure whether this is a bug. Is the qemu-kvm exactly the subprocess which should receive the SIGINT signal, and there is no subprocess for the guestfish sub-commands?

Please feel free to close this if you think this is the expected result, and there is no necessary to improve the behaviour.

Comment 3 Richard W.M. Jones 2012-03-08 10:31:15 UTC
If users set the pgroup flag to false (which they shouldn't do)
then ^C is delivered to guestfish and to the subprocess (kvm),
killing both.

That's the reason why guestfish sets this flag to true: so that
guestfish can catch ^C during long-running commands and cancel
them properly.

https://github.com/libguestfs/libguestfs/blob/4504f424f5589f81086f5250674b55708e162e5f/fish/fish.c#L399