From patchwork Thu Dec 3 06:24:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 552047 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1BB291402A0 for ; Thu, 3 Dec 2015 17:24:47 +1100 (AEDT) Received: from localhost ([::1]:33540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4NJs-00058a-UC for incoming@patchwork.ozlabs.org; Thu, 03 Dec 2015 01:24:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4NJd-0004rI-NH for qemu-devel@nongnu.org; Thu, 03 Dec 2015 01:24:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4NJa-0000vW-J2 for qemu-devel@nongnu.org; Thu, 03 Dec 2015 01:24:29 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:35150 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4NJa-0000tl-5i for qemu-devel@nongnu.org; Thu, 03 Dec 2015 01:24:26 -0500 Received: from irbis.sw.ru ([10.30.2.139]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id tB36OCYB016182; Thu, 3 Dec 2015 09:24:13 +0300 (MSK) From: "Denis V. Lunev" To: Date: Thu, 3 Dec 2015 09:24:12 +0300 Message-Id: <1449123852-9260-1-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.1.4 X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Cc: Olga Krishtal , qemu-devel@nongnu.org, Markus Armbruster , "Denis V. Lunev" , Paolo Bonzini Subject: [Qemu-devel] [PATCH for 2.6 1/1] qemu-char: append opt to stop truncation of serial file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Olga Krishtal Our QA teams 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 Signed-off-by: Denis V. Lunev CC: Eric Blake CC: Markus Armbruster CC: Paolo Bonzini --- qapi-schema.json | 7 ++++++- qemu-char.c | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 8b1a423..802c138 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3020,11 +3020,16 @@ # # @in: #optional The name of the input file # @out: The name of the output file +# @append: #optional Open the file in append mode to preserve the content in +# between QEMU runs. +# +# 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 5448b0f..58454e2 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3479,6 +3479,7 @@ 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->append = qemu_opt_get_bool(opts, "append", false); } static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend, @@ -4036,6 +4037,9 @@ QemuOptsList qemu_chardev_opts = { },{ .name = "chardev", .type = QEMU_OPT_STRING, + },{ + .name = "append", + .type = QEMU_OPT_BOOL, }, { /* end of list */ } }, @@ -4096,7 +4100,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->append) { + flags |= O_APPEND; + } else { + flags |= O_TRUNC; + } + out = qmp_chardev_open_file_source(file->out, flags, errp); if (out < 0) { return NULL;