From 3ea82eecb73c5a994c25435b06c28857fd409150 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Sat, 28 Nov 2015 11:23:57 +0800 Subject: [PATCH] qemu: new package qemu-ga Signed-off-by: Yousong Zhou --- utils/qemu/Makefile | 62 +++++++++++++++++++++++++++ utils/qemu/files/qemu-ga.init | 15 +++++++ utils/qemu/files/virtio-ports.hotplug | 19 ++++++++ 3 files changed, 96 insertions(+) create mode 100644 utils/qemu/Makefile create mode 100755 utils/qemu/files/qemu-ga.init create mode 100755 utils/qemu/files/virtio-ports.hotplug diff --git a/utils/qemu/Makefile b/utils/qemu/Makefile new file mode 100644 index 000000000..a7806d1cf --- /dev/null +++ b/utils/qemu/Makefile @@ -0,0 +1,62 @@ +# +# Copyright (C) 2016 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=qemu +PKG_VERSION:=2.4.1 +PKG_RELEASE:=1 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=http://wiki.qemu-project.org/download/ +PKG_SOURCE_MD5SUM:=a895e93ec1dafc34bc64ed676f0d55a6 +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=LICENSE tcg/LICENSE +PKG_MAINTAINER:=Yousong Zhou + +include $(INCLUDE_DIR)/package.mk + +define Package/qemu-ga + SECTION:=utils + CATEGORY:=Utilities + TITLE:=QEMU Guest Agent + URL:=http://www.qemu.org + DEPENDS:=+glib2 +libpthread +libstdcpp +librt +endef + +define Package/qemu-ga/description +This package contains the QEMU Guest Agent daemon +endef + +# QEMU configure script does not recognize these options +CONFIGURE_ARGS:=$(filter-out \ + --target=% \ + --host=% \ + --build=% \ + --program-prefix=% \ + --program-suffix=% \ + --exec-prefix=% \ + --disable-nls \ + , $(CONFIGURE_ARGS)) + +# Building qemu-ga alone does not require zlib +CONFIGURE_ARGS+= \ + --cross-prefix=$(TARGET_CROSS) \ + --host-cc=$(HOSTCC) \ + --target-list='' \ + --disable-zlib-test \ + --enable-guest-agent + +define Package/qemu-ga/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/qemu-ga $(1)/usr/bin + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/qemu-ga.init $(1)/etc/init.d/qemu-ga + $(INSTALL_DIR) $(1)/etc/hotplug.d/virtio-ports + $(INSTALL_BIN) ./files/virtio-ports.hotplug $(1)/etc/hotplug.d/virtio-ports/qemu-ga +endef + +$(eval $(call BuildPackage,qemu-ga)) diff --git a/utils/qemu/files/qemu-ga.init b/utils/qemu/files/qemu-ga.init new file mode 100755 index 000000000..86c2b7ea7 --- /dev/null +++ b/utils/qemu/files/qemu-ga.init @@ -0,0 +1,15 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2016 OpenWrt.org + +START=99 +USE_PROCD=1 + +BIN=/usr/bin/qemu-ga + +start_service() { + procd_open_instance + procd_set_param command $BIN + procd_set_param respawn + procd_set_param stderr 1 + procd_close_instance +} diff --git a/utils/qemu/files/virtio-ports.hotplug b/utils/qemu/files/virtio-ports.hotplug new file mode 100755 index 000000000..35919a500 --- /dev/null +++ b/utils/qemu/files/virtio-ports.hotplug @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright (C) 2016 OpenWrt.org + +[ "$SUBSYSTEM" = "virtio-ports" ] || exit 0 + +syspath="/sys/$DEVPATH" +name="$(cat "$syspath/name" 2>/dev/null)" +[ -n "$name" ] || exit 0 + +case "$ACTION" in + "add") + mkdir -p /dev/virtio-ports + ln -s "/dev/$DEVNAME" "/dev/virtio-ports/$name" + /etc/init.d/qemu-ga start + ;; + "del") + rm -f "/dev/virtio-ports/$name" + ;; +esac