From a196b19b0c954ba652e411779b9616e09c85fd7e Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Sat, 26 Jul 2025 02:26:55 +0800 Subject: [PATCH] fix(region): iso boot do not check boot mode (#22950) --- pkg/compute/models/guests.go | 46 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index be9505c227..75c3bf7c16 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -1720,6 +1720,7 @@ func (manager *SGuestManager) validateCreateData( } var imgProperties map[string]string var imgEncryptKeyId string + var imageDiskFormat string if len(input.Disks) > 0 { diskConfig := input.Disks[0] @@ -1730,6 +1731,7 @@ func (manager *SGuestManager) validateCreateData( input.Disks[0] = diskConfig imgEncryptKeyId = diskConfig.ImageEncryptKeyId imgProperties = diskConfig.ImageProperties + imageDiskFormat = imgProperties[imageapi.IMAGE_DISK_FORMAT] if imgProperties[imageapi.IMAGE_DISK_FORMAT] == "iso" { return nil, httperrors.NewInputParameterError("System disk does not support iso image, please consider using cdrom parameter") } @@ -1741,6 +1743,7 @@ func (manager *SGuestManager) validateCreateData( return nil, httperrors.NewInputParameterError("parse cdrom device info error %s", err) } input.Cdrom = image.Id + imageDiskFormat = image.DiskFormat if len(imgProperties) == 0 { imgProperties = image.Properties } @@ -1764,28 +1767,29 @@ func (manager *SGuestManager) validateCreateData( input.OsArch = apis.OS_ARCH_AARCH64 } - var imgSupportUEFI *bool - if desc, ok := imgProperties[imageapi.IMAGE_UEFI_SUPPORT]; ok { - support := desc == "true" - imgSupportUEFI = &support - } - if input.OsArch == apis.OS_ARCH_AARCH64 { - // arm image supports UEFI by default - support := true - imgSupportUEFI = &support - } - - switch { - case imgSupportUEFI != nil && *imgSupportUEFI: - if len(input.Bios) == 0 { - input.Bios = "UEFI" - } else if input.Bios != "UEFI" { - return nil, httperrors.NewInputParameterError("UEFI image requires UEFI boot mode") + if imageDiskFormat != "iso" { + var imgSupportUEFI *bool + if desc, ok := imgProperties[imageapi.IMAGE_UEFI_SUPPORT]; ok { + support := desc == "true" + imgSupportUEFI = &support } - default: - // not UEFI image - if input.Bios == "UEFI" && len(imgProperties) != 0 { - return nil, httperrors.NewInputParameterError("UEFI boot mode requires UEFI image") + if input.OsArch == apis.OS_ARCH_AARCH64 { + // arm image supports UEFI by default + support := true + imgSupportUEFI = &support + } + switch { + case imgSupportUEFI != nil && *imgSupportUEFI: + if len(input.Bios) == 0 { + input.Bios = "UEFI" + } else if input.Bios != "UEFI" { + return nil, httperrors.NewInputParameterError("UEFI image requires UEFI boot mode") + } + default: + // not UEFI image + if input.Bios == "UEFI" && len(imgProperties) != 0 { + return nil, httperrors.NewInputParameterError("UEFI boot mode requires UEFI image") + } } }