2 * QEMU I/O channels external command driver
4 * Copyright (c) 2015 Red Hat, Inc.
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.
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.
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/>.
21 #ifndef QIO_CHANNEL_COMMAND_H__
22 #define QIO_CHANNEL_COMMAND_H__
24 #include "io/channel.h"
26 #define TYPE_QIO_CHANNEL_COMMAND "qio-channel-command"
27 #define QIO_CHANNEL_COMMAND(obj) \
28 OBJECT_CHECK(QIOChannelCommand, (obj), TYPE_QIO_CHANNEL_COMMAND)
30 typedef struct QIOChannelCommand QIOChannelCommand
;
36 * The QIOChannelCommand class provides a channel implementation
37 * that can transport data with an externally running command
38 * via its stdio streams.
41 struct QIOChannelCommand
{
50 * qio_channel_command_new_pid:
51 * @writefd: the FD connected to the command's stdin
52 * @readfd: the FD connected to the command's stdout
53 * @pid: the PID of the running child command
54 * @errp: pointer to a NULL-initialized error object
56 * Create a channel for performing I/O with the
57 * previously spawned command identified by @pid.
58 * The two file descriptors provide the connection
59 * to command's stdio streams, either one or which
60 * may be -1 to indicate that stream is not open.
62 * The channel will take ownership of the process
63 * @pid and will kill it when closing the channel.
64 * Similarly it will take responsibility for
65 * closing the file descriptors @writefd and @readfd.
67 * Returns: the command channel object, or NULL on error
70 qio_channel_command_new_pid(int writefd
,
75 * qio_channel_command_new_spawn:
76 * @argv: the NULL terminated list of command arguments
77 * @flags: the I/O mode, one of O_RDONLY, O_WRONLY, O_RDWR
78 * @errp: pointer to a NULL-initialized error object
80 * Create a channel for performing I/O with the
81 * command to be spawned with arguments @argv.
83 * Returns: the command channel object, or NULL on error
86 qio_channel_command_new_spawn(const char *const argv
[],
91 #endif /* QIO_CHANNEL_COMMAND_H__ */