Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1088787 - Libvirt should clean up socket file on destroyed domain with UNIX character device
Libvirt should clean up socket file on destroyed domain with UNIX character d...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.0
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: Ján Tomko
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2014-04-17 03:52 EDT by Hu Jianwei
Modified: 2016-04-26 10:44 EDT (History)
5 users (show)

See Also:
Fixed In Version: libvirt-1.2.7-1.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-03-05 02:34:22 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 07:10:54 EST

  None (edit)
Description Hu Jianwei 2014-04-17 03:52:07 EDT
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 05:06:03 EDT
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 09:21:48 EDT
Upstream patch proposed:
https://www.redhat.com/archives/libvir-list/2014-May/msg00398.html
Comment 5 Ján Tomko 2014-05-26 09:27:09 EDT
Now pushed upstream:
commit 205010c40eb90c1088ddc250d4bcf3d2669b549c
Author:     Ján Tomko <jtomko@redhat.com>
AuthorDate: 2014-05-13 08:54:20 +0200
Commit:     Ján Tomko <jtomko@redhat.com>
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-11-30 22:03:17 EST
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 02:34:22 EST
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.