Bug 1281911

Summary: ovs-dpdk: vhost-user socket has wrong permissions
Product: Red Hat Enterprise Linux 7 Reporter: Flavio Leitner <fleitner>
Component: openvswitch-dpdkAssignee: Aaron Conole <aconole>
Status: CLOSED CANTFIX QA Contact: Jean-Tsung Hsiao <jhsiao>
Severity: high Docs Contact:
Priority: high    
Version: 7.3CC: aconole, aloughla, atragler, jean-mickael.guerin, jkurik, kzhang, maxime.leroy, mleitner, mzhan, nyechiel, rkhan, twilson, vchundur, vincent.jardin
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-28 14:33: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:
Bug Depends On:    
Bug Blocks: 1301628, 1313485    

Description Flavio Leitner 2015-11-13 19:04:17 UTC
Description of problem:

When a vhost-user port is attached, a unix socket is created at var/run/openvswitch/ which qemu should be able to connect to.

However, the permissions are wrong requiring manual intervention. 

Expected results:
No manual intervention is needed

Comment 1 Terry Wilson 2015-11-13 19:40:54 UTC
Should adding:

RuntimeDirectoryMode=0775
Group=qemu
UMask=0002

to /usr/lib/systemd/system/openvswitch-nonetwork.service fix this issue?

Comment 2 Aaron Conole 2015-11-18 18:53:01 UTC
I think a better approach is to use a separate directory for the vhost_user sockets, which would require passing the -vhost_sock_dir option to ovs-vswitchd, and updating the selinux permissions. That way we could make a sgid directory where vhost sockets go.

I will look into this and have a formal proposal (in the form of patches) soon.

Comment 3 Aaron Conole 2015-12-02 18:39:23 UTC
There is a discussion upstream at http://openvswitch.org/pipermail/dev/2015-December/062845.html regarding when and how to apply DPDK parameters to Open vSwitch. Since my solution is based on the -vhost_sock_dir option, and there's a possibility that it will need to be re-architected.

That said, the packages (which haven't been fully tested) are at:
https://copr.fedoraproject.org/coprs/aconole/qemu-kvm/
and
https://copr.fedoraproject.org/coprs/aconole/openvswitch-dpdk/

I will be testing them later today/tomorrow to see that the idea is sound, and then the implementation may need further discussion.

Comment 4 Terry Wilson 2015-12-09 17:41:48 UTC
Aaron: how'd the testing go?

Comment 5 Aaron Conole 2015-12-09 20:17:17 UTC
Sorry for the late response. There are issues in the initial implementation that need to be cleaned up. I will respin and update the bug with corrected patches. The solution _should_ work, but may not be a final one that upstream accepts.

Comment 6 Aaron Conole 2015-12-10 14:27:52 UTC
I have a working set of packages, on COPR:

https://copr.fedoraproject.org/coprs/aconole/openvswitch-dpdk/
and
https://copr.fedoraproject.org/coprs/aconole/qemu-kvm/

The following are the changes that I did:

On package install:
1. QEMU adds itself to the vhost group (if no such group exists, it creates)
2. Openvswitch-DPDK adds the vhost group if it doesn't already exist

Open vSwitch DPDK package has the following changes:

ovs-ctl accepts an (not-required) option in /etc/sysconf/openvswitch called VHOST_SOCK_DIR which should be a path in the filesystem. This variable is only used when DPDK_OPTIONS are specified.

If the path specified by VHOST_SOCK_DIR does not exist, ovs-ctl creates it during openvswitch startup, and sets mode to rwxrwsr-x with a group of vhost

Once the path specified in VHOST_SOCK_DIR exists, openvswitch passes it and DPDK_OPTIONS has a value, ovs-ctl sets umask to 0002, launches ovs-vswitchd, and restores umask.

I will post the patches for Panu and Flavio to review, and then bring it to wider audience (because it may not be the solution upstream accepts).

Comment 7 Aaron Conole 2016-01-06 21:40:37 UTC
The upstream solution is posted at 
http://openvswitch.org/pipermail/dev/2016-January/063959.html

This is the first series to reorganize under the database. The second will be to set vhost-sock permissions and ownership.