xref: /openbmc/qemu/include/io/channel-watch.h (revision fc8c745d)
1 /*
2  * QEMU I/O channels watch helper APIs
3  *
4  * Copyright (c) 2015 Red Hat, Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef QIO_CHANNEL_WATCH_H
22 #define QIO_CHANNEL_WATCH_H
23 
24 #include "io/channel.h"
25 
26 /*
27  * This module provides helper functions that will be needed by
28  * the various QIOChannel implementations, for creating watches
29  * on file descriptors / sockets
30  */
31 
32 /**
33  * qio_channel_create_fd_watch:
34  * @ioc: the channel object
35  * @fd: the file descriptor
36  * @condition: the I/O condition
37  *
38  * Create a new main loop source that is able to
39  * monitor the file descriptor @fd for the
40  * I/O conditions in @condition. This is able
41  * monitor block devices, character devices,
42  * pipes but not plain files or, on Win32, sockets.
43  *
44  * Returns: the new main loop source
45  */
46 GSource *qio_channel_create_fd_watch(QIOChannel *ioc,
47                                      int fd,
48                                      GIOCondition condition);
49 
50 /**
51  * qio_channel_create_socket_watch:
52  * @ioc: the channel object
53  * @fd: the file descriptor
54  * @condition: the I/O condition
55  *
56  * Create a new main loop source that is able to
57  * monitor the file descriptor @fd for the
58  * I/O conditions in @condition. This is equivalent
59  * to qio_channel_create_fd_watch on POSIX systems
60  * but not on Windows.
61  *
62  * Returns: the new main loop source
63  */
64 GSource *qio_channel_create_socket_watch(QIOChannel *ioc,
65                                          int fd,
66                                          GIOCondition condition);
67 
68 /**
69  * qio_channel_create_fd_pair_watch:
70  * @ioc: the channel object
71  * @fdread: the file descriptor for reading
72  * @fdwrite: the file descriptor for writing
73  * @condition: the I/O condition
74  *
75  * Create a new main loop source that is able to
76  * monitor the pair of file descriptors @fdread
77  * and @fdwrite for the I/O conditions in @condition.
78  * This is intended for monitoring unidirectional
79  * file descriptors such as pipes, where a pair
80  * of descriptors is required for bidirectional
81  * I/O
82  *
83  * Returns: the new main loop source
84  */
85 GSource *qio_channel_create_fd_pair_watch(QIOChannel *ioc,
86                                           int fdread,
87                                           int fdwrite,
88                                           GIOCondition condition);
89 
90 #endif /* QIO_CHANNEL_WATCH_H */
91