mirror of
https://github.com/getcompanion-ai/computer-host.git
synced 2026-04-15 18:01:24 +00:00
feat(contracts): add published ports, snapshot request, and storage report types
This commit is contained in:
parent
501ae2abd5
commit
26b5d2966d
20 changed files with 893 additions and 81 deletions
|
|
@ -231,7 +231,9 @@ func (c *apiClient) do(ctx context.Context, method string, endpoint string, inpu
|
|||
if err != nil {
|
||||
return fmt.Errorf("do %s %s via %q: %w", method, endpoint, c.socketPath, err)
|
||||
}
|
||||
defer response.Body.Close()
|
||||
defer func() {
|
||||
_ = response.Body.Close()
|
||||
}()
|
||||
|
||||
if response.StatusCode != wantStatus {
|
||||
return decodeFirecrackerError(method, endpoint, response)
|
||||
|
|
|
|||
|
|
@ -161,7 +161,6 @@ func waitForSocket(ctx context.Context, client *apiClient, socketPath string) er
|
|||
lastPingErr = err
|
||||
continue
|
||||
}
|
||||
lastPingErr = nil
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -231,13 +230,6 @@ func waitForPIDFile(ctx context.Context, pidFilePath string) (int, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func hostVSockPath(paths machinePaths, spec MachineSpec) string {
|
||||
if spec.Vsock == nil {
|
||||
return ""
|
||||
}
|
||||
return filepath.Join(paths.ChrootRootDir, defaultFirecrackerSocketDir, filepath.Base(strings.TrimSpace(spec.Vsock.Path)))
|
||||
}
|
||||
|
||||
func jailedVSockPath(spec MachineSpec) string {
|
||||
if spec.Vsock == nil {
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -67,18 +67,3 @@ func buildMachinePaths(rootDir string, id MachineID, firecrackerBinaryPath strin
|
|||
func procSocketPath(pid int) string {
|
||||
return filepath.Join("/proc", strconv.Itoa(pid), "root", defaultFirecrackerSocketDir, defaultFirecrackerSocketName)
|
||||
}
|
||||
|
||||
type snapshotPaths struct {
|
||||
BaseDir string
|
||||
MemFilePath string
|
||||
StateFilePath string
|
||||
}
|
||||
|
||||
func buildSnapshotPaths(rootDir string, id string) snapshotPaths {
|
||||
baseDir := filepath.Join(rootDir, "snapshots", id)
|
||||
return snapshotPaths{
|
||||
BaseDir: baseDir,
|
||||
MemFilePath: filepath.Join(baseDir, "memory.bin"),
|
||||
StateFilePath: filepath.Join(baseDir, "vmstate.bin"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue