mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-02-07 07:34:27 +01:00
This patch adds the support of the remote hypervisor type.
Shim opens a Unix domain socket specified in the config file,
and sends TTPRC requests to a external process to control
sandbox VMs.
Fixes #4482
Co-authored-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
Co-authored-by: stevenhorsman <steven@uk.ibm.com>
Signed-off-by: Yohei Ueda <yohei@jp.ibm.com>
(based on commit f9278f22c3)
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
// Copyright (c) 2023 IBM Corporation
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package virtcontainers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func newRemoteConfig() HypervisorConfig {
|
|
return HypervisorConfig{
|
|
RemoteHypervisorSocket: "/run/peerpod/hypervisor.sock",
|
|
RemoteHypervisorTimeout: 600,
|
|
DisableGuestSeLinux: true,
|
|
EnableAnnotations: []string{},
|
|
}
|
|
}
|
|
|
|
func TestRemoteHypervisorGenerateSocket(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
remoteHypervisor := remoteHypervisor{
|
|
config: newRemoteConfig(),
|
|
}
|
|
id := "sandboxId"
|
|
|
|
// No socketPath should error
|
|
_, err := remoteHypervisor.GenerateSocket(id)
|
|
assert.Error(err)
|
|
|
|
socketPath := "socketPath"
|
|
remoteHypervisor.agentSocketPath = socketPath
|
|
|
|
result, err := remoteHypervisor.GenerateSocket(id)
|
|
assert.NoError(err)
|
|
|
|
expected := types.RemoteSock{
|
|
SandboxID: id,
|
|
TunnelSocketPath: socketPath,
|
|
}
|
|
assert.Equal(result, expected)
|
|
}
|