[libvirt-python][PATCH] PyArg_ParseTuple: Provide correct function names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently, we parse arguments passed to a python function by
calling PyArg_ParseTuple(). It takes what's called format string
which is something like printf's format string (not that %s would
work for PyArg_ParseTuple). Okay, maybe that wasn't the best
example. Anyway, at the end of the format string we put
:virFunctionName where ':' says "this is the end of argument
list", and virFunctionName is the prefix for error messages then.
However, in some cases we have had wrong names there. Some of
them are actually quite funny: xmlRegisterErrorHandler.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 libvirt-override.c      | 24 ++++++++++++------------
 libvirt-qemu-override.c |  3 ++-
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/libvirt-override.c b/libvirt-override.c
index 07d1d19..fa3e2ca 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -1510,7 +1510,7 @@ libvirt_virDomainPinEmulator(PyObject *self ATTRIBUTE_UNUSED,
     int i_retval;
     unsigned int flags;
 
-    if (!PyArg_ParseTuple(args, (char *)"OOI:virDomainPinVcpu",
+    if (!PyArg_ParseTuple(args, (char *)"OOI:virDomainPinEmulator",
                           &pyobj_domain, &pycpumap, &flags))
         return NULL;
 
@@ -1577,7 +1577,7 @@ libvirt_virDomainGetEmulatorPinInfo(PyObject *self ATTRIBUTE_UNUSED,
     int ret;
     int cpunum;
 
-    if (!PyArg_ParseTuple(args, (char *)"OI:virDomainEmulatorPinInfo",
+    if (!PyArg_ParseTuple(args, (char *)"OI:virDomainGetEmulatorPinInfo",
                           &pyobj_domain, &flags))
         return NULL;
 
@@ -1907,7 +1907,7 @@ libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject *self,
     PyObject *pyobj_f;
     PyObject *pyobj_ctx;
 
-    if (!PyArg_ParseTuple(args, (char *) "OO:xmlRegisterErrorHandler",
+    if (!PyArg_ParseTuple(args, (char *) "OO:virRegisterErrorHandler",
                           &pyobj_f, &pyobj_ctx))
         return NULL;
 
@@ -2091,7 +2091,7 @@ libvirt_virGetVersion(PyObject *self ATTRIBUTE_UNUSED,
     unsigned long libVer, typeVer = 0;
     int c_retval;
 
-    if (!PyArg_ParseTuple(args, (char *) "|s", &type))
+    if (!PyArg_ParseTuple(args, (char *) "|s:virGetVersion", &type))
         return NULL;
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -2712,7 +2712,7 @@ libvirt_virDomainGetBlockInfo(PyObject *self ATTRIBUTE_UNUSED,
     const char *path;
     unsigned int flags;
 
-    if (!PyArg_ParseTuple(args, (char *)"OzI:virDomainGetInfo",
+    if (!PyArg_ParseTuple(args, (char *)"OzI:virDomainGetBlockInfo",
                           &pyobj_domain, &path, &flags))
         return NULL;
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
@@ -2750,7 +2750,7 @@ libvirt_virNodeGetInfo(PyObject *self ATTRIBUTE_UNUSED,
     PyObject *pyobj_conn;
     virNodeInfo info;
 
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetInfo", &pyobj_conn))
+    if (!PyArg_ParseTuple(args, (char *)"O:virNodeGetInfo", &pyobj_conn))
         return NULL;
     conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
 
@@ -2865,7 +2865,7 @@ libvirt_virDomainGetSecurityLabelList(PyObject *self ATTRIBUTE_UNUSED,
     virSecurityLabel *labels = NULL;
     size_t i;
 
-    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetSecurityLabel",
+    if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetSecurityLabelList",
                           &pyobj_dom))
         return NULL;
 
@@ -7338,7 +7338,7 @@ libvirt_virConnectUnregisterCloseCallback(PyObject * self ATTRIBUTE_UNUSED,
     virConnectPtr conn;
     int ret = 0;
 
-    if (!PyArg_ParseTuple(args, (char *) "O:virConnectDomainEventUnregister",
+    if (!PyArg_ParseTuple(args, (char *) "O:virConnectUnregisterCloseCallback",
                           &pyobj_conn))
         return NULL;
 
@@ -7482,7 +7482,7 @@ libvirt_virStreamSend(PyObject *self ATTRIBUTE_UNUSED,
     Py_ssize_t datalen;
     int ret;
 
-    if (!PyArg_ParseTuple(args, (char *) "OO:virStreamRecv",
+    if (!PyArg_ParseTuple(args, (char *) "OO:virStreamSend",
                           &pyobj_stream, &pyobj_data))
         return NULL;
 
@@ -8311,7 +8311,7 @@ libvirt_virNetworkGetDHCPLeases(PyObject *self ATTRIBUTE_UNUSED,
     char *mac = NULL;
     size_t i;
 
-    if (!PyArg_ParseTuple(args, (char *) "OzI:virNetworkDHCPLeasePtr",
+    if (!PyArg_ParseTuple(args, (char *) "OzI:virNetworkGetDHCPLeases",
                           &pyobj_network, &mac, &flags))
         return NULL;
 
@@ -8610,7 +8610,7 @@ libvirt_virDomainGetFSInfo(PyObject *self ATTRIBUTE_UNUSED,
     size_t j;
     PyObject *py_retval = NULL;
 
-    if (!PyArg_ParseTuple(args, (char *)"OI:virDomainFSInfo",
+    if (!PyArg_ParseTuple(args, (char *)"OI:virDomainGetFSInfo",
                           &pyobj_domain, &flags))
         return NULL;
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
@@ -8952,7 +8952,7 @@ libvirt_virConnectStoragePoolEventDeregisterAny(PyObject *self ATTRIBUTE_UNUSED,
     virConnectPtr conn;
     int ret = 0;
 
-    if (!PyArg_ParseTuple(args, (char *) "Oi:virConnectStoragePoolEventDeregister",
+    if (!PyArg_ParseTuple(args, (char *) "Oi:virConnectStoragePoolEventDeregisterAny",
                           &pyobj_conn, &callbackID))
         return NULL;
 
diff --git a/libvirt-qemu-override.c b/libvirt-qemu-override.c
index f2e876a..f166f6e 100644
--- a/libvirt-qemu-override.c
+++ b/libvirt-qemu-override.c
@@ -270,7 +270,8 @@ libvirt_qemu_virConnectDomainQemuMonitorEventRegister(PyObject *self ATTRIBUTE_U
     virDomainPtr dom;
     unsigned int flags;
 
-    if (!PyArg_ParseTuple(args, (char *) "OOzOI", &pyobj_conn, &pyobj_dom,
+    if (!PyArg_ParseTuple(args, (char *) "OOzOI:virConnectDomainQemuMonitorEventRegister",
+                          &pyobj_conn, &pyobj_dom,
                           &event, &pyobj_cbData, &flags))
         return NULL;
 
-- 
2.8.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]