diff --git a/.ci/go-static-checks.sh b/.ci/go-static-checks.sh deleted file mode 100755 index 8015d259f..000000000 --- a/.ci/go-static-checks.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -# Copyright (c) 2018 Intel Corporation -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -# Perform static go tests. - -function usage { - echo "Usage $0 [OPTIONS] [PACKAGES]" - echo "Perform static go checks on PACKAGES (./... by default)." - echo - echo "List of options:" - echo " -h, --help print this help" - echo " -n, --no-network do not access the network" -} - -for i in "$@"; do - case $i in - -h|--help) - usage - exit 0 - ;; - -n|--no-network) - NONETWORK=1 - shift - ;; - *) - args="$args $i" - ;; - esac -done - -go_packages=$args - -[ -z "$go_packages" ] && { - go_packages=$(go list ./... | grep -v vendor) -} - -function install_package { - url="$1" - name=${url##*/} - - if [ -n "$NONETWORK" ]; then - echo "Skipping updating package $name, no network access allowed" - return - fi - - echo Updating $name... - go get -u $url -} - -install_package github.com/fzipp/gocyclo -install_package github.com/client9/misspell/cmd/misspell -install_package github.com/golang/lint/golint -install_package github.com/gordonklaus/ineffassign -install_package github.com/opennota/check/cmd/structcheck -install_package honnef.co/go/tools/cmd/unused -install_package honnef.co/go/tools/cmd/staticcheck - -echo Doing go static checks on packages: $go_packages - -echo "Running misspell..." -go list -f '{{.Dir}}/*.go' $go_packages |\ - xargs -I % bash -c "misspell -error %" - -echo "Running go vet..." -go vet $go_packages - -cmd="gofmt -s -d -l" -echo "Running gofmt..." - -# Note: ignore git directory in case any refs end in ".go" too. -diff=$(find . -not -wholename '*/vendor/*' -not -wholename '*/.git/*' -name '*.go' | \ - xargs $cmd) -if [ -n "$diff" -a $(echo "$diff" | wc -l) -ne 0 ] -then - echo 2>&1 "ERROR: '$cmd' found problems:" - echo 2>&1 "$diff" - exit 1 -fi - -echo "Running cyclo..." -gocyclo -over 15 `go list -f '{{.Dir}}/*.go' $go_packages` - -echo "Running golint..." -for p in $go_packages; do golint -set_exit_status $p; done - -echo "Running ineffassign..." -go list -f '{{.Dir}}' $go_packages | xargs -L 1 ineffassign - -for tool in structcheck unused staticcheck -do - echo "Running ${tool}..." - eval "$tool" "$go_packages" -done - -echo "All Good!" diff --git a/.ci/setup.sh b/.ci/setup.sh index 8580fb735..ff0ab8c9b 100755 --- a/.ci/setup.sh +++ b/.ci/setup.sh @@ -14,3 +14,9 @@ clone_tests_repo pushd "${tests_repo_dir}" .ci/setup.sh popd + +echo "Setup virtcontainers environment" +chronic sudo -E PATH=$PATH bash -c "${cidir}/../virtcontainers/utils/virtcontainers-setup.sh" + +echo "Install virtcontainers" +make -C "${cidir}/../virtcontainers" && chronic sudo make -C "${cidir}/../virtcontainers" install diff --git a/cli/Makefile b/cli/Makefile index 09eda0a45..f55980252 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -374,7 +374,7 @@ check-go-test: $(GENERATED_FILES) $(QUIET_TEST)$(MAKEFILE_DIR)/../.ci/go-test.sh check-go-static: - $(QUIET_CHECK)$(MAKEFILE_DIR)/../.ci/go-static-checks.sh $(GO_STATIC_CHECKS_ARGS) + $(QUIET_CHECK)$(MAKEFILE_DIR)/../.ci/static-checks.sh $(QUIET_CHECK)$(MAKEFILE_DIR)/../.ci/go-no-os-exit.sh coverage: diff --git a/cli/create_test.go b/cli/create_test.go index 41f7e94f3..ececda898 100644 --- a/cli/create_test.go +++ b/cli/create_test.go @@ -26,7 +26,7 @@ import ( vc "github.com/kata-containers/runtime/virtcontainers" "github.com/kata-containers/runtime/virtcontainers/pkg/oci" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/assert" "github.com/urfave/cli" @@ -301,9 +301,9 @@ func TestCreateCLIFunctionCreateFail(t *testing.T) { func TestCreateInvalidArgs(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, - MockContainers: []*vcMock.Container{ + MockContainers: []*vcmock.Container{ {MockID: testContainerID}, {MockID: testContainerID}, {MockID: testContainerID}, @@ -401,7 +401,7 @@ func TestCreateInvalidConfigJSON(t *testing.T) { for detach := range []bool{true, false} { err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig) assert.Errorf(err, "%+v", detach) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } } @@ -448,7 +448,7 @@ func TestCreateInvalidContainerType(t *testing.T) { for detach := range []bool{true, false} { err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig) assert.Errorf(err, "%+v", detach) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } } @@ -496,16 +496,16 @@ func TestCreateContainerInvalid(t *testing.T) { for detach := range []bool{true, false} { err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig) assert.Errorf(err, "%+v", detach) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } } func TestCreateProcessCgroupsPathSuccessful(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, - MockContainers: []*vcMock.Container{ + MockContainers: []*vcmock.Container{ {MockID: testContainerID}, }, } @@ -598,9 +598,9 @@ func TestCreateCreateCgroupsFilesFail(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, - MockContainers: []*vcMock.Container{ + MockContainers: []*vcmock.Container{ {MockID: testContainerID}, }, } @@ -671,7 +671,7 @@ func TestCreateCreateCgroupsFilesFail(t *testing.T) { for detach := range []bool{true, false} { err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig) assert.Errorf(err, "%+v", detach) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } } @@ -683,9 +683,9 @@ func TestCreateCreateCreatePidFileFail(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, - MockContainers: []*vcMock.Container{ + MockContainers: []*vcmock.Container{ {MockID: testContainerID}, }, } @@ -747,16 +747,16 @@ func TestCreateCreateCreatePidFileFail(t *testing.T) { for detach := range []bool{true, false} { err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig) assert.Errorf(err, "%+v", detach) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } } func TestCreate(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, - MockContainers: []*vcMock.Container{ + MockContainers: []*vcmock.Container{ {MockID: testContainerID}, }, } @@ -873,7 +873,7 @@ func TestCreateInvalidKernelParams(t *testing.T) { for detach := range []bool{true, false} { err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig) assert.Errorf(err, "%+v", detach) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } } @@ -921,7 +921,7 @@ func TestCreateCreatePodPodConfigFail(t *testing.T) { _, err = createPod(spec, runtimeConfig, testContainerID, bundlePath, testConsole, true) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestCreateCreatePodFail(t *testing.T) { @@ -956,7 +956,7 @@ func TestCreateCreatePodFail(t *testing.T) { _, err = createPod(spec, runtimeConfig, testContainerID, bundlePath, testConsole, true) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) } func TestCreateCreateContainerContainerConfigFail(t *testing.T) { @@ -998,7 +998,7 @@ func TestCreateCreateContainerContainerConfigFail(t *testing.T) { for _, disableOutput := range []bool{true, false} { _, err = createContainer(spec, testContainerID, bundlePath, testConsole, disableOutput) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) assert.True(strings.Contains(err.Error(), containerType)) } } @@ -1042,7 +1042,7 @@ func TestCreateCreateContainerFail(t *testing.T) { for _, disableOutput := range []bool{true, false} { _, err = createContainer(spec, testContainerID, bundlePath, testConsole, disableOutput) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) } } @@ -1055,7 +1055,7 @@ func TestCreateCreateContainer(t *testing.T) { } testingImpl.CreateContainerFunc = func(podID string, containerConfig vc.ContainerConfig) (vc.VCPod, vc.VCContainer, error) { - return &vcMock.Pod{}, &vcMock.Container{}, nil + return &vcmock.Pod{}, &vcmock.Container{}, nil } defer func() { diff --git a/cli/delete_test.go b/cli/delete_test.go index 25ac8a759..a36375c23 100644 --- a/cli/delete_test.go +++ b/cli/delete_test.go @@ -23,7 +23,7 @@ import ( vc "github.com/kata-containers/runtime/virtcontainers" vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" "github.com/stretchr/testify/assert" "github.com/urfave/cli" ) @@ -61,12 +61,12 @@ func TestDeleteInvalidContainer(t *testing.T) { // Missing container id err := delete("", false) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) // Mock Listpod error err = delete(testContainerID, false) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.ListPodFunc = func() ([]vc.PodStatus, error) { return []vc.PodStatus{}, nil @@ -79,13 +79,13 @@ func TestDeleteInvalidContainer(t *testing.T) { // Container missing in ListPod err = delete(testContainerID, false) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestDeleteMissingContainerTypeAnnotation(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -109,13 +109,13 @@ func TestDeleteMissingContainerTypeAnnotation(t *testing.T) { err := delete(pod.ID(), false) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestDeleteInvalidConfig(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -141,7 +141,7 @@ func TestDeleteInvalidConfig(t *testing.T) { err := delete(pod.ID(), false) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func testConfigSetup(t *testing.T) string { @@ -165,7 +165,7 @@ func testConfigSetup(t *testing.T) string { func TestDeletePod(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -199,7 +199,7 @@ func TestDeletePod(t *testing.T) { err = delete(pod.ID(), false) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.StopPodFunc = func(podID string) (vc.VCPod, error) { return pod, nil @@ -211,7 +211,7 @@ func TestDeletePod(t *testing.T) { err = delete(pod.ID(), false) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.DeletePodFunc = func(podID string) (vc.VCPod, error) { return pod, nil @@ -228,7 +228,7 @@ func TestDeletePod(t *testing.T) { func TestDeleteInvalidContainerType(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -263,13 +263,13 @@ func TestDeleteInvalidContainerType(t *testing.T) { // Delete an invalid container type err = delete(pod.ID(), false) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestDeletePodRunning(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -304,7 +304,7 @@ func TestDeletePodRunning(t *testing.T) { // Delete on a running pod should fail err = delete(pod.ID(), false) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) testingImpl.StopPodFunc = func(podID string) (vc.VCPod, error) { return pod, nil @@ -317,7 +317,7 @@ func TestDeletePodRunning(t *testing.T) { // Force delete a running pod err = delete(pod.ID(), true) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.DeletePodFunc = func(podID string) (vc.VCPod, error) { return pod, nil @@ -334,11 +334,11 @@ func TestDeletePodRunning(t *testing.T) { func TestDeleteRunningContainer(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } - pod.MockContainers = []*vcMock.Container{ + pod.MockContainers = []*vcmock.Container{ { MockID: testContainerID, MockPod: pod, @@ -376,12 +376,12 @@ func TestDeleteRunningContainer(t *testing.T) { // Delete on a running container should fail. err = delete(pod.MockContainers[0].ID(), false) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) // force delete err = delete(pod.MockContainers[0].ID(), true) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.StopContainerFunc = testStopContainerFuncReturnNil defer func() { @@ -390,10 +390,10 @@ func TestDeleteRunningContainer(t *testing.T) { err = delete(pod.MockContainers[0].ID(), true) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.DeleteContainerFunc = func(podID, containerID string) (vc.VCContainer, error) { - return &vcMock.Container{}, nil + return &vcmock.Container{}, nil } defer func() { @@ -407,11 +407,11 @@ func TestDeleteRunningContainer(t *testing.T) { func TestDeleteContainer(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } - pod.MockContainers = []*vcMock.Container{ + pod.MockContainers = []*vcmock.Container{ { MockID: testContainerID, MockPod: pod, @@ -448,7 +448,7 @@ func TestDeleteContainer(t *testing.T) { err = delete(pod.MockContainers[0].ID(), false) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.StopContainerFunc = testStopContainerFuncReturnNil defer func() { @@ -457,10 +457,10 @@ func TestDeleteContainer(t *testing.T) { err = delete(pod.MockContainers[0].ID(), false) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.DeleteContainerFunc = func(podID, containerID string) (vc.VCContainer, error) { - return &vcMock.Container{}, nil + return &vcmock.Container{}, nil } defer func() { @@ -485,7 +485,7 @@ func TestDeleteCLIFunction(t *testing.T) { // no container id in the Metadata err := fn(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError) flagSet.Parse([]string{"xyz"}) @@ -493,17 +493,17 @@ func TestDeleteCLIFunction(t *testing.T) { err = fn(ctx) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) } func TestDeleteCLIFunctionSuccess(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } - pod.MockContainers = []*vcMock.Container{ + pod.MockContainers = []*vcmock.Container{ { MockID: testContainerID, MockPod: pod, @@ -558,7 +558,7 @@ func TestDeleteCLIFunctionSuccess(t *testing.T) { err = fn(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError) flagSet.Parse([]string{pod.ID()}) diff --git a/cli/exec_test.go b/cli/exec_test.go index 1d45cc9f1..6efbeb546 100644 --- a/cli/exec_test.go +++ b/cli/exec_test.go @@ -25,7 +25,7 @@ import ( vc "github.com/kata-containers/runtime/virtcontainers" vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations" "github.com/kata-containers/runtime/virtcontainers/pkg/oci" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" "github.com/stretchr/testify/assert" "github.com/urfave/cli" ) @@ -43,7 +43,7 @@ func TestExecCLIFunction(t *testing.T) { // no container-id in the Metadata err := fn(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) // pass container-id flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError) @@ -52,7 +52,7 @@ func TestExecCLIFunction(t *testing.T) { err = fn(ctx) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) } func TestExecuteErrors(t *testing.T) { @@ -64,13 +64,13 @@ func TestExecuteErrors(t *testing.T) { // missing container id err := execute(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) // ListPod error flagSet.Parse([]string{testContainerID}) err = execute(ctx) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) // Config path missing in annotations annotations := map[string]string{ @@ -87,7 +87,7 @@ func TestExecuteErrors(t *testing.T) { err = execute(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) // Container not running configPath := testConfigSetup(t) @@ -109,7 +109,7 @@ func TestExecuteErrors(t *testing.T) { err = execute(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestExecuteErrorReadingProcessJson(t *testing.T) { @@ -154,7 +154,7 @@ func TestExecuteErrorReadingProcessJson(t *testing.T) { err = fn(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestExecuteErrorOpeningConsole(t *testing.T) { @@ -198,7 +198,7 @@ func TestExecuteErrorOpeningConsole(t *testing.T) { err = fn(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func testExecParamsSetup(t *testing.T, pidFilePath, consolePath string, detach bool) *flag.FlagSet { @@ -260,10 +260,10 @@ func TestExecuteWithFlags(t *testing.T) { // EnterContainer error err = fn(ctx) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.EnterContainerFunc = func(podID, containerID string, cmd vc.Cmd) (vc.VCPod, vc.VCContainer, *vc.Process, error) { - return &vcMock.Pod{}, &vcMock.Container{}, &vc.Process{}, nil + return &vcmock.Pod{}, &vcmock.Container{}, &vc.Process{}, nil } defer func() { @@ -274,7 +274,7 @@ func TestExecuteWithFlags(t *testing.T) { // Process not running error err = fn(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) os.Remove(pidFilePath) @@ -288,7 +288,7 @@ func TestExecuteWithFlags(t *testing.T) { vcProcess := vc.Process{} vcProcess.Pid = command.Process.Pid - return &vcMock.Pod{}, &vcMock.Container{}, &vcProcess, nil + return &vcmock.Pod{}, &vcmock.Container{}, &vcProcess, nil } defer func() { @@ -347,7 +347,7 @@ func TestExecuteWithFlagsDetached(t *testing.T) { vcProcess := vc.Process{} vcProcess.Pid = command.Process.Pid - return &vcMock.Pod{}, &vcMock.Container{}, &vcProcess, nil + return &vcmock.Pod{}, &vcmock.Container{}, &vcProcess, nil } defer func() { @@ -417,7 +417,7 @@ func TestExecuteWithInvalidProcessJson(t *testing.T) { err = fn(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestExecuteWithValidProcessJson(t *testing.T) { @@ -499,7 +499,7 @@ func TestExecuteWithValidProcessJson(t *testing.T) { vcProcess := vc.Process{} vcProcess.Pid = command.Process.Pid - return &vcMock.Pod{}, &vcMock.Container{}, &vcProcess, nil + return &vcmock.Pod{}, &vcmock.Container{}, &vcProcess, nil } defer func() { @@ -572,7 +572,7 @@ func TestExecuteWithInvalidEnvironment(t *testing.T) { // vcAnnotations.EnvVars error due to incorrect environment err = fn(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestGenerateExecParams(t *testing.T) { diff --git a/cli/kill_test.go b/cli/kill_test.go index cc81c1298..f208319ae 100644 --- a/cli/kill_test.go +++ b/cli/kill_test.go @@ -21,7 +21,7 @@ import ( "testing" vc "github.com/kata-containers/runtime/virtcontainers" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" "github.com/stretchr/testify/assert" ) @@ -31,7 +31,7 @@ var ( } testStopContainerFuncReturnNil = func(podID, containerID string) (vc.VCContainer, error) { - return &vcMock.Container{}, nil + return &vcmock.Container{}, nil } ) diff --git a/cli/list_test.go b/cli/list_test.go index 9460a65cd..48b8e2038 100644 --- a/cli/list_test.go +++ b/cli/list_test.go @@ -28,7 +28,7 @@ import ( vc "github.com/kata-containers/runtime/virtcontainers" vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" "github.com/stretchr/testify/assert" "github.com/urfave/cli" ) @@ -395,7 +395,7 @@ func TestListGetContainersListPodFail(t *testing.T) { _, err = getContainers(ctx) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) } func TestListGetContainers(t *testing.T) { @@ -433,7 +433,7 @@ func TestListGetContainers(t *testing.T) { func TestListGetContainersPodWithoutContainers(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -477,7 +477,7 @@ func TestListGetContainersPodWithContainer(t *testing.T) { assert.NoError(err) defer os.RemoveAll(tmpdir) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -550,7 +550,7 @@ func TestListCLIFunctionFormatFail(t *testing.T) { {"invalid", invalidFlags}, } - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -621,7 +621,7 @@ func TestListCLIFunctionFormatFail(t *testing.T) { // invalid output file assert.Error(err, d) - assert.False(vcMock.IsMockError(err), d) + assert.False(vcmock.IsMockError(err), d) output := filepath.Join(tmpdir, "output") f, err := os.OpenFile(output, os.O_WRONLY|os.O_CREATE, testFileMode) @@ -634,7 +634,7 @@ func TestListCLIFunctionFormatFail(t *testing.T) { err = fn(ctx) if d.format == "invalid" { assert.Error(err) - assert.False(vcMock.IsMockError(err), d) + assert.False(vcmock.IsMockError(err), d) } else { assert.NoError(err) } @@ -651,7 +651,7 @@ func TestListCLIFunctionQuiet(t *testing.T) { runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true) assert.NoError(err) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } diff --git a/cli/main_test.go b/cli/main_test.go index cb7470ba7..407be9420 100644 --- a/cli/main_test.go +++ b/cli/main_test.go @@ -34,7 +34,7 @@ import ( "github.com/dlespiau/covertool/pkg/cover" vc "github.com/kata-containers/runtime/virtcontainers" "github.com/kata-containers/runtime/virtcontainers/pkg/oci" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/assert" "github.com/urfave/cli" @@ -62,7 +62,7 @@ var ( ) // testingImpl is a concrete mock RVC implementation used for testing -var testingImpl = &vcMock.VCMock{} +var testingImpl = &vcmock.VCMock{} func init() { if version == "" { diff --git a/cli/oci_test.go b/cli/oci_test.go index 02c11f39a..c96922d78 100644 --- a/cli/oci_test.go +++ b/cli/oci_test.go @@ -29,7 +29,7 @@ import ( vc "github.com/kata-containers/runtime/virtcontainers" vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations" "github.com/kata-containers/runtime/virtcontainers/pkg/oci" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" "github.com/opencontainers/runc/libcontainer/utils" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/assert" @@ -83,7 +83,7 @@ func TestGetContainerInfoContainerIDEmptyFailure(t *testing.T) { func TestGetContainerInfo(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -118,7 +118,7 @@ func TestGetContainerInfo(t *testing.T) { func TestGetContainerInfoMismatch(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -154,7 +154,7 @@ func TestValidCreateParamsContainerIDEmptyFailure(t *testing.T) { _, err := validCreateParams("", "") assert.Error(err, "This test should fail because containerID is empty") - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestGetExistingContainerInfoContainerIDEmptyFailure(t *testing.T) { @@ -170,7 +170,7 @@ func TestValidCreateParamsContainerIDNotUnique(t *testing.T) { containerID := testContainerID + testContainerID - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -204,7 +204,7 @@ func TestValidCreateParamsContainerIDNotUnique(t *testing.T) { _, err := validCreateParams(testContainerID, "") assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestValidCreateParamsContainerIDNotUnique2(t *testing.T) { @@ -212,7 +212,7 @@ func TestValidCreateParamsContainerIDNotUnique2(t *testing.T) { containerID := testContainerID + testContainerID - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -238,7 +238,7 @@ func TestValidCreateParamsContainerIDNotUnique2(t *testing.T) { _, err := validCreateParams(testContainerID, "") assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestValidCreateParamsInvalidBundle(t *testing.T) { @@ -261,7 +261,7 @@ func TestValidCreateParamsInvalidBundle(t *testing.T) { _, err = validCreateParams(testContainerID, bundlePath) // bundle is ENOENT assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestValidCreateParamsBundleIsAFile(t *testing.T) { @@ -286,7 +286,7 @@ func TestValidCreateParamsBundleIsAFile(t *testing.T) { _, err = validCreateParams(testContainerID, bundlePath) // bundle exists as a file, not a directory assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func testProcessCgroupsPath(t *testing.T, ociSpec oci.CompatOCISpec, expected []string) { @@ -565,7 +565,7 @@ func TestProcessCgroupsPathForResource(t *testing.T) { for _, isPod := range []bool{true, false} { _, err := processCgroupsPathForResource(spec, "", isPod) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } } diff --git a/cli/pause_test.go b/cli/pause_test.go index 3fcdd4a6f..08fd5055f 100644 --- a/cli/pause_test.go +++ b/cli/pause_test.go @@ -19,17 +19,17 @@ import ( "testing" vc "github.com/kata-containers/runtime/virtcontainers" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" "github.com/stretchr/testify/assert" ) var ( testPausePodFuncReturnNil = func(podID string) (vc.VCPod, error) { - return &vcMock.Pod{}, nil + return &vcmock.Pod{}, nil } testResumePodFuncReturnNil = func(podID string) (vc.VCPod, error) { - return &vcMock.Pod{}, nil + return &vcmock.Pod{}, nil } ) diff --git a/cli/ps_test.go b/cli/ps_test.go index ca64b4f7c..a5b3d9da4 100644 --- a/cli/ps_test.go +++ b/cli/ps_test.go @@ -20,7 +20,7 @@ import ( vc "github.com/kata-containers/runtime/virtcontainers" vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" "github.com/stretchr/testify/assert" "github.com/urfave/cli" ) @@ -45,11 +45,11 @@ func TestPSCLIAction(t *testing.T) { func TestPSFailure(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testContainerID, } - pod.MockContainers = []*vcMock.Container{ + pod.MockContainers = []*vcmock.Container{ { MockID: pod.ID(), MockPod: pod, @@ -89,11 +89,11 @@ func TestPSFailure(t *testing.T) { func TestPSSuccessful(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testContainerID, } - pod.MockContainers = []*vcMock.Container{ + pod.MockContainers = []*vcmock.Container{ { MockID: pod.ID(), MockPod: pod, diff --git a/cli/run_test.go b/cli/run_test.go index c267e3d87..165aecb85 100644 --- a/cli/run_test.go +++ b/cli/run_test.go @@ -26,7 +26,7 @@ import ( vc "github.com/kata-containers/runtime/virtcontainers" vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations" "github.com/kata-containers/runtime/virtcontainers/pkg/oci" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" "github.com/stretchr/testify/assert" "github.com/urfave/cli" ) @@ -67,9 +67,9 @@ func TestRunCliAction(t *testing.T) { func TestRunInvalidArgs(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, - MockContainers: []*vcMock.Container{ + MockContainers: []*vcmock.Container{ {MockID: testContainerID}, }, } @@ -161,7 +161,7 @@ type runContainerData struct { consolePath string bundlePath string configJSON string - pod *vcMock.Pod + pod *vcmock.Pod runtimeConfig oci.RuntimeConfig process *os.Process tmpDir string @@ -196,11 +196,11 @@ func testRunContainerSetup(t *testing.T) runContainerData { configPath := filepath.Join(bundlePath, specConfig) // pod id and container id must be the same otherwise delete will not works - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testContainerID, } - pod.MockContainers = []*vcMock.Container{ + pod.MockContainers = []*vcmock.Container{ { MockID: testContainerID, MockPid: cmd.Process.Pid, @@ -599,11 +599,11 @@ func TestRunContainerStartFailNoContainers(t *testing.T) { d := testRunContainerSetup(t) defer os.RemoveAll(d.tmpDir) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } - pod.MockContainers = []*vcMock.Container{ + pod.MockContainers = []*vcmock.Container{ { MockID: testContainerID, MockPod: pod, @@ -651,5 +651,5 @@ func TestRunContainerStartFailNoContainers(t *testing.T) { err := run(d.pod.ID(), d.bundlePath, d.consolePath, "", d.pidFilePath, false, d.runtimeConfig) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } diff --git a/cli/start_test.go b/cli/start_test.go index 14756097d..2bbb6e4c0 100644 --- a/cli/start_test.go +++ b/cli/start_test.go @@ -20,7 +20,7 @@ import ( vc "github.com/kata-containers/runtime/virtcontainers" vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" "github.com/stretchr/testify/assert" "github.com/urfave/cli" ) @@ -31,12 +31,12 @@ func TestStartInvalidArgs(t *testing.T) { // Missing container id _, err := start("") assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) // Mock Listpod error _, err = start(testContainerID) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.ListPodFunc = func() ([]vc.PodStatus, error) { return []vc.PodStatus{}, nil @@ -49,13 +49,13 @@ func TestStartInvalidArgs(t *testing.T) { // Container missing in ListPod _, err = start(testContainerID) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestStartPod(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -81,7 +81,7 @@ func TestStartPod(t *testing.T) { _, err := start(pod.ID()) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.StartPodFunc = func(podID string) (vc.VCPod, error) { return pod, nil @@ -98,7 +98,7 @@ func TestStartPod(t *testing.T) { func TestStartMissingAnnotation(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } @@ -122,17 +122,17 @@ func TestStartMissingAnnotation(t *testing.T) { _, err := start(pod.ID()) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) } func TestStartContainerSucessFailure(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } - pod.MockContainers = []*vcMock.Container{ + pod.MockContainers = []*vcmock.Container{ { MockID: testContainerID, MockPod: pod, @@ -161,7 +161,7 @@ func TestStartContainerSucessFailure(t *testing.T) { _, err := start(testContainerID) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) testingImpl.StartContainerFunc = func(podID, containerID string) (vc.VCContainer, error) { return pod.MockContainers[0], nil @@ -189,7 +189,7 @@ func TestStartCLIFunction(t *testing.T) { // no container id in the Metadata err := fn(ctx) assert.Error(err) - assert.False(vcMock.IsMockError(err)) + assert.False(vcmock.IsMockError(err)) flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError) flagSet.Parse([]string{"xyz"}) @@ -197,17 +197,17 @@ func TestStartCLIFunction(t *testing.T) { err = fn(ctx) assert.Error(err) - assert.True(vcMock.IsMockError(err)) + assert.True(vcmock.IsMockError(err)) } func TestStartCLIFunctionSuccess(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testPodID, } - pod.MockContainers = []*vcMock.Container{ + pod.MockContainers = []*vcmock.Container{ { MockID: testContainerID, MockPod: pod, diff --git a/cli/state_test.go b/cli/state_test.go index f5a6fb4d5..a33f3d199 100644 --- a/cli/state_test.go +++ b/cli/state_test.go @@ -20,7 +20,7 @@ import ( vc "github.com/kata-containers/runtime/virtcontainers" vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations" - "github.com/kata-containers/runtime/virtcontainers/pkg/vcMock" + "github.com/kata-containers/runtime/virtcontainers/pkg/vcmock" "github.com/stretchr/testify/assert" "github.com/urfave/cli" ) @@ -49,11 +49,11 @@ func TestStateCliAction(t *testing.T) { func TestStateSuccessful(t *testing.T) { assert := assert.New(t) - pod := &vcMock.Pod{ + pod := &vcmock.Pod{ MockID: testContainerID, } - pod.MockContainers = []*vcMock.Container{ + pod.MockContainers = []*vcmock.Container{ { MockID: pod.ID(), MockPod: pod, diff --git a/virtcontainers/api_test.go b/virtcontainers/api_test.go index 714586d4f..3601b69ce 100644 --- a/virtcontainers/api_test.go +++ b/virtcontainers/api_test.go @@ -279,6 +279,10 @@ func testGenerateCCProxySockDir() (string, error) { } func TestCreatePodHyperstartAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigHyperstartAgent() @@ -308,6 +312,10 @@ func TestCreatePodHyperstartAgentSuccessful(t *testing.T) { } func TestCreatePodKataAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigKataAgent() @@ -383,6 +391,10 @@ func TestDeletePodNoopAgentSuccessful(t *testing.T) { } func TestDeletePodHyperstartAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigHyperstartAgent() @@ -422,6 +434,10 @@ func TestDeletePodHyperstartAgentSuccessful(t *testing.T) { } func TestDeletePodKataAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigKataAgent() @@ -527,6 +543,10 @@ func TestStartPodHyperstartAgentSuccessful(t *testing.T) { } func TestStartPodKataAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigKataAgent() @@ -685,6 +705,10 @@ func TestStopPodHyperstartAgentSuccessful(t *testing.T) { } func TestStopPodKataAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigKataAgent() @@ -791,6 +815,10 @@ func TestRunPodHyperstartAgentSuccessful(t *testing.T) { } func TestRunPodKataAgentSuccessful(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + cleanUp() config := newTestPodConfigKataAgent() diff --git a/virtcontainers/asset_test.go b/virtcontainers/asset_test.go index b9798451a..132f9f6ba 100644 --- a/virtcontainers/asset_test.go +++ b/virtcontainers/asset_test.go @@ -112,6 +112,6 @@ func TestAssetNew(t *testing.T) { }, } - a, err = newAsset(p, kernelAsset) + _, err = newAsset(p, kernelAsset) assert.NotNil(err) } diff --git a/virtcontainers/bridge.go b/virtcontainers/bridge.go index c56c6ac58..dfddd3eee 100644 --- a/virtcontainers/bridge.go +++ b/virtcontainers/bridge.go @@ -22,7 +22,7 @@ type bridgeType string const ( pciBridge bridgeType = "pci" - pcieBridge = "pcie" + pcieBridge bridgeType = "pcie" ) const pciBridgeMaxCapacity = 30 diff --git a/virtcontainers/cc_shim_test.go b/virtcontainers/cc_shim_test.go index ddea0f8d0..9811b3163 100644 --- a/virtcontainers/cc_shim_test.go +++ b/virtcontainers/cc_shim_test.go @@ -37,7 +37,6 @@ const testContainer = "testContainer" var testCCShimPath = "/usr/bin/virtcontainers/bin/test/cc-shim" var testProxyURL = "foo:///foo/clear-containers/proxy.sock" var testWrongConsolePath = "/foo/wrong-console" -var testConsolePath = "tty-console" func getMockCCShimBinPath() string { if DefaultMockCCShimBinPath == "" { diff --git a/virtcontainers/cnm.go b/virtcontainers/cnm.go index 8af32569a..773acf432 100644 --- a/virtcontainers/cnm.go +++ b/virtcontainers/cnm.go @@ -22,7 +22,6 @@ import ( // cnm is a network implementation for the CNM plugin. type cnm struct { - config NetworkConfig } func cnmLogger() *logrus.Entry { diff --git a/virtcontainers/cnm_test.go b/virtcontainers/cnm_test.go deleted file mode 100644 index 419b36c7a..000000000 --- a/virtcontainers/cnm_test.go +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) 2017 Intel Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package virtcontainers - -type mockAddr struct { - network string - ipAddr string -} - -func (m mockAddr) Network() string { - return m.network -} - -func (m mockAddr) String() string { - return m.ipAddr -} diff --git a/virtcontainers/container.go b/virtcontainers/container.go index c91fbba0d..87ea329df 100644 --- a/virtcontainers/container.go +++ b/virtcontainers/container.go @@ -231,10 +231,6 @@ func (c *Container) storeProcess() error { return c.pod.storage.storeContainerProcess(c.podID, c.id, c.process) } -func (c *Container) fetchProcess() (Process, error) { - return c.pod.storage.fetchContainerProcess(c.podID, c.id) -} - func (c *Container) storeMounts() error { return c.pod.storage.storeContainerMounts(c.podID, c.id, c.mounts) } diff --git a/virtcontainers/container_test.go b/virtcontainers/container_test.go index a2e7a063f..1fac1c207 100644 --- a/virtcontainers/container_test.go +++ b/virtcontainers/container_test.go @@ -193,6 +193,10 @@ func cleanupFakeRootfsSetup(testRawFile, loopDev, mntDir string) { } func TestContainerAddDriveDir(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + testRawFile, loopDev, fakeRootfs, err := testSetupFakeRootfs(t) defer cleanupFakeRootfsSetup(testRawFile, loopDev, fakeRootfs) diff --git a/virtcontainers/device.go b/virtcontainers/device.go index 7010f59be..ffe0be486 100644 --- a/virtcontainers/device.go +++ b/virtcontainers/device.go @@ -46,13 +46,6 @@ var sysIOMMUPath = "/sys/kernel/iommu_groups" var sysDevPrefix = "/sys/dev" -var blockPaths = []string{ - "/dev/sd", //SCSI block device - "/dev/hd", //IDE block device - "/dev/vd", //Virtual Block device - "/dev/ida/", //Compaq Intelligent Drive Array devices -} - const ( vfioPath = "/dev/vfio/" ) diff --git a/virtcontainers/hack/virtc/main.go b/virtcontainers/hack/virtc/main.go index f45cf1844..d0e86a1ff 100644 --- a/virtcontainers/hack/virtc/main.go +++ b/virtcontainers/hack/virtc/main.go @@ -20,7 +20,6 @@ import ( "errors" "fmt" "os" - "os/exec" "strings" "text/tabwriter" @@ -860,28 +859,6 @@ var statusContainerCommand = cli.Command{ }, } -func startCCShim(process *vc.Process, shimPath, url string) error { - if process.Token == "" { - return fmt.Errorf("Token cannot be empty") - } - - if url == "" { - return fmt.Errorf("URL cannot be empty") - } - - if shimPath == "" { - return fmt.Errorf("Shim path cannot be empty") - } - - cmd := exec.Command(shimPath, "-t", process.Token, "-u", url) - cmd.Env = os.Environ() - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - return cmd.Run() -} - func main() { cli.VersionFlag = cli.BoolFlag{ Name: "version", diff --git a/virtcontainers/hyperstart_agent.go b/virtcontainers/hyperstart_agent.go index 251e705ea..4f0e487ff 100644 --- a/virtcontainers/hyperstart_agent.go +++ b/virtcontainers/hyperstart_agent.go @@ -40,10 +40,6 @@ var defaultSharedDir = "/run/hyper/shared/pods/" var mountTag = "hyperShared" var maxHostnameLen = 64 -const ( - unixSocket = "unix" -) - // HyperConfig is a structure storing information needed for // hyperstart agent initialization. type HyperConfig struct { @@ -637,7 +633,7 @@ func (h *hyper) processListOneContainer(podID, cID string, options ProcessListOp func (h *hyper) connectProxyRetry(scheme, address string) (conn net.Conn, err error) { attempt := 1 - timeoutSecs := time.Duration(waitForProxyTimeoutSecs * time.Second) + timeoutSecs := waitForProxyTimeoutSecs * time.Second startTime := time.Now() lastLogTime := startTime diff --git a/virtcontainers/hypervisor.go b/virtcontainers/hypervisor.go index 5f111ed6c..ad867bc2e 100644 --- a/virtcontainers/hypervisor.go +++ b/virtcontainers/hypervisor.go @@ -68,13 +68,13 @@ const ( netDev // SerialDev is the serial device type. - serialDev + serialDev // nolint: varcheck,unused // BlockDev is the block device type. blockDev // ConsoleDev is the console device type. - consoleDev + consoleDev // nolint: varcheck,unused // SerialPortDev is the serial port device type. serialPortDev @@ -131,7 +131,7 @@ func newHypervisor(hType HypervisorType) (hypervisor, error) { func makeNameID(namedType string, id string) string { nameID := fmt.Sprintf("%s-%s", namedType, id) if len(nameID) > maxDevIDSize { - nameID = string(nameID[:maxDevIDSize]) + nameID = nameID[:maxDevIDSize] } return nameID @@ -145,6 +145,12 @@ type Param struct { // HypervisorConfig is the hypervisor configuration. type HypervisorConfig struct { + // KernelParams are additional guest kernel parameters. + KernelParams []Param + + // HypervisorParams are additional hypervisor parameters. + HypervisorParams []Param + // KernelPath is the guest kernel host path. KernelPath string @@ -160,26 +166,19 @@ type HypervisorConfig struct { // HypervisorPath is the hypervisor executable host path. HypervisorPath string - // DisableBlockDeviceUse disallows a block device from being used. - DisableBlockDeviceUse bool - // BlockDeviceDriver specifies the driver to be used for block device // either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver BlockDeviceDriver string - // KernelParams are additional guest kernel parameters. - KernelParams []Param - - // HypervisorParams are additional hypervisor parameters. - HypervisorParams []Param - // HypervisorMachineType specifies the type of machine being // emulated. HypervisorMachineType string - // Debug changes the default hypervisor and kernel parameters to - // enable debug output where available. - Debug bool + // customAssets is a map of assets. + // Each value in that map takes precedence over the configured assets. + // For example, if there is a value for the "kernel" key in this map, + // it will be used for the pod's kernel path instead of KernelPath. + customAssets map[assetType]*asset // DefaultVCPUs specifies default number of vCPUs for the VM. DefaultVCPUs uint32 @@ -195,6 +194,13 @@ type HypervisorConfig struct { // Bridges can be used to hot plug devices DefaultBridges uint32 + // DisableBlockDeviceUse disallows a block device from being used. + DisableBlockDeviceUse bool + + // Debug changes the default hypervisor and kernel parameters to + // enable debug output where available. + Debug bool + // MemPrealloc specifies if the memory should be pre-allocated MemPrealloc bool @@ -212,12 +218,6 @@ type HypervisorConfig struct { // DisableNestingChecks is used to override customizations performed // when running on top of another VMM. DisableNestingChecks bool - - // customAssets is a map of assets. - // Each value in that map takes precedence over the configured assets. - // For example, if there is a value for the "kernel" key in this map, - // it will be used for the pod's kernel path instead of KernelPath. - customAssets map[assetType]*asset } func (conf *HypervisorConfig) valid() (bool, error) { diff --git a/virtcontainers/kata_agent.go b/virtcontainers/kata_agent.go index 5df14e9d4..329e576cf 100644 --- a/virtcontainers/kata_agent.go +++ b/virtcontainers/kata_agent.go @@ -515,21 +515,6 @@ func (k *kataAgent) stopPod(pod Pod) error { return k.proxy.stop(pod, k.state.ProxyPid) } -func appendStorageFromMounts(storage []*grpc.Storage, mounts []*Mount) []*grpc.Storage { - for _, m := range mounts { - s := &grpc.Storage{ - Source: m.Source, - MountPoint: m.Destination, - Fstype: m.Type, - Options: m.Options, - } - - storage = append(storage, s) - } - - return storage -} - func (k *kataAgent) replaceOCIMountSource(spec *specs.Spec, guestMounts []Mount) error { ociMounts := spec.Mounts @@ -770,11 +755,7 @@ func (k *kataAgent) stopContainer(pod Pod, c Container) error { return err } - if err := bindUnmountContainerRootfs(kataHostSharedDir, pod.id, c.id); err != nil { - return err - } - - return nil + return bindUnmountContainerRootfs(kataHostSharedDir, pod.id, c.id) } func (k *kataAgent) killContainer(pod Pod, c Container, signal syscall.Signal, all bool) error { diff --git a/virtcontainers/kata_agent_test.go b/virtcontainers/kata_agent_test.go index da2e83824..e49c20460 100644 --- a/virtcontainers/kata_agent_test.go +++ b/virtcontainers/kata_agent_test.go @@ -24,9 +24,9 @@ import ( "reflect" "testing" - "github.com/kata-containers/runtime/virtcontainers/pkg/mock" gpb "github.com/gogo/protobuf/types" pb "github.com/kata-containers/agent/protocols/grpc" + "github.com/kata-containers/runtime/virtcontainers/pkg/mock" "github.com/stretchr/testify/assert" "github.com/vishvananda/netlink" "golang.org/x/net/context" diff --git a/virtcontainers/kata_shim_test.go b/virtcontainers/kata_shim_test.go index 8d5ac7dc9..777c2b72a 100644 --- a/virtcontainers/kata_shim_test.go +++ b/virtcontainers/kata_shim_test.go @@ -29,9 +29,6 @@ import ( . "github.com/kata-containers/runtime/virtcontainers/pkg/mock" ) -// These tests don't care about the format of the container ID -const testKataContainer = "testContainer" - var testKataShimPath = "/usr/bin/virtcontainers/bin/test/kata-shim" var testKataShimProxyURL = "foo:///foo/kata-containers/proxy.sock" diff --git a/virtcontainers/mount.go b/virtcontainers/mount.go index 7bd5ab048..adffa21aa 100644 --- a/virtcontainers/mount.go +++ b/virtcontainers/mount.go @@ -25,19 +25,10 @@ import ( "path/filepath" "strings" "syscall" - - "github.com/sirupsen/logrus" ) var rootfsDir = "rootfs" -func mountLogger() *logrus.Entry { - return virtLog.WithField("subsystem", "mount") -} - -// These mounts need to be created by the agent within the VM -var systemMounts = []string{"/proc", "/dev", "/dev/pts", "/dev/shm", "/dev/mqueue", "/sys", "/sys/fs/cgroup"} - var systemMountPrefixes = []string{"/proc", "/dev", "/sys"} func isSystemMount(m string) bool { diff --git a/virtcontainers/network.go b/virtcontainers/network.go index 491dea60b..45d687bb5 100644 --- a/virtcontainers/network.go +++ b/virtcontainers/network.go @@ -453,7 +453,6 @@ func (n NetworkNamespace) MarshalJSON() ([]byte, error) { // UnmarshalJSON is the custom NetworkNamespace unmarshalling routine. // This is needed for unmarshalling the Endpoints interfaces array. func (n *NetworkNamespace) UnmarshalJSON(b []byte) error { - type tmp NetworkNamespace var s struct { NetNsPath string NetNsCreated bool @@ -1081,15 +1080,6 @@ func createNetNS() (string, error) { return n.Path(), nil } -func setNetNS(netNSPath string) error { - n, err := ns.GetNS(netNSPath) - if err != nil { - return err - } - - return n.Set() -} - // doNetNS is free from any call to a go routine, and it calls // into runtime.LockOSThread(), meaning it won't be executed in a // different thread than the one expected by the caller. diff --git a/virtcontainers/network_test.go b/virtcontainers/network_test.go index db63de80b..1cb04b835 100644 --- a/virtcontainers/network_test.go +++ b/virtcontainers/network_test.go @@ -309,6 +309,10 @@ func TestCreateVirtualNetworkEndpointInvalidArgs(t *testing.T) { } func TestIsPhysicalIface(t *testing.T) { + if os.Geteuid() != 0 { + t.Skip(testDisabledAsNonRoot) + } + testNetIface := "testIface0" testMTU := 1500 testMACAddr := "00:00:00:00:00:01" diff --git a/virtcontainers/no_proxy_test.go b/virtcontainers/no_proxy_test.go index 5fb8d2bf6..d0df409a0 100644 --- a/virtcontainers/no_proxy_test.go +++ b/virtcontainers/no_proxy_test.go @@ -20,8 +20,6 @@ import ( "testing" ) -var testNoProxyVMURL = "vmURL" - func TestNoProxyStart(t *testing.T) { pod := Pod{ agent: newAgent(NoopAgentType), diff --git a/virtcontainers/pkg/hyperstart/hyperstart.go b/virtcontainers/pkg/hyperstart/hyperstart.go index 6ed35af58..52401aa44 100644 --- a/virtcontainers/pkg/hyperstart/hyperstart.go +++ b/virtcontainers/pkg/hyperstart/hyperstart.go @@ -345,7 +345,7 @@ func (h *Hyperstart) WriteCtlMessage(conn net.Conn, m *DecodedMessage) error { return fmt.Errorf("message too long %d", length) } msg := make([]byte, length) - binary.BigEndian.PutUint32(msg[:], uint32(m.Code)) + binary.BigEndian.PutUint32(msg[:], m.Code) binary.BigEndian.PutUint32(msg[CtlHdrLenOffset:], uint32(length)) copy(msg[CtlHdrSize:], m.Message) @@ -485,7 +485,7 @@ func (h *Hyperstart) WaitForPAE(containerID, processID string) (*PAECommand, err msg := <-channel var paeData PAECommand - err = json.Unmarshal(msg.Message, paeData) + err = json.Unmarshal(msg.Message, &paeData) if err != nil { return nil, err } diff --git a/virtcontainers/pkg/hyperstart/mock/hyperstart.go b/virtcontainers/pkg/hyperstart/mock/hyperstart.go index f4d399f83..b2df6de94 100644 --- a/virtcontainers/pkg/hyperstart/mock/hyperstart.go +++ b/virtcontainers/pkg/hyperstart/mock/hyperstart.go @@ -285,7 +285,7 @@ func (h *Hyperstart) SendIo(seq uint64, data []byte) { h.logf("io: <-- writing %d bytes for seq %d\n", len(data), seq) - binary.BigEndian.PutUint64(header[:], uint64(seq)) + binary.BigEndian.PutUint64(header[:], seq) binary.BigEndian.PutUint32(header[8:], uint32(length)) h.writeIo(header) diff --git a/virtcontainers/pkg/hyperstart/multicast.go b/virtcontainers/pkg/hyperstart/multicast.go index ddf1c3037..cedb86eaf 100644 --- a/virtcontainers/pkg/hyperstart/multicast.go +++ b/virtcontainers/pkg/hyperstart/multicast.go @@ -78,7 +78,7 @@ func (m *multicast) buildEventID(containerID, processID string) string { func (m *multicast) sendEvent(msg *DecodedMessage) error { var paeData PAECommand - err := json.Unmarshal(msg.Message, paeData) + err := json.Unmarshal(msg.Message, &paeData) if err != nil { return err } diff --git a/virtcontainers/pkg/hyperstart/types.go b/virtcontainers/pkg/hyperstart/types.go index 5f87b90aa..b3f407b83 100644 --- a/virtcontainers/pkg/hyperstart/types.go +++ b/virtcontainers/pkg/hyperstart/types.go @@ -168,28 +168,34 @@ type Capabilities struct { // Process describes a process running on a container inside a pod. type Process struct { - User string `json:"user,omitempty"` - Group string `json:"group,omitempty"` + // Args specifies the binary and arguments for the application to execute. + Args []string `json:"args"` + + // Rlimits specifies rlimit options to apply to the process. + Rlimits []Rlimit `json:"rlimits,omitempty"` + + // Envs populates the process environment for the process. + Envs []EnvironmentVar `json:"envs,omitempty"` + AdditionalGroups []string `json:"additionalGroups,omitempty"` - // Terminal creates an interactive terminal for the process. - Terminal bool `json:"terminal"` + + // Workdir is the current working directory for the process and must be + // relative to the container's root. + Workdir string `json:"workdir"` + + User string `json:"user,omitempty"` + Group string `json:"group,omitempty"` // Sequeue number for stdin and stdout Stdio uint64 `json:"stdio,omitempty"` // Sequeue number for stderr if it is not shared with stdout Stderr uint64 `json:"stderr,omitempty"` - // Args specifies the binary and arguments for the application to execute. - Args []string `json:"args"` - // Envs populates the process environment for the process. - Envs []EnvironmentVar `json:"envs,omitempty"` - // Workdir is the current working directory for the process and must be - // relative to the container's root. - Workdir string `json:"workdir"` - // Rlimits specifies rlimit options to apply to the process. - Rlimits []Rlimit `json:"rlimits,omitempty"` // NoNewPrivileges indicates that the process should not gain any additional privileges + Capabilities Capabilities `json:"capabilities"` + NoNewPrivileges bool `json:"noNewPrivileges"` // Capabilities specifies the sets of capabilities for the process(es) inside the container. - Capabilities Capabilities `json:"capabilities"` + // Terminal creates an interactive terminal for the process. + Terminal bool `json:"terminal"` } // SystemMountsInfo describes additional information for system mounts that the agent diff --git a/virtcontainers/pkg/mock/cc_proxy_mock.go b/virtcontainers/pkg/mock/cc_proxy_mock.go index af7431ff3..3acee1a67 100644 --- a/virtcontainers/pkg/mock/cc_proxy_mock.go +++ b/virtcontainers/pkg/mock/cc_proxy_mock.go @@ -27,7 +27,6 @@ import ( "github.com/stretchr/testify/assert" ) -const testContainerid = "123456789" const testToken = "pF56IaDpuax6hihJ5PneB8JypqmOvjkqY-wKGVYqgIM=" // CCProxyMock is an object mocking clearcontainers Proxy @@ -73,10 +72,6 @@ func (proxy *CCProxyMock) GetProxyToken() string { return proxy.token } -func newSignalList() []ShimSignal { - return make([]ShimSignal, 0, 5) -} - // GetLastStdinStream returns the last received stdin stream func (proxy *CCProxyMock) GetLastStdinStream() []byte { return proxy.lastStdinStream @@ -375,13 +370,6 @@ type FrameKey struct { opcode int } -func newFrameKey(frameType api.FrameType, opcode int) FrameKey { - return FrameKey{ - ftype: frameType, - opcode: opcode, - } -} - type ccProxyProtocol struct { cmdHandlers map[FrameKey]ccProxyProtocolHandler } @@ -429,7 +417,7 @@ func (proto *ccProxyProtocol) handleCommand(ctx *clientCtx, cmd *api.Frame) *api // cmd.Header.Opcode is guaranteed to be within the right bounds by // ReadFrame(). - handler := proto.cmdHandlers[FrameKey{cmd.Header.Type, int(cmd.Header.Opcode)}] + handler := proto.cmdHandlers[FrameKey{cmd.Header.Type, cmd.Header.Opcode}] handler(cmd.Payload, ctx.userData, &hr) if hr.err != nil { diff --git a/virtcontainers/pkg/nsenter/nsenter.go b/virtcontainers/pkg/nsenter/nsenter.go index 782c25866..ffcfbfb69 100644 --- a/virtcontainers/pkg/nsenter/nsenter.go +++ b/virtcontainers/pkg/nsenter/nsenter.go @@ -52,10 +52,10 @@ type NSType string // without multithreading issues. const ( NSTypeCGroup NSType = "cgroup" - NSTypeIPC = "ipc" - NSTypeNet = "net" - NSTypePID = "pid" - NSTypeUTS = "uts" + NSTypeIPC NSType = "ipc" + NSTypeNet NSType = "net" + NSTypePID NSType = "pid" + NSTypeUTS NSType = "uts" ) // CloneFlagsTable is exported so that consumers of this package don't need diff --git a/virtcontainers/pkg/nsenter/nsenter_test.go b/virtcontainers/pkg/nsenter/nsenter_test.go index a0ad8f382..220d9c63d 100644 --- a/virtcontainers/pkg/nsenter/nsenter_test.go +++ b/virtcontainers/pkg/nsenter/nsenter_test.go @@ -31,10 +31,7 @@ import ( "golang.org/x/sys/unix" ) -const ( - testPID = 12345 - testNSPath = "/foo/bar/ns" -) +const testPID = 12345 func TestGetNSPathFromPID(t *testing.T) { for nsType := range CloneFlagsTable { diff --git a/virtcontainers/pkg/uuid/uuid.go b/virtcontainers/pkg/uuid/uuid.go index 219f19d96..c7df53a42 100644 --- a/virtcontainers/pkg/uuid/uuid.go +++ b/virtcontainers/pkg/uuid/uuid.go @@ -133,7 +133,7 @@ func (u UUID) String() string { clkSeqLow := u[9] buf := make([]byte, 8) copy(buf[2:], u[10:]) - node := uint64(binary.BigEndian.Uint64(buf)) + node := binary.BigEndian.Uint64(buf) return fmt.Sprintf("%08x-%04x-%04x-%02x%02x-%012x", timeLow, timeMid, timeHi, clkSeqHi, clkSeqLow, node) diff --git a/virtcontainers/pkg/vcMock/container.go b/virtcontainers/pkg/vcmock/container.go similarity index 99% rename from virtcontainers/pkg/vcMock/container.go rename to virtcontainers/pkg/vcmock/container.go index 02c7558d2..7bee5567a 100644 --- a/virtcontainers/pkg/vcMock/container.go +++ b/virtcontainers/pkg/vcmock/container.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package vcMock +package vcmock import ( vc "github.com/kata-containers/runtime/virtcontainers" diff --git a/virtcontainers/pkg/vcMock/mock.go b/virtcontainers/pkg/vcmock/mock.go similarity index 99% rename from virtcontainers/pkg/vcMock/mock.go rename to virtcontainers/pkg/vcmock/mock.go index ffc6b89e5..b421b8567 100644 --- a/virtcontainers/pkg/vcMock/mock.go +++ b/virtcontainers/pkg/vcmock/mock.go @@ -22,7 +22,7 @@ // well-known format. Callers can detect this scenario by calling // IsMockError(). -package vcMock +package vcmock import ( "fmt" @@ -34,7 +34,7 @@ import ( // mockErrorPrefix is a string that all errors returned by the mock // implementation itself will contain as a prefix. -const mockErrorPrefix = "vcMock forced failure" +const mockErrorPrefix = "vcmock forced failure" // SetLogger implements the VC function of the same name. func (m *VCMock) SetLogger(logger logrus.FieldLogger) { diff --git a/virtcontainers/pkg/vcMock/mock_test.go b/virtcontainers/pkg/vcmock/mock_test.go similarity index 99% rename from virtcontainers/pkg/vcMock/mock_test.go rename to virtcontainers/pkg/vcmock/mock_test.go index f1875b9da..95d6aac33 100644 --- a/virtcontainers/pkg/vcMock/mock_test.go +++ b/virtcontainers/pkg/vcmock/mock_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package vcMock +package vcmock import ( "reflect" diff --git a/virtcontainers/pkg/vcMock/pod.go b/virtcontainers/pkg/vcmock/pod.go similarity index 99% rename from virtcontainers/pkg/vcMock/pod.go rename to virtcontainers/pkg/vcmock/pod.go index 1bf3ce785..c05462255 100644 --- a/virtcontainers/pkg/vcMock/pod.go +++ b/virtcontainers/pkg/vcmock/pod.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package vcMock +package vcmock import ( vc "github.com/kata-containers/runtime/virtcontainers" diff --git a/virtcontainers/pkg/vcMock/types.go b/virtcontainers/pkg/vcmock/types.go similarity index 99% rename from virtcontainers/pkg/vcMock/types.go rename to virtcontainers/pkg/vcmock/types.go index 79c133268..f38e44108 100644 --- a/virtcontainers/pkg/vcMock/types.go +++ b/virtcontainers/pkg/vcmock/types.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package vcMock +package vcmock import ( "syscall" diff --git a/virtcontainers/pkg/vcMock/utils.go b/virtcontainers/pkg/vcmock/utils.go similarity index 98% rename from virtcontainers/pkg/vcMock/utils.go rename to virtcontainers/pkg/vcmock/utils.go index 3461b6a64..c41068a7a 100644 --- a/virtcontainers/pkg/vcMock/utils.go +++ b/virtcontainers/pkg/vcmock/utils.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package vcMock +package vcmock import ( "runtime" diff --git a/virtcontainers/pod.go b/virtcontainers/pod.go index c5563c93e..e0779477b 100644 --- a/virtcontainers/pod.go +++ b/virtcontainers/pod.go @@ -274,9 +274,9 @@ type LinuxCapabilities struct { // Cmd represents a command to execute in a running container. type Cmd struct { - Args []string - Envs []EnvVar - WorkDir string + Args []string + Envs []EnvVar + SupplementaryGroups []string // Note that these fields *MUST* remain as strings. // @@ -300,15 +300,15 @@ type Cmd struct { // all the user and group mapping is handled by the container manager // and specified to the runtime in terms of UID/GID's in the // configuration file generated by the container manager. - User string - PrimaryGroup string - SupplementaryGroups []string + User string + PrimaryGroup string + WorkDir string + Console string + Capabilities LinuxCapabilities Interactive bool - Console string Detach bool NoNewPrivileges bool - Capabilities LinuxCapabilities } // Resources describes VM resources configuration. @@ -466,8 +466,6 @@ type Pod struct { networkNS NetworkNamespace - lockFile *os.File - annotationsLock *sync.RWMutex wg *sync.WaitGroup diff --git a/virtcontainers/pod_test.go b/virtcontainers/pod_test.go index ef7599792..ff4e370d2 100644 --- a/virtcontainers/pod_test.go +++ b/virtcontainers/pod_test.go @@ -1263,11 +1263,6 @@ func TestFindContainerSuccess(t *testing.T) { assert.True(t, c == pod.containers[0], "Container pointers should point to the same address") } -func testRemoveContainerFailure(t *testing.T, pod *Pod, cid string) { - err := pod.removeContainer(cid) - assert.NotNil(t, err, "Should have returned an error") -} - func TestRemoveContainerPodNilFailure(t *testing.T) { testFindContainerFailure(t, nil, testContainerID) } diff --git a/virtcontainers/proxy.go b/virtcontainers/proxy.go index 8e941333a..e3ff0d426 100644 --- a/virtcontainers/proxy.go +++ b/virtcontainers/proxy.go @@ -21,7 +21,6 @@ import ( "path/filepath" "github.com/mitchellh/mapstructure" - "github.com/sirupsen/logrus" ) // ProxyConfig is a structure storing information needed from any @@ -60,10 +59,6 @@ const ( waitForProxyTimeoutSecs = 5.0 ) -func proxyLogger() *logrus.Entry { - return virtLog.WithField("subsystem", "proxy") -} - // Set sets a proxy type based on the input string. func (pType *ProxyType) Set(value string) error { switch value { diff --git a/virtcontainers/qemu.go b/virtcontainers/qemu.go index e1aad27b2..90004c093 100644 --- a/virtcontainers/qemu.go +++ b/virtcontainers/qemu.go @@ -24,8 +24,8 @@ import ( "strings" "time" - "github.com/kata-containers/runtime/virtcontainers/pkg/uuid" govmmQemu "github.com/intel/govmm/qemu" + "github.com/kata-containers/runtime/virtcontainers/pkg/uuid" "github.com/sirupsen/logrus" ) @@ -559,19 +559,6 @@ func (q *qemu) addDeviceToBridge(ID string) (string, string, error) { return "", "", err } -func (q *qemu) removeDeviceFromBridge(ID string) error { - var err error - for _, b := range q.state.Bridges { - err = b.removeDevice(ID) - if err == nil { - // device was removed correctly - return nil - } - } - - return err -} - func (q *qemu) hotplugBlockDevice(drive Drive, op operation) error { defer func(qemu *qemu) { if q.qmpMonitorCh.qmp != nil {