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/
Home Products Support Community News


[Xen-devel] [PATCH] Expose exception thrown by xen.lowlevel.xc

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Expose exception thrown by xen.lowlevel.xc
From: Anthony Liguori <aliguori@xxxxxxxxxx>
Date: Fri, 19 May 2006 11:16:41 -0500
Cc: Ewan Mellor <ewan@xxxxxxxxxxxxx>, Kaleb Pederson <kibab@xxxxxxxxxxxx>
Delivery-date: Fri, 19 May 2006 09:17:22 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mail/News 1.5 (X11/20060309)
The attached patch exposes the exception thrown by xen.lowlevel.xc as the type xen.lowlevel.xc.Error which is an exception that inherits from RuntimeError.

I only had a few minutes this morning so I didn't get to xen.lowlevel.xs but hopefully someone else can use this as a guide on what needs to be done. If noone else gets to it, I'll be able to submit another one in about a week.

I've only done very basic testing but I don't expect that this should break anything...


Anthony Liguori
# HG changeset patch
# User Anthony Liguori <anthony@xxxxxxxxxxxxx>
# Node ID 352f6cc97066af5a50906a2c4b47794434a7cc30
# Parent  91c77df11b43894a2940b03029be46f6a1c85319
Expose the exceptions thrown by xen.lowlevel.xc so they can be caught.

Signed-off-by: Anthony Liguori <aliguori@xxxxxxxxxx>

diff -r 91c77df11b43 -r 352f6cc97066 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Wed May 10 17:30:42 2006 +0100
+++ b/tools/python/xen/lowlevel/xc/xc.c Fri May 19 11:13:28 2006 -0500
@@ -1172,7 +1172,7 @@ PyXc_init(XcObject *self, PyObject *args
 PyXc_init(XcObject *self, PyObject *args, PyObject *kwds)
     if ((self->xc_handle = xc_interface_open()) == -1) {
-        PyErr_SetFromErrno(PyExc_RuntimeError);
+        PyErr_SetFromErrno(xc_error);
         return -1;
@@ -1245,7 +1245,7 @@ PyMODINIT_FUNC initxc(void)
     if (m == NULL)
-    xc_error = PyErr_NewException(PKG ".error", NULL, NULL);
+    xc_error = PyErr_NewException(PKG ".Error", PyExc_RuntimeError, NULL);
     zero = PyInt_FromLong(0);
     /* KAF: This ensures that we get debug output in a timely manner. */
@@ -1254,6 +1254,9 @@ PyMODINIT_FUNC initxc(void)
     PyModule_AddObject(m, CLS, (PyObject *)&PyXcType);
+    Py_INCREF(xc_error);
+    PyModule_AddObject(m, "Error", xc_error);
Xen-devel mailing list