From bb9d8bbf7881ce13023ac905f98511beaeaaeae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 16 Apr 2014 15:08:38 +0200 Subject: [PATCH] Remove qubes-dom0-network-via-netvm tool (#820) If someone really needs it for debuging he/she should be able to either do it manually (xl network-attach...) or at worst case retrieve this tool from git history. --- .../qubes-dom0-network-via-netvm.rst | 24 ---- qvm-tools/qubes-dom0-network-via-netvm | 103 ------------------ 2 files changed, 127 deletions(-) delete mode 100644 doc/qubes-tools/qubes-dom0-network-via-netvm.rst delete mode 100755 qvm-tools/qubes-dom0-network-via-netvm diff --git a/doc/qubes-tools/qubes-dom0-network-via-netvm.rst b/doc/qubes-tools/qubes-dom0-network-via-netvm.rst deleted file mode 100644 index dfa83b44..00000000 --- a/doc/qubes-tools/qubes-dom0-network-via-netvm.rst +++ /dev/null @@ -1,24 +0,0 @@ -============================ -qubes-dom0-network-via-netvm -============================ - -NAME -==== -qubes-dom0-network-via-netvm - enables networking in dom0 - -:Date: 2012-04-13 - -SYNOPSIS -======== -| qubes-dom0-network-via-netvm [up|down] - -OPTIONS -======= ---help - Show this help message - -AUTHORS -======= -| Joanna Rutkowska -| Rafal Wojtczuk -| Marek Marczykowski diff --git a/qvm-tools/qubes-dom0-network-via-netvm b/qvm-tools/qubes-dom0-network-via-netvm deleted file mode 100755 index f32cb940..00000000 --- a/qvm-tools/qubes-dom0-network-via-netvm +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/python2 -# -# The Qubes OS Project, http://www.qubes-os.org -# -# Copyright (C) 2010 Rafal Wojtczuk -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# - -from qubes.qubes import QubesVmCollection -import os.path -import os -import sys - -qvm_collection = None - -def get_netvm(): - global qvm_collection - qvm_collection = QubesVmCollection() - qvm_collection.lock_db_for_reading() - qvm_collection.load() - qvm_collection.unlock_db() - netvm = qvm_collection.get_default_netvm() - while netvm.netvm is not None: - netvm = netvm.netvm - if netvm is None or netvm.name == 'dom0': - print >> sys.stderr, 'There seems to be no dedicated default netvm, aborting.' - sys.exit(1) - return netvm - -def vif_eth0_exists(): - if not os.path.islink('/sys/class/net/eth0'): - return False - if not os.path.isdir('/sys/devices/vif-0/net/eth0'): - print >> sys.stderr, 'There is a dedicated netvm, but device eth0 is present' - print >> sys.stderr, 'and it is not a Xen interface. Refusing to continue.' - sys.exit(1) - return True - -def bringup_eth0(netvm): - resolv_conf = open('/etc/resolv.conf', "w") - resolv_conf.write('nameserver ' + netvm.gateway + '\n') - resolv_conf.write('nameserver ' + netvm.secondary_dns + '\n') - resolv_conf.close() - return os.system('ip link set eth0 up && ip addr add 10.137.0.2/32 dev eth0 && ' + - 'ip route add 10.137.0.1 dev eth0 && ip route add via 10.137.0.1') == 0 - -def netup(): - netvm = get_netvm() - if os.path.isfile('/var/lock/subsys/NetworkManager'): - os.system('/etc/init.d/NetworkManager stop') - if not vif_eth0_exists(): - cmd = 'modprobe xen-netfront' - if os.system(cmd) != 0: - print >> sys.stderr, 'Error creating network device' - sys.exit(1) - qvm_collection[0].attach_network(verbose=True, netvm=netvm, wait=True) - if not bringup_eth0(netvm): - sys.exit(1) - -def netdown(): - netvm = get_netvm() - if not vif_eth0_exists(): - print >> sys.stderr, 'There is no eth0 that is a Xen vif device, aborting.' - sys.exit(1) - resolv_conf = open('/etc/resolv.conf', "w") - resolv_conf.close() - os.system('ip link set eth0 down') - os.system('xl network-detach 0 0') - -def usage(): - print >> sys.stderr, 'Usage: {0} [up|down]'.format(sys.argv[0]) - sys.exit(1) - -def main(): - if len(sys.argv) != 2: - usage() - if os.getuid() != 0: - print >> sys.stderr, 'This script must be run as root' - sys.exit(1) - if sys.argv[1] == 'up': - netup() - sys.exit(0) - if sys.argv[1] == 'down': - netdown() - sys.exit(0) - usage() - -main() -