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 996050 - virsh undefine command with '--remove-all-storage' or '--storage' option when storage volume is unmanaged will cause memory leak.
Summary: virsh undefine command with '--remove-all-storage' or '--storage' option when...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.5
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 999057
TreeView+ depends on / blocked
 
Reported: 2013-08-12 10:11 UTC by Hao Liu
Modified: 2014-04-04 20:57 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 999057 (view as bug list)
Environment:
Last Closed: 2014-04-04 20:57:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Hao Liu 2013-08-12 10:11:37 UTC
Description of problem:
virsh undefine command with '--remove-all-storage' or '--storage' option when storage volume is unmanaged will cause memory leak.

Version-Release number of selected component (if applicable):
libvirt-0.10.2-21.el6.x86_64 or libvirt-0.10.2-18.el6_4.9.x86_64
kernel-2.6.32-410.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.386.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. create a new volume
# dd if=/dev/null of=/root/foo bs=1 count=1 seek=10M

2. define a domain using that volume
# virsh define foo.xml                   (disk source file points to '/root/foo')

3. check whether the new volume is managed by libvirt
# virsh vol-list default                 (make sure 'foo' volume don't exists)

4. check memory leak when undefined with remove-all-storage or --storage option
# valgrind -v --leak-check=full virsh undefine foo --remove-all-storage
or
# valgrind -v --leak-check=full virsh undefine foo --storage /root/foo


Actual results:

1. virsh output
Storage volume 'hda'(/root/foo) is not managed by libvirt. Remove it manually.
Domain foo has been undefined


2. valgrind result
==19011== 4 bytes in 1 blocks are definitely lost in loss record 1 of 82
==19011==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==19011==    by 0x38F0881041: strdup (in /lib64/libc-2.12.so)
==19011==    by 0x4C88054: virXPathString (xml.c:89)
==19011==    by 0x414EA1: cmdUndefine (virsh-domain.c:2624)
==19011==    by 0x40D200: vshCommandRun (virsh.c:1652)
==19011==    by 0x410964: main (virsh.c:3073)
==19011==
==19011== 10 bytes in 1 blocks are definitely lost in loss record 14 of 82
==19011==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==19011==    by 0x38F0881041: strdup (in /lib64/libc-2.12.so)
==19011==    by 0x40EB00: _vshStrdup (virsh.c:129)
==19011==    by 0x40FC28: vshStringToArray (virsh.c:182)
==19011==    by 0x414A66: cmdUndefine (virsh-domain.c:2609)
==19011==    by 0x40D200: vshCommandRun (virsh.c:1652)
==19011==    by 0x410964: main (virsh.c:3073)
==19011==
==19011== 10 bytes in 1 blocks are definitely lost in loss record 15 of 82
==19011==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==19011==    by 0x38F0881041: strdup (in /lib64/libc-2.12.so)
==19011==    by 0x4C88054: virXPathString (xml.c:89)
==19011==    by 0x414EBF: cmdUndefine (virsh-domain.c:2627)
==19011==    by 0x40D200: vshCommandRun (virsh.c:1652)
==19011==    by 0x410964: main (virsh.c:3073)
==19011==
==19011== LEAK SUMMARY:
==19011==    definitely lost: 24 bytes in 3 blocks

Expected results:
fix memory leak.

Comment 3 Peter Krempa 2013-08-15 16:41:20 UTC
First fix for some of the issues described above was pushed upstream as

commit 5075248ac9e60dd73da3487f83be9aa188200688
Author: Peter Krempa <pkrempa>
Date:   Mon Aug 12 16:09:53 2013 +0200

    virsh-domain: Fix memleak in cmdUndefine with storage
    
    When undefining a domain with storage when the volume isn't managed by
    libvirt the name and path strings weren't freed properly.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=996050

Comment 4 Peter Krempa 2013-08-20 16:01:06 UTC
commit 04898f60d2b509c4d106bf7e1ee269acc240b93d
Author: Peter Krempa <pkrempa>
Date:   Thu Aug 15 16:48:20 2013 +0200

    virsh: Don't leak list of volumes when undefining domain with storage
    
    Use the new semantics of vshStringToArray to avoid leaking the array of
    volumes to be deleted. The array would be leaked in case the first
    volume was found in the domain definition. Also refactor the code a bit
    to sanitize naming of variables hoding arrays and dimensions of the
    arrays.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=996050

Comment 7 RHEL Program Management 2014-04-04 20:57:30 UTC
Development Management has reviewed and declined this request.
You may appeal this decision by reopening this request.


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