mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-06 03:56:34 +00:00
virtcontainers: update KataAgentConfig to support vsocks
add extra field in KataAgentConfig structure to specify if the kata agent have to use a vsock instead of serial port. Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
3adc8626e8
commit
1515bd07a1
@ -428,8 +428,9 @@ func updateRuntimeConfig(configPath string, tomlConf tomlConfig, config *oci.Run
|
|||||||
|
|
||||||
case kataAgentTableType:
|
case kataAgentTableType:
|
||||||
config.AgentType = kataAgentTableType
|
config.AgentType = kataAgentTableType
|
||||||
config.AgentConfig = vc.KataAgentConfig{}
|
config.AgentConfig = vc.KataAgentConfig{
|
||||||
|
UseVSock: config.HypervisorConfig.UseVSock,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ func TestNewAgentConfigFromHyperstartAgentType(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNewAgentConfigFromKataAgentType(t *testing.T) {
|
func TestNewAgentConfigFromKataAgentType(t *testing.T) {
|
||||||
agentConfig := KataAgentConfig{}
|
agentConfig := KataAgentConfig{UseVSock: true}
|
||||||
|
|
||||||
sandboxConfig := SandboxConfig{
|
sandboxConfig := SandboxConfig{
|
||||||
AgentType: KataContainersAgent,
|
AgentType: KataContainersAgent,
|
||||||
|
@ -60,6 +60,7 @@ var (
|
|||||||
// to reach the Kata Containers agent.
|
// to reach the Kata Containers agent.
|
||||||
type KataAgentConfig struct {
|
type KataAgentConfig struct {
|
||||||
LongLiveConn bool
|
LongLiveConn bool
|
||||||
|
UseVSock bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type kataVSOCK struct {
|
type kataVSOCK struct {
|
||||||
@ -128,8 +129,13 @@ func (k *kataAgent) getSharePath(id string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) generateVMSocket(id string, c KataAgentConfig) error {
|
func (k *kataAgent) generateVMSocket(id string, c KataAgentConfig) error {
|
||||||
cid, port, err := parseVSOCKAddr(c.GRPCSocket)
|
if c.UseVSock {
|
||||||
if err != nil {
|
// We want to go through VSOCK. The VM VSOCK endpoint will be our gRPC.
|
||||||
|
k.Logger().Debug("agent: Using vsock VM socket endpoint")
|
||||||
|
// We dont know yet the context ID - set empty vsock configuration
|
||||||
|
k.vmSocket = kataVSOCK{}
|
||||||
|
} else {
|
||||||
|
k.Logger().Debug("agent: Using unix socket form VM socket endpoint")
|
||||||
// We need to generate a host UNIX socket path for the emulated serial port.
|
// We need to generate a host UNIX socket path for the emulated serial port.
|
||||||
kataSock, err := utils.BuildSocketPath(k.getVMPath(id), defaultKataSocketName)
|
kataSock, err := utils.BuildSocketPath(k.getVMPath(id), defaultKataSocketName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -142,12 +148,6 @@ func (k *kataAgent) generateVMSocket(id string, c KataAgentConfig) error {
|
|||||||
HostPath: kataSock,
|
HostPath: kataSock,
|
||||||
Name: defaultKataChannel,
|
Name: defaultKataChannel,
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// We want to go through VSOCK. The VM VSOCK endpoint will be our gRPC.
|
|
||||||
k.vmSocket = kataVSOCK{
|
|
||||||
contextID: cid,
|
|
||||||
port: port,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -676,6 +676,7 @@ func TestAgentPathAPI(t *testing.T) {
|
|||||||
_, ok := k1.vmSocket.(Socket)
|
_, ok := k1.vmSocket.(Socket)
|
||||||
assert.True(ok)
|
assert.True(ok)
|
||||||
|
|
||||||
|
c.UseVSock = true
|
||||||
err = k2.generateVMSocket(id, c)
|
err = k2.generateVMSocket(id, c)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
_, ok = k2.vmSocket.(kataVSOCK)
|
_, ok = k2.vmSocket.(kataVSOCK)
|
||||||
|
Loading…
Reference in New Issue
Block a user