From nobody Fri May 3 15:16:33 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576857291; cv=none; d=zohomail.com; s=zohoarc; b=gozW6Q0yfdXq2K0KI39BHnqSwBd/t+wZojYjJxiIsh9ArO8xw+yL4h6ZuGu1DJe/XbYtYdZFu/BT3TuWGEB3yTEryBnwRD9fLImaTpJEo3hltpz/FqBwh2aH/Q/McM3qmzaL/zAYKlOfpbOZok/7P0Ug2E+xkNf6Ydao4F9Aj/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576857291; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=2Hvqvo7uFgozFwp1XWnY5rf1o1g/m0A48vdzYLucINI=; b=XSFFvDzKg/xY8du7kpzEPwrI3V6XvuHCo7D5jzYMDBpIO1g6m6whUNuBSEyB0rE0+pTGezeiVG864dgiZ/YZcyqcA2fnlNM2uVhjbSdYP1ATockAIpjMOhhuWRzP5350r2hOC8+uGvMKEdL0y9Ptsu4FKz/GlO/UjfVx+5m9at4= 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; dmarc=pass header.from= (p=none dis=none) header.from= 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 1576857291114147.73597058867676; Fri, 20 Dec 2019 07:54:51 -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-401-VbkG5qNxNmK8dYFPLCwQtQ-1; Fri, 20 Dec 2019 10:54:47 -0500 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 D74E5911EB; Fri, 20 Dec 2019 15:54:40 +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 E69421001901; Fri, 20 Dec 2019 15:54:39 +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 1726E252CD; Fri, 20 Dec 2019 15:54:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBKFsZEi002101 for ; Fri, 20 Dec 2019 10:54:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id A81005C1B2; Fri, 20 Dec 2019 15:54:35 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-32.gsslab.fab.redhat.com [10.33.9.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 162C05C1B0; Fri, 20 Dec 2019 15:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576857289; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2Hvqvo7uFgozFwp1XWnY5rf1o1g/m0A48vdzYLucINI=; b=YHbpYW8rGnIELrE7RBaUMSKQ6c198hsT+C1rWFmMzO+0zdZZeiCl7WETU112XFn+zD/ETW suhkpw1K0aoU5H+N4bql24m1OWaSp+p41AXzJXG1hOqtWG34em8vaHAiAfZ383ftDI4Ggg OWxOV5n+9GgLhXV8wKS1KnkosNf6uVY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 15:47:05 +0000 Message-Id: <20191220154705.5118-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] util: add note about event file descriptors on Windows 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-MC-Unique: VbkG5qNxNmK8dYFPLCwQtQ-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) When using GNULIB with Winsock, libvirt will never see the normal HANDLE objects, instead GNULIB guarantees that libvirt gets a C runtime file descriptor. The GNULIB poll impl also expects to get C runtime file descriptors rather than HANDLE objects. Document this behaviour so that it is clear to applications providing event loop implementations if they need Windows portability. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Cole Robinson --- include/libvirt/libvirt-event.h | 4 ++++ src/util/virevent.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/include/libvirt/libvirt-event.h b/include/libvirt/libvirt-even= t.h index 734dbdcbc1..facdc3a3ec 100644 --- a/include/libvirt/libvirt-event.h +++ b/include/libvirt/libvirt-event.h @@ -67,6 +67,10 @@ typedef void (*virEventHandleCallback)(int watch, int fd= , int events, void *opaq * listen for specific events. The same file handle can be registered * multiple times provided the requested event sets are non-overlapping * + * @fd will always be a C runtime file descriptor. On Windows + * the _get_osfhandle() method can be used if a HANDLE is required + * instead. + * * If the opaque user data requires free'ing when the handle * is unregistered, then a 2nd callback can be supplied for * this purpose. This callback needs to be invoked from a clean stack. diff --git a/src/util/virevent.c b/src/util/virevent.c index f6c797724e..fd5d8f5bf1 100644 --- a/src/util/virevent.c +++ b/src/util/virevent.c @@ -60,6 +60,13 @@ static virEventRemoveTimeoutFunc removeTimeoutImpl; * requires that an event loop has previously been registered with * virEventRegisterImpl() or virEventRegisterDefaultImpl(). * + * @fd must always always be a C runtime file descriptor. On Windows + * if the caller only has a HANDLE, the _open_osfhandle() method can + * be used to open an associated C runtime file descriptor for use + * with this API. After opening a runtime file descriptor, CloseHandle() + * must not be used, instead close() will close the runtime file + * descriptor and its original associated HANDLE. + * * Returns -1 if the file handle cannot be registered, otherwise a handle * watch number to be used for updating and unregistering for events. */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list