From 1ecd70fa097b790329e8d5cd378df8d81faf3785 Mon Sep 17 00:00:00 2001 From: Munkyu Im Date: Wed, 7 Oct 2015 19:35:55 +0900 Subject: [PATCH] vhost-net: enable vhost-net kernel module When user uses bridge network on ubuntu, qemu supports vhost-net automatically now. But, vhost kernel driver needs root permission. So, adds modprobe and udev rule for user to access vhost-net. Change-Id: Ib7220fcb49f1bf62bca56413393d15c4b239b4f8 Signed-off-by: Munkyu Im --- .../3.0-emulator-qemu-x86.install.ubuntu-32 | 62 ++++++++++--------- .../3.0-emulator-qemu-x86.install.ubuntu-64 | 62 ++++++++++--------- .../3.0-emulator-qemu-x86.remove.ubuntu-32 | 11 ++-- .../3.0-emulator-qemu-x86.remove.ubuntu-64 | 11 ++-- tizen/src/Makefile | 6 ++ .../supplements/SDK/45-tizen-vhost-net.rules | 1 + tizen/supplements/SDK/tizen-vhost-net | 33 ++++++++++ 7 files changed, 120 insertions(+), 66 deletions(-) create mode 100644 tizen/supplements/SDK/45-tizen-vhost-net.rules create mode 100755 tizen/supplements/SDK/tizen-vhost-net diff --git a/package/3.0-emulator-qemu-x86.install.ubuntu-32 b/package/3.0-emulator-qemu-x86.install.ubuntu-32 index 8710d0a4d9..a398150459 100755 --- a/package/3.0-emulator-qemu-x86.install.ubuntu-32 +++ b/package/3.0-emulator-qemu-x86.install.ubuntu-32 @@ -41,11 +41,15 @@ echo "OS_NAME=$OS_NAME" >> ${TMP_FILE} echo "USER=$USER" >> ${TMP_FILE} echo "cp \"${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/tizen-kvm\" /etc/init.d/" >> ${TMP_FILE} echo "cp \"${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/45-tizen-kvm.rules\" /lib/udev/rules.d/" >> ${TMP_FILE} +echo "cp \"${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/tizen-vhost-net\" /etc/init.d/" >> ${TMP_FILE} +echo "cp \"${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/45-tizen-vhost-net.rules\" /lib/udev/rules.d/" >> ${TMP_FILE} echo "/etc/init.d/tizen-kvm start" >> ${TMP_FILE} +echo "/etc/init.d/tizen-vhost-net start" >> ${TMP_FILE} echo "cp -pR \"${TIZEN_PLATFORM_ETC_PATH}/emulator-ifup.sh\" /etc" >> $TMP_FILE cat << 'EOF' >> $TMP_FILE if [ "ubuntu" = "${OS_NAME}" ] ; then update-rc.d tizen-kvm defaults + update-rc.d tizen-vhost-net defaults fi FILE=/etc/sudoers @@ -59,39 +63,39 @@ count=0 if [[ "$USER" == "" ]] then - echo "user is not set. aborting..." - exit 1 + echo "user is not set. aborting..." + exit 1 fi while read line do - echo $line - count=$((count+1)) - if [[ $line == $LINE1* ]] - then - echo "find original script" - NAMES=`echo $line | cut -d = -f2` - if [[ "$NAMES"x == ""x ]] - then - cp $FILE $BACKFILE - # in case of blank user - eval sed -e "$count"c\"$line $USER\" $FILE > $TMPFILE - exit 0 - fi - for i in $(echo $NAMES | tr "," "\n") - do - if [[ "$i" == "$USER" ]] - then - echo "already added the same user" - exit 0 - fi - done - cp $FILE $BACKFILE - # new user is added with comma behind the original users. - eval sed -e "$count"c\"$line, $USER\" $FILE > $TMPFILE - mv $TMPFILE $FILE - exit 0 - fi + echo $line + count=$((count+1)) + if [[ $line == $LINE1* ]] + then + echo "find original script" + NAMES=`echo $line | cut -d = -f2` + if [[ "$NAMES"x == ""x ]] + then + cp $FILE $BACKFILE + # in case of blank user + eval sed -e "$count"c\"$line $USER\" $FILE > $TMPFILE + exit 0 + fi + for i in $(echo $NAMES | tr "," "\n") + do + if [[ "$i" == "$USER" ]] + then + echo "already added the same user" + exit 0 + fi + done + cp $FILE $BACKFILE + # new user is added with comma behind the original users. + eval sed -e "$count"c\"$line, $USER\" $FILE > $TMPFILE + mv $TMPFILE $FILE + exit 0 + fi done < $FILE cp $FILE $BACKFILE diff --git a/package/3.0-emulator-qemu-x86.install.ubuntu-64 b/package/3.0-emulator-qemu-x86.install.ubuntu-64 index 8710d0a4d9..a398150459 100755 --- a/package/3.0-emulator-qemu-x86.install.ubuntu-64 +++ b/package/3.0-emulator-qemu-x86.install.ubuntu-64 @@ -41,11 +41,15 @@ echo "OS_NAME=$OS_NAME" >> ${TMP_FILE} echo "USER=$USER" >> ${TMP_FILE} echo "cp \"${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/tizen-kvm\" /etc/init.d/" >> ${TMP_FILE} echo "cp \"${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/45-tizen-kvm.rules\" /lib/udev/rules.d/" >> ${TMP_FILE} +echo "cp \"${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/tizen-vhost-net\" /etc/init.d/" >> ${TMP_FILE} +echo "cp \"${TIZEN_SDK_INSTALL_PATH}/platforms/${PLATFORM_VERSION}/common/emulator/etc/45-tizen-vhost-net.rules\" /lib/udev/rules.d/" >> ${TMP_FILE} echo "/etc/init.d/tizen-kvm start" >> ${TMP_FILE} +echo "/etc/init.d/tizen-vhost-net start" >> ${TMP_FILE} echo "cp -pR \"${TIZEN_PLATFORM_ETC_PATH}/emulator-ifup.sh\" /etc" >> $TMP_FILE cat << 'EOF' >> $TMP_FILE if [ "ubuntu" = "${OS_NAME}" ] ; then update-rc.d tizen-kvm defaults + update-rc.d tizen-vhost-net defaults fi FILE=/etc/sudoers @@ -59,39 +63,39 @@ count=0 if [[ "$USER" == "" ]] then - echo "user is not set. aborting..." - exit 1 + echo "user is not set. aborting..." + exit 1 fi while read line do - echo $line - count=$((count+1)) - if [[ $line == $LINE1* ]] - then - echo "find original script" - NAMES=`echo $line | cut -d = -f2` - if [[ "$NAMES"x == ""x ]] - then - cp $FILE $BACKFILE - # in case of blank user - eval sed -e "$count"c\"$line $USER\" $FILE > $TMPFILE - exit 0 - fi - for i in $(echo $NAMES | tr "," "\n") - do - if [[ "$i" == "$USER" ]] - then - echo "already added the same user" - exit 0 - fi - done - cp $FILE $BACKFILE - # new user is added with comma behind the original users. - eval sed -e "$count"c\"$line, $USER\" $FILE > $TMPFILE - mv $TMPFILE $FILE - exit 0 - fi + echo $line + count=$((count+1)) + if [[ $line == $LINE1* ]] + then + echo "find original script" + NAMES=`echo $line | cut -d = -f2` + if [[ "$NAMES"x == ""x ]] + then + cp $FILE $BACKFILE + # in case of blank user + eval sed -e "$count"c\"$line $USER\" $FILE > $TMPFILE + exit 0 + fi + for i in $(echo $NAMES | tr "," "\n") + do + if [[ "$i" == "$USER" ]] + then + echo "already added the same user" + exit 0 + fi + done + cp $FILE $BACKFILE + # new user is added with comma behind the original users. + eval sed -e "$count"c\"$line, $USER\" $FILE > $TMPFILE + mv $TMPFILE $FILE + exit 0 + fi done < $FILE cp $FILE $BACKFILE diff --git a/package/3.0-emulator-qemu-x86.remove.ubuntu-32 b/package/3.0-emulator-qemu-x86.remove.ubuntu-32 index 40699bcc69..5728dc6ca1 100755 --- a/package/3.0-emulator-qemu-x86.remove.ubuntu-32 +++ b/package/3.0-emulator-qemu-x86.remove.ubuntu-32 @@ -10,8 +10,8 @@ fi TIZEN_SDK_INSTALL_PATH=`echo ${INSTALLED_PATH}` if [ -z "${TIZEN_SDK_INSTALL_PATH}" ] then -# echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log - exit 2; +# echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log + exit 2; fi LSB_RELEASE=`which lsb_release` @@ -29,19 +29,22 @@ if [ ! -z "${OS_NAME}" ]; then fi echo "Linux Distribution: ${OS_NAME}" -TMP_FILE=remove_tizen-kvm.sh +TMP_FILE=remove_tizen-init.sh echo "#!/bin/bash -ex" >> ${TMP_FILE} if [ "ubuntu" = "${OS_NAME}" ] ; then echo "update-rc.d -f tizen-kvm remove" >> ${TMP_FILE} + echo "update-rc.d -f tizen-vhost-net remove" >> ${TMP_FILE} fi echo "rm -f /etc/init.d/tizen-kvm" >> ${TMP_FILE} echo "rm -f /lib/udev/rules.d/45-tizen-kvm.rules" >> ${TMP_FILE} +echo "rm -f /etc/init.d/tizen-vhost-net" >> ${TMP_FILE} +echo "rm -f /lib/udev/rules.d/45-tizen-vhost-net.rules" >> ${TMP_FILE} chmod +x ${TMP_FILE} if [ "${TSUDO}" != "" ] # since installer v2.27 then - TSUDO_MSG="Enter your password to remove /etc/init.d/tizen-kvm." + TSUDO_MSG="Enter your password to remove /etc/init.d/tizen-kvm, /etc/init.d/tizen-vhost-net." TMP_PATH="`pwd`/${TMP_FILE}" $TSUDO -m "${TSUDO_MSG}" bash "${TMP_PATH}" else diff --git a/package/3.0-emulator-qemu-x86.remove.ubuntu-64 b/package/3.0-emulator-qemu-x86.remove.ubuntu-64 index 40699bcc69..5728dc6ca1 100755 --- a/package/3.0-emulator-qemu-x86.remove.ubuntu-64 +++ b/package/3.0-emulator-qemu-x86.remove.ubuntu-64 @@ -10,8 +10,8 @@ fi TIZEN_SDK_INSTALL_PATH=`echo ${INSTALLED_PATH}` if [ -z "${TIZEN_SDK_INSTALL_PATH}" ] then -# echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log - exit 2; +# echo "There is no TIZEN_SDK_PATH ENV" >> /tmp/emulator.log + exit 2; fi LSB_RELEASE=`which lsb_release` @@ -29,19 +29,22 @@ if [ ! -z "${OS_NAME}" ]; then fi echo "Linux Distribution: ${OS_NAME}" -TMP_FILE=remove_tizen-kvm.sh +TMP_FILE=remove_tizen-init.sh echo "#!/bin/bash -ex" >> ${TMP_FILE} if [ "ubuntu" = "${OS_NAME}" ] ; then echo "update-rc.d -f tizen-kvm remove" >> ${TMP_FILE} + echo "update-rc.d -f tizen-vhost-net remove" >> ${TMP_FILE} fi echo "rm -f /etc/init.d/tizen-kvm" >> ${TMP_FILE} echo "rm -f /lib/udev/rules.d/45-tizen-kvm.rules" >> ${TMP_FILE} +echo "rm -f /etc/init.d/tizen-vhost-net" >> ${TMP_FILE} +echo "rm -f /lib/udev/rules.d/45-tizen-vhost-net.rules" >> ${TMP_FILE} chmod +x ${TMP_FILE} if [ "${TSUDO}" != "" ] # since installer v2.27 then - TSUDO_MSG="Enter your password to remove /etc/init.d/tizen-kvm." + TSUDO_MSG="Enter your password to remove /etc/init.d/tizen-kvm, /etc/init.d/tizen-vhost-net." TMP_PATH="`pwd`/${TMP_FILE}" $TSUDO -m "${TSUDO_MSG}" bash "${TMP_PATH}" else diff --git a/tizen/src/Makefile b/tizen/src/Makefile index dfc9508e5d..34b6dfbea8 100755 --- a/tizen/src/Makefile +++ b/tizen/src/Makefile @@ -89,6 +89,12 @@ ifdef CONFIG_LINUX cp -pP ../supplements/SDK/45-tizen-kvm.rules $(EMUL_DIR)/etc endif +# Enable vhost-net on Linux +ifdef CONFIG_LINUX + cp -pP ../supplements/SDK/tizen-vhost-net $(EMUL_DIR)/etc + cp -pP ../supplements/SDK/45-tizen-vhost-net.rules $(EMUL_DIR)/etc +endif + # Enable USB pass-through on Linux ifeq ($(CONFIG_LINUX)$(CONFIG_TIZENUSB),yy) cp -pP ../supplements/SDK/tizen-usb $(EMUL_DIR)/etc diff --git a/tizen/supplements/SDK/45-tizen-vhost-net.rules b/tizen/supplements/SDK/45-tizen-vhost-net.rules new file mode 100644 index 0000000000..567e201faf --- /dev/null +++ b/tizen/supplements/SDK/45-tizen-vhost-net.rules @@ -0,0 +1 @@ +KERNEL=="vhost-net", MODE="0666" diff --git a/tizen/supplements/SDK/tizen-vhost-net b/tizen/supplements/SDK/tizen-vhost-net new file mode 100755 index 0000000000..baa2407353 --- /dev/null +++ b/tizen/supplements/SDK/tizen-vhost-net @@ -0,0 +1,33 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: tizen-vhost-net +# Required-Start: $local_fs $syslog +# Required-Stop: $local_fs $syslog +# Should-Start: udev +# Should-Stop: udev +# Default-Start: 2 3 4 5 +# Default-Stop: 1 +# Short-Description: modprobe vhost-net module. +# Description: enable vhost-net module to enable virtio device emulation +### END INIT INFO + +do_start () { + modprobe vhost-net +} + +case "$1" in + start) + do_start + ;; + restart|reload|force-reload) + # No-op + ;; + stop) + # No-op + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac -- 2.34.1