Skip to content

Commit 416c843

Browse files
committed
add docker for building qemu 5.0.0-rc1 on alpine
* cherry-picked patches from apline apk community/qemu: - 0006-linux-user-signal.c-define-__SIGRTMIN-MAX-for-non-GN.patch - fix-sigevent-and-sigval_t.patch - musl-F_SHLCK-and-F_EXLCK.patch
1 parent 193281e commit 416c843

File tree

12 files changed

+215
-0
lines changed

12 files changed

+215
-0
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git

Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM alpine:3.11.5
2+
3+
RUN apk update
4+
RUN apk upgrade
5+
6+
# required by qemu
7+
RUN apk add\
8+
make\
9+
python3\
10+
gcc\
11+
libc-dev\
12+
pkgconf\
13+
linux-headers\
14+
glib-dev glib-static\
15+
zlib-dev zlib-static
16+
17+
# additional
18+
RUN apk add bash xz
19+
20+
WORKDIR /work
21+
22+
COPY command/base command/base
23+
COPY command/fetch command/fetch
24+
RUN /work/command/fetch
25+
26+
COPY command/extract command/extract
27+
RUN /work/command/extract
28+
29+
COPY patch patch
30+
COPY command/patch command/patch
31+
RUN /work/command/patch
32+
33+
COPY command/configure command/configure
34+
RUN /work/command/configure
35+
36+
COPY command/make command/make
37+
RUN /work/command/make
38+
39+
COPY command/install command/install
40+
RUN /work/command/install
41+
42+
COPY command/package command/package
43+
RUN /work/command/package

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# qemu-static
2+
3+
The purpose of this project is to build a highly compatible QEMU binary package
4+
for linux. The overall strategy is to use Alpine Linux and link statically to
5+
all possible libraries.
6+
7+
## build docker image
8+
```
9+
docker build --tag qemu-static:5.0.0-rc1 .
10+
```
11+
12+
## run container, save ID, copy artifact(s)
13+
```
14+
docker run -it --cidfile=qemu.cid qemu-static:5.0.0-rc1 true
15+
docker cp "$(cat qemu.cid):work/artifact" artifact
16+
```
17+
18+
## review final artifact(s)
19+
```
20+
ls -al artifact/
21+
total 28100
22+
drwxr-xr-x 2 nobody users 4096 Apr 11 07:42 .
23+
drwxr-xr-x 6 nobody users 4096 Apr 11 08:02 ..
24+
-rw-r--r-- 1 nobody users 28762792 Apr 11 07:43 qemu-linux-x86_64-5.0.0-rc1.tar.xz
25+
```

command/base

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
WORK_ROOT=$(pwd)
2+
3+
HOST_OS_RAW=$(uname -s)
4+
HOST_ARCH_RAW=$(uname -m)
5+
6+
HOST_OS=${HOST_OS_RAW,,}
7+
HOST_ARCH=${HOST_ARCH_RAW,,}
8+
9+
QEMU_NAME="qemu"
10+
QEMU_REV="5.0.0-rc1"
11+
QEMU_SRC_BASENAME="${QEMU_NAME}-${QEMU_REV}"
12+
QEMU_SRC_URL="https://download.qemu.org/${QEMU_SRC_BASENAME}.tar.xz"
13+
QEMU_SRC_PREFIX="${QEMU_REV}"
14+
QEMU_ARTIFACT_BASENAME="${QEMU_NAME}-${HOST_OS}-${HOST_ARCH}-${QEMU_REV}"
15+
16+
WORKDIR() {
17+
mkdir -p $1
18+
cd $1
19+
echo "workdir: $(pwd)"
20+
}
21+
22+
RUN() {
23+
echo "run: $@"
24+
"$@"
25+
}

command/configure

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
. $(dirname $0)/base
6+
7+
WORKDIR "/work/out/${QEMU_SRC_BASENAME}"
8+
RUN "/work/src/${QEMU_SRC_BASENAME}/configure" \
9+
--prefix="/work/dst/${QEMU_ARTIFACT_BASENAME}" \
10+
--disable-debug-info \
11+
--disable-system \
12+
--disable-werror \
13+
--enable-linux-user \
14+
--static

command/extract

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
. $(dirname $0)/base
6+
7+
WORKDIR /work/src
8+
RUN tar xf "$(basename ${QEMU_SRC_URL})"

command/fetch

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
. $(dirname $0)/base
6+
7+
WORKDIR /work/src
8+
RUN wget "${QEMU_SRC_URL}"

command/install

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
. $(dirname $0)/base
6+
7+
WORKDIR "/work/out/${QEMU_SRC_BASENAME}"
8+
RUN make -j$(nproc) install

command/make

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
. $(dirname $0)/base
6+
7+
WORKDIR "/work/out/${QEMU_SRC_BASENAME}"
8+
RUN make -j$(nproc)

command/package

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
. $(dirname $0)/base
6+
7+
8+
WORKDIR /work/artifact
9+
RUN tar cJf "${QEMU_ARTIFACT_BASENAME}.tar.xz" -C /work/dst "${QEMU_ARTIFACT_BASENAME}"

command/patch

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
. $(dirname $0)/base
6+
7+
WORKDIR "/work/src/${QEMU_SRC_BASENAME}"
8+
RUN patch -p1 -i "${WORK_ROOT}/patch/${QEMU_NAME}.diff"

patch/qemu.diff

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
diff --git a/linux-user/signal.c b/linux-user/signal.c
2+
index 8cf51ffe..a006f7b0 100644
3+
--- a/linux-user/signal.c
4+
+++ b/linux-user/signal.c
5+
@@ -25,6 +25,13 @@
6+
#include "trace.h"
7+
#include "signal-common.h"
8+
9+
+#ifndef __SIGRTMIN
10+
+#define __SIGRTMIN 32
11+
+#endif
12+
+#ifndef __SIGRTMAX
13+
+#define __SIGRTMAX (NSIG-1)
14+
+#endif
15+
+
16+
static struct target_sigaction sigact_table[TARGET_NSIG];
17+
18+
static void host_signal_handler(int host_signum, siginfo_t *info,
19+
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
20+
index 6495ddc4..debb6f33 100644
21+
--- a/linux-user/syscall.c
22+
+++ b/linux-user/syscall.c
23+
@@ -123,6 +123,13 @@
24+
#include "fd-trans.h"
25+
#include "tcg/tcg.h"
26+
27+
+#ifndef F_SHLCK
28+
+#define F_SHLCK 8
29+
+#endif
30+
+#ifndef F_EXLCK
31+
+#define F_EXLCK 4
32+
+#endif
33+
+
34+
#ifndef CLONE_IO
35+
#define CLONE_IO 0x80000000 /* Clone io context */
36+
#endif
37+
@@ -6771,9 +6778,20 @@ static inline abi_long host_to_target_timex(abi_long target_addr,
38+
}
39+
#endif
40+
41+
-static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp,
42+
+struct host_sigevent {
43+
+ union sigval sigev_value;
44+
+ int sigev_signo;
45+
+ int sigev_notify;
46+
+ union {
47+
+ int _pad[64-sizeof(int) * 2 + sizeof(union sigval)];
48+
+ int _tid;
49+
+ } _sigev_un;
50+
+};
51+
+
52+
+static inline abi_long target_to_host_sigevent(struct sigevent *sevp,
53+
abi_ulong target_addr)
54+
{
55+
+ struct host_sigevent *host_sevp = (struct host_sigevent *) sevp;
56+
struct target_sigevent *target_sevp;
57+
58+
if (!lock_user_struct(VERIFY_READ, target_sevp, target_addr, 1)) {

0 commit comments

Comments
 (0)