xref: /openbmc/qemu/include/io/channel-util.h (revision c8198bd5f991f5674960bf6a7754614f69f71620)
1c767ae62SDaniel P. Berrange /*
2c767ae62SDaniel P. Berrange  * QEMU I/O channels utility APIs
3c767ae62SDaniel P. Berrange  *
4c767ae62SDaniel P. Berrange  * Copyright (c) 2016 Red Hat, Inc.
5c767ae62SDaniel P. Berrange  *
6c767ae62SDaniel P. Berrange  * This library is free software; you can redistribute it and/or
7c767ae62SDaniel P. Berrange  * modify it under the terms of the GNU Lesser General Public
8c767ae62SDaniel 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.
10c767ae62SDaniel P. Berrange  *
11c767ae62SDaniel P. Berrange  * This library is distributed in the hope that it will be useful,
12c767ae62SDaniel P. Berrange  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13c767ae62SDaniel P. Berrange  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14c767ae62SDaniel P. Berrange  * Lesser General Public License for more details.
15c767ae62SDaniel P. Berrange  *
16c767ae62SDaniel P. Berrange  * You should have received a copy of the GNU Lesser General Public
17c767ae62SDaniel P. Berrange  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18c767ae62SDaniel P. Berrange  *
19c767ae62SDaniel P. Berrange  */
20c767ae62SDaniel P. Berrange 
212a6a4076SMarkus Armbruster #ifndef QIO_CHANNEL_UTIL_H
222a6a4076SMarkus Armbruster #define QIO_CHANNEL_UTIL_H
23c767ae62SDaniel P. Berrange 
24c767ae62SDaniel P. Berrange #include "io/channel.h"
25c767ae62SDaniel P. Berrange 
26c767ae62SDaniel P. Berrange /*
27c767ae62SDaniel P. Berrange  * This module provides helper functions that are useful when dealing
28c767ae62SDaniel P. Berrange  * with QIOChannel objects
29c767ae62SDaniel P. Berrange  */
30c767ae62SDaniel P. Berrange 
31c767ae62SDaniel P. Berrange 
32c767ae62SDaniel P. Berrange /**
33c767ae62SDaniel P. Berrange  * qio_channel_new_fd:
34c767ae62SDaniel P. Berrange  * @fd: the file descriptor
35c767ae62SDaniel P. Berrange  * @errp: pointer to a NULL-initialized error object
36c767ae62SDaniel P. Berrange  *
37c767ae62SDaniel P. Berrange  * Create a channel for performing I/O on the file
38c767ae62SDaniel P. Berrange  * descriptor @fd. The particular subclass of QIOChannel
39c767ae62SDaniel P. Berrange  * that is returned will depend on what underlying object
40c767ae62SDaniel P. Berrange  * the file descriptor is associated with. It may be either
41c767ae62SDaniel P. Berrange  * a QIOChannelSocket or a QIOChannelFile instance. Upon
42c767ae62SDaniel P. Berrange  * success, the returned QIOChannel instance will own
43c767ae62SDaniel P. Berrange  * the @fd file descriptor, and take responsibility for
44c767ae62SDaniel P. Berrange  * closing it when no longer required. On failure, the
45c767ae62SDaniel P. Berrange  * caller is responsible for closing @fd.
46c767ae62SDaniel P. Berrange  *
47c767ae62SDaniel P. Berrange  * Returns: the channel object, or NULL on error
48c767ae62SDaniel P. Berrange  */
49c767ae62SDaniel P. Berrange QIOChannel *qio_channel_new_fd(int fd,
50c767ae62SDaniel P. Berrange                                Error **errp);
51c767ae62SDaniel P. Berrange 
522a6a4076SMarkus Armbruster #endif /* QIO_CHANNEL_UTIL_H */
53