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 1449510 - libvirt will remove the host file after detach some device or attach failed when enable namespace
Summary: libvirt will remove the host file after detach some device or attach failed w...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.4
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: yafu
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-10 07:59 UTC by Luyao Huang
Modified: 2017-09-22 06:06 UTC (History)
4 users (show)

Fixed In Version: libvirt-3.2.0-5.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-02 00:08:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2017:1846 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2017-08-01 18:02:50 UTC

Description Luyao Huang 2017-05-10 07:59:25 UTC
Description of problem:
libvirt will remove the host resource file after detach some device or attach failed when enable namespace

Version-Release number of selected component (if applicable):
libvirt-3.2.0-4.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. prepare a running guest

# virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     r7                             running

# lsns -t mnt
        NS TYPE NPROCS   PID USER   COMMAND
...
4026532357 mnt       1  4100 qemu   /usr/libexec/qemu-kvm -name guest=r7,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-1-r7/master-key.aes -machine pc-i440fx-rhel7
...

2. prepare a resource not in dev dir:

# touch /tmp/fakerandom

# cat rng.xml 
  <rng model='virtio'>
    <backend model='random'>/tmp/fakerandom</backend>
 </rng>

3. attach a rng device which use this file as an backend:

# virsh attach-device r7 rng.xml 
error: Failed to attach device from rng.xml
error: internal error: unable to execute QEMU command 'object-add': Could not open '/tmp/fakerandom': Permission denied

4. attach failed since label is not correct, but this file also been removed:
# ls /tmp/fakerandom
ls: cannot access /tmp/fakerandom: No such file or directory

Actual results:

libvirt will remove the host resource file after detach some device or attach failed when enable namespace, and i have test this won't happen when disable namespace

Expected results:

file still exist

Additional info:

I think more device will have this problem, since i guess the source file should be deleted by qemuDomainDetachDeviceUnlink, and detach rng, Chardev, nvdimm device will call this function. This file path still in the same namespace of host

Comment 5 Michal Privoznik 2017-06-15 09:06:03 UTC
(In reply to yafu from comment #4)
> Reproduced with libvirt-3.2.0-4.el7.x86_64, test steps are as comment 0.
> 
> Verified pass with libvirt-3.2.0-10.virtcov.el7.x86_64.

You should verify with regular builds and not virtcov ;-) But there's no difference in the code between the two, so you'll find the same result when trying the official build.

Comment 6 yafu 2017-06-16 03:01:29 UTC
(In reply to Michal Privoznik from comment #5)
> (In reply to yafu from comment #4)
> > Reproduced with libvirt-3.2.0-4.el7.x86_64, test steps are as comment 0.
> > 
> > Verified pass with libvirt-3.2.0-10.virtcov.el7.x86_64.
> 
> You should verify with regular builds and not virtcov ;-) But there's no
> difference in the code between the two, so you'll find the same result when
> trying the official build.

You are right. I will update the comments. Thanks for your reminding.:)

Comment 7 yafu 2017-06-16 04:39:57 UTC
Reproduced with libvirt-3.2.0-4.el7.x86_64, test steps are as comment 0.

Verified pass with libvirt-3.2.0-10.el7.x86_64.
Scenario1:Test the host file will not remove by libvirt after attached failed
1.Start a guest:
#virsh start full-73

2.Prepare a resource not in dev dir:

# touch /tmp/testfile

# cat rng.xml 
  <rng model='virtio'>
    <backend model='random'>/tmp/testfile</backend>
 </rng>

4.Attach the rng device to the guest:
# virsh attach-device full-73 rng.xml 
error: Failed to attach device from rng.xml
error: internal error: unable to execute QEMU command 'object-add': Could not open '/tmp/testfile': Permission denied

5.The file still exists after attach failed:
# ll /tmp/testfile 
-rw-r--r--. 1 root root 0 Jun 15 12:50 /tmp/testfile

6.Also test attach chardev,nvdimm device failed, the source file will not delete  
 by libvirt;

Scenario 2:Test the file will not delete by libvirt after detach:
1.Start a guest with 2 disks:
#virsh domblklist full-73
Target     Source
------------------------------------------------
vda        /nfs-images/yafu/rhel7.2.qcow2
vdd        /var/lib/libvirt/images/generic.qcow2


2.Detach vdd from guest:
#cat disk.xml
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/generic.qcow2'/>
      <target dev='vdd' bus='virtio'/>
    </disk>

#virsh detach-device full-73 disk.xml
Device detached successfully

3.Check the source file of vdd:
# ll /var/lib/libvirt/images/generic.qcow2 
-rw-------. 1 root root 21478375424 Jun  9 11:31 /var/lib/libvirt/images/generic.qcow2

Scenario 3:Attach/detach device with source file created in the preserved mount dir
1.Install vhostmd package and start the daemon:
#yum -y install vhostmd
#systemctl start vhostmd

2.Attach a vhostmd disk(Source file is created by vhostmd daemon in the /dev/shm/vhostmd0)
#cat vhostmd.disk
<disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/dev/shm/vhostmd0'/>
      <target dev='vdb' bus='virtio'/>
    </disk>
#virsh attach-device full-73 vhostmd.disk
Device attached successfully

3.Check the vhostmd is attached successfully:
#virsh domblklist full-73
Target     Source
------------------------------------------------
vda        /nfs-images/yafu/rhel7.2.qcow2
vdb        /dev/shm/vhostmd0

4.Detach the vhostmd disk:
# virsh detach-device full-73 disk-vhostmd.xml 
Device detached successfully

5.Check the vhostmd disk is detached successfully:
[root@localhost xml]# virsh domblklist full-73
Target     Source
------------------------------------------------
vda        /nfs-images/yafu/rhel7.2.qcow2

Comment 8 yafu 2017-06-22 11:35:03 UTC
According to comment 7, move this bug to verified.

Comment 9 errata-xmlrpc 2017-08-02 00:08:25 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://access.redhat.com/errata/RHEA-2017:1846

Comment 10 errata-xmlrpc 2017-08-02 01:32:35 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://access.redhat.com/errata/RHEA-2017:1846


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