qvm/internal/virtiofsd/mount.go

51 lines
1.4 KiB
Go

package virtiofsd
import (
"path/filepath"
"qvm/internal/config"
)
// Mount represents a single virtiofsd mount configuration
type Mount struct {
Tag string // Mount tag (e.g., "cargo_home", "ws_abc12345")
HostPath string // Path on host to share
SocketPath string // Path to virtiofsd socket
}
// DefaultCacheMounts returns the standard cache mounts for cargo, pnpm, and sccache.
// These are shared across all projects and mounted at VM start.
func DefaultCacheMounts() []Mount {
return []Mount{
{
Tag: "cargo_home",
HostPath: config.CargoHome,
SocketPath: filepath.Join(config.StateDir, "cargo_home.sock"),
},
{
Tag: "cargo_target",
HostPath: config.CargoTarget,
SocketPath: filepath.Join(config.StateDir, "cargo_target.sock"),
},
{
Tag: "pnpm_store",
HostPath: config.PnpmStore,
SocketPath: filepath.Join(config.StateDir, "pnpm_store.sock"),
},
{
Tag: "sccache",
HostPath: config.Sccache,
SocketPath: filepath.Join(config.StateDir, "sccache.sock"),
},
}
}
// WorkspaceMount creates a Mount configuration for a single workspace.
// mountTag should be the workspace's mount tag (e.g., "ws_abc12345")
// hostPath is the absolute path on the host to share
func WorkspaceMount(mountTag, hostPath string) Mount {
return Mount{
Tag: mountTag,
HostPath: hostPath,
SocketPath: filepath.Join(config.StateDir, mountTag+".sock"),
}
}