summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément Péron <peron.clem@gmail.com>2023-03-10 19:54:22 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-03-14 17:10:00 +0000
commit1c01cbaed575a6bfc97b32af1b55c3707fdaf473 (patch)
tree73fd64a8a38069525d545144959f5b0e52c6673f
parent7c2b42695d95e5916a13bbdeb26cb396e91a5b89 (diff)
downloadpoky-1c01cbaed575a6bfc97b32af1b55c3707fdaf473.tar.gz
qemu: split out qemu-guest-agent, add startup scripts
Split out the QEMU guest agent into a separate package. The agent is intended to be installed within a QEMU VM guest where a user is likely to not want to have the rest of the QEMU installation within it. Additionally, an initscript, udev rules file, and systemd unit file are added to the package so that the guest agent can start automatically; the former two come from Debian's packaging for qemu-guest-agent. (From OE-Core rev: d62fd31c70a9161596594f43c58c73898bfcf52c) Signed-off-by: Brenda Streiff <brenda.streiff@ni.com> Signed-off-by: Clément Péron <peron.clem@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/qemu/qemu.inc35
-rw-r--r--meta/recipes-devtools/qemu/qemu/qemu-guest-agent.init75
-rw-r--r--meta/recipes-devtools/qemu/qemu/qemu-guest-agent.udev2
3 files changed, 111 insertions, 1 deletions
diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc
index 1e768b560d..b41055fe5d 100644
--- a/meta/recipes-devtools/qemu/qemu.inc
+++ b/meta/recipes-devtools/qemu/qemu.inc
@@ -9,7 +9,7 @@ LICENSE = "GPL-2.0-only & LGPL-2.1-only"
9RDEPENDS:${PN}-ptest = "bash" 9RDEPENDS:${PN}-ptest = "bash"
10 10
11require qemu-targets.inc 11require qemu-targets.inc
12inherit pkgconfig ptest 12inherit pkgconfig ptest update-rc.d systemd
13 13
14LIC_FILES_CHKSUM = "file://COPYING;md5=441c28d2cf86e15a37fa47e15a72fbac \ 14LIC_FILES_CHKSUM = "file://COPYING;md5=441c28d2cf86e15a37fa47e15a72fbac \
15 file://COPYING.LIB;endline=24;md5=8c5efda6cf1e1b03dcfd0e6c0d271c7f" 15 file://COPYING.LIB;endline=24;md5=8c5efda6cf1e1b03dcfd0e6c0d271c7f"
@@ -32,6 +32,8 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
32 file://0001-configure-Fix-check-tcg-not-executing-any-tests.patch \ 32 file://0001-configure-Fix-check-tcg-not-executing-any-tests.patch \
33 file://0001-Revert-linux-user-add-more-compat-ioctl-definitions.patch \ 33 file://0001-Revert-linux-user-add-more-compat-ioctl-definitions.patch \
34 file://0002-Revert-linux-user-fix-compat-with-glibc-2.36-sys-mou.patch \ 34 file://0002-Revert-linux-user-fix-compat-with-glibc-2.36-sys-mou.patch \
35 file://qemu-guest-agent.init \
36 file://qemu-guest-agent.udev \
35 " 37 "
36UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" 38UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
37 39
@@ -132,6 +134,20 @@ do_configure[cleandirs] += "${B}"
132do_install () { 134do_install () {
133 export STRIP="" 135 export STRIP=""
134 oe_runmake 'DESTDIR=${D}' install 136 oe_runmake 'DESTDIR=${D}' install
137
138 # If we built the guest agent, also install startup/udev rules
139 if [ -e "${D}${bindir}/qemu-ga" ]; then
140 install -d ${D}${sysconfdir}/init.d/
141 install -m 0755 ${WORKDIR}/qemu-guest-agent.init ${D}${sysconfdir}/init.d/qemu-guest-agent
142 sed -i 's:@bindir@:${bindir}:' ${D}${sysconfdir}/init.d/qemu-guest-agent
143
144 install -d ${D}${sysconfdir}/udev/rules.d/
145 install -m 0644 ${WORKDIR}/qemu-guest-agent.udev ${D}${sysconfdir}/udev/rules.d/60-qemu-guest-agent.rules
146
147 install -d ${D}${systemd_unitdir}/system/
148 install -m 0644 ${S}/contrib/systemd/qemu-guest-agent.service ${D}${systemd_unitdir}/system
149 sed -i -e 's,-/usr/bin/,-${bindir}/,g' ${D}${systemd_unitdir}/system/qemu-guest-agent.service
150 fi
135} 151}
136 152
137# The following fragment will create a wrapper for qemu-mips user emulation 153# The following fragment will create a wrapper for qemu-mips user emulation
@@ -210,3 +226,20 @@ PACKAGECONFIG[jack] = "--enable-jack,--disable-jack,jack,"
210INSANE_SKIP:${PN} = "arch" 226INSANE_SKIP:${PN} = "arch"
211 227
212FILES:${PN} += "${datadir}/icons" 228FILES:${PN} += "${datadir}/icons"
229
230# Put the guest agent in a separate package
231PACKAGES =+ "${PN}-guest-agent"
232SUMMARY:${PN}-guest-agent = "QEMU guest agent"
233FILES:${PN}-guest-agent += " \
234 ${bindir}/qemu-ga \
235 ${sysconfdir}/udev/rules.d/60-qemu-guest-agent.rules \
236 ${sysconfdir}/init.d/qemu-guest-agent \
237 ${systemd_unitdir}/system/qemu-guest-agent.service \
238"
239
240INITSCRIPT_PACKAGES = "${PN}-guest-agent"
241INITSCRIPT_NAME:${PN}-guest-agent = "qemu-guest-agent"
242INITSCRIPT_PARAMS:${PN}-guest-agent = "defaults"
243
244SYSTEMD_PACKAGES = "${PN}-guest-agent"
245SYSTEMD_SERVICE:${PN}-guest-agent = "qemu-guest-agent.service"
diff --git a/meta/recipes-devtools/qemu/qemu/qemu-guest-agent.init b/meta/recipes-devtools/qemu/qemu/qemu-guest-agent.init
new file mode 100644
index 0000000000..5ebaaddeae
--- /dev/null
+++ b/meta/recipes-devtools/qemu/qemu/qemu-guest-agent.init
@@ -0,0 +1,75 @@
1# SPDX-License-Identifier: GPL-2.0-only
2# Initially written by: Michael Tokarev <mjt@tls.msk.ru>
3# For QEMU Debian downstream package
4
5set -e
6
7. /etc/init.d/functions
8
9PATH=/sbin:/usr/sbin:/bin:/usr/bin
10DESC="QEMU Guest Agent"
11NAME=qemu-ga
12DAEMON=@bindir@/$NAME
13PIDFILE=/var/run/$NAME.pid
14
15# config
16DAEMON_ARGS=""
17# default transport
18TRANSPORT=virtio-serial:/dev/virtio-ports/org.qemu.guest_agent.0
19NO_START=0
20
21test ! -r /etc/default/qemu-guest-agent || . /etc/default/qemu-guest-agent
22test "$NO_START" = "0" || exit 0
23test -x "$DAEMON" || exit 0
24
25#
26# Function that checks whenever system has necessary environment
27# It also splits $TRANSPORT into $method and $path
28#
29do_check_transport() {
30 method=${TRANSPORT%%:*};
31 path=${TRANSPORT#*:}
32 case "$method" in
33 virtio-serial | isa-serial)
34 if [ ! -e "$path" ]; then
35 echo "$NAME: transport endpoint not found, not starting"
36 return 1
37 fi
38 ;;
39 esac
40}
41
42case "$1" in
43 start)
44 do_check_transport || exit 0
45 echo -n "Starting $DESC: "
46 start-stop-daemon -S -p $PIDFILE -x "$DAEMON" -- \
47 $DAEMON_ARGS -d -m "$method" -p "$path"
48 echo "$NAME."
49 ;;
50 stop)
51 echo -n "Stopping $DESC: "
52 start-stop-daemon -K -x "$DAEMON" -p $PIDFILE
53 echo "$NAME."
54 ;;
55 status)
56 status "$DAEMON"
57 exit $?
58 ;;
59 restart|force-reload)
60 do_check_transport || exit 0
61 echo -n "Restarting $DESC: "
62 start-stop-daemon -K -x "$DAEMON" -p $PIDFILE
63 sleep 1
64 start-stop-daemon -S -p $PIDFILE -x "$DAEMON" -- \
65 $DAEMON_ARGS -d -m "$method" -p "$path"
66 echo "$NAME."
67 ;;
68 *)
69 N=/etc/init.d/$NAME
70 echo "Usage: $N {start|stop|status|restart|force-reload}" >&2
71 exit 1
72 ;;
73esac
74
75exit 0
diff --git a/meta/recipes-devtools/qemu/qemu/qemu-guest-agent.udev b/meta/recipes-devtools/qemu/qemu/qemu-guest-agent.udev
new file mode 100644
index 0000000000..47097057e3
--- /dev/null
+++ b/meta/recipes-devtools/qemu/qemu/qemu-guest-agent.udev
@@ -0,0 +1,2 @@
1SUBSYSTEM=="virtio-ports", ATTR{name}=="org.qemu.guest_agent.0", \
2 TAG+="systemd", ENV{SYSTEMD_WANTS}="qemu-guest-agent.service"