WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Check the return value of domain_lookup_by_name_or_id_nr

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Check the return value of domain_lookup_by_name_or_id_nr for None (i.e. no
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 30 Mar 2006 12:42:07 +0000
Delivery-date: Thu, 30 Mar 2006 12:44:03 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 7a3f07a334874b83e66df5994e797b1ea59f9484
# Parent  d5f8280c1fa9fb207ce9ea815285a3957eae839f
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@xxxxxxxxxxxxx>

diff -r d5f8280c1fa9 -r 7a3f07a33487 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Thu Mar 30 10:51:44 2006
+++ b/tools/python/xen/xend/XendDomain.py       Thu Mar 30 10:54:07 2006
@@ -34,7 +34,7 @@
 
 from xen.xend import XendRoot
 from xen.xend import XendCheckpoint
-from xen.xend.XendError import XendError
+from xen.xend.XendError import XendError, XendInvalidDomain
 from xen.xend.XendLogging import log
 from xen.xend.xenstore.xstransact import xstransact
 from xen.xend.xenstore.xswatch import xswatch
@@ -357,6 +357,8 @@
         """Unpause domain execution."""
         try:
             dominfo = self.domain_lookup_by_name_or_id_nr(domid)
+            if not dominfo:
+                raise XendInvalidDomain(str(domid))
             log.info("Domain %s (%d) unpaused.", dominfo.getName(),
                      dominfo.getDomid())
             return dominfo.unpause()
@@ -368,6 +370,8 @@
         """Pause domain execution."""
         try:
             dominfo = self.domain_lookup_by_name_or_id_nr(domid)
+            if not dominfo:
+                raise XendInvalidDomain(str(domid))
             log.info("Domain %s (%d) paused.", dominfo.getName(),
                      dominfo.getDomid())
             return dominfo.pause()
@@ -395,6 +399,8 @@
         """Start domain migration."""
 
         dominfo = self.domain_lookup_by_name_or_id_nr(domid)
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
 
         if dominfo.getDomid() == PRIV_DOMAIN:
             raise XendError("Cannot migrate privileged domain %i" % domid)
@@ -420,6 +426,8 @@
 
         try:
             dominfo = self.domain_lookup_by_name_or_id_nr(domid)
+            if not dominfo:
+                raise XendInvalidDomain(str(domid))
 
             if dominfo.getDomid() == PRIV_DOMAIN:
                 raise XendError("Cannot save privileged domain %i" % domid)
@@ -440,9 +448,9 @@
         @param cpumap:  string repr of list of usable cpus
         """
         dominfo = self.domain_lookup_by_name_or_id_nr(domid)
-        # convert cpumap string into a list of ints
-        cpumap = map(lambda x: int(x),
-                     cpumap.replace("[", "").replace("]", "").split(","))
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
+
         try:
             return xc.vcpu_setaffinity(dominfo.getDomid(), vcpu, cpumap)
         except Exception, ex:
@@ -453,6 +461,8 @@
         """Set BVT (Borrowed Virtual Time) scheduler parameters for a domain.
         """
         dominfo = self.domain_lookup_by_name_or_id_nr(domid)
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
         try:
             return xc.bvtsched_domain_set(dom=dominfo.getDomid(),
                                           mcuadv=mcuadv,
@@ -466,6 +476,8 @@
         """Get BVT (Borrowed Virtual Time) scheduler parameters for a domain.
         """
         dominfo = self.domain_lookup_by_name_or_id_nr(domid)
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
         try:
             return xc.bvtsched_domain_get(dominfo.getDomid())
         except Exception, ex:
@@ -477,6 +489,8 @@
         """Set Simple EDF scheduler parameters for a domain.
         """
         dominfo = self.domain_lookup_by_name_or_id_nr(domid)
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
         try:
             return xc.sedf_domain_set(dominfo.getDomid(), period, slice_,
                                       latency, extratime, weight)
@@ -487,8 +501,9 @@
         """Get Simple EDF scheduler parameters for a domain.
         """
         dominfo = self.domain_lookup_by_name_or_id_nr(domid)
-        try:
-            
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
+        try:
             sedf_info = xc.sedf_domain_get(dominfo.getDomid())
             # return sxpr
             return ['sedf',
@@ -509,6 +524,8 @@
         @return: 0 on success, -1 on error
         """
         dominfo = self.domain_lookup_by_name_or_id_nr(domid)
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
         maxmem = int(mem) * 1024
         try:
             return xc.domain_setmaxmem(dominfo.getDomid(), maxmem)
@@ -523,6 +540,8 @@
         @return: 0 on success, -1 on error
         """
         dominfo = self.domain_lookup_by_name_or_id_nr(domid)
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
         nr_ports = last - first + 1
         try:
             return xc.domain_ioport_permission(dominfo.getDomid(),
@@ -540,6 +559,8 @@
         @return: 0 on success, -1 on error
         """
         dominfo = self.domain_lookup_by_name_or_id_nr(domid)
+        if not dominfo:
+            raise XendInvalidDomain(str(domid))
         nr_ports = last - first + 1
         try:
             return xc.domain_ioport_permission(dominfo.getDomid(),

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Check the return value of domain_lookup_by_name_or_id_nr for None (i.e. no, Xen patchbot -unstable <=