Added exception handler for ProtocolError.
Quoted 15 lines · Xen patchbot -unstable
# HG changeset patch
# User [email protected]
# Node IDc1bb4eb565296bdb00aed84fcc877befbcebd8e9# Parentb55ca95fdc846a5db9f30ba1c5d065fe898f88e7Added exception handler for ProtocolError.Signed-off-by Ewan Mellor <[email protected]>diff -r
b55ca95fdc84-rc1bb4eb56529tools/python/xen/xm/main.pytools/python/xen/xm/main.py +0
-0@@ -1102,6 +1102,12 @@ else: err("Error connecting to xend: %s." % ex[1])
tools/python/xen/xm/main.py line 1113
Quoted 10 lines
tools/python/xen/xm/main.py +6
-0sys.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:
Hi Ewan,
ProtocolError's shouldn't happen. The case where os.geteuid() != 0 is a possibility (although I thought we had a check earlier for that?). However, if we are getting them for another reason, something's wrong.
What commands were you seeing this with? There may be a latent bug in the dispatch code that marshals exceptions...
Regards,
Anthony Liguori
Quoted 5 lines
_______________________________________________
Xen-changelog mailing list
[email protected]
http://lists.xensource.com/xen-changelog
Quoted 30 lines · Anthony Liguori
Quoted 24 lines · Xen patchbot -unstable
# HG changeset patch
# User [email protected]
# Node IDc1bb4eb565296bdb00aed84fcc877befbcebd8e9# Parentb55ca95fdc846a5db9f30ba1c5d065fe898f88e7Added exception handler for ProtocolError.Signed-off-by Ewan Mellor <[email protected]>diff -r
b55ca95fdc84-rc1bb4eb56529tools/python/xen/xm/main.pytools/python/xen/xm/main.py +6
-0@@ -1102,6 +1102,12 @@ 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)Quoted 2 lines
except xmlrpclib.Fault, ex:
Hi Ewan,
Quoted 3 lines
ProtocolError's shouldn't happen. The case where
os.geteuid()!= 0 is a possibility (although I thought we had a check earlier for that?). However, if we are getting them for another reason, something's wrong.
I wasn't sure whether you'd get a ProtocolError or an IOError if you tried to connect to the socket as non-root, so I just threw the geteuid test in -- if we can confirm that it's not needed (i.e. you are guaranteed to get an IOError) then we can do without that.
The ProtocolErrors in general were being thrown whenever an exception made it all the way back to the top of a function registered with the server (i.e. any of our message handlers). These exceptions would get translated to a 500 Internal Server Error which would appear at the client as a ProtocolError. I don't know whether it is any exception that causes this, or only ones that inherit from StandardError or something like that. One particular trigger was XMLRPCServer.dispatch, which wasn't checking the return value from lookup. This caused it to try and call None as a function whenever the user specified a domain that did not exist.
Ewan.
Quoted 7 lines · Ewan Mellor
Quoted 4 lines · Anthony Liguori
Hi Ewan,
ProtocolError's shouldn't happen. The case where
os.geteuid()!= 0 is a possibility (although I thought we had a check earlier for that?). However, if we are getting them for another reason, something's wrong.
Quoted 8 lines
I wasn't sure whether you'd get a ProtocolError or an IOError if you tried to connect to the socket as non-root, so I just threw the geteuid test in -- if we can confirm that it's not needed (i.e. you are guaranteed to get an IOError) then we can do without that.
The ProtocolErrors in general were being thrown whenever an exception made it all the way back to the top of a function registered with the server (i.e. any of our message handlers).
Yeah, in xen.util.xmlrpclib2:TCPXMLRPCServer::_marshaled_dispatch() we should catch any exception and convert it to a proper xmlrpclib.Fault. If exceptions are getting past that, there's something wrong.
I'll look at it today and see if I can't figure out what's happening.
Thanks for all your effort in merging this stuff Ewan!
Regards,
Anthony Liguori
Quoted 10 lines
These exceptions would get translated to a 500
Internal Server Error which would appear at the client as a ProtocolError. I don't know whether it is any exception that causes this, or only ones that inherit from StandardError or something like that. One particular trigger was XMLRPCServer.dispatch, which wasn't checking the return value from lookup. This caused it to try and call None as a function whenever the user specified a domain that did not exist.Ewan.