Merge branch 'master' of git.qubes-os.org:/var/lib/qubes/git/marmarek/core

This commit is contained in:
Joanna Rutkowska 2011-04-05 14:41:52 +02:00
commit a7ac3a089c
5 changed files with 13 additions and 22 deletions

View File

@ -8,5 +8,7 @@ if [ $# != 1 ]; then
exit
fi
xdg-desktop-menu uninstall $APPSDIR/*.directory $APPSDIR/*.desktop
if ls $APPSDIR/*.directory $APPSDIR/*.desktop > /dev/null 2>&1; then
xdg-desktop-menu uninstall $APPSDIR/*.directory $APPSDIR/*.desktop
fi

View File

@ -204,6 +204,8 @@ class QubesVm(object):
self.uses_default_netvm = uses_default_netvm
self.netvm_vm = netvm_vm
if netvm_vm is not None:
netvm_vm.connected_vms[qid] = self
# We use it in remove from disk to avoid removing rpm files (for templates)
self.installed_by_rpm = installed_by_rpm
@ -1251,6 +1253,7 @@ class QubesNetVm(QubesVm):
if "vcpus" not in kwargs or kwargs["vcpus"] is None:
kwargs["vcpus"] = default_servicevm_vcpus
super(QubesNetVm, self).__init__(**kwargs)
self.connected_vms = QubesVmCollection()
@property
def type(self):
@ -1392,17 +1395,8 @@ class QubesProxyVm(QubesNetVm):
# Allow dom0 networking
iptables += "-A FORWARD -i vif0.0 -j ACCEPT\n"
qvm_collection = QubesVmCollection()
qvm_collection.lock_db_for_reading()
qvm_collection.load()
qvm_collection.unlock_db()
vms = [vm for vm in qvm_collection.values()]
vms = [vm for vm in self.connected_vms.values()]
for vm in vms:
# Process only VMs connected to this ProxyVM
if not vm.netvm_vm or vm.netvm_vm.qid != self.qid:
continue
if vm.has_firewall():
conf = vm.get_firewall_conf()
else:
@ -1794,7 +1788,7 @@ class QubesVmCollection(dict):
def get_vms_based_on(self, template_qid):
vms = set([vm for vm in self.values()
if (vm.is_appvm() and vm.template_vm.qid == template_qid)])
if (vm.template_vm and vm.template_vm.qid == template_qid)])
return vms
def get_vms_connected_to(self, netvm_qid):
@ -1807,8 +1801,8 @@ class QubesVmCollection(dict):
while len(new_vms) > 0:
cur_vm = new_vms.pop()
for vm in self.values():
if vm.netvm_vm and vm.netvm_vm.qid == cur_vm and vm.qid not in dependend_vms_qid:
for vm in cur_vm.connected_vms.values():
if vm.qid not in dependend_vms_qid:
dependend_vms_qid.append(vm.qid)
if vm.is_netvm():
new_vms.append(vm.qid)
@ -1976,6 +1970,8 @@ class QubesVmCollection(dict):
netvm_vm = self[netvm_qid]
vm.netvm_vm = netvm_vm
if netvm_vm:
netvm_vm.connected_vms[vm.qid] = vm
def load(self):
self.clear()

View File

@ -156,7 +156,6 @@ def main():
except (IOError, OSError) as err:
print "ERROR: {0}".format(err)
vm.remove_from_disk()
exit (1)

View File

@ -54,9 +54,6 @@ def bringup_eth0(netvm):
resolv_conf.close()
return os.system('ifconfig eth0 10.137.0.1 netmask 255.255.255.255 && route add default dev eth0') == 0
def unpause_all(netvm_name):
os.system('qvm-run --exclude=' + netvm_name + ' --all --unpause')
def netup():
netvm = get_netvm()
if os.path.isfile('/var/lock/subsys/NetworkManager'):
@ -68,9 +65,7 @@ def netup():
if os.system(cmd) != 0:
print 'Error creating network device'
sys.exit(1)
os.system('qvm-run --exclude=' + netvm.name + ' --all --pause')
if not bringup_eth0(netvm):
unpause_all(netvm.name)
sys.exit(1)
def netdown():
@ -79,7 +74,6 @@ def netdown():
print 'There is no eth0 that is a Xen vif device, aborting.'
sys.exit(1)
os.system('ifconfig eth0 down')
unpause_all(netvm.name)
def usage():
print 'Usage: qvm-dom0-network-via-netvm [up|down]'

View File

@ -48,7 +48,7 @@ def main():
print "The following AppVMs use '{0}' as a template:".format(vmname)
for vm in dependent_vms:
print "{name:<12} (qid={qid})".format(qid=vm.qid, name=vm.name)
print "Please remove those VMs first, or use the --force option."
print "Please remove those VMs first."
exit (1)
if qvm_collection.default_template_qid == vm.qid:
qvm_collection.default_template_qid = None