Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conf/local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,5 @@ QB_CPU = "-smp 4"
require packages.conf

require added_packages.conf

PREFERRED_VERSION_qemu = "9.1.0%"
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
SUMMARY = "Qemu helper scripts"
LICENSE = "GPL-2.0-only"
RDEPENDS:${PN} = "nativesdk-qemu nativesdk-unfs3 nativesdk-pseudo \
nativesdk-python3-shell nativesdk-python3-fcntl nativesdk-python3-logging \
"


LIC_FILES_CHKSUM = "file://${COREBASE}/scripts/runqemu;beginline=5;endline=10;md5=ac2b489a58739c7628a2604698db5e7f"


SRC_URI = "file://${COREBASE}/scripts/runqemu \
file://${COREBASE}/scripts/runqemu-addptable2image \
file://${COREBASE}/scripts/runqemu-gen-tapdevs \
file://${COREBASE}/scripts/runqemu-ifup \
file://${COREBASE}/scripts/runqemu-ifdown \
file://${COREBASE}/scripts/oe-find-native-sysroot \
file://${COREBASE}/scripts/runqemu-extract-sdk \
file://${COREBASE}/scripts/runqemu-export-rootfs \
"

S = "${WORKDIR}/sources"
UNPACKDIR = "${S}"

inherit nativesdk

do_compile() {
:
}

do_install() {
install -d ${D}${bindir}
install -m 0755 ${S}${COREBASE}/scripts/oe-* ${D}${bindir}/
install -m 0755 ${S}${COREBASE}/scripts/runqemu* ${D}${bindir}/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SUMMARY = "Helper utilities needed by the runqemu script"
LICENSE = "GPL-2.0-only"
RDEPENDS:${PN} = "qemu-system-native"

LIC_FILES_CHKSUM = "file://${S}/qemu-oe-bridge-helper.c;endline=4;md5=ae00a3bab86f2caaa8462eacda77f4d7"

SRC_URI = "file://qemu-oe-bridge-helper.c"

S = "${WORKDIR}/sources"
UNPACKDIR = "${S}"

inherit native

do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} -Wall qemu-oe-bridge-helper.c -o qemu-oe-bridge-helper
}

do_install() {
install -d ${D}${bindir}
install qemu-oe-bridge-helper ${D}${bindir}/
}

DEPENDS += "qemu-system-native unfs3-native pseudo-native"
addtask addto_recipe_sysroot after do_populate_sysroot before do_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2022 Garmin Ltd. or its subsidiaries
*
* SPDX-License-Identifier: GPL-2.0
*
* Attempts to find and exec the host qemu-bridge-helper program
*/

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

void try_program(char const* path, char** args) {
if (access(path, X_OK) == 0) {
execv(path, args);
}
}

int main(int argc, char** argv) {
char* var;

var = getenv("QEMU_BRIDGE_HELPER");
if (var && var[0] != '\0') {
execvp(var, argv);
return 1;
}

if (argc == 2 && strcmp(argv[1], "--help") == 0) {
fprintf(stderr, "Helper function to find and exec qemu-bridge-helper. Set QEMU_BRIDGE_HELPER to override default search path\n");
return 0;
}

try_program("/usr/libexec/qemu-bridge-helper", argv);
try_program("/usr/lib/qemu/qemu-bridge-helper", argv);

fprintf(stderr, "No bridge helper found\n");
return 1;
}
7 changes: 7 additions & 0 deletions layers/meta-image-tests/recipes-devtools/qemu/qemu-native.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require qemu.inc

inherit_defer native

EXTRA_OEMAKE:append = " LD='${LD}' AR='${AR}' OBJCOPY='${OBJCOPY}' LDFLAGS='${LDFLAGS}'"

LDFLAGS += "-fuse-ld=bfd"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BPN = "qemu"

DEPENDS += "glib-2.0-native zlib-native"

require qemu-native.inc

EXTRA_OECONF:append = " --target-list=${@get_qemu_usermode_target_list(d)} --disable-tools --disable-install-blobs --disable-guest-agent"

PACKAGECONFIG ??= "pie"
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
BPN = "qemu"

require qemu-native.inc

# As some of the files installed by qemu-native and qemu-system-native
# are the same, we depend on qemu-native to get the full installation set
# and avoid file clashes
DEPENDS += "glib-2.0-native zlib-native pixman-native qemu-native"

EXTRA_OECONF:append = " --target-list=${@get_qemu_system_target_list(d)}"

PACKAGECONFIG ??= "fdt alsa kvm pie slirp png \
${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'virglrenderer epoxy', '', d)} \
"

# Handle distros such as CentOS 5 32-bit that do not have kvm support
PACKAGECONFIG:remove = "${@'kvm' if not os.path.exists('/usr/include/linux/kvm.h') else ''}"

do_install:append() {
install -Dm 0755 ${UNPACKDIR}/powerpc_rom.bin ${D}${datadir}/qemu

# The following is also installed by qemu-native
rm -f ${D}${datadir}/qemu/trace-events-all
rm -rf ${D}${datadir}/qemu/keymaps
rm -rf ${D}${datadir}/icons/
rm -rf ${D}${includedir}/qemu-plugin.h

# Install qmp.py to be used with testimage
install -d ${D}${libdir}/qemu-python/qmp/
install -D ${S}/python/qemu/qmp/* ${D}${libdir}/qemu-python/qmp/
}
28 changes: 28 additions & 0 deletions layers/meta-image-tests/recipes-devtools/qemu/qemu-targets.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# possible arch values are:
# aarch64 arm armeb alpha cris i386 x86_64 m68k microblaze
# mips mipsel mips64 mips64el ppc ppc64 ppc64abi32 ppcemb
# riscv32 riscv64 sparc sparc32 sparc32plus

def get_qemu_target_list(d):
import bb
archs = d.getVar('QEMU_TARGETS').split()
tos = d.getVar('HOST_OS')
softmmuonly = ""
for arch in ['ppcemb', 'lm32']:
if arch in archs:
softmmuonly += arch + "-softmmu,"
archs.remove(arch)
linuxuseronly = ""
for arch in ['armeb', 'alpha', 'ppc64abi32', 'ppc64le', 'sparc32plus', 'aarch64_be']:
if arch in archs:
linuxuseronly += arch + "-linux-user,"
archs.remove(arch)
if 'linux' not in tos:
return softmmuonly + ''.join([arch + "-softmmu" + "," for arch in archs]).rstrip(',')
return softmmuonly + linuxuseronly + ''.join([arch + "-linux-user" + "," + arch + "-softmmu" + "," for arch in archs]).rstrip(',')

def get_qemu_usermode_target_list(d):
return ",".join(filter(lambda i: "-linux-user" in i, get_qemu_target_list(d).split(',')))

def get_qemu_system_target_list(d):
return ",".join(filter(lambda i: "-linux-user" not in i, get_qemu_target_list(d).split(',')))
Loading
Loading