]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: add note about event file descriptors on Windows
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 18 Dec 2019 16:46:07 +0000 (16:46 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 3 Jan 2020 15:42:12 +0000 (15:42 +0000)
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.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
build-aux/syntax-check.mk
include/libvirt/libvirt-event.h
src/util/virevent.c

index 19a11ce34816ee3ac13d924390a75d623a77508d..8de82e9872a86597ea9f791bb700c68b4d0bc364 100644 (file)
@@ -2238,7 +2238,7 @@ exclude_file_name_regexp--sc_prohibit_strdup = \
   ^(docs/|examples/|src/util/virstring\.c|tests/vir(netserverclient|cgroup)mock.c|tests/commandhelper\.c|tools/nss/libvirt_nss_(leases|macs)\.c$$)
 
 exclude_file_name_regexp--sc_prohibit_close = \
-  (\.p[yl]$$|\.spec\.in$$|^docs/|^(src/util/virfile\.c|src/libvirt-stream\.c|tests/(vir.+mock\.c|commandhelper\.c|qemusecuritymock\.c)|tools/nss/libvirt_nss_(leases|macs)\.c)$$)
+  (\.p[yl]$$|\.spec\.in$$|^docs/|^(src/util/vir(file|event)\.c|src/libvirt-stream\.c|tests/(vir.+mock\.c|commandhelper\.c|qemusecuritymock\.c)|tools/nss/libvirt_nss_(leases|macs)\.c)$$)
 
 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = \
   (^tests/(virhostcpu|virpcitest)data/|docs/js/.*\.js|docs/fonts/.*\.woff|\.diff|tests/virconfdata/no-newline\.conf$$)
index 734dbdcbc173e6fdbdb4811ece7d65c0d41800ed..facdc3a3ec062203381d47b02ef0393dd6baa106 100644 (file)
@@ -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.
index f6c797724e2e7db5de707458e6172ae939145542..fd5d8f5bf18760db86acd5f3036eaba965528c56 100644 (file)
@@ -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.
  */