Bug 1754392

Summary: Xattr for “guestfwd channel” device will not be cleaned after VM was destroyed or device was detached; thus Other VM can not use it.
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: jiyan <jiyan>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED NEXTRELEASE QA Contact: Jing Qi <jinqi>
Severity: medium Docs Contact:
Priority: low    
Version: 8.1CC: dyuan, lhuang, mprivozn, xuzhang, yafu, yalzhang
Target Milestone: rc   
Target Release: 8.0   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-25 13:24:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description jiyan 2019-09-23 07:11:37 UTC
Description of problem:
Xattr for “guestfwd channel” device will not be cleaned after VM was destroyed  or device was detached; thus Other VM can not use it.

Version-Release number of selected component (if applicable):
libvirt-5.6.0-6.module+el8.1.0+4244+9aa4e6bb.x86_64
qemu-kvm-4.1.0-10.module+el8.1.0+4234+33aa4f57.x86_64
kernel-4.18.0-145.el8.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare 2 VMs with the following conf, and start them.
# virsh domstate test1
shut off

# virsh domstate test2
shut off

# virsh dumpxml test1 |grep "<channel" -A5
    <channel type='unix'>
      <source mode='bind' path='/mnt/guestfwd'/>
      <target type='guestfwd' address='10.0.2.1' port='4600'/>
      <alias name='ua-d830c2c4-93ac-4eb7-b714-593483f10044'/>
    </channel>

# virsh dumpxml test2 |grep "<channel" -A5
No output

# virsh start test1 
Domain test1 started

# virsh start test2
Domain test2 started

2. Check channel device related info for test1
# getfattr -m trusted.libvirt.security -d /mnt/guestfwd 
getfattr: Removing leading '/' from absolute path names
# file: mnt/guestfwd
trusted.libvirt.security.dac="+0:+0"
trusted.libvirt.security.ref_dac="1"
trusted.libvirt.security.timestamp_dac="1569207112"

# virsh dumpxml test1 |grep "<channel" -A5
    <channel type='unix'>
      <source mode='bind' path='/mnt/guestfwd'/>
      <target type='guestfwd' address='10.0.2.1' port='4600'/>
      <alias name='ua-d830c2c4-93ac-4eb7-b714-593483f10044'/>
    </channel>

3. Detach channel device from test1; then destroy test
# virsh detach-device-alias test1 ua-d830c2c4-93ac-4eb7-b714-593483f10044
Device detach request sent successfully

# virsh dumpxml test1 |grep "<channel" -A5
No output
 
# getfattr -m trusted.libvirt.security -d /mnt/guestfwd 
getfattr: Removing leading '/' from absolute path names
# file: mnt/guestfwd
trusted.libvirt.security.dac="+0:+0"
trusted.libvirt.security.ref_dac="1"
trusted.libvirt.security.timestamp_dac="1569207112"

# virsh destroy test1
Domain test1 destroyed

# getfattr -m trusted.libvirt.security -d /mnt/guestfwd 
getfattr: Removing leading '/' from absolute path names
# file: mnt/guestfwd
trusted.libvirt.security.dac="+0:+0"
trusted.libvirt.security.ref_dac="1"
trusted.libvirt.security.timestamp_dac="1569207112"

4. Attach the channel device to test2
# cat channel.xml 
    <channel type='unix'>
      <source mode='bind' path='/mnt/guestfwd'/>
      <target type='guestfwd' address='10.0.2.1' port='4600'/>
      <alias name='ua-d830c2c4-93ac-4eb7-b714-593483f10044'/>
    </channel>

# virsh attach-device test2 channel.xml 
error: Failed to attach device from channel.xml
error: internal error: unable to execute QEMU command 'chardev-add': Failed to unlink socket /mnt/guestfwd: Permission denied


Actual results:
As step-4 shows

Expected results:
Xttr related info for channel device should clear once this device is detached or the VM is destroyed.

Additional info:
1> This bug comes from https://bugzilla.redhat.com/show_bug.cgi?id=1652078#c12. After checking with my colleague, we decided to track this issue with a single bug for earlier verification of original bug.

2> Relate analysis from Michal can be seen here: https://bugzilla.redhat.com/show_bug.cgi?id=1652078#c13

3> Test result for the scratch build provided by Michal can be seen here: https://bugzilla.redhat.com/show_bug.cgi?id=1652078#c16

Comment 3 Michal Privoznik 2021-02-25 13:24:22 UTC
I can't reproduce anymore. There was a lot of fixes in this area since libvirt-5.6.0 and it's likely this bug was fixed. Therefore, I'm closing it. If you disagree, please reopen with debug logs attached.