ia64/xen-unstable

changeset 6812:26cf3cfd3bed

Switch vcpu hotplugging to use xstransact.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Sep 13 17:31:13 2005 +0000 (2005-09-13)
parents f562c0f1d222
children c1450b657ede
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Sep 13 16:57:45 2005 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Sep 13 17:31:13 2005 +0000
     1.3 @@ -262,7 +262,6 @@ class XendDomainInfo:
     1.4          self.restart_count = 0
     1.5          
     1.6          self.vcpus = 1
     1.7 -        self.vcpusdb = {}
     1.8          self.bootloader = None
     1.9          self.device_model_pid = 0
    1.10  
    1.11 @@ -657,15 +656,11 @@ class XendDomainInfo:
    1.12          except:
    1.13              raise VmError('invalid vcpus value')
    1.14  
    1.15 -    def exportVCPUSToDB(self, vcpus):
    1.16 -        for v in range(0,vcpus):
    1.17 -            path = "/cpu/%d"%(v)
    1.18 -            if not self.vcpusdb.has_key(path):
    1.19 -                self.vcpusdb[path] = self.db.addChild(path)
    1.20 -            db = self.vcpusdb[path]
    1.21 -            log.debug("writing key availability=online to path %s in store"%(path))
    1.22 -            db['availability'] = "online"
    1.23 -            db.saveDB(save=True)
    1.24 +    def configure_vcpus(self, vcpus):
    1.25 +        d = {}
    1.26 +        for v in range(0, vcpus):
    1.27 +            d["cpu/%d/availability" % v] = "online"
    1.28 +        xstransact.Write(self.path, d)
    1.29  
    1.30      def init_image(self):
    1.31          """Create boot image handler for the domain.
    1.32 @@ -685,7 +680,7 @@ class XendDomainInfo:
    1.33              IntroduceDomain(self.id, self.store_mfn, self.store_channel.port1,
    1.34                              self.path)
    1.35          # get the configured value of vcpus and update store
    1.36 -        self.exportVCPUSToDB(self.vcpus)
    1.37 +        self.configure_vcpus(self.vcpus)
    1.38  
    1.39      def delete(self):
    1.40          """Delete the vm's db.
    1.41 @@ -1051,20 +1046,14 @@ class XendDomainInfo:
    1.42      def vcpu_hotplug(self, vcpu, state):
    1.43          """Disable or enable VCPU in domain.
    1.44          """
    1.45 -        db = ""
    1.46 -        try:
    1.47 -            db = self.vcpusdb['/cpu/%d'%(vcpu)]
    1.48 -        except:
    1.49 -            log.error("Invalid VCPU")
    1.50 +        if vcpu > self.vcpus:
    1.51 +            log.error("Invalid VCPU %d" % vcpu)
    1.52              return
    1.53 -
    1.54 -        if self.store_channel:
    1.55 -            if int(state) == 0:
    1.56 -                db['availability'] = "offline"
    1.57 -            else:
    1.58 -                db['availability'] = "online"
    1.59 -
    1.60 -        db.saveDB(save=True)
    1.61 +        if int(state) == 0:
    1.62 +            availability = "offline"
    1.63 +        else:
    1.64 +            availability = "online"
    1.65 +        xstransact.Write(self.path, "cpu/%d/availability" % vcpu, availability)
    1.66  
    1.67      def shutdown(self, reason):
    1.68          if not reason in shutdown_reasons.values():
    1.69 @@ -1107,7 +1096,7 @@ class XendDomainInfo:
    1.70                  else:
    1.71                      raise
    1.72              # get run-time value of vcpus and update store
    1.73 -            self.exportVCPUSToDB(dom_get(self.id)['vcpus'])
    1.74 +            self.configure_vcpus(dom_get(self.id)['vcpus'])
    1.75  
    1.76  
    1.77  def vm_field_ignore(_, _1, _2, _3):