ia64/xen-unstable
changeset 6837:a8edb2655c5d
Add methods to read/write Vm/Domain store entries.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author | cl349@firebug.cl.cam.ac.uk |
---|---|
date | Wed Sep 14 15:47:48 2005 +0000 (2005-09-14) |
parents | 2277377dfc3a |
children | 481a4ce27c15 |
files | tools/python/xen/xend/XendDomainInfo.py |
line diff
1.1 --- a/tools/python/xen/xend/XendDomainInfo.py Wed Sep 14 15:25:28 2005 +0000 1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Wed Sep 14 15:47:48 2005 +0000 1.3 @@ -149,7 +149,7 @@ class XendDomainInfo: 1.4 path = "/".join(db.getPath().split("/")[0:-2]) 1.5 vm = cls(uuid, path, db) 1.6 vm.setDomid(domid) 1.7 - vm.name = vm.readStore("name") 1.8 + vm.name = vm.readVm("name") 1.9 try: 1.10 db.readDB() 1.11 except: pass 1.12 @@ -262,10 +262,26 @@ class XendDomainInfo: 1.13 self.bootloader = None 1.14 self.device_model_pid = 0 1.15 1.16 - xstransact.Write(self.path, "uuid", self.uuid) 1.17 + self.writeVm("uuid", self.uuid) 1.18 + self.writeDom("vm", self.path) 1.19 + 1.20 + def readVm(self, *args): 1.21 + return xstransact.Read(self.path, *args) 1.22 + 1.23 + def writeVm(self, *args): 1.24 + return xstransact.Write(self.path, *args) 1.25 1.26 - def readStore(self, key): 1.27 - return xstransact.Read(self.path, key) 1.28 + def removeVm(self, *args): 1.29 + return xstransact.Remove(self.path, *args) 1.30 + 1.31 + def readDom(self, *args): 1.32 + return xstransact.Read(self.path, *args) 1.33 + 1.34 + def writeDom(self, *args): 1.35 + return xstransact.Write(self.path, *args) 1.36 + 1.37 + def removeDom(self, *args): 1.38 + return xstransact.Remove(self.path, *args) 1.39 1.40 def setDB(self, db): 1.41 self.db = db 1.42 @@ -288,14 +304,14 @@ class XendDomainInfo: 1.43 @param dom: domain id 1.44 """ 1.45 self.domid = domid 1.46 - xstransact.Write(self.path, "domid", "%i" % self.domid) 1.47 + self.writeDom("domid", "%i" % self.domid) 1.48 1.49 def getDomain(self): 1.50 return self.domid 1.51 1.52 def setName(self, name): 1.53 self.name = name 1.54 - xstransact.Write(self.path, "name", name) 1.55 + self.writeVm("name", name) 1.56 1.57 def getName(self): 1.58 return self.name 1.59 @@ -303,32 +319,32 @@ class XendDomainInfo: 1.60 def setStoreRef(self, ref): 1.61 self.store_mfn = ref 1.62 if ref: 1.63 - xstransact.Write(self.path, "store/ring-ref", "%i" % ref) 1.64 + self.writeDom("store/ring-ref", "%i" % ref) 1.65 else: 1.66 - xstransact.Remove(self.path, "store/ring-ref") 1.67 + self.removeDom("store/ring-ref") 1.68 1.69 def setStoreChannel(self, channel): 1.70 if self.store_channel and self.store_channel != channel: 1.71 self.store_channel.close() 1.72 self.store_channel = channel 1.73 if channel: 1.74 - xstransact.Write(self.path, "store/port", "%i" % channel.port1) 1.75 + self.writeDom("store/port", "%i" % channel.port1) 1.76 else: 1.77 - xstransact.Remove(self.path, "store/port") 1.78 + self.removeDom("store/port") 1.79 1.80 def setConsoleRef(self, ref): 1.81 self.console_mfn = ref 1.82 if ref: 1.83 - xstransact.Write(self.path, "console/ring-ref", "%i" % ref) 1.84 + self.writeDom("console/ring-ref", "%i" % ref) 1.85 else: 1.86 - xstransact.Remove(self.path, "console/ring-ref") 1.87 + self.removeDom("console/ring-ref") 1.88 1.89 def setMemoryTarget(self, target): 1.90 self.memory_target = target 1.91 if target: 1.92 - xstransact.Write(self.path, "memory/target", "%i" % target) 1.93 + self.writeDom("memory/target", "%i" % target) 1.94 else: 1.95 - xstransact.Remove(self.path, "memory/target") 1.96 + self.removeDom("memory/target") 1.97 1.98 def update(self, info=None): 1.99 """Update with info from xc.domain_getinfo(). 1.100 @@ -668,7 +684,7 @@ class XendDomainInfo: 1.101 d = {} 1.102 for v in range(0, vcpus): 1.103 d["cpu/%d/availability" % v] = "online" 1.104 - xstransact.Write(self.path, d) 1.105 + self.writeVm(d) 1.106 1.107 def init_image(self): 1.108 """Create boot image handler for the domain. 1.109 @@ -801,12 +817,12 @@ class XendDomainInfo: 1.110 port = 0 1.111 if path: 1.112 try: 1.113 - port = int(xstransact.Read(self.path, path)) 1.114 + port = int(self.readDom(path)) 1.115 except: 1.116 # if anything goes wrong, assume the port was not yet set 1.117 pass 1.118 ret = EventChannel.interdomain(0, self.domid, port1=port, port2=0) 1.119 - xstransact.Write(self.path, path, "%i" % ret.port1) 1.120 + self.writeDom(path, "%i" % ret.port1) 1.121 return ret 1.122 1.123 def create_channel(self): 1.124 @@ -1053,20 +1069,20 @@ class XendDomainInfo: 1.125 availability = "offline" 1.126 else: 1.127 availability = "online" 1.128 - xstransact.Write(self.path, "cpu/%d/availability" % vcpu, availability) 1.129 + self.writeVm("cpu/%d/availability" % vcpu, availability) 1.130 1.131 def shutdown(self, reason): 1.132 if not reason in shutdown_reasons.values(): 1.133 raise XendError('invalid reason:' + reason) 1.134 - xstransact.Write(self.path, "control/shutdown", reason) 1.135 + self.writeVm("control/shutdown", reason) 1.136 if not reason in ['suspend']: 1.137 self.shutdown_pending = {'start':time.time(), 'reason':reason} 1.138 1.139 def clear_shutdown(self): 1.140 - xstransact.Remove(self.path, "control/shutdown") 1.141 + self.removeVm("control/shutdown") 1.142 1.143 def send_sysrq(self, key=0): 1.144 - xstransact.Write(self.path, "control/sysrq", '%c' % key) 1.145 + self.writeVm("control/sysrq", '%c' % key) 1.146 1.147 def shutdown_time_left(self, timeout): 1.148 if not self.shutdown_pending: