xref: /openbmc/qemu/include/io/channel-watch.h (revision 61d9f32b)
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 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  * sockets, pipes but not plain files.
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_fd_pair_watch:
52  * @ioc: the channel object
53  * @fdread: the file descriptor for reading
54  * @fdwrite: the file descriptor for writing
55  * @condition: the I/O condition
56  *
57  * Create a new main loop source that is able to
58  * monitor the pair of file descriptors @fdread
59  * and @fdwrite for the I/O conditions in @condition.
60  * This is intended for monitoring unidirectional
61  * file descriptors such as pipes, where a pair
62  * of descriptors is required for bidirectional
63  * I/O
64  *
65  * Returns: the new main loop source
66  */
67 GSource *qio_channel_create_fd_pair_watch(QIOChannel *ioc,
68                                           int fdread,
69                                           int fdwrite,
70                                           GIOCondition condition);
71 
72 #endif /* QIO_CHANNEL_WATCH_H__ */
73