From patchwork Thu Apr 7 20:01:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brenda Streiff X-Patchwork-Id: 6433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BB19C38A2D for ; Thu, 7 Apr 2022 20:36:09 +0000 (UTC) Received: from mx0b-00010702.pphosted.com (mx0b-00010702.pphosted.com [148.163.156.75]) by mx.groups.io with SMTP id smtpd.web11.3422.1649361681784407750 for ; Thu, 07 Apr 2022 13:01:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ni.com header.s=pps11062020 header.b=i7qxyqvp; spf=pass (domain: ni.com, ip: 148.163.156.75, mailfrom: prvs=1096971498=brenda.streiff@ni.com) Received: from pps.filterd (m0098780.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 237Dn0jo003964 for ; Thu, 7 Apr 2022 15:01:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ni.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=PPS11062020; bh=xK67MqCVZNtP7txicgLc6/Iv7Lrs7X61SNB7PkX1GVo=; b=i7qxyqvpLxBpO2rGvWbQx05vZp1lBvsjO4R2enUhK0ZncQtNahHYb2spb1tDLZi/Y5J/ 45P5w63TCDOtWzr0iuXBhE9y5x99DnMGnQmx4CddQQLG6L34xiwFew9bnc0iQ7Oiio1r 0LkTtWseZPdpLZPjCKzgbWhGCQ6TqMKQy3/DkKI0Xh1cLLg0VxjitB89Dj9vaIdyHQMj 5q7J87EO6cfIfCbBcyyUVhaDzMmtlz4+0MpAu9aqf5L7ITJlwmIv/nRfy/skg7cENhTR te6cZZEfKGodHgXtGkDR5fQ0gOfozfaQoeps1QxrfrsGtbizrbOl6sbj9niI/7AVqCOe yw== Received: from ni.com ([130.164.80.24]) by mx0a-00010702.pphosted.com (PPS) with ESMTPS id 3f6m0t4ndv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 07 Apr 2022 15:01:20 -0500 Received: from us-aus-exch2.ni.corp.natinst.com (us-aus-exch2.ni.corp.natinst.com [130.164.68.12]) by us-aus-skprod3.natinst.com (8.16.1.2/8.16.1.2) with ESMTPS id 237K1KLK018154 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 7 Apr 2022 15:01:20 -0500 Received: from us-aus-exch4.ni.corp.natinst.com (130.164.68.14) by us-aus-exch2.ni.corp.natinst.com (130.164.68.12) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Thu, 7 Apr 2022 15:01:19 -0500 Received: from us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) by us-aus-exch4.ni.corp.natinst.com (130.164.68.14) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Thu, 7 Apr 2022 15:01:19 -0500 Received: from starthinker.amer.corp.natinst.com (172.18.68.32) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server id 15.0.1497.28 via Frontend Transport; Thu, 7 Apr 2022 15:01:19 -0500 From: Brenda Streiff To: CC: Brenda Streiff Subject: [PATCH 1/2] qemu: split out qemu-guest-agent, add startup scripts Date: Thu, 7 Apr 2022 15:01:16 -0500 Message-ID: <20220407200117.7576-1-brenda.streiff@ni.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Proofpoint-GUID: jn68RYB2T-kukvd9SbqMOui4koa8pQf3 X-Proofpoint-ORIG-GUID: jn68RYB2T-kukvd9SbqMOui4koa8pQf3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-07_04,2022-04-07_01,2022-02-23_01 X-Proofpoint-Spam-Reason: orgsafe List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 07 Apr 2022 20:36:09 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/164142 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. Signed-off-by: Brenda Streiff --- meta/recipes-devtools/qemu/qemu.inc | 35 +++++++- .../qemu/qemu/qemu-guest-agent.init | 84 +++++++++++++++++++ .../qemu/qemu/qemu-guest-agent.udev | 2 + 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-devtools/qemu/qemu/qemu-guest-agent.init create mode 100644 meta/recipes-devtools/qemu/qemu/qemu-guest-agent.udev diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc index 9f2fa4322e..bd1d1ea010 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" RDEPENDS:${PN}-ptest = "bash" require qemu-targets.inc -inherit pkgconfig ptest python3-dir +inherit pkgconfig ptest python3-dir update-rc.d systemd LIC_FILES_CHKSUM = "file://COPYING;md5=441c28d2cf86e15a37fa47e15a72fbac \ file://COPYING.LIB;endline=24;md5=8c5efda6cf1e1b03dcfd0e6c0d271c7f" @@ -32,6 +32,8 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \ file://0001-Define-MAP_SYNC-and-MAP_SHARED_VALIDATE-on-needed-li.patch \ file://0001-vhost-vsock-detach-the-virqueue-element-in-case-of-e.patch \ file://0002-virtio-net-fix-map-leaking-on-error-during-receive.patch \ + file://qemu-guest-agent.init \ + file://qemu-guest-agent.udev \ " UPSTREAM_CHECK_REGEX = "qemu-(?P\d+(\.\d+)+)\.tar" @@ -127,6 +129,20 @@ do_configure[cleandirs] += "${B}" do_install () { export STRIP="" oe_runmake 'DESTDIR=${D}' install + + # If we built the guest agent, also install startup/udev rules + if [ -e "${D}${bindir}/qemu-ga" ]; then + install -d ${D}${sysconfdir}/init.d/ + install -m 0755 ${WORKDIR}/qemu-guest-agent.init ${D}${sysconfdir}/init.d/qemu-guest-agent + sed -i 's:@bindir@:${bindir}:' ${D}${sysconfdir}/init.d/qemu-guest-agent + + install -d ${D}${sysconfdir}/udev/rules.d/ + install -m 0644 ${WORKDIR}/qemu-guest-agent.udev ${D}${sysconfdir}/udev/rules.d/60-qemu-guest-agent.rules + + install -d ${D}${systemd_unitdir}/system/ + install -m 0644 ${S}/contrib/systemd/qemu-guest-agent.service ${D}${systemd_unitdir}/system + sed -i -e 's,-/usr/bin/,-${bindir}/,g' ${D}${systemd_unitdir}/system/qemu-guest-agent.service + fi } # The following fragment will create a wrapper for qemu-mips user emulation @@ -199,3 +215,20 @@ PACKAGECONFIG[selinux] = "--enable-selinux,--disable-selinux" INSANE_SKIP:${PN} = "arch" FILES:${PN} += "${datadir}/icons" + +# Put the guest agent in a separate package +PACKAGES =+ "${PN}-guest-agent" +SUMMARY:${PN}-guest-agent = "QEMU guest agent" +FILES:${PN}-guest-agent += " \ + ${bindir}/qemu-ga \ + ${sysconfdir}/udev/rules.d/60-qemu-guest-agent.rules \ + ${sysconfdir}/init.d/qemu-guest-agent \ + ${systemd_unitdir}/system/qemu-guest-agent.service \ +" + +INITSCRIPT_PACKAGES = "${PN}-guest-agent" +INITSCRIPT_NAME:${PN}-guest-agent = "qemu-guest-agent" +INITSCRIPT_PARAMS:${PN}-guest-agent = "defaults" + +SYSTEMD_PACKAGES = "${PN}-guest-agent" +SYSTEMD_SERVICE:${PN}-guest-agent = "${PN}-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..493da0ef1a --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/qemu-guest-agent.init @@ -0,0 +1,84 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: qemu-guest-agent +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: QEMU Guest Agent +### END INIT INFO +# +# Do not configure this file. Edit /etc/default/qemu-guest-agent +# + +set -e + +. /etc/init.d/functions + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="QEMU Guest Agent" +NAME=qemu-ga +DAEMON=@bindir@/$NAME +PIDFILE=/var/run/$NAME.pid + +# config +DAEMON_ARGS="" +# default transport +TRANSPORT=virtio-serial:/dev/virtio-ports/org.qemu.guest_agent.0 +NO_START=0 + +test ! -r /etc/default/qemu-guest-agent || . /etc/default/qemu-guest-agent +test "$NO_START" = "0" || exit 0 +test -x "$DAEMON" || exit 0 + +# +# Function that checks whenever system has necessary environment +# It also splits $TRANSPORT into $method and $path +# +do_check_transport() { + method=${TRANSPORT%%:*}; + path=${TRANSPORT#*:} + case "$method" in + virtio-serial | isa-serial) + if [ ! -e "$path" ]; then + echo "$NAME: transport endpoint not found, not starting" + return 1 + fi + ;; + esac +} + +case "$1" in + start) + do_check_transport || exit 0 + echo -n "Starting $DESC: " + start-stop-daemon -S -p $PIDFILE -x "$DAEMON" -- \ + $DAEMON_ARGS -d -m "$method" -p "$path" + echo "$NAME." + ;; + stop) + echo -n "Stopping $DESC: " + start-stop-daemon -K -x "$DAEMON" -p $PIDFILE + echo "$NAME." + ;; + status) + status "$DAEMON" + exit $? + ;; + restart|force-reload) + do_check_transport || exit 0 + echo -n "Restarting $DESC: " + start-stop-daemon -K -x "$DAEMON" -p $PIDFILE + sleep 1 + start-stop-daemon -S -p $PIDFILE -x "$DAEMON" -- \ + $DAEMON_ARGS -d -m "$method" -p "$path" + echo "$NAME." + ;; + *) + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|status|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 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..8a290abbd3 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/qemu-guest-agent.udev @@ -0,0 +1,2 @@ +SUBSYSTEM=="virtio-ports", ATTR{name}=="org.qemu.guest_agent.0", \ + TAG+="systemd" ENV{SYSTEMD_WANTS}="qemu-guest-agent.service"