From 999698bd6862b51f01caa181d12619bb2272b54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 28 Mar 2015 22:36:28 +0100 Subject: [PATCH] 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. --- core-modules/000QubesVm.py | 16 ++++++++-------- core-modules/006QubesProxyVm.py | 16 ++++++---------- core-modules/01QubesDisposableVm.py | 7 +++---- dispvm/qfile-daemon-dvm | 2 +- qvm-tools/qvm-firewall | 2 +- tests/network.py | 8 ++++---- 6 files changed, 23 insertions(+), 28 deletions(-) diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index 7024876d..4244f305 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -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 = " \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 diff --git a/core-modules/006QubesProxyVm.py b/core-modules/006QubesProxyVm.py index 2662fb91..88a4781b 100644 --- a/core-modules/006QubesProxyVm.py +++ b/core-modules/006QubesProxyVm.py @@ -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" diff --git a/core-modules/01QubesDisposableVm.py b/core-modules/01QubesDisposableVm.py index 9f1d989d..007a69f2 100644 --- a/core-modules/01QubesDisposableVm.py +++ b/core-modules/01QubesDisposableVm.py @@ -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 diff --git a/dispvm/qfile-daemon-dvm b/dispvm/qfile-daemon-dvm index e04dddbe..d8bba4b3 100755 --- a/dispvm/qfile-daemon-dvm +++ b/dispvm/qfile-daemon-dvm @@ -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 diff --git a/qvm-tools/qvm-firewall b/qvm-tools/qvm-firewall index 7ccebafb..6a959eed 100755 --- a/qvm-tools/qvm-firewall +++ b/qvm-tools/qvm-firewall @@ -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: diff --git a/tests/network.py b/tests/network.py index 83b53081..ae835d47 100644 --- a/tests/network.py +++ b/tests/network.py @@ -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,