Skip to content

Commit

Permalink
kvm: handle uefi_firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Nov 29, 2024
1 parent 2607d35 commit 8d42bb0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ echo $GIT_VERSION > kvirt/version/git

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

podman build -t quay.io/karmab/kcli:latest -f extras/debian .
podman login -u $QUAY_USERNAME -p $QUAY_PASSWORD quay.io
podman build -t quay.io/karmab/kcli:latest -f extras/debian .
podman push quay.io/karmab/kcli:latest

# podman build --arch=amd64 -t quay.io/karmab/kcli:amd64 -f extras/debian .
Expand Down
10 changes: 8 additions & 2 deletions .github/container_snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ if [ -n "${EGG}" ] ; then
TAG="${EGG}-${TAG}"
fi

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
if [ "$TAG" == "arm64" ] ; then
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"
sed -i 's/bookworm/bookworm-arm64/' extras/debian
sed -i 's/\[all\]//' extras/debian
else
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
fi

podman build -t quay.io/karmab/kcli:$TAG -f extras/debian .
podman login -u $QUAY_USERNAME -p $QUAY_PASSWORD quay.io
podman build -t quay.io/karmab/kcli:$TAG -f extras/debian .
podman push quay.io/karmab/kcli:$TAG
1 change: 1 addition & 0 deletions kvirt/extra_keywords/kvm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ machine: Custom machine type
qemuextra: Extra cmdline for qemu
secureboot: Enable secureboot
uefi: Enable uefi
uefi_firmware: Path to specific UEFI firmware
uefi_legacy: Enable uefi for rhel8 hypervisors
uuid: Uuid
boot_order: Set boot order on all disks to allow to boot from any of them
Expand Down
33 changes: 18 additions & 15 deletions kvirt/providers/kvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ def create(self, name, virttype=None, profile='kvirt', flavor=None, plan='kvirt'
default_disksize = disksize
default_pool = pool
conn = self.conn
capabilities = self.get_capabilities(overrides.get('arch'))
if 'arch' not in overrides:
overrides['arch'] = capabilities['arch']
iommu_model = 'intel' if overrides.get('arch', 'x86_64') == 'x86_64' else 'smmuv3'
custom_emulator = overrides.get('emulator')
default_arch = overrides.get('arch')
arch = 'aarch64' if custom_emulator is not None and custom_emulator.endswith('aarch64') else default_arch
capabilities = self.get_capabilities(arch)
arch = arch or capabilities['arch']
if custom_emulator is not None:
if os.path.exists(custom_emulator):
emulator = custom_emulator
Expand All @@ -251,17 +251,20 @@ def create(self, name, virttype=None, profile='kvirt', flavor=None, plan='kvirt'
else:
emulator = which(custom_emulator)
elif 'emulator' not in capabilities:
return {'result': 'failure', 'reason': "No valid emulator found for target arch"}
return {'result': 'failure', 'reason': f"No valid emulator found for target arch {arch}"}
else:
emulator = capabilities['emulator']
if 'machine' in overrides and overrides['machine'] not in capabilities['machines']:
machines = ','.join(sorted(capabilities['machines']))
return {'result': 'failure', 'reason': f"Incorrect machine. Choose between {machines}"}
aarch64 = capabilities['arch'] == 'aarch64'
if 'machine' in overrides and overrides['machine'] not in capabilities['machines']:
machines = ','.join(sorted(capabilities['machines']))
return {'result': 'failure', 'reason': f"Incorrect machine. Choose between {machines}"}
iommu_model = 'smmuv3' if arch == 'aarch64' else 'intel'
aarch64 = arch == 'aarch64'
aarch64_full = aarch64 and capabilities['kvm']
as390x = capabilities['arch'] == 's390x'
as390x = arch == 's390x'
if aarch64:
if 'machine' not in overrides:
if custom_emulator is not None:
warning("Not checking whether a valid machine is provided")
elif 'machine' not in overrides:
virtmachines = [m for m in sorted(capabilities['machines']) if m.startswith('virt-')]
if not virtmachines:
return {'result': 'failure', 'reason': "Couldn't find a valid machine"}
Expand Down Expand Up @@ -1206,11 +1209,11 @@ def create(self, name, virttype=None, profile='kvirt', flavor=None, plan='kvirt'
ramxml = ""
smmxml = ""
osfirmware = ""
if uefi or uefi_legacy or secureboot or aarch64:
uefi_firmware = '/usr/share/OVMF/OVMF_CODE.secboot.fd' if uefi_legacy else overrides.get('uefi_firmware')
if uefi or uefi_firmware is not None or secureboot or aarch64:
secure = 'yes' if secureboot else 'no'
if uefi_legacy:
firmware = '/usr/share/OVMF/OVMF_CODE.secboot.fd'
ramxml = f"<loader secure='{secure}' readonly='yes' type='pflash'>{firmware}</loader>"
if uefi_firmware is not None:
ramxml = f"<loader secure='{secure}' readonly='yes' type='pflash'>{uefi_firmware}</loader>"
if secureboot:
smmxml = "<smm state='on'/>"
sectemplate = '/usr/share/OVMF/OVMF_VARS.secboot.fd'
Expand Down

0 comments on commit 8d42bb0

Please sign in to comment.