aboutsummaryrefslogtreecommitdiff
path: root/writeups/hackintosh/build-qemu_rhel.md
blob: d30e66445381affb8ebd84e53e53cf0d5b5b2577 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Since we're going to install stuff in `/usr/local`, the subsystems should be set
up accordingly. Check if it's already set up on the system. You probably have to
do both of these if the system is fresh from install.

```sh
# Check ldconfig
sudo ldconfig -v | grep /usr/local
# should yield:
# /usr/local/lib: (from /etc/ld.so.conf.d/...)
# /usr/local/lib64: (from /etc/ld.so.conf.d/...)

# Check pkgconf
echo $PKG_CONFIG_PATH
# should yield:
# .../usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig...
```

If the ldconfig setting is missing:

```sh
sudo su -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/usr-local.conf'
sudo su -c 'echo "/usr/local/lib64" >> /etc/ld.so.conf.d/usr-local.conf'
```

If the pkgconf setting is missing, create the file at
`/etc/profile.d/usr-local.sh`:

```
if [ -z "$PKG_CONFIG_PATH" ]; then
	export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
else
	export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig"
fi
```

Install the dependencies and tools needed to build qemu.

```sh
sudo dnf install\
	git\
	curl\
	make\
	tar\
	bison\
	flex\
	meson\
	gcc-c++\
\
	zlib-devel\
\
	openssl-devel\
\
	ncurses-devel\
	bzip2-devel\
	glib2-devel\
\
	usbredir-devel\
	libusb-devel\
	pixman-devel\
	libgudev-devel\
	spice-protocol\
	opus-devel\
	libjpeg-turbo-devel\
	libepoxy-devel\
\
	edk2-ovmf
```

For when things go wrong (you don't need these unless you're an expert)

```sh
sudo dnf install gdb setroubleshoot-server
```

Add fcontext entries for the custom built qemu. This doc may be outdated and the
fcontext entries for qemu in your distro may have been changed. Check the output
of the following command to see if there's any discrepancy. Basically, what has
to be done is making `/usr/local` variants for each qemu executable entry.

```sh
sudo semanage fcontext -l | egrep '/usr/.*/qemu'
```

For Rocky 9, the entries looked like this. Feel free to use it if you see no
difference.

```sh
sudo semanage fcontext -a -t qemu_exec_t                    '/usr/local/bin/qemu'
sudo semanage fcontext -a -t virt_qemu_ga_exec_t            '/usr/local/bin/qemu-ga'
sudo semanage fcontext -a -t qemu_exec_t                    '/usr/local/bin/qemu-kvm'
sudo semanage fcontext -a -t virtd_exec_t                   '/usr/local/bin/qemu-pr-helper'
sudo semanage fcontext -a -t virtd_exec_t                   '/usr/local/bin/qemu-storage-daemon'
sudo semanage fcontext -a -t qemu_exec_t                    '/usr/local/bin/qemu-system-.*'
sudo semanage fcontext -a -t virt_bridgehelper_exec_t       '/usr/local/libexec/qemu-bridge-helper'
sudo semanage fcontext -a -t virt_qemu_ga_exec_t            '/usr/local/libexec/qemu-ga(/.*)?'
sudo semanage fcontext -a -t virt_qemu_ga_unconfined_exec_t '/usr/local/libexec/qemu-ga/fsfreeze-hook.d(/.*)?'
sudo semanage fcontext -a -t virtd_exec_t                   '/usr/local/libexec/qemu-pr-helper'
sudo semanage fcontext -a -t qemu_exec_t                    '/usr/local/libexec/qemu.*'
```

Get the sources. dmg2img is not on RHEL repos either so it has to be built from
the source as well.

```sh
git clone https://github.com/Lekensteyn/dmg2img
curl -LO https://download.qemu.org/qemu-8.2.2.tar.xz
curl -LO https://www.spice-space.org/download/releases/spice-server/spice-0.15.2.tar.bz2
```

Build and install.

```sh
pushd dmg2img
make && sudo make install
popd

tar xf spice-0.15.2.tar.bz2
pushd spice-0.15.2
./configure
make -j$(nproc) && sudo make install
popd

tar xf qemu-8.2.2.tar.xz
pushd qemu-8.2.2
./configure \
	--target-list=x86_64-softmmu \
	--enable-debug \
	--enable-docs \
	--enable-vnc \
	--enable-spice-protocol \
	--enable-curses \
	--enable-libusb \
	--enable-usb-redir \
	--enable-libudev \
	--enable-slirp \
	--enable-spice \
	--enable-opengl
make -j$(nproc) && make -j$(nproc) test && sudo make install
popd

# qemu-kvm is just a symbolic link to the host arch qemu
# qemu makefile doesn't do it for us
sudo ln -s /bin/qemu-system-x86_64 /bin/qemu-kvm
```