File tree Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -28,25 +28,18 @@ func init() {
2828// The format is "VMID:Service", "VMID", or ":Service" as well as an
2929// empty string. For VMID we also support "parent" and assume
3030// "loopback" if the string can't be parsed.
31- func hvsockParseSockStr (sockStr string ) hvsockAddr {
31+ func hvsockParseSockStr (vmStr , svcStr string ) hvsockAddr {
3232 hvAddr := hvsock.Addr {hvsock .GUIDZero , svcid }
3333 port , _ := svcid .Port ()
3434 vAddr := vsock.Addr {vsock .CIDAny , port }
35- if sockStr == "" {
35+ if svcStr != "" && svcStr [0 ] == '/' {
36+ svcStr = svcStr [1 :]
37+ }
38+ if vmStr == "" && svcStr == "" {
3639 return hvsockAddr {hvAddr : hvAddr , vAddr : vAddr }
3740 }
3841
3942 var err error
40- vmStr := ""
41- svcStr := ""
42- if strings .Contains (sockStr , ":" ) {
43- vmStr , svcStr , err = net .SplitHostPort (sockStr )
44- if err != nil {
45- log .Fatalf ("Error parsing socket string '%s': %v" , sockStr , err )
46- }
47- } else {
48- vmStr = sockStr
49- }
5043
5144 if vmStr != "" {
5245 if strings .Contains (vmStr , "-" ) {
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ func init() {
9999 fmt .Printf (" %s -s vsock Start server in vsock mode on standard port\n " , prog )
100100 fmt .Printf (" %s -s vsock://:1235 Start server in vsock mode on a non-standard port\n " , prog )
101101 fmt .Printf (" %s -c hvsock://<vmid> Start client in hvsock mode connecting to VM with <vmid>\n " , prog )
102+ fmt .Printf (" %s -c hvsock://<vmid>/<svcid> Start client in hvsock mode connecting to VM with <vmid> on a non-standard <svcid>\n " , prog )
102103 }
103104 rand .Seed (time .Now ().UnixNano ())
104105}
@@ -172,7 +173,7 @@ func parseSockStr(inStr string) (string, Sock) {
172173 case "vsock" :
173174 return u .Scheme , vsockParseSockStr (u .Host )
174175 case "hvsock" :
175- return u .Scheme , hvsockParseSockStr (u .Host )
176+ return u .Scheme , hvsockParseSockStr (u .Host , u . Path )
176177 case "tcp" , "tcp4" , "tcp6" :
177178 return u .Scheme , tcpParseSockStr (u .Scheme , u .Host )
178179 case "udp" , "udp4" , "udp6" :
You can’t perform that action at this time.
0 commit comments