diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2022-10-21 13:14:51 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-12-01 19:35:11 +0000 |
commit | 39e2c09f4a2ef6aa34f3c830a9eefd6b387dfd2d (patch) | |
tree | 9e159467d80962820745a11ad009c4f06654a4dd /meta/recipes-devtools/qemu | |
parent | d0a6b104965a84f1aab4313a8f5a62df49c75424 (diff) | |
download | poky-39e2c09f4a2ef6aa34f3c830a9eefd6b387dfd2d.tar.gz |
qemu-helper-native: Re-write bridge helper as C program
The bridge helper program is invoked directly from QEMU when it needs to
attach to a network bridge. As such, it is subject to the environment of
QEMU itself. Specifically, if bridging is enabled with direct rendering
acceleration, QEMU is run with an LD_PRELOAD that attempts to preload
several uninative libraries; however /bin/sh doesn't use the uninative
loader which means it can fail to start with an error like:
/bin/sh: symbol lookup error: sysroots-uninative/x86_64-linux/lib/librt.so.1: undefined symbol: __libc_unwind_link_get, version GLIBC_PRIVATE
Converting the helper program to a C program resolves this problem
because it will now use the uninative loader so the preload doesn't
cause errors.
(From OE-Core rev: adabfbd9245553d1fb6abb050856e3da89f7a3d5)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
(cherry picked from commit f698e98f2f09952b34488b8cf9e73e82bd7aea07)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/qemu')
3 files changed, 44 insertions, 28 deletions
diff --git a/meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb b/meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb index aa9e499c77..e297586bbb 100644 --- a/meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb +++ b/meta/recipes-devtools/qemu/qemu-helper-native_1.0.bb | |||
@@ -7,7 +7,7 @@ LIC_FILES_CHKSUM = "file://${WORKDIR}/tunctl.c;endline=4;md5=ff3a09996bc5fff6bc5 | |||
7 | 7 | ||
8 | SRC_URI = "\ | 8 | SRC_URI = "\ |
9 | file://tunctl.c \ | 9 | file://tunctl.c \ |
10 | file://qemu-oe-bridge-helper \ | 10 | file://qemu-oe-bridge-helper.c \ |
11 | " | 11 | " |
12 | 12 | ||
13 | S = "${WORKDIR}" | 13 | S = "${WORKDIR}" |
@@ -16,13 +16,13 @@ inherit native | |||
16 | 16 | ||
17 | do_compile() { | 17 | do_compile() { |
18 | ${CC} ${CFLAGS} ${LDFLAGS} -Wall tunctl.c -o tunctl | 18 | ${CC} ${CFLAGS} ${LDFLAGS} -Wall tunctl.c -o tunctl |
19 | ${CC} ${CFLAGS} ${LDFLAGS} -Wall qemu-oe-bridge-helper.c -o qemu-oe-bridge-helper | ||
19 | } | 20 | } |
20 | 21 | ||
21 | do_install() { | 22 | do_install() { |
22 | install -d ${D}${bindir} | 23 | install -d ${D}${bindir} |
23 | install tunctl ${D}${bindir}/ | 24 | install tunctl ${D}${bindir}/ |
24 | 25 | install qemu-oe-bridge-helper ${D}${bindir}/ | |
25 | install -m 755 ${WORKDIR}/qemu-oe-bridge-helper ${D}${bindir}/ | ||
26 | } | 26 | } |
27 | 27 | ||
28 | DEPENDS += "qemu-system-native" | 28 | DEPENDS += "qemu-system-native" |
diff --git a/meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper b/meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper deleted file mode 100755 index f057d4eef0..0000000000 --- a/meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | #! /bin/sh | ||
2 | # Copyright 2020 Garmin Ltd. or its subsidiaries | ||
3 | # | ||
4 | # SPDX-License-Identifier: GPL-2.0 | ||
5 | # | ||
6 | # Attempts to find and exec the host qemu-bridge-helper program | ||
7 | |||
8 | # If the QEMU_BRIDGE_HELPER variable is set by the user, exec it. | ||
9 | if [ -n "$QEMU_BRIDGE_HELPER" ]; then | ||
10 | exec "$QEMU_BRIDGE_HELPER" "$@" | ||
11 | fi | ||
12 | |||
13 | # Search common paths for the helper program | ||
14 | BN="qemu-bridge-helper" | ||
15 | PATHS="/usr/libexec/ /usr/lib/qemu/" | ||
16 | |||
17 | for p in $PATHS; do | ||
18 | if [ -e "$p/$BN" ]; then | ||
19 | exec "$p/$BN" "$@" | ||
20 | fi | ||
21 | done | ||
22 | |||
23 | echo "$BN not found!" > /dev/stderr | ||
24 | exit 1 | ||
25 | |||
diff --git a/meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper.c b/meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper.c new file mode 100644 index 0000000000..cadf2a012a --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper.c | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * Copyright 2022 Garmin Ltd. or its subsidiaries | ||
3 | * | ||
4 | * SPDX-License-Identifier: GPL-2.0 | ||
5 | * | ||
6 | * Attempts to find and exec the host qemu-bridge-helper program | ||
7 | */ | ||
8 | |||
9 | #include <stdio.h> | ||
10 | #include <unistd.h> | ||
11 | |||
12 | void try_program(char const* path, char** args) { | ||
13 | if (access(path, X_OK) == 0) { | ||
14 | execv(path, args); | ||
15 | } | ||
16 | } | ||
17 | |||
18 | int main(int argc, char** argv) { | ||
19 | char* var; | ||
20 | |||
21 | /* Copy arguments so that they are a NULL terminated list, skipping argv[0] | ||
22 | * since it is this program name */ | ||
23 | char** args = malloc(argc * sizeof(char*)); | ||
24 | for (int i = 0; i < argc - 1; i++) { | ||
25 | args[i] = argv[i + 1]; | ||
26 | } | ||
27 | args[argc - 1] = NULL; | ||
28 | |||
29 | var = getenv("QEMU_BRIDGE_HELPER"); | ||
30 | if (var && var[0] != '\0') { | ||
31 | execvp(var, args); | ||
32 | return 1; | ||
33 | } | ||
34 | |||
35 | try_program("/usr/libexec/qemu-bridge-helper", args); | ||
36 | try_program("/usr/lib/qemu/qemu-bridge-helper", args); | ||
37 | |||
38 | fprintf(stderr, "No bridge helper found\n"); | ||
39 | return 1; | ||
40 | } | ||
41 | |||