From c2f366a4a36a9783cc877ae87d86285f4b823f86 Mon Sep 17 00:00:00 2001 From: Vladimir Popov Date: Wed, 17 Feb 2021 13:54:26 +0700 Subject: [PATCH] Manually update to the latest sdk-sriov version Signed-off-by: Vladimir Popov --- go.mod | 2 +- go.sum | 4 ++-- main.go | 34 +--------------------------------- 3 files changed, 4 insertions(+), 36 deletions(-) diff --git a/go.mod b/go.mod index 0f5dbeb..81427bb 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/kelseyhightower/envconfig v1.4.0 github.com/networkservicemesh/api v0.0.0-20210202152048-ec956057eb3a github.com/networkservicemesh/sdk v0.0.0-20210216095211-a36209b21c4b - github.com/networkservicemesh/sdk-sriov v0.0.0-20210216100057-84463e4b82ce + github.com/networkservicemesh/sdk-sriov v0.0.0-20210217064121-69fae3fcd42e github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.7.0 github.com/spiffe/go-spiffe/v2 v2.0.0-alpha.5 diff --git a/go.sum b/go.sum index 2af1121..cd48a34 100644 --- a/go.sum +++ b/go.sum @@ -296,8 +296,8 @@ github.com/networkservicemesh/sdk v0.0.0-20210216095211-a36209b21c4b h1:6M4ZAQwA github.com/networkservicemesh/sdk v0.0.0-20210216095211-a36209b21c4b/go.mod h1:7Y9JsBKKjgvOT2faCXy/aM76bWsA//xvdVfbdLe0WXk= github.com/networkservicemesh/sdk-kernel v0.0.0-20210216095528-c177e58a0d03 h1:ooGOUOXve7Dwdt25oyDrKINenrfG86UoxfEIXsQSorE= github.com/networkservicemesh/sdk-kernel v0.0.0-20210216095528-c177e58a0d03/go.mod h1:fYNkQR64twi8v9ATVTXDfMRbfKktUHA49nxI/kqwvDE= -github.com/networkservicemesh/sdk-sriov v0.0.0-20210216100057-84463e4b82ce h1:ig+1CO9xtH7ZhNymp30bAnyMCcc+yZewIoTvOVVMXhM= -github.com/networkservicemesh/sdk-sriov v0.0.0-20210216100057-84463e4b82ce/go.mod h1:SAfJDaAfFQ7z+2hRlddcqP4MVdMY6LEl6v2ApU2HkQQ= +github.com/networkservicemesh/sdk-sriov v0.0.0-20210217064121-69fae3fcd42e h1:dsbp9wJc4ZB8P8gOt6+lXMUhBTyM7eyc0OmvBNjTvdA= +github.com/networkservicemesh/sdk-sriov v0.0.0-20210217064121-69fae3fcd42e/go.mod h1:SAfJDaAfFQ7z+2hRlddcqP4MVdMY6LEl6v2ApU2HkQQ= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nishanths/exhaustive v0.0.0-20200811152831-6cf413ae40e0/go.mod h1:wBEpHwM2OdmeNpdCvRPUlkEbBuaFmcK4Wv8Q7FuGW3c= diff --git a/main.go b/main.go index 4de8979..2f07a33 100644 --- a/main.go +++ b/main.go @@ -20,13 +20,9 @@ package main import ( - "bufio" "context" "fmt" "os" - "path/filepath" - "regexp" - "strings" nested "github.com/antonfisher/nested-logrus-formatter" "github.com/edwarnicke/grpcfd" @@ -230,13 +226,7 @@ func RunClient( } clients = append(clients, kernel.NewClient(kernel.WithInterfaceName(iface))) case vfiomech.MECHANISM: - var cgroupDir string - cgroupDir, err = cgroupDirPath() - if err != nil { - log.FromContext(ctx).Errorf("failed to get devices cgroup: %v", err.Error()) - continue - } - clients = append(clients, vfio.NewClient("/dev/vfio", cgroupDir)) + clients = append(clients, vfio.NewClient()) } nsmClient := nsmClientFactory(clients...) @@ -271,25 +261,3 @@ func RunClient( } return cleanup, nil } - -var devicesCgroup = regexp.MustCompile("^[1-9][0-9]*?:devices:(.*)$") - -func cgroupDirPath() (string, error) { - cgroupInfo, err := os.OpenFile("/proc/self/cgroup", os.O_RDONLY, 0) - if err != nil { - return "", errors.Wrap(err, "error opening cgroup info file") - } - for scanner := bufio.NewScanner(cgroupInfo); scanner.Scan(); { - line := scanner.Text() - if devicesCgroup.MatchString(line) { - return podCgroupDirPath(devicesCgroup.FindStringSubmatch(line)[1]), nil - } - } - return "", errors.New("can't find out cgroup directory") -} - -func podCgroupDirPath(containerCgroupDirPath string) string { - split := strings.Split(containerCgroupDirPath, string(filepath.Separator)) - split[len(split)-1] = "*" // any container match - return filepath.Join(split...) -}