Le 08/10/15 19:22, Michael Tokarev a écrit :
14.08.2015 17:15, Laurent Bigonville wrote:
Package: qemu-guest-agent
Version: 1:2.3+dfsg-6a
Severity: wishlist
User: pkg-systemd-maintain...@lists.alioth.debian.org
Usertags: systemd-units
Hi,
Would be nice if you could add a .service file for the guest agent.
Fedora is shipping the two following files (a .service file and an udev
rule) in their packages:
http://pkgs.fedoraproject.org/cgit/qemu.git/tree/99-qemu-guest-agent.rules
http://pkgs.fedoraproject.org/cgit/qemu.git/tree/qemu-guest-agent.service
I guess something similar could be used in debian too.
Yeah, this is actually in the todo file.
But I haven't learned systemd enough to tell what else is needed
to enable these files. Can you tell me please?
The attached patch is installing a systemd .service and a dbus
configuration file and the resulting package is installing fine in a VM
with the needed channel added (the daemon defaults to the virtio channel).
BUT it is not working properly if it's installed outside of a VM or in a
VM without the correct channel. This is because the .service want the
virtio channel to be present and will fail if it's not.
We should be able to tell dh_installinit to not start a service if
systemd is PID1 (see: #804332) or bypass dh_installinit completely and
start try to start the service only if we are not using systemd.
Cheers,
Laurent Bigonville
diff -Nru qemu-2.4+dfsg/debian/control qemu-2.4+dfsg/debian/control
--- qemu-2.4+dfsg/debian/control 2015-10-08 19:30:23.000000000 +0200
+++ qemu-2.4+dfsg/debian/control 2015-11-07 11:53:32.000000000 +0100
@@ -7,6 +7,7 @@
Vagrant Cascadian <vagr...@debian.org>,
Michael Tokarev <m...@tls.msk.ru>
Build-Depends: debhelper (>= 9),
+ dh-systemd (>= 1.5),
# In comments below we also specify (system-specific) arguments
# to qemu's configure script, -- optional features which depend
# on build-dependencies.
diff -Nru qemu-2.4+dfsg/debian/control-in qemu-2.4+dfsg/debian/control-in
--- qemu-2.4+dfsg/debian/control-in 2015-09-22 13:30:41.000000000 +0200
+++ qemu-2.4+dfsg/debian/control-in 2015-11-07 11:53:28.000000000 +0100
@@ -9,6 +9,7 @@
Vagrant Cascadian <vagr...@debian.org>,
Michael Tokarev <m...@tls.msk.ru>
Build-Depends: debhelper (>= 9),
+ dh-systemd (>= 1.5),
# In comments below we also specify (system-specific) arguments
# to qemu's configure script, -- optional features which depend
# on build-dependencies.
diff -Nru qemu-2.4+dfsg/debian/qemu-guest-agent.service qemu-2.4+dfsg/debian/qemu-guest-agent.service
--- qemu-2.4+dfsg/debian/qemu-guest-agent.service 1970-01-01 01:00:00.000000000 +0100
+++ qemu-2.4+dfsg/debian/qemu-guest-agent.service 2015-11-07 12:32:56.000000000 +0100
@@ -0,0 +1,10 @@
+[Unit]
+Description=QEMU Guest Agent
+BindTo=dev-virtio\x2dports-org.qemu.guest_agent.0.device
+After=dev-virtio\x2dports-org.qemu.guest_agent.0.device
+
+[Service]
+EnvironmentFile=-/etc/default/qemu-guest-agent
+ExecStart=/usr/sbin/qemu-ga $DAEMON_ARGS
+Restart=always
+RestartSec=0
diff -Nru qemu-2.4+dfsg/debian/qemu-guest-agent.udev qemu-2.4+dfsg/debian/qemu-guest-agent.udev
--- qemu-2.4+dfsg/debian/qemu-guest-agent.udev 1970-01-01 01:00:00.000000000 +0100
+++ qemu-2.4+dfsg/debian/qemu-guest-agent.udev 2015-11-07 11:55:10.000000000 +0100
@@ -0,0 +1,2 @@
+SUBSYSTEM=="virtio-ports", ATTR{name}=="org.qemu.guest_agent.0", \
+ TAG+="systemd" ENV{SYSTEMD_WANTS}="qemu-guest-agent.service"
diff -Nru qemu-2.4+dfsg/debian/rules qemu-2.4+dfsg/debian/rules
--- qemu-2.4+dfsg/debian/rules 2015-10-08 19:12:32.000000000 +0200
+++ qemu-2.4+dfsg/debian/rules 2015-11-07 11:52:31.000000000 +0100
@@ -273,7 +273,9 @@
install -D debian/qemu-ifup.$(DEB_HOST_ARCH_OS) \
debian/qemu-system-common/etc/qemu-ifup
endif
+ dh_systemd_enable -pqemu-guest-agent
dh_installinit -pqemu-guest-agent
+ dh_systemd_start -pqemu-guest-agent
endif
dh_link ${ai}
dh_strip ${ai}