-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Test ITF QEMU plugin with Ubuntu image #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lurtz
wants to merge
3
commits into
eclipse-score:main
Choose a base branch
from
elektrobit-contrib:add-ubuntu-support-to-qemu-plugin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
|
|
||
| genrule( | ||
| name = "itf-image", | ||
| srcs = [ | ||
| "@ubuntu_noble_minimal_cloudimg_amd64//file", | ||
| "build_image.sh", | ||
| "render_user_data.py", | ||
| "cloud-init/user-data", | ||
| "cloud-init/meta-data", | ||
| "qemu_config.json", | ||
| ], | ||
| outs = ["ubuntu-x86_64-itf/ubuntu-24.04-minimal-cloudimg-amd64.img"], | ||
| cmd = """ | ||
| bash $(location build_image.sh) \ | ||
| $(RULEDIR) \ | ||
| $(location @ubuntu_noble_minimal_cloudimg_amd64//file) \ | ||
| $(RULEDIR)/ubuntu-x86_64-itf/ubuntu-24.04-minimal-cloudimg-amd64.img \ | ||
| $(location cloud-init/user-data) \ | ||
| $(location cloud-init/meta-data) \ | ||
| $(location qemu_config.json) \ | ||
| $(location render_user_data.py) | ||
| """, | ||
| tags = [ | ||
| "manual", | ||
| ], | ||
| visibility = ["//visibility:private"], | ||
| ) | ||
|
|
||
| filegroup( | ||
| name = "image", | ||
| srcs = [":ubuntu-x86_64-itf/ubuntu-24.04-minimal-cloudimg-amd64.img"], | ||
| tags = [ | ||
| "manual", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| filegroup( | ||
| name = "qemu_config", | ||
| srcs = ["qemu_config.json"], | ||
| visibility = ["//:__subpackages__"], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| #!/bin/bash | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| # | ||
| # Turns a stock Ubuntu cloud image into an image that can be driven by the score | ||
| # ITF QEMU plugin. | ||
| # | ||
| # The image is booted exactly once with a cloud-init NoCloud seed image attached. | ||
| # cloud-init applies the configuration from a rendered cloud-init/user-data | ||
| # derived from qemu_config.json, then powers the machine off again, so this | ||
| # script simply has to wait for QEMU to exit. | ||
| # | ||
| # Usage: build_image.sh <working dir> <source image> <target image> <user-data> <meta-data> <qemu-config> <user-data-renderer> | ||
|
|
||
| set -euxo pipefail | ||
|
|
||
| if [[ $# -ne 7 ]]; then | ||
| echo "Error: Expected 7 arguments (working directory, source image, target image, cloud-init user-data, cloud-init meta-data, qemu config, user-data renderer)" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| WORKING_DIR="$1" | ||
| IMAGE_SOURCE="$2" | ||
| IMAGE_TARGET="$3" | ||
| USER_DATA="$4" | ||
| META_DATA="$5" | ||
| QEMU_CONFIG="$6" | ||
| USER_DATA_RENDERER="$7" | ||
|
|
||
| # Size of the resulting disk. The stock cloud image ships a small virtual disk; | ||
| # growing it leaves room for artifacts uploaded by tests. | ||
| IMAGE_SIZE="8G" | ||
| # Upper bound for the customization boot. Generous because the build machine may | ||
| # not provide KVM, in which case QEMU falls back to TCG emulation. | ||
| BOOT_TIMEOUT_SECONDS=1200 | ||
|
|
||
| for tool in qemu-system-x86_64 qemu-img cloud-localds python3; do | ||
| if ! command -v "${tool}" &>/dev/null; then | ||
| echo "Error: ${tool} is not installed. Please install it to proceed." >&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| if [[ ! -f "${IMAGE_SOURCE}" ]]; then | ||
| echo "Error: Image source is not a file: ${IMAGE_SOURCE}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| for f in "${USER_DATA}" "${META_DATA}"; do | ||
| if [[ ! -f "${f}" ]]; then | ||
| echo "Error: cloud-init file does not exist: ${f}" >&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| if [[ ! -f "${QEMU_CONFIG}" ]]; then | ||
| echo "Error: QEMU config does not exist: ${QEMU_CONFIG}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! -f "${USER_DATA_RENDERER}" ]]; then | ||
| echo "Error: user-data renderer does not exist: ${USER_DATA_RENDERER}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| mkdir -p "$(dirname "${IMAGE_TARGET}")" | ||
| rm -f "${IMAGE_TARGET}" | ||
| cp -L "${IMAGE_SOURCE}" "${IMAGE_TARGET}" | ||
|
|
||
| # The image file must be writable, both for the customization boot below and for | ||
| # the qemu overlay handling in the ITF QEMU plugin. | ||
| chmod +w "${IMAGE_TARGET}" | ||
| qemu-img resize "${IMAGE_TARGET}" "${IMAGE_SIZE}" | ||
|
|
||
| SEED_IMAGE="${WORKING_DIR}/score-itf-seed.img" | ||
| USER_DATA_RENDERED="${WORKING_DIR}/score-itf-user-data.yaml" | ||
| rm -f "${SEED_IMAGE}" | ||
|
|
||
| # Keep cloud-init network settings in sync with runtime QEMU settings. | ||
| python3 "${USER_DATA_RENDERER}" "${QEMU_CONFIG}" "${USER_DATA}" "${USER_DATA_RENDERED}" | ||
|
|
||
| cloud-localds "${SEED_IMAGE}" "${USER_DATA_RENDERED}" "${META_DATA}" | ||
|
|
||
| QEMU_LOG="${WORKING_DIR}/qemu_customization.log" | ||
|
|
||
| # -no-reboot makes QEMU exit instead of restarting, should cloud-init decide to | ||
| # reboot rather than power off. | ||
| timeout "${BOOT_TIMEOUT_SECONDS}" qemu-system-x86_64 \ | ||
| -accel kvm -accel tcg \ | ||
| -machine pc \ | ||
| -cpu Cascadelake-Server-v5 \ | ||
| -smp 2 \ | ||
| -m 2048 \ | ||
| -no-reboot \ | ||
| -device virtio-blk-pci,drive=vd0 -drive if=none,format=qcow2,file="${IMAGE_TARGET}",id=vd0 \ | ||
| -device virtio-blk-pci,drive=vd1 -drive if=none,format=raw,file="${SEED_IMAGE}",id=vd1,readonly=on \ | ||
| -netdev user,id=net0 \ | ||
| -device virtio-net-pci,netdev=net0 \ | ||
| -nographic \ | ||
| -serial mon:stdio </dev/null >"${QEMU_LOG}" 2>&1 | ||
|
|
||
| rm -f "${SEED_IMAGE}" | ||
| rm -f "${USER_DATA_RENDERED}" | ||
|
|
||
| # cloud-init reports failures on stdout but still powers the machine off, so the | ||
| # exit code of QEMU alone is not a sufficient success criterion. | ||
| if ! grep -q "score ITF image customization finished" "${QEMU_LOG}"; then | ||
| echo "Error: cloud-init did not complete the image customization." >&2 | ||
| echo "----- QEMU log -----" >&2 | ||
| cat "${QEMU_LOG}" >&2 | ||
| exit 1 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| instance-id: score-itf-ubuntu-x86-64 | ||
| local-hostname: score-itf |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.