Replace Bash qvm scripts with Go CLI implementation

This commit is contained in:
Joshua Bell 2026-01-26 20:48:32 -06:00
parent ffb456707f
commit 2a6a333721
27 changed files with 2551 additions and 1702 deletions

View file

@ -0,0 +1,51 @@
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"),
}
}