From nobody Sat Feb 7 21:16:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1575299046; cv=none; d=zohomail.com; s=zohoarc; b=BygVyoxlSSO+Zfxc43iWuQ/A6mnReC9D9ZTCdDz52MCbEH4JLO4FacElthe/CPILQRjl0pxKuuOBxvmnfU7UjSWblrr0Z1aoyudArmn29zGGsokJhT31exjguWMZcPlPyakIwlV1uhyWcFklpURQL8aRHtf8gOh35TwyXfafBl4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575299046; 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=vYHTojIsTs98c5X2PmGuHvHXac9Cj87mG/g3fuNoH0U=; b=fbQ/JE7haL/zz1/Nt7ShR8vAxBL5UKZOHnkFxmCYflX2ThVAxtc1JS2pqWE8Ci4KeBL6OMKj5/1cyE1h3di7xQq9Fiy9yZqU4gr/bYUnCC7oB08nbe/+k73NVlDkBYwHhSQcJXbPSjO+pegM8eTyFn9Q7YzKpyNsTVKuWuZRAaM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1575299046260900.2028680309921; Mon, 2 Dec 2019 07:04:06 -0800 (PST) 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-82-t8ZQ7WjJNbmydoMjpMu5pg-1; Mon, 02 Dec 2019 10:03:57 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82593107ACCD; Mon, 2 Dec 2019 15:03:50 +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 52BCD19C6A; Mon, 2 Dec 2019 15:03:50 +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 E43995BBFD; Mon, 2 Dec 2019 15:03:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB2F3cZX030581 for ; Mon, 2 Dec 2019 10:03:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1276B600CA; Mon, 2 Dec 2019 15:03:38 +0000 (UTC) Received: from dhcp-16-105.lcy.redhat.com (unknown [10.42.16.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82497600C9; Mon, 2 Dec 2019 15:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575299044; 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=vYHTojIsTs98c5X2PmGuHvHXac9Cj87mG/g3fuNoH0U=; b=T+XzK5fJerzjbQZMA3FDAAJFBVuUM/T7gQtcIBtSN4YV338abwnDELux2hzlJgMYEAlTPe GD8JWS6BeCVZ1NCp8BVGNc38LGSOb/5z6j3xyyBB/IGas31rO87XxfiTp9cEr+AYH8sol2 D6o3Rx5QyXE7bExhQBzU9x7myJU/poU= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 2 Dec 2019 15:03:27 +0000 Message-Id: <20191202150331.173475-4-berrange@redhat.com> In-Reply-To: <20191202150331.173475-1-berrange@redhat.com> References: <20191202150331.173475-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/7] event: add API for requiring an event loop impl to be registered 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.23 X-MC-Unique: t8ZQ7WjJNbmydoMjpMu5pg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Cole Robinson --- po/POTFILES.in | 1 + src/util/virevent.c | 25 +++++++++++++++++++++++++ src/util/virevent.h | 2 ++ 3 files changed, 28 insertions(+) diff --git a/po/POTFILES.in b/po/POTFILES.in index debb51cd70..b396797ff2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -238,6 +238,7 @@ @SRCDIR@/src/util/virdnsmasq.c @SRCDIR@/src/util/virerror.c @SRCDIR@/src/util/virerror.h +@SRCDIR@/src/util/virevent.c @SRCDIR@/src/util/vireventpoll.c @SRCDIR@/src/util/virfcp.c @SRCDIR@/src/util/virfdstream.c diff --git a/src/util/virevent.c b/src/util/virevent.c index 3cac9f9472..a86acf64c0 100644 --- a/src/util/virevent.c +++ b/src/util/virevent.c @@ -29,6 +29,9 @@ =20 VIR_LOG_INIT("util.event"); =20 + +#define VIR_FROM_THIS VIR_FROM_EVENT + static virEventAddHandleFunc addHandleImpl; static virEventUpdateHandleFunc updateHandleImpl; static virEventRemoveHandleFunc removeHandleImpl; @@ -251,6 +254,26 @@ void virEventRegisterImpl(virEventAddHandleFunc addHan= dle, removeTimeoutImpl =3D removeTimeout; } =20 + +/** + * virEventRequireImpl: + * + * Require that there is an event loop implementation + * registered. + * + * Returns: -1 if no event loop is registered, 0 otherwise + */ +int virEventRequireImpl(void) +{ + if (!addHandleImpl || !addTimeoutImpl) { + virReportError(VIR_ERR_NO_SUPPORT, "%s", + _("An event loop implementation must be registered"= )); + return -1; + } + + return 0; +} + /** * virEventRegisterDefaultImpl: * @@ -276,6 +299,8 @@ int virEventRegisterDefaultImpl(void) { VIR_DEBUG("registering default event implementation"); =20 + virInitialize(); + virResetLastError(); =20 if (virEventPollInit() < 0) { diff --git a/src/util/virevent.h b/src/util/virevent.h index 0b4f7d2b1b..6c8fdcbac4 100644 --- a/src/util/virevent.h +++ b/src/util/virevent.h @@ -21,3 +21,5 @@ =20 #pragma once #include "internal.h" + +int virEventRequireImpl(void); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list