mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
Use global thread-local error for all python error reporting
This commit is contained in:
parent
839c6de58b
commit
554d82a200
@ -1,3 +1,8 @@
|
|||||||
|
Tue Jan 20 22:06:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
* python/libvir.c, python/libvir.py: Use global thread
|
||||||
|
local error variable for all exceptions.
|
||||||
|
|
||||||
Tue Jan 20 13:35:36 PST 2009 John Levon <john.levon@sun.com>
|
Tue Jan 20 13:35:36 PST 2009 John Levon <john.levon@sun.com>
|
||||||
|
|
||||||
* qemud/qemud.c: respect LIBVIRT_DEBUG when logging to syslog
|
* qemud/qemud.c: respect LIBVIRT_DEBUG when logging to syslog
|
||||||
|
@ -438,23 +438,23 @@ static PyObject *libvirt_virPythonErrorFuncCtxt = NULL;
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
libvirt_virGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args ATTRIBUTE_UNUSED)
|
libvirt_virGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
virError err;
|
virError *err;
|
||||||
PyObject *info;
|
PyObject *info;
|
||||||
|
|
||||||
if (virCopyLastError(&err) <= 0)
|
if ((err = virGetLastError()) == NULL)
|
||||||
return VIR_PY_NONE;
|
return VIR_PY_NONE;
|
||||||
|
|
||||||
if ((info = PyTuple_New(9)) == NULL)
|
if ((info = PyTuple_New(9)) == NULL)
|
||||||
return VIR_PY_NONE;
|
return VIR_PY_NONE;
|
||||||
PyTuple_SetItem(info, 0, PyInt_FromLong((long) err.code));
|
PyTuple_SetItem(info, 0, PyInt_FromLong((long) err->code));
|
||||||
PyTuple_SetItem(info, 1, PyInt_FromLong((long) err.domain));
|
PyTuple_SetItem(info, 1, PyInt_FromLong((long) err->domain));
|
||||||
PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err.message));
|
PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err->message));
|
||||||
PyTuple_SetItem(info, 3, PyInt_FromLong((long) err.level));
|
PyTuple_SetItem(info, 3, PyInt_FromLong((long) err->level));
|
||||||
PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err.str1));
|
PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err->str1));
|
||||||
PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err.str2));
|
PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err->str2));
|
||||||
PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err.str3));
|
PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err->str3));
|
||||||
PyTuple_SetItem(info, 7, PyInt_FromLong((long) err.int1));
|
PyTuple_SetItem(info, 7, PyInt_FromLong((long) err->int1));
|
||||||
PyTuple_SetItem(info, 8, PyInt_FromLong((long) err.int2));
|
PyTuple_SetItem(info, 8, PyInt_FromLong((long) err->int2));
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@ -462,7 +462,7 @@ libvirt_virGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args ATTRIBUT
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
libvirt_virConnGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
|
libvirt_virConnGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
|
||||||
{
|
{
|
||||||
virError err;
|
virError *err;
|
||||||
PyObject *info;
|
PyObject *info;
|
||||||
virConnectPtr conn;
|
virConnectPtr conn;
|
||||||
PyObject *pyobj_conn;
|
PyObject *pyobj_conn;
|
||||||
@ -471,20 +471,20 @@ libvirt_virConnGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
|
conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
|
||||||
|
|
||||||
if (virConnCopyLastError(conn, &err) <= 0)
|
if ((err = virConnGetLastError(conn)) == NULL)
|
||||||
return VIR_PY_NONE;
|
return VIR_PY_NONE;
|
||||||
|
|
||||||
if ((info = PyTuple_New(9)) == NULL)
|
if ((info = PyTuple_New(9)) == NULL)
|
||||||
return VIR_PY_NONE;
|
return VIR_PY_NONE;
|
||||||
PyTuple_SetItem(info, 0, PyInt_FromLong((long) err.code));
|
PyTuple_SetItem(info, 0, PyInt_FromLong((long) err->code));
|
||||||
PyTuple_SetItem(info, 1, PyInt_FromLong((long) err.domain));
|
PyTuple_SetItem(info, 1, PyInt_FromLong((long) err->domain));
|
||||||
PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err.message));
|
PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err->message));
|
||||||
PyTuple_SetItem(info, 3, PyInt_FromLong((long) err.level));
|
PyTuple_SetItem(info, 3, PyInt_FromLong((long) err->level));
|
||||||
PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err.str1));
|
PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err->str1));
|
||||||
PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err.str2));
|
PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err->str2));
|
||||||
PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err.str3));
|
PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err->str3));
|
||||||
PyTuple_SetItem(info, 7, PyInt_FromLong((long) err.int1));
|
PyTuple_SetItem(info, 7, PyInt_FromLong((long) err->int1));
|
||||||
PyTuple_SetItem(info, 8, PyInt_FromLong((long) err.int2));
|
PyTuple_SetItem(info, 8, PyInt_FromLong((long) err->int2));
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,9 @@ class libvirtError(Exception):
|
|||||||
elif vol is not None:
|
elif vol is not None:
|
||||||
conn = vol._conn
|
conn = vol._conn
|
||||||
|
|
||||||
if conn is None:
|
# Never call virConnGetLastError().
|
||||||
err = virGetLastError()
|
# virGetLastError() is now thread local
|
||||||
else:
|
err = virGetLastError()
|
||||||
err = conn.virConnGetLastError()
|
|
||||||
if err is None:
|
if err is None:
|
||||||
msg = defmsg
|
msg = defmsg
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user