Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Clh driver: removed hard-coded vsock contextid (cid) #2217

Merged
merged 2 commits into from
Nov 22, 2019
Merged

Clh driver: removed hard-coded vsock contextid (cid) #2217

merged 2 commits into from
Nov 22, 2019

Conversation

ericooper
Copy link
Contributor

Removed hardcoded cid in the driver and replaced it by a call to utils find context id. To support this approach an addition of a contextid field in the hybrid vsock type was necessary in sandbox

sync fork after merge clh driver #1
Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ericooper.

@@ -436,7 +429,13 @@ func (clh *cloudHypervisor) addDevice(devInfo interface{}, devType deviceType) e
device: v.Name(),
mac: v.HardwareAddr(),
})

case types.HybridVSock:
clh.Logger().WithField("function", "addDevice").Infof("Adding HybridVSock: path=%s, cid=%d, port=%d", v.UdsPath, v.ContextID, v.Port)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change the log calls to be "structured" by pulling out the relevant info into a set of fields:

.WithFields(logrus.Fields{
    "function" : "addDevice",
    "path" : v.UdsPath,
    "cid" : v.ContextID,
    "port" : v.Port,
}).Info("Adding HybridVSock")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

clh.Logger().WithField("function", "generateSocket").Infof("Using hybrid vsock %s:%d", udsPath, vSockPort)
_, cid, err := utils.FindContextID()
if err != nil {
return nil, fmt.Errorf("Can't generate hybrid vsocket for cloud-hypervisor: error finding available context id")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include err in the returned error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ericooper.

lgtm but please reformat the file using gofmt -s as shown in the Travis log:

virtcontainers/types/sandbox.go:190: File is not `gofmt`-ed with `-s` (gofmt)
	UdsPath string
	ContextID uint64	
	Port    uint32
The command ".ci/static-checks.sh" failed and exited with 1 during .

Note that you can run the static-checks.sh script locally to avoid CI surprises once you push 😄

update after review 2. applied ci static checks

Fixes: #2206

Signed-off-by: Johan Kuijpers <[email protected]>
@ericooper
Copy link
Contributor Author

Thanks @ericooper.

lgtm but please reformat the file using gofmt -s as shown in the Travis log:

virtcontainers/types/sandbox.go:190: File is not `gofmt`-ed with `-s` (gofmt)
	UdsPath string
	ContextID uint64	
	Port    uint32
The command ".ci/static-checks.sh" failed and exited with 1 during .

Note that you can run the static-checks.sh script locally to avoid CI surprises once you push smile

Sure. I didn't know, thanks for the tip. I've applied the ci script and did an update so it should be good to go now. Cheers.

@grahamwhaley
Copy link
Contributor

/test-ubuntu

@codecov
Copy link

codecov bot commented Nov 22, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@eae8449). Click here to learn what that means.
The diff coverage is 0%.

@@            Coverage Diff            @@
##             master    #2217   +/-   ##
=========================================
  Coverage          ?   48.95%           
=========================================
  Files             ?      111           
  Lines             ?    16049           
  Branches          ?        0           
=========================================
  Hits              ?     7857           
  Misses            ?     7217           
  Partials          ?      975

@devimc devimc merged commit 0ff0e54 into kata-containers:master Nov 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants