From bac734f5485f451345cf520f9b2d503d618d43bd Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Fri, 21 Jan 2022 19:00:05 +0800 Subject: [PATCH] fix: arm image support UEFI by default --- cmd/climc/shell/image/images.go | 6 ++++++ pkg/compute/models/guests.go | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/climc/shell/image/images.go b/cmd/climc/shell/image/images.go index f24ee89f5c..2941adf77c 100644 --- a/cmd/climc/shell/image/images.go +++ b/cmd/climc/shell/image/images.go @@ -58,6 +58,7 @@ type ImageOptionalOptions struct { DiskDriver string `help:"Perfer disk driver" choices:"virtio|scsi|pvscsi|ide|sata"` NetDriver string `help:"Preferred network driver" choices:"virtio|e1000|vmxnet3"` DisableUsbKbd bool `help:"Disable usb keyboard on this image(for hypervisor kvm)"` + BootMode string `help:"UEFI support" choices:"UEFI|BIOS"` } func addImageOptionalOptions(s *mcclient.ClientSession, params *jsonutils.JSONDict, args ImageOptionalOptions) error { @@ -138,6 +139,11 @@ func addImageOptionalOptions(s *mcclient.ClientSession, params *jsonutils.JSONDi if args.DisableUsbKbd { params.Add(jsonutils.NewString("true"), "properties", "disable_usb_kbd") } + if args.BootMode == "UEFI" { + params.Add(jsonutils.JSONTrue, "properties", "uefi_support") + } else if args.BootMode == "BIOS" { + params.Add(jsonutils.JSONFalse, "properties", "uefi_support") + } return nil } diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index 0334d0f213..32a423398f 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -1193,11 +1193,19 @@ func (manager *SGuestManager) validateCreateData( } } + if arch := imgProperties["os_arch"]; strings.Contains(arch, "aarch") || strings.Contains(arch, "arm") { + input.OsArch = apis.OS_ARCH_AARCH64 + } + imgSupportUEFI := imgProperties[imageapi.IMAGE_UEFI_SUPPORT] == "true" // imgIsWindows := imgProperties[imageapi.IMAGE_OS_TYPE] == "Windows" // if imgSupportUEFI && imgIsWindows && len(input.IsolatedDevices) > 0 { // input.Bios = "UEFI" // windows gpu passthrough // } + if input.OsArch == apis.OS_ARCH_AARCH64 { + // arm image supports UEFI by default + imgSupportUEFI = true + } if imgSupportUEFI { if len(input.Bios) == 0 { @@ -1212,10 +1220,6 @@ func (manager *SGuestManager) validateCreateData( } } - if arch := imgProperties["os_arch"]; strings.Contains(arch, "aarch") { - input.OsArch = apis.OS_ARCH_AARCH64 - } - if len(imgProperties) == 0 { imgProperties = map[string]string{"os_type": "Linux"} }