mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-10 12:22:36 +00:00
clh: removed hard-coded vsock contextid (cid)
update after review 2. applied ci static checks Fixes: #2206 Signed-off-by: Johan Kuijpers <johan.kuijpers@ericsson.com>
This commit is contained in:
parent
164fa18858
commit
1abe52abd7
@ -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,11 +556,15 @@ 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,
|
||||||
Port: uint32(vSockPort),
|
ContextID: cid,
|
||||||
|
Port: uint32(vSockPort),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,8 +187,9 @@ func (s *VSock) String() string {
|
|||||||
// This kind of socket is not supported in all hypervisors.
|
// This kind of socket is not supported in all hypervisors.
|
||||||
// Firecracker supports it.
|
// Firecracker supports it.
|
||||||
type HybridVSock struct {
|
type HybridVSock struct {
|
||||||
UdsPath string
|
UdsPath string
|
||||||
Port uint32
|
ContextID uint64
|
||||||
|
Port uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *HybridVSock) String() string {
|
func (s *HybridVSock) String() string {
|
||||||
|
Loading…
Reference in New Issue
Block a user