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 1088787 - Libvirt should clean up socket file on destroyed domain with UNIX character device
Summary: Libvirt should clean up socket file on destroyed domain with UNIX character d...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-04-17 07:52 UTC by Hu Jianwei
Modified: 2016-04-26 14:44 UTC (History)
5 users (show)

Fixed In Version: libvirt-1.2.7-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-05 07:34:22 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 12:10:54 UTC

Description Hu Jianwei 2014-04-17 07:52:07 UTC
Description of problem:
After destroying or undefining the domain with UNIX type character device, libvirt did not clean up its socket file

Version-Release number of selected component (if applicable):
libvirt-0.10.2-33.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.424.el6.x86_64
kernel-2.6.32-456.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Define a guest with a unix type serial and start it.
[root@localhost src]# virsh dumpxml test | grep serial -A5
...
    <serial type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/test_jiahu'/>
      <target port='1'/>
    </serial>
...
[root@localhost src]# virsh start test
Domain test started

2. Check the socket file of that serial.
[root@localhost src]# ll /var/lib/libvirt/qemu/ -Z
...
srwxr-xr-x. qemu qemu system_u:object_r:qemu_var_run_t:s0 test_jiahu      
srwxr-xr-x. qemu qemu system_u:object_r:qemu_var_run_t:s0 test.monitor

3. Destroy the guest and check it again, "test.monitor" is disappeared due to the domain is shutoff, but "test_jiahu" is still existing.
[root@localhost src]# virsh destroy test
Domain test destroyed

[root@localhost src]# ll /var/lib/libvirt/qemu/ -Z
...
srwxr-xr-x. qemu qemu system_u:object_r:qemu_var_run_t:s0 test_jiahu

4. Undefine the domain and restart the libvirtd, the socket file still exists.
[root@localhost src]# virsh undefine test
Domain test has been undefined

[root@localhost src]# ll /var/lib/libvirt/qemu/ -Z
...
srwxr-xr-x. qemu qemu system_u:object_r:qemu_var_run_t:s0 test_jiahu

[root@localhost src]# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service

[root@localhost src]# ll /var/lib/libvirt/qemu/ -Z
...
srwxr-xr-x. qemu qemu system_u:object_r:qemu_var_run_t:s0 test_jiahu


Actual results:
Libvirt did not delete/remove the related socket file after the domain destroy/undefine, even if libvirtd restarted.

Expected results:
The socket file of character device should be deleted after the domain destroy or undefine, should have same behavior with the "$DOMAIN.monitor".

Additional info:
N/A

Comment 3 Jiri Denemark 2014-04-23 09:06:03 UTC
This bug was not selected to be addressed in Red Hat Enterprise Linux 6. We will look at it again within the Red Hat Enterprise Linux 7 product.

Comment 4 Ján Tomko 2014-05-13 13:21:48 UTC
Upstream patch proposed:
https://www.redhat.com/archives/libvir-list/2014-May/msg00398.html

Comment 5 Ján Tomko 2014-05-26 13:27:09 UTC
Now pushed upstream:
commit 205010c40eb90c1088ddc250d4bcf3d2669b549c
Author:     Ján Tomko <jtomko>
AuthorDate: 2014-05-13 08:54:20 +0200
Commit:     Ján Tomko <jtomko>
CommitDate: 2014-05-26 15:17:54 +0200

    Clean up chardev sockets on QEMU shutdown
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1088787
    
    Clean up unix socket files for chardevs using mode='bind',
    like we clean up the monitor socket.
    They are created by QEMU on startup and not really useful
    after shutting it down.

git describe: v1.2.5-rc1-1-g205010c

Comment 7 Hu Jianwei 2014-12-01 03:03:17 UTC
Verify as below:

[root@ibm-x3850x5-06 ~]# rpm -q libvirt qemu-kvm-rhev
libvirt-1.2.8-9.el7.x86_64
qemu-kvm-rhev-2.1.2-8.el7.x86_64

<1> On a persistent guest
[root@ibm-x3850x5-06 ~]# ll /var/lib/libvirt/qemu/test_jiahu
ls: cannot access /var/lib/libvirt/qemu/test_jiahu: No such file or directory

[root@ibm-x3850x5-06 ~]# virsh dumpxml r7 | grep serial -A5
...
    <serial type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/test_jiahu'/>
      <target port='1'/>
    </serial>
    <console type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/test_jiahu'/>
      <target type='serial' port='1'/>
    </console>
..

[root@ibm-x3850x5-06 ~]# virsh start r7
Domain r7 started

[root@ibm-x3850x5-06 ~]# ll /var/lib/libvirt/qemu/test_jiahu -Z
srwxr-xr-x. qemu qemu system_u:object_r:qemu_var_run_t:s0 /var/lib/libvirt/qemu/test_jiahu
[root@ibm-x3850x5-06 ~]# virsh destroy r7
Domain r7 destroyed

[root@ibm-x3850x5-06 ~]# ll /var/lib/libvirt/qemu/test_jiahu -Z
ls: cannot access /var/lib/libvirt/qemu/test_jiahu: No such file or directory

<2> On a transient guest
[root@ibm-x3850x5-06 ~]# virsh create r7.xml 
Domain r7 created from r7.xml

[root@ibm-x3850x5-06 ~]# ll /var/lib/libvirt/qemu/test_jiahu -Z
srwxr-xr-x. qemu qemu system_u:object_r:qemu_var_run_t:s0 /var/lib/libvirt/qemu/test_jiahu
[root@ibm-x3850x5-06 ~]# virsh destroy r7
Domain r7 destroyed

[root@ibm-x3850x5-06 ~]# ll /var/lib/libvirt/qemu/test_jiahu -Z
ls: cannot access /var/lib/libvirt/qemu/test_jiahu: No such file or directory

We can get expected results, move to Verified.

Comment 9 errata-xmlrpc 2015-03-05 07:34:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2015-0323.html


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