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 1465833 - Permission denied when hotplug the chardev with source path as "dev/ttyS0" to the guest
Summary: Permission denied when hotplug the chardev with source path as "dev/ttyS0" to...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.4
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Pavel Hrdina
QA Contact: chhu
URL:
Whiteboard:
Depends On:
Blocks: 1473046
TreeView+ depends on / blocked
 
Reported: 2017-06-28 10:22 UTC by yafu
Modified: 2018-04-10 10:52 UTC (History)
10 users (show)

Fixed In Version: libvirt-3.9.0-6.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 10:50:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2018:0704 0 None None None 2018-04-10 10:52:02 UTC

Description yafu 2017-06-28 10:22:18 UTC
Description of problem:
Permission denied when hotplug the chardev with source path as "dev/ttyS0" to the guest

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

How reproducible:
100%

Steps to reproduce:
1.Prepare a chardev with source path as "dev/ttyS0":
#cat console.xml
<console type='dev'>
      <source path='/dev/ttyS0'/>
      <target type='virtio' port='1'/>
</console>

2.Attach the chardev to a running guest:
# virsh attach-device V console.xml
error: Failed to attach device from console.xml
error: internal error: unable to execute QEMU command 'chardev-add': Could not open '/dev/ttyS0': Permission denied

3.Start a guest with /dev/ttySO chardev device:
#virsh edit V
...
<console type='dev'>
      <source path='/dev/ttyS0'/>
      <target type='virtio' port='1'/>
</console>
...
#virsh start V
Domain V started

#virsh dumpxml V | grep -A5 ttyS0
  <console type='dev'>
      <source path='/dev/ttyS0'/>
      <target type='virtio' port='1'/>
      <alias name='console1'/>
    </console>


Actual results:
/dev/ttyS0 chardev failed to hotplug to the guest with permission denied error, but the guest with this device can start successfully.

Expected results:
If libvirt relabel the source file while starting the guest, it also should relabel the source file while hotpluging the device.

Additional info:
The /dev/ttyS0 chardev can hotunplug from the guest successfully.

Comment 2 Michal Privoznik 2017-08-18 07:00:01 UTC
I think this is fixed upstream by:

commit e93d844b90aab2676a1ad910a165c9c83c99de3d
Author:     Michal Privoznik <mprivozn>
AuthorDate: Mon Jun 19 17:05:31 2017 +0200
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue Jul 11 14:45:15 2017 +0200

    qemu ns: Create chardev backends more frequently
    
    Currently, the only type of chardev that we create the backend
    for in the namespace is type='dev'. This is not enough, other
    backends might have files under /dev too. For instance channels
    might have a unix socket under /dev (well, bind mounted under
    /dev from a different place).
    
    Signed-off-by: Michal Privoznik <mprivozn>
    Reviewed-by: John Ferlan <jferlan>

It is part of the 3.6.0 release. This commit was a part of bigger patch set that tried to fix bug 1462060. Therefore I suggest closing this one as a duplicate of that one.

Comment 3 Pavel Hrdina 2017-12-01 12:55:34 UTC
That patch is not good enough, the permission denied failure is still valid.

Upstream patches posted:

https://www.redhat.com/archives/libvir-list/2017-December/msg00020.html

Comment 4 Pavel Hrdina 2017-12-05 13:00:06 UTC
Upstream commit:

commit 1c57eea3625f59a80bea08d8779837a40acc4660
Author: Pavel Hrdina <phrdina>
Date:   Fri Dec 1 13:10:35 2017 +0100

    qemu: fix security labeling for attach/detach of char devices

Comment 7 chhu 2018-01-12 03:51:24 UTC
Reproduced on packages:
libvirt-3.2.0-14.el7_4.7.x86_64
qemu-kvm-rhev-2.9.0-16.el7_4.13.x86_64

Verified on packages:
libvirt-3.9.0-6.el7.x86_64
qemu-kvm-rhev-2.10.0-14.el7.x86_64

Test steps:
1. Start a guest.
2. Prepare a chardev with source path as "/dev/ttyS0".
#cat console.xml
<console type='dev'>
      <source path='/dev/ttyS0'/>
      <target type='virtio' port='1'/>
</console>

3. Attach the chardev to the running guest successfully.
# virsh attach-device r7 console.xml 
Device attached successfully
# virsh dumpxml r7|grep -A5 ttyS0
      <source path='/dev/ttyS0'/>
      <target type='virtio' port='1'/>
      <alias name='console1'/>
    </console>
4. Login to the guest, check there is new added: /dev/vport1p0

5. Detach the chardev from the running guest successfully, 
   login to the guest, check /dev/vport1p0 is no longer exist.
# virsh detach-device r7 console.xml 
Device detached successfully

# virsh dumpxml r7|grep -A5 console
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>

According to the test above, set the status to "VERIFIED".

Comment 11 errata-xmlrpc 2018-04-10 10:50:46 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-2018:0704


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