vhost-net: enable vhost-net kernel module
authorMunkyu Im <munkyu.im@samsung.com>
Wed, 7 Oct 2015 10:35:55 +0000 (19:35 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 18 Nov 2015 10:04:05 +0000 (19:04 +0900)
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 <munkyu.im@samsung.com>
package/3.0-emulator-qemu-x86.install.ubuntu-32
package/3.0-emulator-qemu-x86.install.ubuntu-64
package/3.0-emulator-qemu-x86.remove.ubuntu-32
package/3.0-emulator-qemu-x86.remove.ubuntu-64
tizen/src/Makefile
tizen/supplements/SDK/45-tizen-vhost-net.rules [new file with mode: 0644]
tizen/supplements/SDK/tizen-vhost-net [new file with mode: 0755]

index 8710d0a4d9e5be05cf4c812ec6c2cdcceebac770..a398150459c82fb85f091253932ba828a34abe00 100755 (executable)
@@ -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
index 8710d0a4d9e5be05cf4c812ec6c2cdcceebac770..a398150459c82fb85f091253932ba828a34abe00 100755 (executable)
@@ -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
index 40699bcc694778ec6e2c8139813f0f4052115a91..5728dc6ca131b45d657b3715203bed7cb8053371 100755 (executable)
@@ -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
index 40699bcc694778ec6e2c8139813f0f4052115a91..5728dc6ca131b45d657b3715203bed7cb8053371 100755 (executable)
@@ -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
index dfc9508e5d5866c8f3c0898ce4bd7f58e9b2f3e8..34b6dfbea87e5bb4971b102e6e8080a8c43105b4 100755 (executable)
@@ -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 (file)
index 0000000..567e201
--- /dev/null
@@ -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 (executable)
index 0000000..baa2407
--- /dev/null
@@ -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