From nobody Sat May 4 06:20:10 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490799611149855.3996557594239; Wed, 29 Mar 2017 08:00:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6BD9B4DD4B; Wed, 29 Mar 2017 15:00:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 376E31840D; Wed, 29 Mar 2017 15:00: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 B71DB5EC65; Wed, 29 Mar 2017 15:00:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2TF01Pj026875 for ; Wed, 29 Mar 2017 11:00:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4C9479AB44; Wed, 29 Mar 2017 15:00:01 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FE06996BA; Wed, 29 Mar 2017 15:00:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6BD9B4DD4B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6BD9B4DD4B From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 17:00:54 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [python PATCH 1/2] event: fix comment for _dispatchDomainEventMetadataChangeCallback 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 29 Mar 2017 15:00:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The comment was copied from the device removal failed event. --- libvirt-override-virConnect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py index bcd72ac..35009bb 100644 --- a/libvirt-override-virConnect.py +++ b/libvirt-override-virConnect.py @@ -244,7 +244,7 @@ return 0 def _dispatchDomainEventMetadataChangeCallback(self, dom, mtype, nsuri= , cbData): - """Dispatches event to python user domain device removal failed ev= ent callbacks + """Dispatches event to python user domain metadata change event ca= llbacks """ cb =3D cbData["cb"] opaque =3D cbData["opaque"] --=20 2.12.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 06:20:10 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490799865220550.2733763786766; Wed, 29 Mar 2017 08:04:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19585C0586AC; Wed, 29 Mar 2017 15:04:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD96C7FBF0; Wed, 29 Mar 2017 15:04:22 +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 8CE595EC64; Wed, 29 Mar 2017 15:04:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2TF03do026893 for ; Wed, 29 Mar 2017 11:00:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 329079AB49; Wed, 29 Mar 2017 15:00:03 +0000 (UTC) Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 807C99AB48; Wed, 29 Mar 2017 15:00:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 19585C0586AC Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 19585C0586AC From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 17:00:55 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [python PATCH 2/2] event: Add handler for block threshold event 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 29 Mar 2017 15:04:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Unfortunately python doesn't generate those. --- examples/event-test.py | 4 +++ libvirt-override-virConnect.py | 9 ++++++ libvirt-override.c | 62 ++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 75 insertions(+) diff --git a/examples/event-test.py b/examples/event-test.py index d5af33c..a1105a3 100755 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -541,6 +541,9 @@ def myDomainEventDeviceRemovalFailedCallback(conn, dom,= dev, opaque): def myDomainEventMetadataChangeCallback(conn, dom, mtype, nsuri, opaque): print("myDomainEventMetadataChangeCallback: Domain %s(%s) changed meta= data mtype=3D%d nsuri=3D%s" % ( dom.name(), dom.ID(), mtype, nsuri)) +def myDomainEventBlockThresholdCallback(conn, dom, dev, path, threshold, e= xcess, opaque): + print("myDomainEventBlockThresholdCallback: Domain %s(%s) block device= %s(%s) threshold %d exceeded by %d" % ( + dom.name(), dom.ID(), dev, path, threshold, excess)) ########################################################################## # Network events @@ -710,6 +713,7 @@ def main(): vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_JOB_COMPLE= TED, myDomainEventJobCompletedCallback, None) vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REM= OVAL_FAILED, myDomainEventDeviceRemovalFailedCallback, None) vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_METADATA_C= HANGE, myDomainEventMetadataChangeCallback, None) + vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_BLOCK_THRE= SHOLD, myDomainEventBlockThresholdCallback, None) vc.networkEventRegisterAny(None, libvirt.VIR_NETWORK_EVENT_ID_LIFECYCL= E, myNetworkEventLifecycleCallback, None) diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py index 35009bb..f26e65a 100644 --- a/libvirt-override-virConnect.py +++ b/libvirt-override-virConnect.py @@ -252,6 +252,15 @@ cb(self, virDomain(self, _obj=3Ddom), mtype, nsuri, opaque) return 0 + def _dispatchDomainEventBlockThresholdCallback(self, dom, dev, path, t= hreshold, excess, cbData): + """Dispatches event to python user domain block device threshold e= vent callbacks + """ + cb =3D cbData["cb"] + opaque =3D cbData["opaque"] + + cb(self, virDomain(self, _obj=3Ddom), dev, path, threshold, excess= , opaque) + return 0 + def domainEventDeregisterAny(self, callbackID): """Removes a Domain Event Callback. De-registering for a domain callback will disable delivery of this event type """ diff --git a/libvirt-override.c b/libvirt-override.c index 9e40f00..93c7ef0 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6932,6 +6932,63 @@ libvirt_virConnectDomainEventMetadataChangeCallback(= virConnectPtr conn ATTRIBUTE } #endif /* VIR_DOMAIN_EVENT_ID_METADATA_CHANGE */ +#ifdef VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD +static int +libvirt_virConnectDomainEventBlockThresholdCallback(virConnectPtr conn ATT= RIBUTE_UNUSED, + virDomainPtr dom, + const char *dev, + const char *path, + unsigned long long thr= eshold, + unsigned long long exc= ess, + void *opaque) +{ + PyObject *pyobj_cbData =3D (PyObject*)opaque; + PyObject *pyobj_dom; + PyObject *pyobj_ret =3D NULL; + PyObject *pyobj_conn; + PyObject *dictKey; + int ret =3D -1; + + LIBVIRT_ENSURE_THREAD_STATE; + + if (!(dictKey =3D libvirt_constcharPtrWrap("conn"))) + goto cleanup; + pyobj_conn =3D PyDict_GetItem(pyobj_cbData, dictKey); + Py_DECREF(dictKey); + + /* Create a python instance of this virDomainPtr */ + virDomainRef(dom); + if (!(pyobj_dom =3D libvirt_virDomainPtrWrap(dom))) { + virDomainFree(dom); + goto cleanup; + } + Py_INCREF(pyobj_cbData); + + /* Call the Callback Dispatcher */ + pyobj_ret =3D PyObject_CallMethod(pyobj_conn, + (char*)"_dispatchDomainEventBlockThres= holdCallback", + (char*)"OssiiO", + pyobj_dom, dev, path, threshold, exces= s, + pyobj_cbData); + + Py_DECREF(pyobj_cbData); + Py_DECREF(pyobj_dom); + + cleanup: + if (!pyobj_ret) { + DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret); + PyErr_Print(); + } else { + Py_DECREF(pyobj_ret); + ret =3D 0; + } + + LIBVIRT_RELEASE_THREAD_STATE; + return ret; +} +#endif /* VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD */ + + static PyObject * libvirt_virConnectDomainEventRegisterAny(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -7052,6 +7109,11 @@ libvirt_virConnectDomainEventRegisterAny(PyObject *s= elf ATTRIBUTE_UNUSED, cb =3D VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventMeta= dataChangeCallback); break; #endif /* VIR_DOMAIN_EVENT_ID_METADATA_CHANGE */ +#ifdef VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD + case VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD: + cb =3D VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBloc= kThresholdCallback); + break; +#endif /* VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD */ case VIR_DOMAIN_EVENT_ID_LAST: break; } --=20 2.12.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list