aboutsummaryrefslogtreecommitdiff
path: root/chardev/char.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-12-12 18:51:52 +0300
committerMarc-André Lureau <marcandre.lureau@redhat.com>2017-01-31 23:31:21 +0400
commit6fdafac1c165821054e1d0786bd6630e90f2379f (patch)
tree2d50927d52eeeddaf4a66ae7d7be6a1e1b5d8bec /chardev/char.c
parent3b4482a26dd6d722004fcb7ee031064ee50288e3 (diff)
char: move file chardev in its own file
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'chardev/char.c')
-rw-r--r--chardev/char.c106
1 files changed, 0 insertions, 106 deletions
diff --git a/chardev/char.c b/chardev/char.c
index 05fceb0d73..7ec867ffc8 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -1687,26 +1687,6 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend)
backend->logappend = qemu_opt_get_bool(opts, "logappend", false);
}
-
-static void qemu_chr_parse_file_out(QemuOpts *opts, ChardevBackend *backend,
- Error **errp)
-{
- const char *path = qemu_opt_get(opts, "path");
- ChardevFile *file;
-
- backend->type = CHARDEV_BACKEND_KIND_FILE;
- if (path == NULL) {
- error_setg(errp, "chardev: file: no filename given");
- return;
- }
- file = backend->u.file.data = g_new0(ChardevFile, 1);
- qemu_chr_parse_common(opts, qapi_ChardevFile_base(file));
- file->out = g_strdup(path);
-
- file->has_append = true;
- file->append = qemu_opt_get_bool(opts, "append", false);
-}
-
static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend,
Error **errp)
{
@@ -2260,41 +2240,6 @@ QemuOptsList qemu_chardev_opts = {
#ifdef _WIN32
-static void qmp_chardev_open_file(Chardev *chr,
- ChardevBackend *backend,
- bool *be_opened,
- Error **errp)
-{
- ChardevFile *file = backend->u.file.data;
- HANDLE out;
- DWORD accessmode;
- DWORD flags;
-
- if (file->has_in) {
- error_setg(errp, "input file not supported");
- return;
- }
-
- if (file->has_append && file->append) {
- /* Append to file if it already exists. */
- accessmode = FILE_GENERIC_WRITE & ~FILE_WRITE_DATA;
- flags = OPEN_ALWAYS;
- } else {
- /* Truncate file if it already exists. */
- accessmode = GENERIC_WRITE;
- flags = CREATE_ALWAYS;
- }
-
- out = CreateFile(file->out, accessmode, FILE_SHARE_READ, NULL, flags,
- FILE_ATTRIBUTE_NORMAL, NULL);
- if (out == INVALID_HANDLE_VALUE) {
- error_setg(errp, "open %s failed", file->out);
- return;
- }
-
- qemu_chr_open_win_file(chr, out);
-}
-
static void qmp_chardev_open_serial(Chardev *chr,
ChardevBackend *backend,
bool *be_opened,
@@ -2307,38 +2252,6 @@ static void qmp_chardev_open_serial(Chardev *chr,
#else /* WIN32 */
-static void qmp_chardev_open_file(Chardev *chr,
- ChardevBackend *backend,
- bool *be_opened,
- Error **errp)
-{
- ChardevFile *file = backend->u.file.data;
- int flags, in = -1, out;
-
- flags = O_WRONLY | O_CREAT | O_BINARY;
- if (file->has_append && file->append) {
- flags |= O_APPEND;
- } else {
- flags |= O_TRUNC;
- }
-
- out = qmp_chardev_open_file_source(file->out, flags, errp);
- if (out < 0) {
- return;
- }
-
- if (file->has_in) {
- flags = O_RDONLY;
- in = qmp_chardev_open_file_source(file->in, flags, errp);
- if (in < 0) {
- qemu_close(out);
- return;
- }
- }
-
- qemu_chr_open_fd(chr, in, out);
-}
-
#ifdef HAVE_CHARDEV_SERIAL
static void qmp_chardev_open_serial(Chardev *chr,
ChardevBackend *backend,
@@ -2415,24 +2328,6 @@ static const TypeInfo char_parallel_type_info = {
#endif /* WIN32 */
-static void char_file_class_init(ObjectClass *oc, void *data)
-{
- ChardevClass *cc = CHARDEV_CLASS(oc);
-
- cc->parse = qemu_chr_parse_file_out;
- cc->open = qmp_chardev_open_file;
-}
-
-static const TypeInfo char_file_type_info = {
- .name = TYPE_CHARDEV_FILE,
-#ifdef _WIN32
- .parent = TYPE_CHARDEV_WIN,
-#else
- .parent = TYPE_CHARDEV_FD,
-#endif
- .class_init = char_file_class_init,
-};
-
#ifdef HAVE_CHARDEV_SERIAL
static void char_serial_class_init(ObjectClass *oc, void *data)
@@ -2558,7 +2453,6 @@ void qemu_chr_cleanup(void)
static void register_types(void)
{
type_register_static(&char_type_info);
- type_register_static(&char_file_type_info);
type_register_static(&char_stdio_type_info);
#ifdef HAVE_CHARDEV_SERIAL
type_register_static(&char_serial_type_info);