From 325f1acff530123851148966f501f3a2c303ecde Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Sat, 23 May 2026 22:26:21 +0200 Subject: [PATCH] f-28: api: add uefi params Signed-off-by: GnomeZworc --- api/agent.yaml | 7 +++++++ internal/api/agent/models.go | 2 ++ internal/api/agent/vm.go | 1 + internal/api/agent/vms.go | 1 + internal/dispatcher/agent/vm_commands.go | 4 ++++ 5 files changed, 15 insertions(+) diff --git a/api/agent.yaml b/api/agent.yaml index e75601d..7e9c461 100644 --- a/api/agent.yaml +++ b/api/agent.yaml @@ -430,6 +430,10 @@ components: minItems: 1 items: $ref: "#/components/schemas/VMStorage" + uefi: + type: boolean + description: Boot with UEFI firmware (OVMF). Defaults to false (SeaBIOS). + example: false VMInterface: type: object @@ -487,6 +491,9 @@ components: type: array items: $ref: "#/components/schemas/VMStorage" + uefi: + type: boolean + example: false Error: type: object diff --git a/internal/api/agent/models.go b/internal/api/agent/models.go index dc0c47f..079d8db 100644 --- a/internal/api/agent/models.go +++ b/internal/api/agent/models.go @@ -49,6 +49,7 @@ type VMCreateRequest struct { Name string `json:"name"` Memory int `json:"memory"` CPUs int `json:"cpus"` + UEFI bool `json:"uefi"` Password string `json:"password"` SSHKey string `json:"sshkey"` Interfaces []VMInterface `json:"interfaces"` @@ -61,6 +62,7 @@ type VM struct { MetadataPort string `json:"metadata_port"` Memory int `json:"memory"` CPUs int `json:"cpus"` + UEFI bool `json:"uefi"` Interfaces []VMInterface `json:"interfaces"` Storage []VMStorage `json:"storage"` } diff --git a/internal/api/agent/vm.go b/internal/api/agent/vm.go index a150d16..f932766 100644 --- a/internal/api/agent/vm.go +++ b/internal/api/agent/vm.go @@ -79,6 +79,7 @@ func vmFromDB(name string, entries map[string]string) (VM, error) { vm.MetadataPort = entries[prefix+"metadata_port"] vm.Memory, _ = strconv.Atoi(entries[prefix+"memory"]) vm.CPUs, _ = strconv.Atoi(entries[prefix+"cpus"]) + vm.UEFI = entries[prefix+"uefi"] == "true" subnet := entries[prefix+"subnet"] ip := entries[prefix+"ip"] diff --git a/internal/api/agent/vms.go b/internal/api/agent/vms.go index 95f2c85..4dc6136 100644 --- a/internal/api/agent/vms.go +++ b/internal/api/agent/vms.go @@ -84,6 +84,7 @@ func (s *Server) startVM(w http.ResponseWriter, r *http.Request) { VolumePath: req.Storage[0].Path, Memory: req.Memory, CPUs: req.CPUs, + UEFI: req.UEFI, Password: req.Password, SSHKey: req.SSHKey, } diff --git a/internal/dispatcher/agent/vm_commands.go b/internal/dispatcher/agent/vm_commands.go index 1bb55d4..1c4bbce 100644 --- a/internal/dispatcher/agent/vm_commands.go +++ b/internal/dispatcher/agent/vm_commands.go @@ -20,6 +20,7 @@ type StartVMCommand struct { VolumePath string Memory int CPUs int + UEFI bool Password string SSHKey string } @@ -46,6 +47,9 @@ func (c StartVMCommand) Prepare(db *badger.DB, _ *configuration.Config) error { kv.AddInDB(db, "vm/"+c.Name+"/volume_path", c.VolumePath) kv.AddInDB(db, "vm/"+c.Name+"/memory", strconv.Itoa(c.Memory)) kv.AddInDB(db, "vm/"+c.Name+"/cpus", strconv.Itoa(c.CPUs)) + if c.UEFI { + kv.AddInDB(db, "vm/"+c.Name+"/uefi", "true") + } if c.Password != "" { kv.AddInDB(db, "vm/"+c.Name+"/password", c.Password) }