From nobody Wed Nov 27 20:51:25 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153753694917297.77848144579877; Fri, 21 Sep 2018 06:35:49 -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 1A96E40F2B; Fri, 21 Sep 2018 13:35:47 +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 D658E7DFDA; Fri, 21 Sep 2018 13:35:46 +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 86587181A531; Fri, 21 Sep 2018 13:35:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8LDZSgY022079 for ; Fri, 21 Sep 2018 09:35:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6788E308BDB0; Fri, 21 Sep 2018 13:35:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D352308BDB3 for ; Fri, 21 Sep 2018 13:35:24 +0000 (UTC) Received: from mail.univention.de (mail.univention.de [82.198.197.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93ED980467 for ; Fri, 21 Sep 2018 13:35:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by solig.knut.univention.de (Postfix) with ESMTP id 4728D32A7C0B for ; Fri, 21 Sep 2018 15:35:22 +0200 (CEST) Received: from mail.univention.de ([127.0.0.1]) by localhost (solig.knut.univention.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jfDaXM0JvT81; Fri, 21 Sep 2018 15:35:21 +0200 (CEST) Received: from fixa.knut.univention.de (mail.univention.de [82.198.197.8]) by solig.knut.univention.de (Postfix) with ESMTPSA id 3839D32A7BB4; Fri, 21 Sep 2018 15:35:18 +0200 (CEST) Received: by fixa.knut.univention.de (Postfix, from userid 2260) id 9B3F615F8EA; Fri, 21 Sep 2018 15:35:17 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.10.1 (20141025) (Debian) at knut.univention.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Philipp Hahn To: libvir-list@redhat.com Date: Fri, 21 Sep 2018 15:35:01 +0200 Message-Id: <17d5f6a465a91d70c60f5339f5a7be187473d33c.1537536402.git.hahn@univention.de> In-Reply-To: References: In-Reply-To: References: <1ce5060e-4249-0246-89d0-b7e01f8dd30a@redhat.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 214 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 21 Sep 2018 13:35:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 21 Sep 2018 13:35:23 +0000 (UTC) for IP:'82.198.197.8' DOMAIN:'mail.univention.de' HELO:'mail.univention.de' FROM:'hahn@univention.de' RCPT:'' X-RedHat-Spam-Score: -0.011 (RCVD_IN_DNSWL_NONE, SPF_PASS) 82.198.197.8 mail.univention.de 82.198.197.8 mail.univention.de X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH libvirt-python v2 06/22] event-test.py: Merge livecycle callbacks 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.30]); Fri, 21 Sep 2018 13:35:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Registering the same function twice using the old domainEventRegister() interface would not work, as the function reference is used for un-registering. But it is not a problem with the new interface domainEventRegisterAn(), as that returns a unique ID. While at it also demonstrate the 'opaque' mechanism. Signed-off-by: Philipp Hahn --- examples/event-test.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/examples/event-test.py b/examples/event-test.py index ab1da4a..2dcdee3 100755 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -499,15 +499,11 @@ def agentLifecycleReasonToString(reason): agentReasons =3D ( "unknown", "domain started", "channel event", ) return agentReasons[reason] =20 -def myDomainEventCallback1 (conn, dom, event, detail, opaque): - print("myDomainEventCallback1 EVENT: Domain %s(%s) %s %s" % (dom.name(= ), dom.ID(), - domEventT= oString(event), - domDetail= ToString(event, detail))) =20 -def myDomainEventCallback2 (conn, dom, event, detail, opaque): - print("myDomainEventCallback2 EVENT: Domain %s(%s) %s %s" % (dom.name(= ), dom.ID(), - domEventT= oString(event), - domDetail= ToString(event, detail))) +def myDomainEventCallback(conn, dom, event, detail, opaque): + print("myDomainEventCallback%d EVENT: Domain %s(%s) %s %s" % ( + opaque, dom.name(), dom.ID(), domEventToString(event), domDetailTo= String(event, detail))) + =20 def myDomainEventRebootCallback(conn, dom, opaque): print("myDomainEventRebootCallback: Domain %s(%s)" % (dom.name(), dom.= ID())) @@ -725,9 +721,9 @@ def main(): vc.registerCloseCallback(myConnectionCloseCallback, None) =20 #Add 2 lifecycle callbacks to prove this works with more than just one - vc.domainEventRegister(myDomainEventCallback1,None) + vc.domainEventRegister(myDomainEventCallback, 1) domcallbacks =3D [] - domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN= _EVENT_ID_LIFECYCLE, myDomainEventCallback2, None)) + domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN= _EVENT_ID_LIFECYCLE, myDomainEventCallback, 2)) domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN= _EVENT_ID_REBOOT, myDomainEventRebootCallback, None)) domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN= _EVENT_ID_RTC_CHANGE, myDomainEventRTCChangeCallback, None)) domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN= _EVENT_ID_WATCHDOG, myDomainEventWatchdogCallback, None)) @@ -784,7 +780,7 @@ def main(): if not run: return =20 - vc.domainEventDeregister(myDomainEventCallback1) + vc.domainEventDeregister(myDomainEventCallback) =20 for id in seccallbacks: vc.secretEventDeregisterAny(id) --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list