From nobody Mon Feb 9 10:30:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1673340188; cv=none; d=zohomail.com; s=zohoarc; b=K2i0Cur1z5YKNkP3X2Eh362Mqg7VYGRkDJuh8iDuOLu6XS/3MtfPcrtaDc88YXnfrCVjV/DOj2iCXZKoTnTit4osL2sxfGdo8g4LMjt4DNScvLtsnO5Bmdo7I5uVtn9UGUUruuOdTk+49qcKJET1AJfk/SoX0v5AaVW3OUUbajU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673340188; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=EzF5GtHSrNBp6QHIMalNnzZOFhT4ZgJJicOP1IslN4M=; b=h71bKyf3pEqSxNSmjzu/8VKgN5t5lucpEUqznmAt89EZxBwA3IGNN8Vj8Ngbr+jmomZAc7eNNfqy+YaK29eeyO/jbN8BdwotIgyalEWd3NIubi5NcjBuz3XeOa9ExSGLm/hLU1JSyLujzfgiJy4NjNVaz6kbqDInTaCHy44f67w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673340188052497.6425180780534; Tue, 10 Jan 2023 00:43:08 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-449-__5T9l_6Ma68CiZkaUaH0w-1; Tue, 10 Jan 2023 03:43:00 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C5B5101B429; Tue, 10 Jan 2023 08:42:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCABCC16031; Tue, 10 Jan 2023 08:42:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AE96F1940377; Tue, 10 Jan 2023 08:42:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9C7E81946587 for ; Tue, 10 Jan 2023 08:42:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3E53D2166B29; Tue, 10 Jan 2023 08:42:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37D2A2166B26 for ; Tue, 10 Jan 2023 08:42:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 15E49101A521 for ; Tue, 10 Jan 2023 08:42:53 +0000 (UTC) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-261-ezohArtfPRK9i5QAW2xWHQ-1; Tue, 10 Jan 2023 03:42:51 -0500 Received: from [192.168.16.202] (helo=dv.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.95) (envelope-from ) id 1pFADQ-003dMb-GO; Tue, 10 Jan 2023 09:42:40 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673340187; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=EzF5GtHSrNBp6QHIMalNnzZOFhT4ZgJJicOP1IslN4M=; b=IBgTSuC0Z0mpD4jUq0kEnFREBYHwD5w+lrQ8ngdNJuDjlws58MO/6vZJ6V4aoPhU45pAYT mPxwJdAz/refqOoSSWRmdOx2z8KNKHgw2bmGQKzUBFq1wuU7MRotPnGkkb96aNoPuxG/jZ Vv9rceftjjS6ebVKgSm8A+fvE+myxNY= X-MC-Unique: __5T9l_6Ma68CiZkaUaH0w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: ezohArtfPRK9i5QAW2xWHQ-1 From: Oleg Vasilev To: libvir-list@redhat.com Subject: [PATCH v2] qemu: add append mode config for serial file Date: Tue, 10 Jan 2023 14:42:34 +0600 Message-Id: <20230110084234.160760-1-oleg.vasilev@virtuozzo.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Kletzander , Den Lunev , Oleg Vasilev Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673340188964100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Serial log file contains lots of useful information for debugging configuration problems. It makes sense to preserve the log in between restarts, so that one can later figure out what was going on. Before that, we could do that on a per-domain basis, now we can configure it once for all domains. Signed-off-by: Oleg Vasilev --- src/qemu/libvirtd_qemu.aug | 3 ++ src/qemu/qemu.conf.in | 9 ++++ src/qemu/qemu_conf.c | 4 ++ src/qemu/qemu_conf.h | 2 + src/qemu/qemu_domain.c | 13 +++++ src/qemu/test_libvirtd_qemu.aug.in | 1 + tests/qemuxml2argvdata/serial-append.xml | 53 +++++++++++++++++++ .../qemuxml2xmloutdata/serial-append.off.xml | 53 +++++++++++++++++++ tests/qemuxml2xmloutdata/serial-append.on.xml | 53 +++++++++++++++++++ tests/qemuxml2xmloutdata/serial-append.xml | 53 +++++++++++++++++++ tests/qemuxml2xmltest.c | 10 ++++ 11 files changed, 254 insertions(+) create mode 100644 tests/qemuxml2argvdata/serial-append.xml create mode 100644 tests/qemuxml2xmloutdata/serial-append.off.xml create mode 100644 tests/qemuxml2xmloutdata/serial-append.on.xml create mode 100644 tests/qemuxml2xmloutdata/serial-append.xml diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index ed097ea3d9..7f3eec7cfd 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -147,6 +147,8 @@ module Libvirtd_qemu =3D =20 let capability_filters_entry =3D str_array_entry "capability_filters" =20 + let serial_file_append_entry =3D str_entry "serial_file_append" + (* Each entry in the config is one of the following ... *) let entry =3D default_tls_entry | vnc_entry @@ -171,6 +173,7 @@ module Libvirtd_qemu =3D | swtpm_entry | capability_filters_entry | obsolete_entry + | serial_file_append_entry =20 let comment =3D [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \= t\n][^\n]*)?/ . del /\n/ "\n" ] let empty =3D [ label "#empty" . eol ] diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index 3895d42514..9c9a535e8d 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -968,3 +968,12 @@ # "full" - both QEMU and its helper processes are placed into separate # scheduling group #sched_core =3D "none" + +# Default append mode for writing to serial file. QEMU will set the chosen +# value everytime it processes the config, unless some value is already th= ere. +# +# Possible options are: +# "default" - leave as-is for QEMU to decide. +# "on" - set append value to "on", meaning file won't be truncated on= restart +# "off" - set append value to "off", file will be cleared on restart +#serial_file_append =3D "default" diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index ae5bbcd138..bfd93a168f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -288,6 +288,7 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privil= eged, return NULL; =20 cfg->deprecationBehavior =3D g_strdup("none"); + cfg->serialFileAppend =3D g_strdup("default"); =20 return g_steal_pointer(&cfg); } @@ -376,6 +377,7 @@ static void virQEMUDriverConfigDispose(void *obj) g_strfreev(cfg->capabilityfilters); =20 g_free(cfg->deprecationBehavior); + g_free(cfg->serialFileAppend); } =20 =20 @@ -903,6 +905,8 @@ virQEMUDriverConfigLoadDebugEntry(virQEMUDriverConfig *= cfg, return -1; if (virConfGetValueString(conf, "deprecation_behavior", &cfg->deprecat= ionBehavior) < 0) return -1; + if (virConfGetValueString(conf, "serial_file_append", &cfg->serialFile= Append) < 0) + return -1; =20 return 0; } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 8cf2dd2ec5..316200f38d 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -229,6 +229,8 @@ struct _virQEMUDriverConfig { char *deprecationBehavior; =20 virQEMUSchedCore schedCore; + + char *serialFileAppend; }; =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUDriverConfig, virObjectUnref); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8ae458ae45..0d1fe1ffcc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -37,6 +37,7 @@ #include "qemu_validate.h" #include "qemu_namespace.h" #include "viralloc.h" +#include "virenum.h" #include "virlog.h" #include "virerror.h" #include "viridentity.h" @@ -5357,6 +5358,8 @@ qemuDomainChrDefPostParse(virDomainChrDef *chr, virQEMUDriver *driver, unsigned int parseFlags) { + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + /* Historically, isa-serial and the default matched, so in order to * maintain backwards compatibility we map them here. The actual defau= lt * will be picked below based on the architecture and machine type. */ @@ -5428,6 +5431,16 @@ qemuDomainChrDefPostParse(virDomainChrDef *chr, } } =20 + + if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && + chr->source && + chr->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_FILE && + chr->source->data.file.append =3D=3D VIR_TRISTATE_SWITCH_ABSENT) { + + chr->source->data.file.append =3D + virTristateSwitchTypeFromString(cfg->serialFileAppend); + } + return 0; } =20 diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index 1dbd692921..d1ca9c8d3d 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -117,3 +117,4 @@ module Test_libvirtd_qemu =3D } { "deprecation_behavior" =3D "none" } { "sched_core" =3D "none" } +{ "serial_file_append" =3D "default" } diff --git a/tests/qemuxml2argvdata/serial-append.xml b/tests/qemuxml2argvd= ata/serial-append.xml new file mode 100644 index 0000000000..662a711dd0 --- /dev/null +++ b/tests/qemuxml2argvdata/serial-append.xml @@ -0,0 +1,53 @@ + + machine + 2187c512-ff97-47d7-b67c-c02d3bdc219d + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +