mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-30 17:22:33 +00:00
virtcontainers: remove parseVSOCKAddr function
parseVSOCKAddr function is no more needed since now agent config contains a field to identify if vsocks should be used or not. Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
052769196d
commit
3c15bc50d0
@ -99,27 +99,6 @@ func (k *kataAgent) Logger() *logrus.Entry {
|
||||
return virtLog.WithField("subsystem", "kata_agent")
|
||||
}
|
||||
|
||||
func parseVSOCKAddr(sock string) (uint32, uint32, error) {
|
||||
sp := strings.Split(sock, ":")
|
||||
if len(sp) != 3 {
|
||||
return 0, 0, fmt.Errorf("Invalid vsock address: %s", sock)
|
||||
}
|
||||
if sp[0] != vsockSocketScheme {
|
||||
return 0, 0, fmt.Errorf("Invalid vsock URL scheme: %s", sp[0])
|
||||
}
|
||||
|
||||
cid, err := strconv.ParseUint(sp[1], 10, 32)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("Invalid vsock cid: %s", sp[1])
|
||||
}
|
||||
port, err := strconv.ParseUint(sp[2], 10, 32)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("Invalid vsock port: %s", sp[2])
|
||||
}
|
||||
|
||||
return uint32(cid), uint32(port), nil
|
||||
}
|
||||
|
||||
func (k *kataAgent) getVMPath(id string) string {
|
||||
return filepath.Join(RunVMStoragePath, id)
|
||||
}
|
||||
|
@ -708,36 +708,6 @@ func TestAgentConfigure(t *testing.T) {
|
||||
assert.Nil(err)
|
||||
}
|
||||
|
||||
func TestParseVSOCKAddr(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
sock := "randomfoobar"
|
||||
_, _, err := parseVSOCKAddr(sock)
|
||||
assert.Error(err)
|
||||
|
||||
sock = "vsock://1:2"
|
||||
_, _, err = parseVSOCKAddr(sock)
|
||||
assert.Error(err)
|
||||
|
||||
sock = "unix:1:2"
|
||||
_, _, err = parseVSOCKAddr(sock)
|
||||
assert.Error(err)
|
||||
|
||||
sock = "vsock:foo:2"
|
||||
_, _, err = parseVSOCKAddr(sock)
|
||||
assert.Error(err)
|
||||
|
||||
sock = "vsock:1:bar"
|
||||
_, _, err = parseVSOCKAddr(sock)
|
||||
assert.Error(err)
|
||||
|
||||
sock = "vsock:1:2"
|
||||
cid, port, err := parseVSOCKAddr(sock)
|
||||
assert.Nil(err)
|
||||
assert.Equal(cid, uint32(1))
|
||||
assert.Equal(port, uint32(2))
|
||||
}
|
||||
|
||||
func TestCmdToKataProcess(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user