diff --git a/99-qemu-guest-agent.rules b/99-qemu-guest-agent.rules new file mode 100644 index 0000000..8a290ab --- /dev/null +++ b/99-qemu-guest-agent.rules @@ -0,0 +1,2 @@ +SUBSYSTEM=="virtio-ports", ATTR{name}=="org.qemu.guest_agent.0", \ + TAG+="systemd" ENV{SYSTEMD_WANTS}="qemu-guest-agent.service" diff --git a/qemu-ga-sysconfig b/qemu-ga-sysconfig new file mode 100644 index 0000000..f54018e --- /dev/null +++ b/qemu-ga-sysconfig @@ -0,0 +1,19 @@ +# This is a systemd environment file, not a shell script. +# It provides settings for "/lib/systemd/system/qemu-guest-agent.service". + +# Comma-separated blacklist of RPCs to disable, or empty list to enable all. +# +# You can get the list of RPC commands using "qemu-ga --blacklist='?'". +# There should be no spaces between commas and commands in the blacklist. +BLACKLIST_RPC=guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush + +# Fsfreeze hook script specification. +# +# FSFREEZE_HOOK_PATHNAME=/dev/null : disables the feature. +# +# FSFREEZE_HOOK_PATHNAME=/path/to/executable : enables the feature with the +# specified binary or shell script. +# +# FSFREEZE_HOOK_PATHNAME= : enables the feature with the +# default value (invoke "qemu-ga --help" to interrogate). +FSFREEZE_HOOK_PATHNAME=/etc/qemu-ga/fsfreeze-hook diff --git a/qemu-guest-agent.service b/qemu-guest-agent.service new file mode 100644 index 0000000..44b11cd --- /dev/null +++ b/qemu-guest-agent.service @@ -0,0 +1,18 @@ +[Unit] +Description=QEMU Guest Agent +BindsTo=dev-virtio\x2dports-org.qemu.guest_agent.0.device +After=dev-virtio\x2dports-org.qemu.guest_agent.0.device + +[Service] +UMask=0077 +EnvironmentFile=/etc/sysconfig/qemu-ga +ExecStart=/usr/bin/qemu-ga \ + --method=virtio-serial \ + --path=/dev/virtio-ports/org.qemu.guest_agent.0 \ + --blacklist=${BLACKLIST_RPC} \ + -F${FSFREEZE_HOOK_PATHNAME} +StandardError=syslog +Restart=always +RestartSec=0 + +[Install] diff --git a/qemu.service b/qemu.service new file mode 100644 index 0000000..09d2ad5 --- /dev/null +++ b/qemu.service @@ -0,0 +1,11 @@ +[Unit] +Description=QEMU configuration for non-native binary formats + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/lib/systemd/scripts/qemu-binfmt start +ExecStop=/usr/lib/systemd/scripts/qemu-binfmt stop + +[Install] +WantedBy=multi-user.target diff --git a/qemu.spec b/qemu.spec index a1ae83c..e81470e 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,6 +1,6 @@ Name: qemu Version: 2.4.1 -Release: 1mamba +Release: 2mamba Summary: A generic and open source processor emulator Group: Applications/Emulators Vendor: openmamba @@ -9,6 +9,10 @@ Packager: Silvan Calarco URL: http://qemu.org Source: http://wiki.qemu.org/download/qemu-%{version}.tar.bz2 Source1: %{name}-initscript +Source2: qemu-guest-agent.service +Source3: 99-qemu-guest-agent.rules +Source4: qemu-ga-sysconfig +Source5: qemu.service Patch0: %{name}-0.8.1-build.patch Patch1: %{name}-0.8.0-dyngen.patch Patch2: %{name}-0.8.0-gcc4_x86.patch @@ -74,6 +78,7 @@ BuildRequires: libnfs-devel #BuildRequires: gcc34 #% endif Conflicts: kvm +%systemd_requires BuildRoot: %{_tmppath}/%{name}-%{version}-root %description @@ -82,6 +87,14 @@ QEMU has two operating modes: - Full system emulation. In this mode, QEMU emulates a full system (for example a PC or a PowerMac), including a processor and various peripherials. It can be used to launch different Operating Systems without rebooting the PC or to debug system code. - User mode emulation (Linux host only). In this mode, QEMU can launch Linux processes compiled for one CPU on another CPU. +%package guest-agent +Group: Applications/Emullators +Summary: QEMU agent for guest VMs +%systemd_requires + +%description guest-agent +QEMU agent for guest VMs. + %package -n libcacard Group: System/Libraries Summary: QEMU virtual smart card emulator library @@ -168,7 +181,8 @@ make clean %endif --audio-drv-list="alsa pa" \ --enable-spice \ - --enable-usb-redir + --enable-usb-redir \ + --enable-guest-agent %make @@ -177,7 +191,9 @@ make clean %makeinstall install -D -m 755 %{S:1} \ - %{buildroot}%{_initrddir}/%{name} + %{buildroot}%{_prefix}/lib/systemd/scripts/%{name}-binfmt +install -D -m 0644 %{S:5} \ + %{buildroot}%{_unitdir}/qemu.service cd static for f in *; do @@ -186,6 +202,13 @@ install -m644 $f %{buildroot}%{_bindir}/$f.static done cd .. +# guest agent +install -d -m0755 %{buildroot}%{_sysconfdir}/qemu-ga +cp -a scripts/qemu-guest-agent/* %{buildroot}%{_sysconfdir}/qemu-ga/ +install -D -m0644 %{SOURCE2} %{buildroot}%{_unitdir}/qemu-guest-agent.service +install -D -m0644 %{SOURCE3} %{buildroot}%{_udevrulesdir}/99-qemu-guest-agent.rules +install -D -m0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/qemu-ga + %find_lang %{name} %clean @@ -193,28 +216,34 @@ cd .. %post # new install -if [ $1 -eq 1 ]; then - systemctl -q enable %{name} || true - systemctl -q daemon-reload - systemctl start %{name} -fi +%systemd_post qemu.service : %preun # erase -if [ $1 -eq 0 ]; then - systemctl stop %{name} - systemctl -q disable %{name} -fi +%systemd_preun qemu.service : %postun # upgrade -if [ $1 -eq 1 ]; then - systemctl -q daemon-reload - /sbin/chkconfig %{name} - [ $? -eq 0 ] && service %{name} restart -fi +%systemd_postun_with_restart qemu.service +: + +%post guest-agent +%systemd_post qemu-guest-agent.service +: + +%preun guest-agent +%systemd_preun qemu-guest-agent.service +: + +%postun guest-agent +%systemd_postun_with_restart qemu-guest-agent.service +: + +%posttrans +# clean old sysv broken links +find /etc/rc[0-6].d/ -type l -xtype l -exec rm -f {} \; : %post -n libcacard @@ -227,21 +256,32 @@ fi %files -f %{name}.lang %defattr(-,root,root) -#%dir %{_sysconfdir}/qemu -#%config %{_sysconfdir}/qemu/target-x86_64.conf -%{_initrddir}/%{name} %{_bindir}/%{name}* +%exclude %{_bindir}/qemu-ga %{_bindir}/vscclient %exclude %{_bindir}/%{name}*.static %{_bindir}/virtfs-proxy-helper +%{_unitdir}/qemu.service +%{_prefix}/lib/systemd/scripts/%{name}-binfmt %{_libexecdir}/qemu-bridge-helper %{_datadir}/%{name} %{_docdir}/%{name} %{_mandir}/man1/%{name}* -%{_mandir}/man1/virtfs-proxy-helper.1.gz -%{_mandir}/man8/%{name}-nbd.8.gz +%{_mandir}/man1/virtfs-proxy-helper.1* +%{_mandir}/man8/%{name}-nbd.8* %doc COPYING COPYING.LIB +%files guest-agent +%defattr(-,root,root) +%dir %{_sysconfdir}/qemu-ga +%{_sysconfdir}/qemu-ga/fsfreeze-hook +%dir %{_sysconfdir}/qemu-ga/fsfreeze-hook.d +%{_sysconfdir}/qemu-ga/fsfreeze-hook.d/mysql-flush.sh.sample +%{_sysconfdir}/sysconfig/qemu-ga +%{_bindir}/%{name}-ga +%{_unitdir}/qemu-guest-agent.service +%{_udevrulesdir}/99-qemu-guest-agent.rules + #% ifnarch x86_64 %files -n libcacard %defattr(-,root,root) @@ -263,6 +303,10 @@ fi %attr(0755,root,root) %{_bindir}/%{name}*.static %changelog +* Fri Feb 05 2016 Silvan Calarco 2.4.1-2mamba +- added qemu-guest-agent package +- switch initscript to systemd service + * Wed Nov 04 2015 Automatic Build System 2.4.1-1mamba - automatic version update by autodist