mirror of
https://github.com/getcompanion-ai/computer-host.git
synced 2026-04-16 18:03:51 +00:00
fix: seed mmds data via --metadata flag at boot, eliminates race with guest init
This commit is contained in:
parent
9dd606f26a
commit
44bd0ff089
4 changed files with 32 additions and 17 deletions
|
|
@ -141,3 +141,21 @@ func writeConfigFile(chrootRootDir string, spec MachineSpec, paths machinePaths,
|
|||
|
||||
return "/vm_config.json", nil
|
||||
}
|
||||
|
||||
func writeMetadataFile(chrootRootDir string, spec MachineSpec) (string, error) {
|
||||
if spec.MMDS == nil || spec.MMDS.Data == nil {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
data, err := json.Marshal(spec.MMDS.Data)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("marshal mmds data: %w", err)
|
||||
}
|
||||
|
||||
metadataPath := filepath.Join(chrootRootDir, "mmds.json")
|
||||
if err := os.WriteFile(metadataPath, data, 0o644); err != nil {
|
||||
return "", fmt.Errorf("write mmds data: %w", err)
|
||||
}
|
||||
|
||||
return "/mmds.json", nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue