All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Ewan Mellor <ewan@xensource.com>,
	xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] Fixup a couple of problems with XML-RPC error handling
Date: Thu, 23 Mar 2006 14:25:54 -0600	[thread overview]
Message-ID: <44230452.7000703@us.ibm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 229 bytes --]

This fixes a number of problems introduces in the recent XML-RPC 
check-in.  The higher level errors are a great idea and I've also 
extended it a bit to have a slightly nicer interface.  Please apply.

Regards,

Anthony Liguori

[-- Attachment #2: xend-xmlrpc-fixups.diff --]
[-- Type: text/plain, Size: 3628 bytes --]

# HG changeset patch
# User anthony@rhesis.austin.ibm.com
# Node ID e4c39bd3fb27129532d55f7bb30c800143b390b3
# Parent  8f722ac17efa4ba84eb6c678c7f33dab82fceb3e
1) Introduce new exception type XendInvalidDomain that maps to the high level
   XEND_INVALID_DOMAIN faultType.
2) Fix exception logic in XMLRPCServer
3) Fix TCP server
4) Remove catching of ProtocolError in main.py.  ProtocolErrors only occur
   when there is an exception in the exception handling code which shouldn't
   ever happen.  I've reproduced the error cases described by Ewan with
   xend_domain_setTargetMemory and once I fixed the exception logic, I get a
   normal faultType of 1 as would be expected.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

diff -r 8f722ac17efa -r e4c39bd3fb27 tools/python/xen/xend/XendError.py
--- a/tools/python/xen/xend/XendError.py	Thu Mar 23 16:37:37 2006
+++ b/tools/python/xen/xend/XendError.py	Thu Mar 23 20:17:52 2006
@@ -19,6 +19,10 @@
 
 import XendClient
 
+class XendInvalidDomain(Fault):
+    def __init__(self, value):
+        Fault.__init__(self, XendClient.ERROR_INVALID_DOMAIN, value)
+
 class XendError(Fault):
     
     def __init__(self, value):
diff -r 8f722ac17efa -r e4c39bd3fb27 tools/python/xen/xend/server/XMLRPCServer.py
--- a/tools/python/xen/xend/server/XMLRPCServer.py	Thu Mar 23 16:37:37 2006
+++ b/tools/python/xen/xend/server/XMLRPCServer.py	Thu Mar 23 20:17:52 2006
@@ -23,35 +23,21 @@
 from xen.util.xmlrpclib2 import UnixXMLRPCServer, TCPXMLRPCServer
 
 from xen.xend.XendClient import XML_RPC_SOCKET, ERROR_INVALID_DOMAIN
+from xen.xend.XendError import *
 
 def lookup(domid):
-    try:
-        return XendDomain.instance().domain_lookup_by_name_or_id(domid)
-    except exn:
-        log.exception(exn)
-        raise exn
+    info = XendDomain.instance().domain_lookup_by_name_or_id(domid)
+    if not info:
+        raise XendInvalidDomain(str(domid))
+    return info
 
 def dispatch(domid, fn, args):
     info = lookup(domid)
-    if info:
-        try:
-            return getattr(info, fn)(*args)
-        except exn:
-            log.exception(exn)
-            raise exn
-    else:
-        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
+    return getattr(info, fn)(*args)
 
 def domain(domid):
     info = lookup(domid)
-    if info:
-        try:
-            return info.sxpr()
-        except exn:
-            log.exception(exn)
-            raise exn
-    else:
-        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
+    return info.sxpr()
 
 def domains(detail=1):
     if detail < 1:
@@ -90,7 +76,7 @@
         if self.use_tcp:
             # bind to something fixed for now as we may eliminate
             # tcp support completely.
-            self.server = TCPXMLRPCServer(("localhost", 8005, False))
+            self.server = TCPXMLRPCServer(("localhost", 8005), logRequests=False)
         else:
             self.server = UnixXMLRPCServer(XML_RPC_SOCKET, False)
 
diff -r 8f722ac17efa -r e4c39bd3fb27 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py	Thu Mar 23 16:37:37 2006
+++ b/tools/python/xen/xm/main.py	Thu Mar 23 20:17:52 2006
@@ -1102,12 +1102,6 @@
             else:
                 err("Error connecting to xend: %s." % ex[1])
             sys.exit(1)
-        except xmlrpclib.ProtocolError, ex:
-            if os.geteuid() != 0:
-                err("Most commands need root access.  Please try again as root.")
-            else:
-                err("Error connecting to xend: %s." % ex.errmsg)
-            sys.exit(1)
         except SystemExit:
             sys.exit(1)
         except xmlrpclib.Fault, ex:

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

             reply	other threads:[~2006-03-23 20:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-23 20:25 Anthony Liguori [this message]
2006-03-24 13:40 ` [PATCH] Fixup a couple of problems with XML-RPC error handling Ewan Mellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44230452.7000703@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=ewan@xensource.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.