From nobody Mon Apr 29 19:53:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528780610138325.871065540008; Mon, 11 Jun 2018 22:16:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61E8C356F6; Tue, 12 Jun 2018 05:16:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E80525C543; Tue, 12 Jun 2018 05:16:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2B7A31804480; Tue, 12 Jun 2018 05:16:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C5Ggam006500 for ; Tue, 12 Jun 2018 01:16:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD0D7202660C; Tue, 12 Jun 2018 05:16:42 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 703BB2026609 for ; Tue, 12 Jun 2018 05:16:42 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 07:16:38 +0200 Message-Id: <7d51ebf1924b4e3af51421b5026a1751814d3ac9.1528780553.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [python PATCH 1/4] libvirt-utils: remove unused py_str function X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 12 Jun 2018 05:16:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit <57a160b5248ba47d4e1c9d22d95847dad8e0524f> removed last usage but did not remove the function itself. Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- libvirt-utils.c | 14 -------------- libvirt-utils.h | 1 - 2 files changed, 15 deletions(-) diff --git a/libvirt-utils.c b/libvirt-utils.c index f7b4478..e17e794 100644 --- a/libvirt-utils.c +++ b/libvirt-utils.c @@ -199,20 +199,6 @@ virTypedParamsFree(virTypedParameterPtr params, } #endif /* ! LIBVIR_CHECK_VERSION(1, 0, 2) */ =20 -char * -py_str(PyObject *obj) -{ - PyObject *str =3D PyObject_Str(obj); - char *ret; - if (!str) { - PyErr_Print(); - PyErr_Clear(); - return NULL; - }; - libvirt_charPtrUnwrap(str, &ret); - return ret; -} - /* Helper function to convert a virTypedParameter output array into a * Python dictionary for return to the user. Return NULL on failure, * after raising a python exception. */ diff --git a/libvirt-utils.h b/libvirt-utils.h index 0af1e62..cc3d278 100644 --- a/libvirt-utils.h +++ b/libvirt-utils.h @@ -319,7 +319,6 @@ void virTypedParamsClear(virTypedParameterPtr params, i= nt nparams); void virTypedParamsFree(virTypedParameterPtr params, int nparams); # endif /* ! LIBVIR_CHECK_VERSION(1, 0, 2) */ =20 -char * py_str(PyObject *obj); PyObject * getPyVirTypedParameter(const virTypedParameter *params, int nparams); virTypedParameterPtr setPyVirTypedParameter(PyObject *info, --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:53:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528780610079114.34581658383206; Mon, 11 Jun 2018 22:16:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 63AA585A05; Tue, 12 Jun 2018 05:16:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB0A68E199; Tue, 12 Jun 2018 05:16:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 017D51808852; Tue, 12 Jun 2018 05:16:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C5Gh0h006505 for ; Tue, 12 Jun 2018 01:16:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 72D19202660C; Tue, 12 Jun 2018 05:16:43 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1570D2026609 for ; Tue, 12 Jun 2018 05:16:42 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 07:16:39 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [python PATCH 2/4] typewrappers: Fix libvirt_charPtrUnwrap to set an exception if it fails X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 12 Jun 2018 05:16:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If the function fails it should always set an exception. Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- typewrappers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/typewrappers.c b/typewrappers.c index 01ee310..99a8fb8 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -384,8 +384,11 @@ libvirt_charPtrUnwrap(PyObject *obj, #else ret =3D PyString_AsString(obj); #endif - if (ret) + if (ret) { *str =3D strdup(ret); + if (!*str) + PyErr_NoMemory(); + } #if PY_MAJOR_VERSION > 2 Py_DECREF(bytes); #endif --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:53:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528780630578335.67612419319687; Mon, 11 Jun 2018 22:17:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D50830820C1; Tue, 12 Jun 2018 05:17:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15337A293D; Tue, 12 Jun 2018 05:17:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C14E4180BA80; Tue, 12 Jun 2018 05:17:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C5GiXk006511 for ; Tue, 12 Jun 2018 01:16:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 17305202660C; Tue, 12 Jun 2018 05:16:44 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE8A52026609 for ; Tue, 12 Jun 2018 05:16:43 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 07:16:40 +0200 Message-Id: <15527f6c63f71270efde84e55df3f4c68e056d46.1528780553.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [python PATCH 3/4] libvirt-override: Reset exception if the error is ignored X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 12 Jun 2018 05:17:09 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In virConnectCredCallbackWrapper() we ignore the error case of libvirt_charPtrUnwrap() function so we should also reset the exception. Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- libvirt-override.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libvirt-override.c b/libvirt-override.c index 1c95c18..dac481b 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -1918,8 +1918,10 @@ virConnectCredCallbackWrapper(virConnectCredentialPt= r cred, char *result =3D NULL; pycreditem =3D PyTuple_GetItem(pycred, i); pyresult =3D PyList_GetItem(pycreditem, 4); - if (pyresult !=3D Py_None) + if (pyresult !=3D Py_None) { libvirt_charPtrUnwrap(pyresult, &result); + PyErr_Clear(); + } if (result !=3D NULL) { cred[i].result =3D result; cred[i].resultlen =3D strlen(result); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 19:53:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528780634528586.8927013195068; Mon, 11 Jun 2018 22:17:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B4FF30820E1; Tue, 12 Jun 2018 05:17:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35B3CA293A; Tue, 12 Jun 2018 05:17:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C8F204CA81; Tue, 12 Jun 2018 05:17:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C5Gijf006518 for ; Tue, 12 Jun 2018 01:16:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id B075A202660C; Tue, 12 Jun 2018 05:16:44 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53CBE2026609 for ; Tue, 12 Jun 2018 05:16:44 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 07:16:41 +0200 Message-Id: <1ef2499b37c690b74438fa67d410f159ac32c755.1528780553.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [python PATCH 4/4] libvirt_charPtrUnwrap: remove unnecessary check of returned string X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 12 Jun 2018 05:17:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Function libvirt_charPtrUnwrap() either fails or always sets the unwrapped string so there is no need to check it explicitly. Signed-off-by: Pavel Hrdina Reviewed-by: J=EF=BF=BDn Tomko --- libvirt-override.c | 12 ++++-------- libvirt-utils.c | 10 +++------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index dac481b..2f2c4ff 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -4639,8 +4639,7 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUT= E_UNUSED, =20 for (i =3D 0; i < ncpus; i++) { if (libvirt_charPtrUnwrap(PyList_GetItem(list, i), - &(xmlcpus[i])) < 0 || - xmlcpus[i] =3D=3D NULL) { + &(xmlcpus[i])) < 0) { for (j =3D 0 ; j < i ; j++) VIR_FREE(xmlcpus[j]); VIR_FREE(xmlcpus); @@ -8245,8 +8244,7 @@ libvirt_virDomainFSFreeze(PyObject *self ATTRIBUTE_UN= USED, =20 for (i =3D 0; i < nmountpoints; i++) { if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i), - mountpoints+i) < 0 || - mountpoints[i] =3D=3D NULL) + mountpoints+i) < 0) goto cleanup; } } @@ -8293,8 +8291,7 @@ libvirt_virDomainFSThaw(PyObject *self ATTRIBUTE_UNUS= ED, =20 for (i =3D 0; i < nmountpoints; i++) { if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i), - mountpoints+i) < 0 || - mountpoints[i] =3D=3D NULL) + mountpoints+i) < 0) goto cleanup; } } @@ -9743,8 +9740,7 @@ libvirt_virConnectBaselineHypervisorCPU(PyObject *sel= f ATTRIBUTE_UNUSED, =20 for (i =3D 0; i < ncpus; i++) { if (libvirt_charPtrUnwrap(PyList_GetItem(list, i), - &(xmlCPUs[i])) < 0 || - !xmlCPUs[i]) + &(xmlCPUs[i])) < 0) goto cleanup; } } diff --git a/libvirt-utils.c b/libvirt-utils.c index e17e794..78b94ca 100644 --- a/libvirt-utils.c +++ b/libvirt-utils.c @@ -302,8 +302,7 @@ setPyVirTypedParameter(PyObject *info, while (PyDict_Next(info, &pos, &key, &value)) { char *keystr =3D NULL; =20 - if (libvirt_charPtrUnwrap(key, &keystr) < 0 || - keystr =3D=3D NULL) + if (libvirt_charPtrUnwrap(key, &keystr) < 0) goto cleanup; =20 for (i =3D 0; i < nparams; i++) { @@ -359,8 +358,7 @@ setPyVirTypedParameter(PyObject *info, case VIR_TYPED_PARAM_STRING: { char *string_val; - if (libvirt_charPtrUnwrap(value, &string_val) < 0 || - !string_val) + if (libvirt_charPtrUnwrap(value, &string_val) < 0) goto cleanup; temp->value.s =3D string_val; break; @@ -489,7 +487,6 @@ virPyDictToTypedParamOne(virTypedParameterPtr *params, { char *val;; if (libvirt_charPtrUnwrap(value, &val) < 0 || - !val || virTypedParamsAddString(params, n, max, keystr, val) < 0) { VIR_FREE(val); goto cleanup; @@ -541,8 +538,7 @@ virPyDictToTypedParams(PyObject *dict, return -1; =20 while (PyDict_Next(dict, &pos, &key, &value)) { - if (libvirt_charPtrUnwrap(key, &keystr) < 0 || - !keystr) + if (libvirt_charPtrUnwrap(key, &keystr) < 0) goto cleanup; =20 if (PyList_Check(value) || PyTuple_Check(value)) { --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list