tests: Fixes test-io-channel-file by mask only owner file state mask bits
[qemu/ar7.git] / include / io / channel-command.h
blob4b64ff011bec4f5760039343492e364d4ef8feef
1 /*
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"
25 #include "qom/object.h"
27 #define TYPE_QIO_CHANNEL_COMMAND "qio-channel-command"
28 typedef struct QIOChannelCommand QIOChannelCommand;
29 DECLARE_INSTANCE_CHECKER(QIOChannelCommand, QIO_CHANNEL_COMMAND,
30 TYPE_QIO_CHANNEL_COMMAND)
34 /**
35 * QIOChannelCommand:
37 * The QIOChannelCommand class provides a channel implementation
38 * that can transport data with an externally running command
39 * via its stdio streams.
42 struct QIOChannelCommand {
43 QIOChannel parent;
44 int writefd;
45 int readfd;
46 pid_t pid;
50 /**
51 * qio_channel_command_new_pid:
52 * @writefd: the FD connected to the command's stdin
53 * @readfd: the FD connected to the command's stdout
54 * @pid: the PID of the running child command
55 * @errp: pointer to a NULL-initialized error object
57 * Create a channel for performing I/O with the
58 * previously spawned command identified by @pid.
59 * The two file descriptors provide the connection
60 * to command's stdio streams, either one or which
61 * may be -1 to indicate that stream is not open.
63 * The channel will take ownership of the process
64 * @pid and will kill it when closing the channel.
65 * Similarly it will take responsibility for
66 * closing the file descriptors @writefd and @readfd.
68 * Returns: the command channel object, or NULL on error
70 QIOChannelCommand *
71 qio_channel_command_new_pid(int writefd,
72 int readfd,
73 pid_t pid);
75 /**
76 * qio_channel_command_new_spawn:
77 * @argv: the NULL terminated list of command arguments
78 * @flags: the I/O mode, one of O_RDONLY, O_WRONLY, O_RDWR
79 * @errp: pointer to a NULL-initialized error object
81 * Create a channel for performing I/O with the
82 * command to be spawned with arguments @argv.
84 * Returns: the command channel object, or NULL on error
86 QIOChannelCommand *
87 qio_channel_command_new_spawn(const char *const argv[],
88 int flags,
89 Error **errp);
92 #endif /* QIO_CHANNEL_COMMAND_H */