11c809fa0SDaniel P. Berrange /* 21c809fa0SDaniel P. Berrange * QEMU I/O channels watch helper APIs 31c809fa0SDaniel P. Berrange * 41c809fa0SDaniel P. Berrange * Copyright (c) 2015 Red Hat, Inc. 51c809fa0SDaniel P. Berrange * 61c809fa0SDaniel P. Berrange * This library is free software; you can redistribute it and/or 71c809fa0SDaniel P. Berrange * modify it under the terms of the GNU Lesser General Public 81c809fa0SDaniel P. Berrange * License as published by the Free Software Foundation; either 9*c8198bd5SChetan Pant * version 2.1 of the License, or (at your option) any later version. 101c809fa0SDaniel P. Berrange * 111c809fa0SDaniel P. Berrange * This library is distributed in the hope that it will be useful, 121c809fa0SDaniel P. Berrange * but WITHOUT ANY WARRANTY; without even the implied warranty of 131c809fa0SDaniel P. Berrange * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 141c809fa0SDaniel P. Berrange * Lesser General Public License for more details. 151c809fa0SDaniel P. Berrange * 161c809fa0SDaniel P. Berrange * You should have received a copy of the GNU Lesser General Public 171c809fa0SDaniel P. Berrange * License along with this library; if not, see <http://www.gnu.org/licenses/>. 181c809fa0SDaniel P. Berrange * 191c809fa0SDaniel P. Berrange */ 201c809fa0SDaniel P. Berrange 212a6a4076SMarkus Armbruster #ifndef QIO_CHANNEL_WATCH_H 222a6a4076SMarkus Armbruster #define QIO_CHANNEL_WATCH_H 231c809fa0SDaniel P. Berrange 241c809fa0SDaniel P. Berrange #include "io/channel.h" 251c809fa0SDaniel P. Berrange 261c809fa0SDaniel P. Berrange /* 271c809fa0SDaniel P. Berrange * This module provides helper functions that will be needed by 281c809fa0SDaniel P. Berrange * the various QIOChannel implementations, for creating watches 291c809fa0SDaniel P. Berrange * on file descriptors / sockets 301c809fa0SDaniel P. Berrange */ 311c809fa0SDaniel P. Berrange 321c809fa0SDaniel P. Berrange /** 331c809fa0SDaniel P. Berrange * qio_channel_create_fd_watch: 341c809fa0SDaniel P. Berrange * @ioc: the channel object 351c809fa0SDaniel P. Berrange * @fd: the file descriptor 361c809fa0SDaniel P. Berrange * @condition: the I/O condition 371c809fa0SDaniel P. Berrange * 381c809fa0SDaniel P. Berrange * Create a new main loop source that is able to 391c809fa0SDaniel P. Berrange * monitor the file descriptor @fd for the 401c809fa0SDaniel P. Berrange * I/O conditions in @condition. This is able 411c809fa0SDaniel P. Berrange * monitor block devices, character devices, 42b83b68a0SPaolo Bonzini * pipes but not plain files or, on Win32, sockets. 431c809fa0SDaniel P. Berrange * 441c809fa0SDaniel P. Berrange * Returns: the new main loop source 451c809fa0SDaniel P. Berrange */ 461c809fa0SDaniel P. Berrange GSource *qio_channel_create_fd_watch(QIOChannel *ioc, 471c809fa0SDaniel P. Berrange int fd, 481c809fa0SDaniel P. Berrange GIOCondition condition); 491c809fa0SDaniel P. Berrange 501c809fa0SDaniel P. Berrange /** 51b83b68a0SPaolo Bonzini * qio_channel_create_socket_watch: 52b83b68a0SPaolo Bonzini * @ioc: the channel object 53b83b68a0SPaolo Bonzini * @fd: the file descriptor 54b83b68a0SPaolo Bonzini * @condition: the I/O condition 55b83b68a0SPaolo Bonzini * 56b83b68a0SPaolo Bonzini * Create a new main loop source that is able to 57b83b68a0SPaolo Bonzini * monitor the file descriptor @fd for the 58b83b68a0SPaolo Bonzini * I/O conditions in @condition. This is equivalent 59b83b68a0SPaolo Bonzini * to qio_channel_create_fd_watch on POSIX systems 60b83b68a0SPaolo Bonzini * but not on Windows. 61b83b68a0SPaolo Bonzini * 62b83b68a0SPaolo Bonzini * Returns: the new main loop source 63b83b68a0SPaolo Bonzini */ 64b83b68a0SPaolo Bonzini GSource *qio_channel_create_socket_watch(QIOChannel *ioc, 65b83b68a0SPaolo Bonzini int fd, 66b83b68a0SPaolo Bonzini GIOCondition condition); 67b83b68a0SPaolo Bonzini 68b83b68a0SPaolo Bonzini /** 691c809fa0SDaniel P. Berrange * qio_channel_create_fd_pair_watch: 701c809fa0SDaniel P. Berrange * @ioc: the channel object 711c809fa0SDaniel P. Berrange * @fdread: the file descriptor for reading 721c809fa0SDaniel P. Berrange * @fdwrite: the file descriptor for writing 731c809fa0SDaniel P. Berrange * @condition: the I/O condition 741c809fa0SDaniel P. Berrange * 751c809fa0SDaniel P. Berrange * Create a new main loop source that is able to 761c809fa0SDaniel P. Berrange * monitor the pair of file descriptors @fdread 771c809fa0SDaniel P. Berrange * and @fdwrite for the I/O conditions in @condition. 781c809fa0SDaniel P. Berrange * This is intended for monitoring unidirectional 791c809fa0SDaniel P. Berrange * file descriptors such as pipes, where a pair 801c809fa0SDaniel P. Berrange * of descriptors is required for bidirectional 811c809fa0SDaniel P. Berrange * I/O 821c809fa0SDaniel P. Berrange * 831c809fa0SDaniel P. Berrange * Returns: the new main loop source 841c809fa0SDaniel P. Berrange */ 851c809fa0SDaniel P. Berrange GSource *qio_channel_create_fd_pair_watch(QIOChannel *ioc, 861c809fa0SDaniel P. Berrange int fdread, 871c809fa0SDaniel P. Berrange int fdwrite, 881c809fa0SDaniel P. Berrange GIOCondition condition); 891c809fa0SDaniel P. Berrange 902a6a4076SMarkus Armbruster #endif /* QIO_CHANNEL_WATCH_H */ 91