Red Hat Bugzilla – Bug 1088787
Libvirt should clean up socket file on destroyed domain with UNIX character device
Last modified: 2016-04-26 10:44:03 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
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.
Upstream patch proposed: https://www.redhat.com/archives/libvir-list/2014-May/msg00398.html
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
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.
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