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

Commit

Permalink
Merge pull request #2217 from ericooper/clh-driver-fix-2206
Browse files Browse the repository at this point in the history
Clh driver: removed hard-coded vsock contextid (cid)
  • Loading branch information
Julio Montes authored Nov 22, 2019
2 parents eae8449 + 1abe52a commit 0ff0e54
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
32 changes: 20 additions & 12 deletions virtcontainers/clh.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,6 @@ func (clh *cloudHypervisor) createSandbox(ctx context.Context, id string, networ
iommu: false,
})

// Add the hybrid vsock device to hypervisor
clh.cliBuilder.SetVsock(&CLIVsock{
cid: 3,
socketPath: clh.socketPath,
iommu: false,
})

// set the initial root/boot disk of hypervisor
imagePath, err := clh.config.ImageAssetPath()
if err != nil {
Expand Down Expand Up @@ -436,7 +429,18 @@ func (clh *cloudHypervisor) addDevice(devInfo interface{}, devType deviceType) e
device: v.Name(),
mac: v.HardwareAddr(),
})

case types.HybridVSock:
clh.Logger().WithFields(log.Fields{
"function": "addDevice",
"path": v.UdsPath,
"cid": v.ContextID,
"port": v.Port,
}).Info("Adding HybridVSock")
clh.cliBuilder.SetVsock(&CLIVsock{
cid: uint32(v.ContextID),
socketPath: v.UdsPath,
iommu: false,
})
default:
clh.Logger().WithField("function", "addDevice").Warnf("Add device of type %v is not supported.", v)
}
Expand Down Expand Up @@ -544,19 +548,23 @@ func (clh *cloudHypervisor) reset() {

func (clh *cloudHypervisor) generateSocket(id string, useVsock bool) (interface{}, error) {
if !useVsock {
return nil, fmt.Errorf("Can't generate socket path for cloud-hypervisor: vsocks is disabled")
return nil, fmt.Errorf("Can't generate hybrid vsocket for cloud-hypervisor: vsocks is disabled")
}

udsPath, err := clh.vsockSocketPath(id)
if err != nil {
clh.Logger().Info("Can't generate socket path for cloud-hypervisor")
return types.HybridVSock{}, err
}
clh.Logger().WithField("function", "generateSocket").Infof("Using hybrid vsock %s:%d", udsPath, vSockPort)
_, cid, err := utils.FindContextID()
if err != nil {
return nil, err
}
clh.socketPath = udsPath
return types.HybridVSock{
UdsPath: udsPath,
Port: uint32(vSockPort),
UdsPath: udsPath,
ContextID: cid,
Port: uint32(vSockPort),
}, nil
}

Expand Down
5 changes: 3 additions & 2 deletions virtcontainers/types/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ func (s *VSock) String() string {
// This kind of socket is not supported in all hypervisors.
// Firecracker supports it.
type HybridVSock struct {
UdsPath string
Port uint32
UdsPath string
ContextID uint64
Port uint32
}

func (s *HybridVSock) String() string {
Expand Down

0 comments on commit 0ff0e54

Please sign in to comment.