From nobody Sun Feb 8 20:13:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587995087; cv=none; d=zohomail.com; s=zohoarc; b=Xd42J7i/QVHUDSd27uozSCOvSrXXd2YakFqUsbjm+3Nd6MRklfFBgSrguqii32vTVQOkIz8mN0gVIwzz9WwdV1RrMkY6J1E1L2S+zEhDHa1gYKyQQfIJzGOB8/6HwhdwCiEcGeudc52niL2SfKoVR3G8UyazqYgJFzsIRk5Yj0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587995087; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u6DUrk9yKss6DQ6+dDiTTwqdN/n7sUE5DOxdCob2uO4=; b=f5d6xcHo9LWAQ2oBWjRMU+GIN4hGGTmO+icpH2UG6pDgwGaGECZx/jTljhwXyGJBnuKJcH5KtwYPDcReo06ZXBnNoBgCsMGrNWB/+TQCpfTOjsAql8UaH8Mg1LvVSKO2QyqDxXc1c1oXm4S5ol5kheSHyvDvIbG57x08va5LLnk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1587995087900771.3167383948911; Mon, 27 Apr 2020 06:44:47 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247--TmTAFTtMfq0sdhgzjRJrg-1; Mon, 27 Apr 2020 09:44:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7032D876EE2; Mon, 27 Apr 2020 13:44:37 +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 47ADC1002387; Mon, 27 Apr 2020 13:44:37 +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 004401806B0B; Mon, 27 Apr 2020 13:44:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03RDiL2w015652 for ; Mon, 27 Apr 2020 09:44:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 62FDA110F0DA; Mon, 27 Apr 2020 13:44:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F162110F0C5 for ; Mon, 27 Apr 2020 13:44:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4589A108C268 for ; Mon, 27 Apr 2020 13:44:21 +0000 (UTC) Received: from mail.univention.de (mail.univention.de [82.198.197.8]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-HeRVY-DxOb2tJrLk1qTzhg-1; Mon, 27 Apr 2020 09:44:17 -0400 Received: from localhost (localhost [127.0.0.1]) by solig.knut.univention.de (Postfix) with ESMTP id 819828F6B360 for ; Mon, 27 Apr 2020 15:44:16 +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 gYIJtC-dbdsu; Mon, 27 Apr 2020 15:44:14 +0200 (CEST) Received: from fixa.knut.univention.de (p5B21E6AF.dip0.t-ipconnect.de [91.33.230.175]) by solig.knut.univention.de (Postfix) with ESMTPSA id 089BE8F6B32E; Mon, 27 Apr 2020 15:44:12 +0200 (CEST) Received: by fixa.knut.univention.de (Postfix, from userid 2260) id 10EFD161776; Mon, 27 Apr 2020 15:44:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587995086; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=u6DUrk9yKss6DQ6+dDiTTwqdN/n7sUE5DOxdCob2uO4=; b=EFVSGEZDyr7RbwJ9ao0iSZ0q9DJIowluWdOUEWGRx51Bbn44yYLmJ3QwFRg8sRNoQ3PS+M 0wh7XiumRogRn1CwSupmy9OLfPpWgZ8lJsVPRkzetZwALhAsm83UMbmcekEz9MjRz6BTQv 53C2w6WSQeqFIH4GhPD5CmCgZV2l2/o= X-MC-Unique: -TmTAFTtMfq0sdhgzjRJrg-1 X-MC-Unique: HeRVY-DxOb2tJrLk1qTzhg-1 X-Virus-Scanned: by amavisd-new-2.10.1 (20141025) (Debian) at knut.univention.de From: Philipp Hahn To: libvir-list@redhat.com Subject: [PATCH libvirt-python 5/5] libvirtaio: Fix return types of callback Date: Mon, 27 Apr 2020 15:44:10 +0200 Message-Id: <293afd961b6153d2005a856997b951f38032015b.1587993402.git.hahn@univention.de> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 03RDiL2w015652 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" libvirt defines the signature for the callback functions, e.g. the functions for remove() must return -1 on error and 0 on success. Raising an exception violates that contract. _remove_timeout() did not explicitly handle a double-remove and implicitly passed on the exception. update() expects no return value, so remove the pointless return to pass on None. Signed-off-by: Philipp Hahn --- libvirtaio.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libvirtaio.py b/libvirtaio.py index 328e6f2..f1811c1 100644 --- a/libvirtaio.py +++ b/libvirtaio.py @@ -370,13 +370,13 @@ class virEventAsyncIOImpl(object): https://libvirt.org/html/libvirt-libvirt-event.html#virEventUp= dateHandleFunc ''' self.log.debug('update_handle(watch=3D%d, event=3D%d)', watch, eve= nt) - return self.callbacks[watch].update(event=3Devent) + self.callbacks[watch].update(event=3Devent) =20 def _remove_handle(self, watch): '''Unregister a callback from a file handle. =20 :param int watch: file descriptor watch to stop listening on - :returns: None (see source for explanation) + :returns: -1 on error, 0 on success =20 .. seealso:: https://libvirt.org/html/libvirt-libvirt-event.html#virEventRe= moveHandleFunc @@ -386,12 +386,13 @@ class virEventAsyncIOImpl(object): callback =3D self.callbacks.pop(watch) except KeyError as err: self.log.warning('remove_handle(): no such handle: %r', err.ar= gs[0]) - raise + return -1 fd =3D callback.descriptor.fd assert callback is self.descriptors[fd].remove_handle(watch) if len(self.descriptors[fd].callbacks) =3D=3D 0: del self.descriptors[fd] callback.close() + return 0 =20 def _add_timeout(self, timeout, cb, opaque): '''Register a callback for a timer event @@ -425,20 +426,25 @@ class virEventAsyncIOImpl(object): https://libvirt.org/html/libvirt-libvirt-event.html#virEventUp= dateTimeoutFunc ''' self.log.debug('update_timeout(timer=3D%d, timeout=3D%d)', timer, = timeout) - return self.callbacks[timer].update(timeout=3Dtimeout) + self.callbacks[timer].update(timeout=3Dtimeout) =20 def _remove_timeout(self, timer): '''Unregister a callback for a timer =20 :param int timer: the timer to remove - :returns: None (see source for explanation) + :returns: -1 on error, 0 on success =20 .. seealso:: https://libvirt.org/html/libvirt-libvirt-event.html#virEventRe= moveTimeoutFunc ''' self.log.debug('remove_timeout(timer=3D%d)', timer) - callback =3D self.callbacks.pop(timer) + try: + callback =3D self.callbacks.pop(timer) + except KeyError as err: + self.log.warning('remove_timeout(): no such timeout: %r', err.= args[0]) + return -1 callback.close() + return 0 =20 =20 _current_impl =3D None --=20 2.20.1