mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-09-09 08:17:53 -06:00

Simplify qio_channel_command_new_spawn() with GSpawn API. This will allow to build for WIN32 in the following patches. As pointed out by Daniel Berrangé: there is a change in semantics here too. The current code only touches stdin/stdout/stderr. Any other FDs which do NOT have O_CLOEXEC set will be inherited. With the new code, all FDs except stdin/out/err will be explicitly closed, because we don't set the flag G_SPAWN_LEAVE_DESCRIPTORS_OPEN. The only place we use QIOChannelCommand today is the migration exec: protocol, and that is only declared to use stdin/stdout. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20221006113657.2656108-5-marcandre.lureau@redhat.com>
65 lines
1.8 KiB
C
65 lines
1.8 KiB
C
/*
|
|
* QEMU I/O channels external command driver
|
|
*
|
|
* Copyright (c) 2015 Red Hat, Inc.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
#ifndef QIO_CHANNEL_COMMAND_H
|
|
#define QIO_CHANNEL_COMMAND_H
|
|
|
|
#include "io/channel.h"
|
|
#include "qom/object.h"
|
|
|
|
#define TYPE_QIO_CHANNEL_COMMAND "qio-channel-command"
|
|
OBJECT_DECLARE_SIMPLE_TYPE(QIOChannelCommand, QIO_CHANNEL_COMMAND)
|
|
|
|
|
|
|
|
/**
|
|
* QIOChannelCommand:
|
|
*
|
|
* The QIOChannelCommand class provides a channel implementation
|
|
* that can transport data with an externally running command
|
|
* via its stdio streams.
|
|
*/
|
|
|
|
struct QIOChannelCommand {
|
|
QIOChannel parent;
|
|
int writefd;
|
|
int readfd;
|
|
GPid pid;
|
|
};
|
|
|
|
|
|
/**
|
|
* qio_channel_command_new_spawn:
|
|
* @argv: the NULL terminated list of command arguments
|
|
* @flags: the I/O mode, one of O_RDONLY, O_WRONLY, O_RDWR
|
|
* @errp: pointer to a NULL-initialized error object
|
|
*
|
|
* Create a channel for performing I/O with the
|
|
* command to be spawned with arguments @argv.
|
|
*
|
|
* Returns: the command channel object, or NULL on error
|
|
*/
|
|
QIOChannelCommand *
|
|
qio_channel_command_new_spawn(const char *const argv[],
|
|
int flags,
|
|
Error **errp);
|
|
|
|
|
|
#endif /* QIO_CHANNEL_COMMAND_H */
|