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:
parent
e92da0e116
commit
999698bd68
@ -69,7 +69,7 @@ class QubesVm(object):
|
|||||||
# without introducing new ones
|
# without introducing new ones
|
||||||
hooks_clone_disk_files = []
|
hooks_clone_disk_files = []
|
||||||
hooks_create_on_disk = []
|
hooks_create_on_disk = []
|
||||||
hooks_create_xenstore_entries = []
|
hooks_create_qubesdb_entries = []
|
||||||
hooks_get_attrs_config = []
|
hooks_get_attrs_config = []
|
||||||
hooks_get_clone_attrs = []
|
hooks_get_clone_attrs = []
|
||||||
hooks_get_config_params = []
|
hooks_get_config_params = []
|
||||||
@ -440,7 +440,7 @@ class QubesVm(object):
|
|||||||
|
|
||||||
if self.is_running():
|
if self.is_running():
|
||||||
# refresh IP, DNS etc
|
# refresh IP, DNS etc
|
||||||
self.create_xenstore_entries(self.xid)
|
self.create_qubesdb_entries()
|
||||||
self.attach_network()
|
self.attach_network()
|
||||||
if hasattr(self.netvm, 'post_vm_net_attach'):
|
if hasattr(self.netvm, 'post_vm_net_attach'):
|
||||||
self.netvm.post_vm_net_attach(self)
|
self.netvm.post_vm_net_attach(self)
|
||||||
@ -966,7 +966,7 @@ class QubesVm(object):
|
|||||||
# remove dead device
|
# remove dead device
|
||||||
vmm.xs.rm('', '%s/%s' % (dev_basepath, dev))
|
vmm.xs.rm('', '%s/%s' % (dev_basepath, dev))
|
||||||
|
|
||||||
def create_xenstore_entries(self, xid = None):
|
def create_qubesdb_entries(self):
|
||||||
if dry_run:
|
if dry_run:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1005,11 +1005,11 @@ class QubesVm(object):
|
|||||||
# xenstore for it until decided otherwise
|
# xenstore for it until decided otherwise
|
||||||
if qmemman_present:
|
if qmemman_present:
|
||||||
vmm.xs.set_permissions('', '/local/domain/{0}/memory'.format(self.xid),
|
vmm.xs.set_permissions('', '/local/domain/{0}/memory'.format(self.xid),
|
||||||
[{ 'dom': xid }])
|
[{ 'dom': self.xid }])
|
||||||
|
|
||||||
# fire hooks
|
# fire hooks
|
||||||
for hook in self.hooks_create_xenstore_entries:
|
for hook in self.hooks_create_qubesdb_entries:
|
||||||
hook(self, xid=xid)
|
hook(self)
|
||||||
|
|
||||||
def _format_net_dev(self, ip, mac, backend):
|
def _format_net_dev(self, ip, mac, backend):
|
||||||
template = " <interface type='ethernet'>\n" \
|
template = " <interface type='ethernet'>\n" \
|
||||||
@ -1683,14 +1683,14 @@ class QubesVm(object):
|
|||||||
self.services['qubes-dvm'] = True
|
self.services['qubes-dvm'] = True
|
||||||
if verbose:
|
if verbose:
|
||||||
print >> sys.stderr, "--> Setting Qubes DB info for the VM..."
|
print >> sys.stderr, "--> Setting Qubes DB info for the VM..."
|
||||||
self.create_xenstore_entries(xid)
|
self.create_qubesdb_entries()
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print >> sys.stderr, "--> Updating firewall rules..."
|
print >> sys.stderr, "--> Updating firewall rules..."
|
||||||
netvm = self.netvm
|
netvm = self.netvm
|
||||||
while netvm is not None:
|
while netvm is not None:
|
||||||
if netvm.is_proxyvm() and netvm.is_running():
|
if netvm.is_proxyvm() and netvm.is_running():
|
||||||
netvm.write_iptables_xenstore_entry()
|
netvm.write_iptables_qubesdb_entry()
|
||||||
netvm = netvm.netvm
|
netvm = netvm.netvm
|
||||||
|
|
||||||
# fire hooks
|
# fire hooks
|
||||||
|
@ -67,12 +67,12 @@ class QubesProxyVm(QubesNetVm):
|
|||||||
def post_vm_net_attach(self, vm):
|
def post_vm_net_attach(self, vm):
|
||||||
""" Called after some VM net-attached to this ProxyVm """
|
""" 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):
|
def post_vm_net_detach(self, vm):
|
||||||
""" Called after some VM net-detached from this ProxyVm """
|
""" Called after some VM net-detached from this ProxyVm """
|
||||||
|
|
||||||
self.write_iptables_xenstore_entry()
|
self.write_iptables_qubesdb_entry()
|
||||||
|
|
||||||
def start(self, **kwargs):
|
def start(self, **kwargs):
|
||||||
if dry_run:
|
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())
|
self.netvm.remove_external_ip_permission(kwargs['xid'] if 'xid' in kwargs else self.get_xid())
|
||||||
super(QubesProxyVm, self).force_shutdown(**kwargs)
|
super(QubesProxyVm, self).force_shutdown(**kwargs)
|
||||||
|
|
||||||
def create_xenstore_entries(self, xid = None):
|
def create_qubesdb_entries(self):
|
||||||
if dry_run:
|
if dry_run:
|
||||||
return
|
return
|
||||||
|
|
||||||
if xid is None:
|
super(QubesProxyVm, self).create_qubesdb_entries()
|
||||||
xid = self.xid
|
|
||||||
|
|
||||||
|
|
||||||
super(QubesProxyVm, self).create_xenstore_entries(xid)
|
|
||||||
self.qdb.write("/qubes-iptables-error", '')
|
self.qdb.write("/qubes-iptables-error", '')
|
||||||
self.write_iptables_xenstore_entry()
|
self.write_iptables_qubesdb_entry()
|
||||||
|
|
||||||
def write_netvm_domid_entry(self, xid = -1):
|
def write_netvm_domid_entry(self, xid = -1):
|
||||||
if not self.is_running():
|
if not self.is_running():
|
||||||
@ -115,7 +111,7 @@ class QubesProxyVm(QubesNetVm):
|
|||||||
self.qdb.write("/qubes-netvm-domid",
|
self.qdb.write("/qubes-netvm-domid",
|
||||||
"{0}".format(self.netvm.get_xid()))
|
"{0}".format(self.netvm.get_xid()))
|
||||||
|
|
||||||
def write_iptables_xenstore_entry(self):
|
def write_iptables_qubesdb_entry(self):
|
||||||
self.qdb.rm("/qubes-iptables-domainrules/")
|
self.qdb.rm("/qubes-iptables-domainrules/")
|
||||||
iptables = "# Generated by Qubes Core on {0}\n".format(datetime.now().ctime())
|
iptables = "# Generated by Qubes Core on {0}\n".format(datetime.now().ctime())
|
||||||
iptables += "*filter\n"
|
iptables += "*filter\n"
|
||||||
|
@ -117,9 +117,8 @@ class QubesDisposableVm(QubesVm):
|
|||||||
attrs['privatedev'] = ''
|
attrs['privatedev'] = ''
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
def create_qubesdb_entries(self):
|
||||||
def create_xenstore_entries(self, xid):
|
super(QubesDisposableVm, self).create_qubesdb_entries()
|
||||||
super(QubesDisposableVm, self).create_xenstore_entries(xid)
|
|
||||||
|
|
||||||
self.qdb.write('/qubes-restore-complete', '1')
|
self.qdb.write('/qubes-restore-complete', '1')
|
||||||
|
|
||||||
@ -171,7 +170,7 @@ class QubesDisposableVm(QubesVm):
|
|||||||
self.services['qubes-dvm'] = True
|
self.services['qubes-dvm'] = True
|
||||||
if verbose:
|
if verbose:
|
||||||
print >> sys.stderr, "--> Setting Qubes DB info for the VM..."
|
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()))
|
print >>sys.stderr, "time=%s, done qubesdb" % (str(time.time()))
|
||||||
|
|
||||||
# fire hooks
|
# fire hooks
|
||||||
|
@ -95,7 +95,7 @@ class QfileDaemonDvm:
|
|||||||
print >>sys.stderr, "time=%s, reloading firewall" % (str(time.time()))
|
print >>sys.stderr, "time=%s, reloading firewall" % (str(time.time()))
|
||||||
for vm in qvm_collection.values():
|
for vm in qvm_collection.values():
|
||||||
if vm.is_proxyvm() and vm.is_running():
|
if vm.is_proxyvm() and vm.is_running():
|
||||||
vm.write_iptables_xenstore_entry()
|
vm.write_iptables_qubesdb_entry()
|
||||||
|
|
||||||
return dispvm
|
return dispvm
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ def main():
|
|||||||
if changed or options.reload:
|
if changed or options.reload:
|
||||||
if vm.is_running():
|
if vm.is_running():
|
||||||
if vm.netvm is not None and vm.netvm.is_proxyvm():
|
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()
|
qvm_collection.save()
|
||||||
|
|
||||||
if not options.do_list:
|
if not options.do_list:
|
||||||
|
@ -200,7 +200,7 @@ class VmNetworkingMixin(qubes.tests.SystemTestsMixin):
|
|||||||
'allowDns': False,
|
'allowDns': False,
|
||||||
'allowIcmp': 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
|
# Ugly hack b/c there is no feedback when the rules are actually applied
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.assertEqual(self.run_cmd(self.testvm1, self.ping_ip), 0,
|
self.assertEqual(self.run_cmd(self.testvm1, self.ping_ip), 0,
|
||||||
@ -215,7 +215,7 @@ class VmNetworkingMixin(qubes.tests.SystemTestsMixin):
|
|||||||
'allowDns': True,
|
'allowDns': True,
|
||||||
'allowIcmp': 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
|
# Ugly hack b/c there is no feedback when the rules are actually applied
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.assertEqual(self.run_cmd(self.testvm1, self.ping_name), 0,
|
self.assertEqual(self.run_cmd(self.testvm1, self.ping_name), 0,
|
||||||
@ -234,7 +234,7 @@ class VmNetworkingMixin(qubes.tests.SystemTestsMixin):
|
|||||||
'proto': 'tcp',
|
'proto': 'tcp',
|
||||||
'portBegin': 1234
|
'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
|
# Ugly hack b/c there is no feedback when the rules are actually applied
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.assertEqual(self.run_cmd(self.testvm1, nc_cmd), 0,
|
self.assertEqual(self.run_cmd(self.testvm1, nc_cmd), 0,
|
||||||
@ -252,7 +252,7 @@ class VmNetworkingMixin(qubes.tests.SystemTestsMixin):
|
|||||||
'portBegin': 1234
|
'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
|
# Ugly hack b/c there is no feedback when the rules are actually applied
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.assertNotEqual(self.run_cmd(self.testvm1, nc_cmd), 0,
|
self.assertNotEqual(self.run_cmd(self.testvm1, nc_cmd), 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user