ia64/xen-unstable

changeset 9530:7a3f07a33487

Check the return value of domain_lookup_by_name_or_id_nr for None (i.e. no
such domain) inside each of the public-facing functions. This fixes the
Internal errors seen when specifying an invalid domain.

domain_pincpu takes cpumap, which is a list, not a string, so there's no need
to try and split it up. Fixes xm vcpu-pin.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Thu Mar 30 11:54:07 2006 +0100 (2006-03-30)
parents d5f8280c1fa9
children 2cd44eba4df6
files tools/python/xen/xend/XendDomain.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Thu Mar 30 11:51:44 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Thu Mar 30 11:54:07 2006 +0100
     1.3 @@ -34,7 +34,7 @@ import XendDomainInfo
     1.4  
     1.5  from xen.xend import XendRoot
     1.6  from xen.xend import XendCheckpoint
     1.7 -from xen.xend.XendError import XendError
     1.8 +from xen.xend.XendError import XendError, XendInvalidDomain
     1.9  from xen.xend.XendLogging import log
    1.10  from xen.xend.xenstore.xstransact import xstransact
    1.11  from xen.xend.xenstore.xswatch import xswatch
    1.12 @@ -357,6 +357,8 @@ class XendDomain:
    1.13          """Unpause domain execution."""
    1.14          try:
    1.15              dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.16 +            if not dominfo:
    1.17 +                raise XendInvalidDomain(str(domid))
    1.18              log.info("Domain %s (%d) unpaused.", dominfo.getName(),
    1.19                       dominfo.getDomid())
    1.20              return dominfo.unpause()
    1.21 @@ -368,6 +370,8 @@ class XendDomain:
    1.22          """Pause domain execution."""
    1.23          try:
    1.24              dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.25 +            if not dominfo:
    1.26 +                raise XendInvalidDomain(str(domid))
    1.27              log.info("Domain %s (%d) paused.", dominfo.getName(),
    1.28                       dominfo.getDomid())
    1.29              return dominfo.pause()
    1.30 @@ -395,6 +399,8 @@ class XendDomain:
    1.31          """Start domain migration."""
    1.32  
    1.33          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.34 +        if not dominfo:
    1.35 +            raise XendInvalidDomain(str(domid))
    1.36  
    1.37          if dominfo.getDomid() == PRIV_DOMAIN:
    1.38              raise XendError("Cannot migrate privileged domain %i" % domid)
    1.39 @@ -420,6 +426,8 @@ class XendDomain:
    1.40  
    1.41          try:
    1.42              dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.43 +            if not dominfo:
    1.44 +                raise XendInvalidDomain(str(domid))
    1.45  
    1.46              if dominfo.getDomid() == PRIV_DOMAIN:
    1.47                  raise XendError("Cannot save privileged domain %i" % domid)
    1.48 @@ -440,9 +448,9 @@ class XendDomain:
    1.49          @param cpumap:  string repr of list of usable cpus
    1.50          """
    1.51          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.52 -        # convert cpumap string into a list of ints
    1.53 -        cpumap = map(lambda x: int(x),
    1.54 -                     cpumap.replace("[", "").replace("]", "").split(","))
    1.55 +        if not dominfo:
    1.56 +            raise XendInvalidDomain(str(domid))
    1.57 +
    1.58          try:
    1.59              return xc.vcpu_setaffinity(dominfo.getDomid(), vcpu, cpumap)
    1.60          except Exception, ex:
    1.61 @@ -453,6 +461,8 @@ class XendDomain:
    1.62          """Set BVT (Borrowed Virtual Time) scheduler parameters for a domain.
    1.63          """
    1.64          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.65 +        if not dominfo:
    1.66 +            raise XendInvalidDomain(str(domid))
    1.67          try:
    1.68              return xc.bvtsched_domain_set(dom=dominfo.getDomid(),
    1.69                                            mcuadv=mcuadv,
    1.70 @@ -466,6 +476,8 @@ class XendDomain:
    1.71          """Get BVT (Borrowed Virtual Time) scheduler parameters for a domain.
    1.72          """
    1.73          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.74 +        if not dominfo:
    1.75 +            raise XendInvalidDomain(str(domid))
    1.76          try:
    1.77              return xc.bvtsched_domain_get(dominfo.getDomid())
    1.78          except Exception, ex:
    1.79 @@ -477,6 +489,8 @@ class XendDomain:
    1.80          """Set Simple EDF scheduler parameters for a domain.
    1.81          """
    1.82          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.83 +        if not dominfo:
    1.84 +            raise XendInvalidDomain(str(domid))
    1.85          try:
    1.86              return xc.sedf_domain_set(dominfo.getDomid(), period, slice_,
    1.87                                        latency, extratime, weight)
    1.88 @@ -487,8 +501,9 @@ class XendDomain:
    1.89          """Get Simple EDF scheduler parameters for a domain.
    1.90          """
    1.91          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
    1.92 +        if not dominfo:
    1.93 +            raise XendInvalidDomain(str(domid))
    1.94          try:
    1.95 -            
    1.96              sedf_info = xc.sedf_domain_get(dominfo.getDomid())
    1.97              # return sxpr
    1.98              return ['sedf',
    1.99 @@ -509,6 +524,8 @@ class XendDomain:
   1.100          @return: 0 on success, -1 on error
   1.101          """
   1.102          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
   1.103 +        if not dominfo:
   1.104 +            raise XendInvalidDomain(str(domid))
   1.105          maxmem = int(mem) * 1024
   1.106          try:
   1.107              return xc.domain_setmaxmem(dominfo.getDomid(), maxmem)
   1.108 @@ -523,6 +540,8 @@ class XendDomain:
   1.109          @return: 0 on success, -1 on error
   1.110          """
   1.111          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
   1.112 +        if not dominfo:
   1.113 +            raise XendInvalidDomain(str(domid))
   1.114          nr_ports = last - first + 1
   1.115          try:
   1.116              return xc.domain_ioport_permission(dominfo.getDomid(),
   1.117 @@ -540,6 +559,8 @@ class XendDomain:
   1.118          @return: 0 on success, -1 on error
   1.119          """
   1.120          dominfo = self.domain_lookup_by_name_or_id_nr(domid)
   1.121 +        if not dominfo:
   1.122 +            raise XendInvalidDomain(str(domid))
   1.123          nr_ports = last - first + 1
   1.124          try:
   1.125              return xc.domain_ioport_permission(dominfo.getDomid(),