Bug 1130912 - save job displayed as "Stopped" and always taken system resource even if save job finished when running it under background
Summary: save job displayed as "Stopped" and always taken system resource even if save...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Erik Skultety
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-18 07:48 UTC by zhengqin
Modified: 2014-09-10 13:43 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-09-10 13:43:58 UTC


Attachments (Terms of Use)

Description zhengqin 2014-08-18 07:48:57 UTC
Description of problem:


Version-Release number of selected component (if applicable):
libvirt-1.2.7-1.el7.x86_64
qemu-kvm-rhev-2.1.0-1.el7.x86_64
kernel-3.10.0-142.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1.Prepare a running guest named "rhel6-new", execute the following commands:

[root@rhel7 ~]# virsh save rhel6-new savefile &
[1] 6295
[root@rhel7 ~]# jobs
[1]+  Stopped                 virsh save rhel6-new savefile
[root@rhel7 ~]# jobs
[1]+  Stopped                 virsh save rhel6-new savefile

2. "savefile" is generated and guest is shutoff, but background job displayed as "Stopped"

3. "virsh save" command still taken process resource.
[root@rhel7 ~]# ps aux | grep virsh
root     19227  0.0  0.3 401216  6528 pts/0    Tl   03:39   0:00 virsh save rhel6-new savefile


Actual results:
save job is finished but background job displayed it still "Stopped", and it still taken process resource by checking command "ps" 

Expected results:
save job is finished but background job displayed as "Done", and it should release process resource by checking command "ps"



Additional info:
This issue does not occur on rhel6.6

on rhel6.6:
[root@rhel6 ~]# jobs
[1]+  Running                 virsh save rhel6 rhel6.save &
[root@rhel6 ~]#
Domain rhel6 saved to rhel6.save


[1]+  Done                    virsh save rhel6 rhel6.save

Comment 1 zhe peng 2014-08-19 02:22:28 UTC
This not only occured when using 'save' cmd, 'dump' 'managedsave' also have this issue.

Comment 2 Erik Skultety 2014-09-10 13:43:58 UTC
It is because if a process is executed in background, it cannot read from stdin nor write to stdout (the latter not entirely true, it is controlled by TOSTOP flag in terminal driver which is by default off). If it tries to read from stdin, it receives SIGTTIN signal which resolves into stopping the process by default.
An example:
$ cat &
[1] 24270
$ jobs
[1]+  Stopped    cat

If you place the job back to foreground (fg), everything works as expected. Now the problem why it worked in rhel6 is because there was a different signal handler which introduced a bug https://bugzilla.redhat.com/show_bug.cgi?id=983348 (clone https://bugzilla.redhat.com/show_bug.cgi?id=983350).
Now the handling works as expected and if you really want to run commands that require reading from stdin on background, you might want to redirect the input from /dev/null, in that case the process won't get stopped from trying to read from stdin.

Erik


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