Skip to content

Commit

Permalink
Fix copy of the URL in RemoteName
Browse files Browse the repository at this point in the history
Fixes dmacvicar#1040

The copy performed in RemoteName was shallow and this corrupted to
original URI that is used during the Dial() call made by the go-libvirt
library.

The issue always existed but did not manifest when libvirt.New(conn) was
used because the connection was established before the call to
RemoteName. The problem manifested when the switch to
libvirt.NewWithDialer was made, because the dialing is now made during
the call to ConnectToURI, which receives as paramater the result of the
call to RemoteName.
  • Loading branch information
Florian Maury committed Nov 3, 2023
1 parent 6bf5862 commit 4fc6781
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions libvirt/uri/connection_uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@ func Parse(uriStr string) (*ConnectionURI, error) {
// The name passed to the remote virConnectOpen function is formed by removing
// transport, hostname, port number, username and extra parameters from the remote URI
// unless the name option is specified.
func (u *ConnectionURI) RemoteName() string {
func (u ConnectionURI) RemoteName() string {
q := u.Query()
if name := q.Get("name"); name != "" {
return name
}

newURI := *u
newURI.Scheme = u.driver()
newURI.User = nil
newURI.Host = ""
newURI.RawQuery = ""
newURI := url.URL{
Scheme: u.driver(),
Path: u.Path,
}

return newURI.String()
}
Expand Down

0 comments on commit 4fc6781

Please sign in to comment.