#
# @in: #optional The name of the input file
# @out: The name of the output file
+# @append: #optional Open the file in append mode (default false to
+# truncate) (Since 2.6)
#
# Since: 1.4
##
{ 'struct': 'ChardevFile', 'data': { '*in' : 'str',
- 'out' : 'str' } }
+ 'out' : 'str',
+ '*append': 'bool' } }
##
# @ChardevHostdev:
}
backend->u.file = g_new0(ChardevFile, 1);
backend->u.file->out = g_strdup(path);
+
+ backend->u.file->has_append = true;
+ backend->u.file->append = qemu_opt_get_bool(opts, "append", false);
}
static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend,
},{
.name = "chardev",
.type = QEMU_OPT_STRING,
+ },{
+ .name = "append",
+ .type = QEMU_OPT_BOOL,
},
{ /* end of list */ }
},
ChardevFile *file = backend->u.file;
int flags, in = -1, out;
- flags = O_WRONLY | O_TRUNC | O_CREAT | O_BINARY;
+ 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 NULL;