core: rename create_xenstore_entries, get rid of xid parameter

It have nothing to do with xenstore, so change the name to not mislead.
Also get rid of unused "xid" parameter - we should use XID as little as
possible, because it is not a simple task to keep it current.
This commit is contained in:
Marek Marczykowski-Górecki 2015-03-28 22:36:28 +01:00
parent e92da0e116
commit 999698bd68
6 changed files with 23 additions and 28 deletions

View File

@ -69,7 +69,7 @@ class QubesVm(object):
# without introducing new ones
hooks_clone_disk_files = []
hooks_create_on_disk = []
hooks_create_xenstore_entries = []
hooks_create_qubesdb_entries = []
hooks_get_attrs_config = []
hooks_get_clone_attrs = []
hooks_get_config_params = []
@ -440,7 +440,7 @@ class QubesVm(object):
if self.is_running():
# refresh IP, DNS etc
self.create_xenstore_entries(self.xid)
self.create_qubesdb_entries()
self.attach_network()
if hasattr(self.netvm, 'post_vm_net_attach'):
self.netvm.post_vm_net_attach(self)
@ -966,7 +966,7 @@ class QubesVm(object):
# remove dead device
vmm.xs.rm('', '%s/%s' % (dev_basepath, dev))
def create_xenstore_entries(self, xid = None):
def create_qubesdb_entries(self):
if dry_run:
return
@ -1005,11 +1005,11 @@ class QubesVm(object):
# xenstore for it until decided otherwise
if qmemman_present:
vmm.xs.set_permissions('', '/local/domain/{0}/memory'.format(self.xid),
[{ 'dom': xid }])
[{ 'dom': self.xid }])
# fire hooks
for hook in self.hooks_create_xenstore_entries:
hook(self, xid=xid)
for hook in self.hooks_create_qubesdb_entries:
hook(self)
def _format_net_dev(self, ip, mac, backend):
template = " <interface type='ethernet'>\n" \
@ -1683,14 +1683,14 @@ class QubesVm(object):
self.services['qubes-dvm'] = True
if verbose:
print >> sys.stderr, "--> Setting Qubes DB info for the VM..."
self.create_xenstore_entries(xid)
self.create_qubesdb_entries()
if verbose:
print >> sys.stderr, "--> Updating firewall rules..."
netvm = self.netvm
while netvm is not None:
if netvm.is_proxyvm() and netvm.is_running():
netvm.write_iptables_xenstore_entry()
netvm.write_iptables_qubesdb_entry()
netvm = netvm.netvm
# fire hooks

View File

@ -67,12 +67,12 @@ class QubesProxyVm(QubesNetVm):
def post_vm_net_attach(self, vm):
""" Called after some VM net-attached to this ProxyVm """
self.write_iptables_xenstore_entry()
self.write_iptables_qubesdb_entry()
def post_vm_net_detach(self, vm):
""" Called after some VM net-detached from this ProxyVm """
self.write_iptables_xenstore_entry()
self.write_iptables_qubesdb_entry()
def start(self, **kwargs):
if dry_run:
@ -90,17 +90,13 @@ class QubesProxyVm(QubesNetVm):
self.netvm.remove_external_ip_permission(kwargs['xid'] if 'xid' in kwargs else self.get_xid())
super(QubesProxyVm, self).force_shutdown(**kwargs)
def create_xenstore_entries(self, xid = None):
def create_qubesdb_entries(self):
if dry_run:
return
if xid is None:
xid = self.xid
super(QubesProxyVm, self).create_xenstore_entries(xid)
super(QubesProxyVm, self).create_qubesdb_entries()
self.qdb.write("/qubes-iptables-error", '')
self.write_iptables_xenstore_entry()
self.write_iptables_qubesdb_entry()
def write_netvm_domid_entry(self, xid = -1):
if not self.is_running():
@ -115,7 +111,7 @@ class QubesProxyVm(QubesNetVm):
self.qdb.write("/qubes-netvm-domid",
"{0}".format(self.netvm.get_xid()))
def write_iptables_xenstore_entry(self):
def write_iptables_qubesdb_entry(self):
self.qdb.rm("/qubes-iptables-domainrules/")
iptables = "# Generated by Qubes Core on {0}\n".format(datetime.now().ctime())
iptables += "*filter\n"

View File

@ -117,9 +117,8 @@ class QubesDisposableVm(QubesVm):
attrs['privatedev'] = ''
return attrs
def create_xenstore_entries(self, xid):
super(QubesDisposableVm, self).create_xenstore_entries(xid)
def create_qubesdb_entries(self):
super(QubesDisposableVm, self).create_qubesdb_entries()
self.qdb.write('/qubes-restore-complete', '1')
@ -171,7 +170,7 @@ class QubesDisposableVm(QubesVm):
self.services['qubes-dvm'] = True
if verbose:
print >> sys.stderr, "--> Setting Qubes DB info for the VM..."
self.create_xenstore_entries(self.xid)
self.create_qubesdb_entries()
print >>sys.stderr, "time=%s, done qubesdb" % (str(time.time()))
# fire hooks

View File

@ -95,7 +95,7 @@ class QfileDaemonDvm:
print >>sys.stderr, "time=%s, reloading firewall" % (str(time.time()))
for vm in qvm_collection.values():
if vm.is_proxyvm() and vm.is_running():
vm.write_iptables_xenstore_entry()
vm.write_iptables_qubesdb_entry()
return dispvm

View File

@ -311,7 +311,7 @@ def main():
if changed or options.reload:
if vm.is_running():
if vm.netvm is not None and vm.netvm.is_proxyvm():
vm.netvm.write_iptables_xenstore_entry()
vm.netvm.write_iptables_qubesdb_entry()
qvm_collection.save()
if not options.do_list:

View File

@ -200,7 +200,7 @@ class VmNetworkingMixin(qubes.tests.SystemTestsMixin):
'allowDns': False,
'allowIcmp': True,
})
self.proxy.write_iptables_xenstore_entry()
self.proxy.write_iptables_qubesdb_entry()
# Ugly hack b/c there is no feedback when the rules are actually applied
time.sleep(1)
self.assertEqual(self.run_cmd(self.testvm1, self.ping_ip), 0,
@ -215,7 +215,7 @@ class VmNetworkingMixin(qubes.tests.SystemTestsMixin):
'allowDns': True,
'allowIcmp': True,
})
self.proxy.write_iptables_xenstore_entry()
self.proxy.write_iptables_qubesdb_entry()
# Ugly hack b/c there is no feedback when the rules are actually applied
time.sleep(1)
self.assertEqual(self.run_cmd(self.testvm1, self.ping_name), 0,
@ -234,7 +234,7 @@ class VmNetworkingMixin(qubes.tests.SystemTestsMixin):
'proto': 'tcp',
'portBegin': 1234
}] })
self.proxy.write_iptables_xenstore_entry()
self.proxy.write_iptables_qubesdb_entry()
# Ugly hack b/c there is no feedback when the rules are actually applied
time.sleep(1)
self.assertEqual(self.run_cmd(self.testvm1, nc_cmd), 0,
@ -252,7 +252,7 @@ class VmNetworkingMixin(qubes.tests.SystemTestsMixin):
'portBegin': 1234
}]
})
self.proxy.write_iptables_xenstore_entry()
self.proxy.write_iptables_qubesdb_entry()
# Ugly hack b/c there is no feedback when the rules are actually applied
time.sleep(1)
self.assertNotEqual(self.run_cmd(self.testvm1, nc_cmd), 0,