Currently, OSv needs root permission for tap networking.
However, if we have a tap interface with proper permission,
we can do tap networking without root permission.
This adds --tap option to specify tap interface.
It enables tap networking without root permission.
Usage:
On root:
adduser user1 kvm # allow user 1 to use kvm
tunctl -u user1 -t user1_tap0 # add tap interface for user1
On user1 (without root/sudo):
./scripts/run.py -n --tap user1_tap0
Signed-off-by: Wonsup Yoon <
pus...@kaist.ac.kr>
---
scripts/run.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/run.py b/scripts/run.py
index 26177d57..034228b1 100755
--- a/scripts/run.py
+++ b/scripts/run.py
@@ -190,7 +190,9 @@ def start_osv_qemu(options):
net_device_options.append('mac=%s' % options.mac)
if options.networking:
- if options.vhost:
+ if options.tap:
+ args += ["-netdev", "tap,id=hn%d,ifname=%s,script=no,downscript=no" % (idx, options.tap)]
+ elif options.vhost:
args += ["-netdev", "tap,id=hn%d,script=%s,vhost=on" % (idx, os.path.join(osv_base, "scripts/qemu-ifup.sh"))]
else:
for bridge_helper_dir in ['/usr/libexec', '/usr/lib/qemu']:
@@ -489,6 +491,8 @@ if __name__ == "__main__":
help="bridge name for tap networking")
parser.add_argument("-v", "--vhost", action="store_true",
help="needs root. tap networking and vhost")
+ parser.add_argument("-t", "--tap", action="store",
+ help="tap interface name")
parser.add_argument("-m", "--memsize", action="store", default="2G",
help="specify memory: ex. 1G, 2G, ...")
parser.add_argument("-c", "--vcpus", action="store", default="4",
--
2.20.1