qemu: new package qemu-ga 2041/head
authorYousong Zhou <yszhou4tech@gmail.com>
Sat, 28 Nov 2015 03:23:57 +0000 (11:23 +0800)
committerYousong Zhou <yszhou4tech@gmail.com>
Fri, 26 Feb 2016 10:07:53 +0000 (18:07 +0800)
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
utils/qemu/Makefile [new file with mode: 0644]
utils/qemu/files/qemu-ga.init [new file with mode: 0755]
utils/qemu/files/virtio-ports.hotplug [new file with mode: 0755]

diff --git a/utils/qemu/Makefile b/utils/qemu/Makefile
new file mode 100644 (file)
index 0000000..a7806d1
--- /dev/null
@@ -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 <yszhou4tech@gmail.com>
+
+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 (executable)
index 0000000..86c2b7e
--- /dev/null
@@ -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 (executable)
index 0000000..35919a5
--- /dev/null
@@ -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