public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/proj/guru:dev commit in: sys-apps/qemu-openrc/files/, sys-apps/qemu-openrc/
@ 2022-05-15 15:53 Aisha Tammy
  0 siblings, 0 replies; only message in thread
From: Aisha Tammy @ 2022-05-15 15:53 UTC (permalink / raw
  To: gentoo-commits

commit:     5c1c154ef90eb1815542cbcbc38f05f54a8d5820
Author:     Aisha Tammy <gentoo <AT> aisha <DOT> cc>
AuthorDate: Sun May 15 15:52:52 2022 +0000
Commit:     Aisha Tammy <gentoo <AT> aisha <DOT> cc>
CommitDate: Sun May 15 15:53:02 2022 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=5c1c154e

sys-apps/qemu-openrc: initial import

Signed-off-by: Aisha Tammy <gentoo <AT> aisha.cc>

 sys-apps/qemu-openrc/Manifest                      |  1 +
 .../files/qemu-openrc-0.10.0-guest-agent.patch     | 87 ++++++++++++++++++++++
 sys-apps/qemu-openrc/metadata.xml                  |  8 ++
 sys-apps/qemu-openrc/qemu-openrc-0.10.0.ebuild     | 32 ++++++++
 sys-apps/qemu-openrc/qemu-openrc-9999.ebuild       | 32 ++++++++
 5 files changed, 160 insertions(+)

diff --git a/sys-apps/qemu-openrc/Manifest b/sys-apps/qemu-openrc/Manifest
new file mode 100644
index 000000000..e8dc7b35a
--- /dev/null
+++ b/sys-apps/qemu-openrc/Manifest
@@ -0,0 +1 @@
+DIST qemu-openrc-0.10.0.tar.gz 8367 BLAKE2B 34447e04c1a81fa13bddf2f4a742059beea6eeb0025ec32219ef3718a0ff62b98a3d0c39083068f52362eb6fe3eb105338febdd36ea696f144a6b2ce583b3441 SHA512 cdcf51dc59dbca96102c1b73032a726a44cb62c0c93a42adb9b6806609a0fa24bf8dde4814ed5010de63d54fde75f661bb9f5245d85e28de08cdba08d538c959

diff --git a/sys-apps/qemu-openrc/files/qemu-openrc-0.10.0-guest-agent.patch b/sys-apps/qemu-openrc/files/qemu-openrc-0.10.0-guest-agent.patch
new file mode 100644
index 000000000..e030870b4
--- /dev/null
+++ b/sys-apps/qemu-openrc/files/qemu-openrc-0.10.0-guest-agent.patch
@@ -0,0 +1,87 @@
+From 6928925968faf8c8c07e6e955b6864e11f614f77 Mon Sep 17 00:00:00 2001
+From: Aisha Tammy <floss@bsd.ac>
+Date: Mon, 24 Jan 2022 13:50:37 +0000
+Subject: [PATCH] allow shutdown via guest agent socket
+
+This allows shutdown events to be sent
+via qemu guest agent, which works for
+BSD agents which don't handle ACPI events
+correctly.
+
+Tested with OpenBSD 7.0.
+
+Signed-off-by: Aisha Tammy <floss@bsd.ac>
+---
+ qemu.initd | 31 +++++++++++++++++++++++++++----
+ 1 file changed, 27 insertions(+), 4 deletions(-)
+
+diff --git a/qemu.initd b/qemu.initd
+index a80d291..8756080 100644
+--- a/qemu.initd
++++ b/qemu.initd
+@@ -25,6 +25,7 @@ VM_NAME="${RC_SVCNAME#qemu.}"
+ : ${vnc_listen:=0.0.0.0}
+ : ${hugepages_path:=/dev/hugepages}
+ : ${monitor_socket:=/run/qemu/${VM_NAME}/monitor.sock}
++: ${guest_agent_socket:=/run/qemu/${VM_NAME}/ga.sock}
+ : ${extra_args:=}
+ 
+ name="VM $VM_NAME"
+@@ -53,7 +54,9 @@ command_args="
+ 	-vga $vga
+ 	-device virtio-rng-pci
+ 	-device virtio-scsi-pci,id=scsi
+-	-monitor unix:$monitor_socket,server,nowait"
++	-monitor unix:$monitor_socket,server,nowait
++	-chardev socket,path=$guest_agent_socket,server,nowait,id=qga0
++	-device isa-serial,chardev=qga0"
+ command_background='yes'
+ 
+ start_stop_daemon_args="
+@@ -125,10 +128,22 @@ stop() {
+ 
+ 	ebegin "Stopping $name"
+ 
++	if is_running && qemush "${guest_agent_socket}" "{'execute': 'guest-exec', 'arguments': {'path': '/sbin/halt', 'arg': ['-p']}}"; then
++		count="$shutdown_timeout"
++
++		printf "   Waiting $count seconds for VM shutdown via guest agent "
++		while is_running && [ $count -gt 0 ]; do
++			sleep 1
++			printf '.'
++			count=$(( count - 1 ))
++		done
++		printf '\n'
++	fi
++
+ 	if is_running && qemush 'system_powerdown'; then
+ 		count="$shutdown_timeout"
+ 
+-		printf "   Waiting $count seconds for VM shutdown "
++		printf "   Waiting $count seconds for VM shutdown via ACPI"
+ 		while is_running && [ $count -gt 0 ]; do
+ 			sleep 1
+ 			printf '.'
+@@ -281,12 +296,20 @@ check_bridge() {
+ 
+ qemush() {
+ 	local IFS=$'\n'
+-	printf "%b\n" "$*" | socat - "UNIX-CONNECT:${monitor_socket}" 1>/dev/null
++	socket_path="${monitor_socket}"
++	case "$1" in
++		/*) socket_path="$1"; shift;
++	esac
++	printf "%b\n" "$*" | socat - "UNIX-CONNECT:${socket_path}" 1>/dev/null
+ }
+ 
+ qemush_show() {
+ 	local IFS=$'\n'
+-	printf "%b\n" "$*" | socat - "UNIX-CONNECT:${monitor_socket}" | tail -n +3 | head -n -1
++	socket_path="${monitor_socket}"
++	case "$1" in
++		/*) socket_path="$1"; shift;
++	esac
++	printf "%b\n" "$*" | socat - "UNIX-CONNECT:${socket_path}" | tail -n +3 | head -n -1
+ }
+ 
+ gen_macaddr() {

diff --git a/sys-apps/qemu-openrc/metadata.xml b/sys-apps/qemu-openrc/metadata.xml
new file mode 100644
index 000000000..65ac1f205
--- /dev/null
+++ b/sys-apps/qemu-openrc/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<maintainer type="person">
+		<email>gentoo@aisha.cc</email>
+		<name>Aisha Tammy</name>
+	</maintainer>
+</pkgmetadata>

diff --git a/sys-apps/qemu-openrc/qemu-openrc-0.10.0.ebuild b/sys-apps/qemu-openrc/qemu-openrc-0.10.0.ebuild
new file mode 100644
index 000000000..9db2cfd8f
--- /dev/null
+++ b/sys-apps/qemu-openrc/qemu-openrc-0.10.0.ebuild
@@ -0,0 +1,32 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="OpenRC init script for QEMU/KVM"
+HOMEPAGE="https://github.com/jirutka/qemu-openrc"
+
+if [[ ${PV} == 9999 ]]; then
+	inherit git-r3
+	EGIT_REPO_URI="https://github.com/jirutka/qemu-openrc"
+else
+	SRC_URI="https://github.com/jirutka/qemu-openrc/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+	KEYWORDS="~amd64"
+fi
+
+LICENSE="MIT"
+SLOT="0"
+
+RDEPEND="net-misc/socat"
+
+PATCHES=( "${FILESDIR}/qemu-openrc-0.10.0-guest-agent.patch")
+
+src_compile() {
+	:
+}
+
+src_install() {
+	newinitd qemu.initd qemu
+	newconfd qemu.confd qemu
+	dobin qemush
+}

diff --git a/sys-apps/qemu-openrc/qemu-openrc-9999.ebuild b/sys-apps/qemu-openrc/qemu-openrc-9999.ebuild
new file mode 100644
index 000000000..9db2cfd8f
--- /dev/null
+++ b/sys-apps/qemu-openrc/qemu-openrc-9999.ebuild
@@ -0,0 +1,32 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="OpenRC init script for QEMU/KVM"
+HOMEPAGE="https://github.com/jirutka/qemu-openrc"
+
+if [[ ${PV} == 9999 ]]; then
+	inherit git-r3
+	EGIT_REPO_URI="https://github.com/jirutka/qemu-openrc"
+else
+	SRC_URI="https://github.com/jirutka/qemu-openrc/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+	KEYWORDS="~amd64"
+fi
+
+LICENSE="MIT"
+SLOT="0"
+
+RDEPEND="net-misc/socat"
+
+PATCHES=( "${FILESDIR}/qemu-openrc-0.10.0-guest-agent.patch")
+
+src_compile() {
+	:
+}
+
+src_install() {
+	newinitd qemu.initd qemu
+	newconfd qemu.confd qemu
+	dobin qemush
+}


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-15 15:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-15 15:53 [gentoo-commits] repo/proj/guru:dev commit in: sys-apps/qemu-openrc/files/, sys-apps/qemu-openrc/ Aisha Tammy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox