Skip to content

Commit

Permalink
lxd/instance/drivers: Use shorter socket path in deviceAttachPath
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <pedro.ribeiro@canonical.com>
  • Loading branch information
hamistao committed Jun 6, 2024
1 parent 35ea8fb commit 97e9be4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lxd/instance/drivers/driver_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,16 @@ func (d *qemu) deviceAttachPath(deviceName string, configCopy map[string]string,
return fmt.Errorf("Failed to connect to QMP monitor: %w", err)
}

addr, err := net.ResolveUnixAddr("unix", virtiofsdSockPath)
virtiofsdSocketDir, err := os.Open(filepath.Dir(virtiofsdSockPath))
if err != nil {
return err
}

defer func() { _ = virtiofsdSocketDir.Close() }()

shortPath := fmt.Sprintf("/proc/self/fd/%d/%s", virtiofsdSocketDir.Fd(), filepath.Base(virtiofsdSockPath))

addr, err := net.ResolveUnixAddr("unix", shortPath)
if err != nil {
return err
}
Expand Down

0 comments on commit 97e9be4

Please sign in to comment.