Bug 667188 - device-assignment leaks option ROM memory
Summary: device-assignment leaks option ROM memory
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.1
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: rc
: ---
Assignee: Alex Williamson
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 580954
TreeView+ depends on / blocked
 
Reported: 2011-01-04 18:57 UTC by Alex Williamson
Modified: 2011-05-19 13:00 UTC (History)
4 users (show)

Fixed In Version: qemu-kvm-0.12.1.2-2.132.el6
Doc Type: Bug Fix
Doc Text:
Cause: Device assignment code failed to release memory used for storing device PCI option ROM contents. Consequence: Hot-unplugging assigned devices with an option ROM from a VM did not free the associated ROM memory. Repeatedly adding and removing such devices results in the qemu process size growing. Fix: Fix management of memory used for PCI option ROM of assigned devices. Result: Removal of assigned devices removes all resources consumed by that device in the qemu process.
Clone Of:
Environment:
Last Closed: 2011-05-19 11:30:51 UTC


Attachments (Terms of Use)


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

Description Alex Williamson 2011-01-04 18:57:22 UTC
Description of problem:
When a PCI device with an option ROM is repeatedly added and removed from a guest, the option ROM memory is leaked, causing the guest processes size to grow and eventually be OOM killed.

Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.128.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Launch guest via libvirt
2. Create xml file to assign device, ex:

<hostdev mode='subsystem' type='pci' managed='yes'>
  <source>
    <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
  </source>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</hostdev>

In this case the device is an 82576 PF device w/ 4MB option ROM (leaks even though ROM is invalid).

3. Loop adding and removing the device:

i=1; while virsh attach-device <guest> <xml>; do echo $i; i=$[i+1]; sleep 1; virsh detach-device <guest> <xml>; sleep 1; done
  
Actual results:
top in the host shows the guest process size increasing on each iteration

Expected results:
stable guest process size

Additional info:
Fixed by backporting the following patches:
4b785d9624c1127b358d71933bb5ec476a39db25
576af1b5f5524ca0d6587ae43e395313c14059bb
plus additional patch to chmod the rom file

Comment 5 juzhang 2011-02-11 05:14:27 UTC
Reproduced on qemu-kvm-0.12.1.2-2.129.el6.

step
1.boot guest.
2.run script
while true; do ps --format 'vsz' `pidof qemu-kvm`; sleep 10; done
3.repeat hotplug and hotunplug PF and observe qemu-kvm process VSZ

Results
shows the guest process size increasing
 while true; do ps --format 'vsz' `pidof qemu-kvm`; sleep 10; done
   VSZ
2521376
   VSZ
2521376
   VSZ
2525476 after hotplug
   VSZ
2525476
   VSZ
2525472 after hotunplug
   VSZ
2525472
   VSZ

Verified on qemu-kvm-0.12.1.2-2.144.el6 using the same steps.
Results
stable guest process size
while true; do ps --format 'vsz' `pidof qemu-kvm`; sleep 10; done
   VSZ
2522228
   VSZ
2522228 
   VSZ
2522232 after hotpulg
   VSZ
2522232
   VSZ
2522228 after hotunplug
   VSZ
2522228
   VSZ
2522232 after hotplug
   VSZ
2522232
   VSZ
2522228 after hotunplug
   VSZ
2522228

This issue has been fixed.

Comment 7 Alex Williamson 2011-05-05 16:31:06 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:
Device assignment code failed to release memory used for storing device PCI option ROM contents.
Consequence:
Hot-unplugging assigned devices with an option ROM from a VM did not free the associated ROM memory.  Repeatedly adding and removing such devices results in the qemu process size growing.
Fix:
Fix management of memory used for PCI option ROM of assigned devices.
Result:
Removal of assigned devices removes all resources consumed by that device in the qemu process.

Comment 8 errata-xmlrpc 2011-05-19 11:30:51 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 9 errata-xmlrpc 2011-05-19 13:00:48 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.