Skip to content

Commit

Permalink
virtcontainers: remove parseVSOCKAddr function
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Julio Montes committed Jul 31, 2018
1 parent 0527691 commit 3c15bc5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 51 deletions.
21 changes: 0 additions & 21 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
30 changes: 0 additions & 30 deletions virtcontainers/kata_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3c15bc5

Please sign in to comment.