Skip to content

Commit b7263fa

Browse files
authored
Merge pull request #204 from rojkov/nokerneldrv
qat: make users explicitly opt in to have kernel mode compiled in
2 parents 3d9b19d + a2debf6 commit b7263fa

File tree

8 files changed

+51
-9
lines changed

8 files changed

+51
-9
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ before_install:
4343
script:
4444
- make format
4545
- make lint
46-
- make
46+
- make BUILDTAGS=kerneldrv
4747
- make vet
4848
- make cyclomatic-check
49-
- make test
49+
- make test BUILDTAGS=kerneldrv
5050
- make images
5151
- make images BUILDER=buildah
5252
- make demos

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ pipeline {
8686
}
8787
}
8888
}
89-
stage("make test") {
89+
stage("make test BUILDTAGS=kerneldrv") {
9090
steps {
9191
dir(path: "$REPO_DIR") {
92-
sh "make test"
92+
sh "make test BUILDTAGS=kerneldrv"
9393
}
9494
}
9595
}

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ GO := go
22
GOFMT := gofmt
33
GOCYCLO := gocyclo
44

5+
BUILDTAGS ?= ""
6+
57
pkgs = $(shell $(GO) list ./... | grep -v vendor)
68
cmds = $(shell ls cmd)
79

@@ -18,10 +20,10 @@ cyclomatic-check:
1820

1921
test:
2022
ifndef WHAT
21-
@$(GO) test -race -coverprofile=coverage.txt -covermode=atomic $(pkgs)
23+
@$(GO) test -tags $(BUILDTAGS) -race -coverprofile=coverage.txt -covermode=atomic $(pkgs)
2224
else
2325
@cd $(WHAT) && \
24-
$(GO) test -v -cover -coverprofile cover.out || rc=1; \
26+
$(GO) test -tags $(BUILDTAGS) -v -cover -coverprofile cover.out || rc=1; \
2527
$(GO) tool cover -html=cover.out -o coverage.html; \
2628
rm cover.out; \
2729
echo "Coverage report: file://$$(realpath coverage.html)"; \
@@ -32,12 +34,12 @@ lint:
3234
@rc=0 ; for f in $$(find -name \*.go | grep -v \.\/vendor) ; do golint -set_exit_status $$f || rc=1 ; done ; exit $$rc
3335

3436
$(cmds):
35-
cd cmd/$@; go build
37+
cd cmd/$@; $(GO) build -tags $(BUILDTAGS)
3638

3739
build: $(cmds)
3840

3941
clean:
40-
@for cmd in $(cmds) ; do pwd=$(shell pwd) ; cd cmd/$$cmd ; go clean ; cd $$pwd ; done
42+
@for cmd in $(cmds) ; do pwd=$(shell pwd) ; cd cmd/$$cmd ; $(GO) clean ; cd $$pwd ; done
4143

4244
TAG?=$(shell git rev-parse HEAD)
4345

cmd/qat_plugin/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,16 @@ Use the `kernel-vf-drivers flag` to specify the vf Device Driver for the particu
6161

6262
`-dpdk-driver` is set to `vfio-pci` by default since it is more robust and secure driver compared with `igb_uio`. See [DPDK Linux Driver Guide](http://dpdk.org/doc/guides/linux_gsg/linux_drivers.html) for more information.
6363

64+
`-mode` parameter can be set to `kerneldrv` to override the default mode (`dpdkdrv`). With `-mode kerneldrv`, no other parameter documented above are valid, except `-debug` which is global for both modes. `kerneldrv` mode implements resource allocation based on system configured [logical instances](https://01.org/sites/default/files/downloads//336210-009qatswprogrammersguide.pdfhttps://01.org/sites/default/files/downloads//336210-009qatswprogrammersguide.pdf). The mode does not guarantee full device isolation between containers and therefore it's not recommended. Moreover, the mode will be deprecated and removed once `libqat` implements non-UIO based device access.
65+
6466
### Build QAT device plugin Docker image:
6567
```
6668
$ cd $GOPATH/src/github.com/intel/intel-device-plugins-for-kubernetes
6769
$ make intel-qat-plugin
6870
```
6971

72+
**Note**: `kerneldrv` mode is excluded from the build by default. Add `BUILDTAGS=kerneldrv` to `make` to get `kerneldrv` functionality added to the build.
73+
7074
### Deploy QAT device plugin as a DaemonSet:
7175
```
7276
$ cd $GOPATH/src/github.com/intel/intel-device-plugins-for-kubernetes

cmd/qat_plugin/kerneldrv/kerneldrv.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// +build kerneldrv
16+
1517
package kerneldrv
1618

1719
import (

cmd/qat_plugin/kerneldrv/kerneldrv_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// +build kerneldrv
16+
1517
package kerneldrv
1618

1719
import (

cmd/qat_plugin/kerneldrv/stub.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2019 Intel Corporation. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// +build !kerneldrv
16+
17+
package kerneldrv
18+
19+
import (
20+
"fmt"
21+
"os"
22+
23+
dpapi "github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin"
24+
)
25+
26+
// NewDevicePlugin creates a non-functional stub for kernel mode device plugins.
27+
func NewDevicePlugin() dpapi.Scanner {
28+
fmt.Println("kernel mode is not supported in this build. Use 'kerneldrv' build tag to have this mode enabled. Exiting...")
29+
os.Exit(1)
30+
31+
return nil
32+
}

cmd/qat_plugin/qat_plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func main() {
5353
case "kernel":
5454
plugin = kerneldrv.NewDevicePlugin()
5555
default:
56-
err = errors.Errorf("Uknown mode: %s", *mode)
56+
err = errors.Errorf("Unknown mode: %s", *mode)
5757
}
5858
if err != nil {
5959
fmt.Println(err.Error())

0 commit comments

Comments
 (0)