dom0: Do not use transactions to access xenstore

Unfortunately they aren't reliable... at least for writing ~10 keys at once
from python.
This commit is contained in:
Marek Marczykowski 2011-06-25 22:31:22 +02:00
parent a72902e32d
commit a0b60af3d6

View File

@ -502,9 +502,7 @@ class QubesVm(object):
uuid = self.get_uuid() uuid = self.get_uuid()
xs_trans = xs.transaction_start() start_time = xs.read('', "/vm/%s/start_time" % str(uuid))
start_time = xs.read(xs_trans, "/vm/%s/start_time" % str(uuid))
xs.transaction_end()
return start_time return start_time
@ -585,43 +583,41 @@ class QubesVm(object):
domain_path = xs.get_domain_path(xid) domain_path = xs.get_domain_path(xid)
# Set Xen Store entires with VM networking info: # Set Xen Store entires with VM networking info:
xs_trans = xs.transaction_start()
xs.write(xs_trans, "{0}/qubes_vm_type".format(domain_path), xs.write('', "{0}/qubes_vm_type".format(domain_path),
self.type) self.type)
xs.write(xs_trans, "{0}/qubes_vm_updateable".format(domain_path), xs.write('', "{0}/qubes_vm_updateable".format(domain_path),
str(self.updateable)) str(self.updateable))
if self.is_netvm(): if self.is_netvm():
xs.write(xs_trans, xs.write('',
"{0}/qubes_netvm_gateway".format(domain_path), "{0}/qubes_netvm_gateway".format(domain_path),
self.gateway) self.gateway)
xs.write(xs_trans, xs.write('',
"{0}/qubes_netvm_secondary_dns".format(domain_path), "{0}/qubes_netvm_secondary_dns".format(domain_path),
self.secondary_dns) self.secondary_dns)
xs.write(xs_trans, xs.write('',
"{0}/qubes_netvm_netmask".format(domain_path), "{0}/qubes_netvm_netmask".format(domain_path),
self.netmask) self.netmask)
xs.write(xs_trans, xs.write('',
"{0}/qubes_netvm_network".format(domain_path), "{0}/qubes_netvm_network".format(domain_path),
self.network) self.network)
if self.netvm_vm is not None: if self.netvm_vm is not None:
xs.write(xs_trans, "{0}/qubes_ip".format(domain_path), self.ip) xs.write('', "{0}/qubes_ip".format(domain_path), self.ip)
xs.write(xs_trans, "{0}/qubes_netmask".format(domain_path), xs.write('', "{0}/qubes_netmask".format(domain_path),
self.netvm_vm.netmask) self.netvm_vm.netmask)
xs.write(xs_trans, "{0}/qubes_gateway".format(domain_path), xs.write('', "{0}/qubes_gateway".format(domain_path),
self.netvm_vm.gateway) self.netvm_vm.gateway)
xs.write(xs_trans, xs.write('',
"{0}/qubes_secondary_dns".format(domain_path), "{0}/qubes_secondary_dns".format(domain_path),
self.netvm_vm.secondary_dns) self.netvm_vm.secondary_dns)
# Fix permissions # Fix permissions
xs.set_permissions(xs_trans, '{0}/device'.format(domain_path), xs.set_permissions('', '{0}/device'.format(domain_path),
[{ 'dom': xid }]) [{ 'dom': xid }])
xs.set_permissions(xs_trans, '{0}/memory'.format(domain_path), xs.set_permissions('', '{0}/memory'.format(domain_path),
[{ 'dom': xid }]) [{ 'dom': xid }])
xs.transaction_end(xs_trans)
def get_rootdev(self, source_template=None): def get_rootdev(self, source_template=None):
if self.template_vm: if self.template_vm:
@ -1395,11 +1391,9 @@ class QubesProxyVm(QubesNetVm):
return return
super(QubesProxyVm, self).create_xenstore_entries(xid) super(QubesProxyVm, self).create_xenstore_entries(xid)
xs_trans = xs.start_transaction() xs.write('', "/local/domain/{0}/qubes_iptables_error".format(xid), '')
xs.write(xs_trans, "/local/domain/{0}/qubes_iptables_error".format(xid), '') xs.set_permissions('', "/local/domain/{0}/qubes_iptables_error".format(xid),
xs.set_permissions(xs_trans, "/local/domain/{0}/qubes_iptables_error".format(xid),
[{ 'dom': xid, 'write': True }]) [{ 'dom': xid, 'write': True }])
xs.end_transaction(xs_trans)
self.write_iptables_xenstore_entry() self.write_iptables_xenstore_entry()
def write_netvm_domid_entry(self, xid = -1): def write_netvm_domid_entry(self, xid = -1):