RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 680058 - can't hotplug second vf successful with message "Too many open files"
Summary: can't hotplug second vf successful with message "Too many open files"
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Alex Williamson
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 580953
TreeView+ depends on / blocked
 
Reported: 2011-02-24 09:17 UTC by Chao Yang
Modified: 2013-01-09 23:35 UTC (History)
7 users (show)

Fixed In Version: qemu-kvm-0.12.1.2-2.149.el6
Doc Type: Bug Fix
Doc Text:
Cause: On device removal, the device assignment code was only removing resources that had been mapped into the guest address space. Consequence: The qemu process may leak open file handles if an assigned device is removed before the guest maps the device resources. If this is repeated, the qemu process may eventually reach it's limit of open file handles. Fix: Close all file handles for assigned devices when the device is removed. Result: Qemu no longer leaks file handles, regardless of how quickly devices are add and removed from the VM.
Clone Of:
Environment:
Last Closed: 2011-05-19 11:28:15 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
device message generated by hot plug/unplug (476.86 KB, text/plain)
2011-02-24 09:17 UTC, Chao Yang
no flags Details
listing of /proc/<pid of qemu>/fd (105.85 KB, text/plain)
2011-02-25 07:26 UTC, Chao Yang
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:0534 0 normal SHIPPED_LIVE Important: qemu-kvm security, bug fix, and enhancement update 2011-05-19 11:20:36 UTC

Description Chao Yang 2011-02-24 09:17:09 UTC
Created attachment 480692 [details]
device message generated by hot plug/unplug

Description of problem:
when doing hot plug/unplug two vfs about 300 times, qemu reports " get_real_device: /sys/bus/pci/devices/0000:04:10.3/resource: Too many open files"

Version-Release number of selected component (if applicable):
# rpm -qa|grep qemu
gpxe-roms-qemu-0.9.7-6.4.el6.noarch
qemu-kvm-0.12.1.2-2.147.el6.x86_64
qemu-img-0.12.1.2-2.147.el6.x86_64

# uname -r
2.6.32-117.el6.x86_64

# lspci|grep 82576
04:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
04:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)


How reproducible:
2/2

Steps to Reproduce:
1.boot a guest
# /usr/libexec/qemu-kvm -M rhel6.1.0 -enable-kvm -m 4096 -smp 4 -cpu qemu64,+sse2,+x2apic -name win2008r2 -uuid b044ca52-c418-461e-bf1e-4075b3e613e4 -rtc base=localtime -boot c -drive file=/root/images/windows2008r2-copy-2.qcow2,if=none,id=drive-ide2-0-0,media=disk,format=qcow2,cache=none -device ide-drive,drive=drive-ide2-0-0,id=ide2-0-0 -netdev tap,id=hostnet2 -device e1000,netdev=hostnet2,id=net2,mac=52:54:87:91:87:93 -usb -device usb-tablet -vnc :2 -monitor stdio -balloon none -qmp tcp:0:4445,server,nowait

2.execute a python script to issue hot plug/unplug vf
for i in range(num):
        t = i + 1
        print("Try %s times" % t)
        cmd = "device_add driver=pci-assign host=04:10.1 id=vf1"
        qmp_socket.send(cmd)
	time.sleep(3)
        cmd = "device_add driver=pci-assign host=04:10.3 id=vf3"
        qmp_socket.send(cmd)
        time.sleep(3)
        cmd = "device_del id=vf1"
        qmp_socket.send(cmd)
	time.sleep(3)
        cmd = "device_del id=vf3"
        qmp_socket.send(cmd)
        time.sleep(3)

3.
  
Actual results:

300 times around, qemu failed to hot plug 2nd vf and monitor starts reporting "get_real_device: /sys/bus/pci/devices/0000:04:10.3/resource: Too many open files" when hotplug the second vf every time. At this time, if hot unplug the first vf, then hot plug the second one, qemu won't report such info, and then hot plug the first vf, qemu reports "get_real_device: /sys/bus/pci/devices/0000:04:10.1/resource: Too many open files
pci-assign: Error: Couldn't get real device (vf1)!
Device 'pci-assign' could not be initialized"


Expected results:
qemu could hot plug 2nd vf successfully.

Additional info:

Comment 2 Alex Williamson 2011-02-24 15:38:36 UTC
When this occurs, can you please find the qemu process id (note there may be more than one), and add the listing (ls -l) of /proc/<pid>/fd to the bz.  You should use the pid that has entries for anon_inode:kvm-vcpu in the same directory.  In my testing, all device assignment related file handles are successfully closed when the device is removed.

Comment 3 Chao Yang 2011-02-25 07:26:20 UTC
Created attachment 480945 [details]
listing of /proc/<pid of qemu>/fd

Hi Alex,
Hit again with windows guest, for detail please check the attachment, and I tested with rhel6.1 guest twice, seems the issue can't reproduce on rhel6.1 guest. 

# ps -aux|grep qemu
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      4021 43.0  0.9 4764716 4245716 pts/0 Sl+  14:25   2:07 /usr/libexec/qemu-kvm -M rhel6.1.0 -enable-kvm -m 4096 -smp 4 -cpu qemu64,+sse2,+x2apic -name win2008r2 -uuid b51bc5eb-098b-470c-ab40-fca98dae921c -rtc base=localtime -boot c -drive file=/root/images/windows2008r2-copy-2.qcow2,if=none,id=drive-ide2-0-0,media=disk,format=qcow2,cache=none -device ide-drive,drive=drive-ide2-0-0,id=ide2-0-0 -netdev tap,id=hostnet2 -device e1000,netdev=hostnet2,id=net2,mac=52:54:87:91:87:93 -usb -device usb-tablet -vnc :2 -monitor stdio -balloon none -qmp tcp:0:4445,server,nowait


# ls -l /proc/4021/fd >> fd.txt

Comment 4 Alex Williamson 2011-02-25 20:10:21 UTC
Please test to see if this brew build fixes the problem, I believe I found the error you're hitting:

https://brewweb.devel.redhat.com/taskinfo?taskID=3143074

Comment 5 Chao Yang 2011-02-28 11:11:37 UTC
(In reply to comment #4)
> Please test to see if this brew build fixes the problem, I believe I found the
> error you're hitting:
> 
> https://brewweb.devel.redhat.com/taskinfo?taskID=3143074

Alex,
I am testing your brew build, will get result tmr.

Comment 6 Chao Yang 2011-03-01 04:30:09 UTC
(In reply to comment #4)
> Please test to see if this brew build fixes the problem, I believe I found the
> error you're hitting:
> 
> https://brewweb.devel.redhat.com/taskinfo?taskID=3143074

Alex,
 I test for 3 times, I think this brew build you offer has fixed the error.

Comment 12 Chao Yang 2011-03-18 01:53:23 UTC
Verified with package qemu-kvm-0.12.1.2-2.150.el6.x86_64, have hot plug/unplug for 5000 times on windows 2k8 r2 guest, this issue doesn't exist any more.

/usr/libexec/qemu-kvm -M rhel6.1.0 -enable-kvm -m 4096 -smp 4 -name win2008r2 -uuid 918f1abd-b769-452b-8672-795acd07c9d4 -rtc base=localtime,clock=vm,driftfix=slew -no-kvm-pit-reinjection -boot c -drive file=/root/win2008r2.raw,if=none,id=drive-ide0-0-0,media=disk,format=raw,cache=none -device ide-drive,drive=drive-ide0-0-0,id=ide0-0-0 -netdev tap,id=hostnet2 -device e1000,netdev=hostnet2,id=net2,mac=52:54:87:91:87:93 -usb -device usb-tablet -vnc :2 -monitor stdio -balloon none -qmp tcp:0:4445,server,nowait

Comment 13 Alex Williamson 2011-05-05 16:20:52 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause:
On device removal, the device assignment code was only removing resources that had been mapped into the guest address space.
Consequence:
The qemu process may leak open file handles if an assigned device is removed before the guest maps the device resources.  If this is repeated, the qemu process may eventually reach it's limit of open file handles.
Fix:
Close all file handles for assigned devices when the device is removed.
Result:
Qemu no longer leaks file handles, regardless of how quickly devices are add and removed from the VM.

Comment 14 errata-xmlrpc 2011-05-19 11:28:15 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0534.html

Comment 15 errata-xmlrpc 2011-05-19 13:01:50 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0534.html


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