Merge pull request #2217 from ericooper/clh-driver-fix-2206

Clh driver: removed hard-coded vsock contextid (cid)
This commit is contained in:
Julio Montes
2019-11-22 07:23:14 -06:00
committed by GitHub
2 changed files with 23 additions and 14 deletions

View File

@@ -192,13 +192,6 @@ func (clh *cloudHypervisor) createSandbox(ctx context.Context, id string, networ
iommu: false, 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 // set the initial root/boot disk of hypervisor
imagePath, err := clh.config.ImageAssetPath() imagePath, err := clh.config.ImageAssetPath()
if err != nil { if err != nil {
@@ -436,7 +429,18 @@ func (clh *cloudHypervisor) addDevice(devInfo interface{}, devType deviceType) e
device: v.Name(), device: v.Name(),
mac: v.HardwareAddr(), 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: default:
clh.Logger().WithField("function", "addDevice").Warnf("Add device of type %v is not supported.", v) clh.Logger().WithField("function", "addDevice").Warnf("Add device of type %v is not supported.", v)
} }
@@ -544,7 +548,7 @@ func (clh *cloudHypervisor) reset() {
func (clh *cloudHypervisor) generateSocket(id string, useVsock bool) (interface{}, error) { func (clh *cloudHypervisor) generateSocket(id string, useVsock bool) (interface{}, error) {
if !useVsock { 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) udsPath, err := clh.vsockSocketPath(id)
@@ -552,10 +556,14 @@ func (clh *cloudHypervisor) generateSocket(id string, useVsock bool) (interface{
clh.Logger().Info("Can't generate socket path for cloud-hypervisor") clh.Logger().Info("Can't generate socket path for cloud-hypervisor")
return types.HybridVSock{}, err 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 clh.socketPath = udsPath
return types.HybridVSock{ return types.HybridVSock{
UdsPath: udsPath, UdsPath: udsPath,
ContextID: cid,
Port: uint32(vSockPort), Port: uint32(vSockPort),
}, nil }, nil
} }

View File

@@ -188,6 +188,7 @@ func (s *VSock) String() string {
// Firecracker supports it. // Firecracker supports it.
type HybridVSock struct { type HybridVSock struct {
UdsPath string UdsPath string
ContextID uint64
Port uint32 Port uint32
} }