xref: /openbmc/qemu/include/io/channel-command.h (revision 644eb9ceb4582ee2ccb84b6b7f7cb6d3b2d0c692)
1195e14d0SDaniel P. Berrange /*
2195e14d0SDaniel P. Berrange  * QEMU I/O channels external command driver
3195e14d0SDaniel P. Berrange  *
4195e14d0SDaniel P. Berrange  * Copyright (c) 2015 Red Hat, Inc.
5195e14d0SDaniel P. Berrange  *
6195e14d0SDaniel P. Berrange  * This library is free software; you can redistribute it and/or
7195e14d0SDaniel P. Berrange  * modify it under the terms of the GNU Lesser General Public
8195e14d0SDaniel P. Berrange  * License as published by the Free Software Foundation; either
9c8198bd5SChetan Pant  * version 2.1 of the License, or (at your option) any later version.
10195e14d0SDaniel P. Berrange  *
11195e14d0SDaniel P. Berrange  * This library is distributed in the hope that it will be useful,
12195e14d0SDaniel P. Berrange  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13195e14d0SDaniel P. Berrange  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14195e14d0SDaniel P. Berrange  * Lesser General Public License for more details.
15195e14d0SDaniel P. Berrange  *
16195e14d0SDaniel P. Berrange  * You should have received a copy of the GNU Lesser General Public
17195e14d0SDaniel P. Berrange  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18195e14d0SDaniel P. Berrange  *
19195e14d0SDaniel P. Berrange  */
20195e14d0SDaniel P. Berrange 
212a6a4076SMarkus Armbruster #ifndef QIO_CHANNEL_COMMAND_H
222a6a4076SMarkus Armbruster #define QIO_CHANNEL_COMMAND_H
23195e14d0SDaniel P. Berrange 
24195e14d0SDaniel P. Berrange #include "io/channel.h"
25db1015e9SEduardo Habkost #include "qom/object.h"
26195e14d0SDaniel P. Berrange 
27195e14d0SDaniel P. Berrange #define TYPE_QIO_CHANNEL_COMMAND "qio-channel-command"
288063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(QIOChannelCommand, QIO_CHANNEL_COMMAND)
29195e14d0SDaniel P. Berrange 
30195e14d0SDaniel P. Berrange 
31195e14d0SDaniel P. Berrange 
32195e14d0SDaniel P. Berrange /**
33195e14d0SDaniel P. Berrange  * QIOChannelCommand:
34195e14d0SDaniel P. Berrange  *
35195e14d0SDaniel P. Berrange  * The QIOChannelCommand class provides a channel implementation
36195e14d0SDaniel P. Berrange  * that can transport data with an externally running command
37195e14d0SDaniel P. Berrange  * via its stdio streams.
38195e14d0SDaniel P. Berrange  */
39195e14d0SDaniel P. Berrange 
40195e14d0SDaniel P. Berrange struct QIOChannelCommand {
41195e14d0SDaniel P. Berrange     QIOChannel parent;
42195e14d0SDaniel P. Berrange     int writefd;
43195e14d0SDaniel P. Berrange     int readfd;
44a95570e3SMarc-André Lureau     GPid pid;
45*ec5b6c9cSMarc-André Lureau #ifdef WIN32
46*ec5b6c9cSMarc-André Lureau     bool blocking;
47*ec5b6c9cSMarc-André Lureau #endif
48195e14d0SDaniel P. Berrange };
49195e14d0SDaniel P. Berrange 
50195e14d0SDaniel P. Berrange 
51195e14d0SDaniel P. Berrange /**
52195e14d0SDaniel P. Berrange  * qio_channel_command_new_spawn:
53195e14d0SDaniel P. Berrange  * @argv: the NULL terminated list of command arguments
54195e14d0SDaniel P. Berrange  * @flags: the I/O mode, one of O_RDONLY, O_WRONLY, O_RDWR
55821791b5SDaniel P. Berrange  * @errp: pointer to a NULL-initialized error object
56195e14d0SDaniel P. Berrange  *
57195e14d0SDaniel P. Berrange  * Create a channel for performing I/O with the
58195e14d0SDaniel P. Berrange  * command to be spawned with arguments @argv.
59195e14d0SDaniel P. Berrange  *
60195e14d0SDaniel P. Berrange  * Returns: the command channel object, or NULL on error
61195e14d0SDaniel P. Berrange  */
62195e14d0SDaniel P. Berrange QIOChannelCommand *
63195e14d0SDaniel P. Berrange qio_channel_command_new_spawn(const char *const argv[],
64195e14d0SDaniel P. Berrange                               int flags,
65195e14d0SDaniel P. Berrange                               Error **errp);
66195e14d0SDaniel P. Berrange 
67195e14d0SDaniel P. Berrange 
682a6a4076SMarkus Armbruster #endif /* QIO_CHANNEL_COMMAND_H */
69