From: "Denis V. Lunev" <den@openvz.org>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Olga Krishtal <okrishtal@virtuozzo.com>,
"Denis V. Lunev" <den@openvz.org>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH for 2.6 v3 1/1] qemu-char: append opt to stop truncation of serial file
Date: Fri, 4 Dec 2015 09:42:04 +0300 [thread overview]
Message-ID: <1449211324-17856-1-git-send-email-den@openvz.org> (raw)
From: Olga Krishtal <okrishtal@virtuozzo.com>
Our QA team wants to preserve serial output of the guest in between QEMU
runs to perform post-analysis.
By default this behavior is off (file is truncated each time QEMU is
started or device is plugged).
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Eric Blake <eblake@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
---
Changes from v1:
- s/parallels.com/virtuozzo.com/ :(
Changes from v2:
- fixed QAPI description
- added has_append filling and checking
qapi-schema.json | 5 ++++-
qemu-char.c | 14 +++++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/qapi-schema.json b/qapi-schema.json
index 18c9a6c..89201a9 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3020,11 +3020,14 @@
#
# @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:
diff --git a/qemu-char.c b/qemu-char.c
index 2969c44..66703e3 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3484,6 +3484,9 @@ static void qemu_chr_parse_file_out(QemuOpts *opts, ChardevBackend *backend,
}
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,
@@ -4041,6 +4044,9 @@ QemuOptsList qemu_chardev_opts = {
},{
.name = "chardev",
.type = QEMU_OPT_STRING,
+ },{
+ .name = "append",
+ .type = QEMU_OPT_BOOL,
},
{ /* end of list */ }
},
@@ -4101,7 +4107,13 @@ static CharDriverState *qmp_chardev_open_file(const char *id,
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;
--
2.5.0
next reply other threads:[~2015-12-04 6:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-04 6:42 Denis V. Lunev [this message]
2015-12-04 13:25 ` [Qemu-devel] [PATCH for 2.6 v3 1/1] qemu-char: append opt to stop truncation of serial file Eric Blake
2015-12-04 13:33 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1449211324-17856-1-git-send-email-den@openvz.org \
--to=den@openvz.org \
--cc=armbru@redhat.com \
--cc=okrishtal@virtuozzo.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).