From nobody Mon Feb 9 23:00:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643018986; cv=none; d=zohomail.com; s=zohoarc; b=UpgcakTmJXmliIR7h0hVL96OtxczQzBuVyaBWPYVwjp8hnv1GPCSWPv62Hq7A8yP7jUFihUcSY8NnBu/Z9G9tYVGKTZd/j0hjoynUA9qVFBFhjMIO/wOYqam9MfDOZStylJnDy5iwl7C9NTdMnp1c/Yb0rpNsfi1rzA8Ek2rsTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643018986; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K9Ufnwo5g1t3v4P6n0jBosYc892QoCb5v8TULiS/kJg=; b=UFN9BI49TZIHdFYAE1dAA7tNHc163BjgUPxrzLaUB393rVbn/znM3tQqy863s9xkijSN95YOPaGMD4oAsFdJLhY2IIZ4/BdhlWjeWNXLrgzki8Ro4TEkPyyBVpfRvttkfwR00nCOjSS/o0tJopWLV/OZR9Lsf5E6f1mTyGfsCds= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1643018986015991.1594107332967; Mon, 24 Jan 2022 02:09:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-iDjNRDfjPGet9BcsumuGBw-1; Mon, 24 Jan 2022 05:09:41 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 362EF85EE61; Mon, 24 Jan 2022 10:09:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 132DC70D5B; Mon, 24 Jan 2022 10:09:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A891D4A7CA; Mon, 24 Jan 2022 10:09:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20OA9a8X021659 for ; Mon, 24 Jan 2022 05:09:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1FCE96F16B; Mon, 24 Jan 2022 10:09:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86EC76F169 for ; Mon, 24 Jan 2022 10:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643018985; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=K9Ufnwo5g1t3v4P6n0jBosYc892QoCb5v8TULiS/kJg=; b=TtRkFsT37osoMUq0SykSLv2qewnCwKcFHEKAoofZ5JrYcDGvIAK+Aq/Wf58PrYVVPr0QO7 l3f/WQXQDt/h/klRmi1QydbTphDDoDMZ5kaFgMxEybP6+DOY8jApzB+a7W3SO/aA593uCq QQOlXmY1Z9asVf73KYZGjmbERIkLLhg= X-MC-Unique: iDjNRDfjPGet9BcsumuGBw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 11/11] conf: Separate out virDomainClockDef formatting Date: Mon, 24 Jan 2022 11:07:33 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1643018987669100001 Content-Type: text/plain; charset="utf-8" Currently, virDomainClockDef is formatted inside virDomainDefFormatInternalSetRootName() which is already long enough. Move the code into a new function (virDomainClockDefFormat()) and make the code use virXMLFormatElement() while at it. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 75 +++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a5fa3acd32..79cc58f8d7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26147,6 +26147,47 @@ virDomainTimerDefFormat(virBuffer *buf, virXMLFormatElement(buf, "timer", &timerAttr, &timerChld); } =20 + +static void +virDomainClockDefFormat(virBuffer *buf, + const virDomainClockDef *def, + unsigned int flags) +{ + virBuffer clockAttr =3D VIR_BUFFER_INITIALIZER; + virBuffer clockChld =3D VIR_BUFFER_INIT_CHILD(buf); + size_t n; + + virBufferAsprintf(&clockAttr, " offset=3D'%s'", + virDomainClockOffsetTypeToString(def->offset)); + switch (def->offset) { + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + if (def->data.utc_reset) + virBufferAddLit(&clockAttr, " adjustment=3D'reset'"); + break; + case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: + virBufferAsprintf(&clockAttr, " adjustment=3D'%lld' basis=3D'%s'", + def->data.variable.adjustment, + virDomainClockBasisTypeToString(def->data.variab= le.basis)); + if (flags & VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST && + def->data.variable.adjustment0) { + virBufferAsprintf(&clockAttr, " adjustment0=3D'%lld'", + def->data.variable.adjustment0); + } + break; + case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE: + virBufferEscapeString(&clockAttr, " timezone=3D'%s'", def->data.ti= mezone); + break; + } + + for (n =3D 0; n < def->ntimers; n++) { + virDomainTimerDefFormat(&clockChld, def->timers[n]); + } + + virXMLFormatElement(buf, "clock", &clockAttr, &clockChld); +} + + static void virDomainGraphicsAuthDefFormatAttr(virBuffer *buf, virDomainGraphicsAuthDef *def, @@ -28161,39 +28202,7 @@ virDomainDefFormatInternalSetRootName(virDomainDef= *def, if (virCPUDefFormatBufFull(buf, def->cpu, def->numa) < 0) return -1; =20 - virBufferAsprintf(buf, "clock.offset)); - switch (def->clock.offset) { - case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: - case VIR_DOMAIN_CLOCK_OFFSET_UTC: - if (def->clock.data.utc_reset) - virBufferAddLit(buf, " adjustment=3D'reset'"); - break; - case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: - virBufferAsprintf(buf, " adjustment=3D'%lld' basis=3D'%s'", - def->clock.data.variable.adjustment, - virDomainClockBasisTypeToString(def->clock.data.= variable.basis)); - if (flags & VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST) { - if (def->clock.data.variable.adjustment0) - virBufferAsprintf(buf, " adjustment0=3D'%lld'", - def->clock.data.variable.adjustment0); - } - break; - case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE: - virBufferEscapeString(buf, " timezone=3D'%s'", def->clock.data.tim= ezone); - break; - } - if (def->clock.ntimers =3D=3D 0) { - virBufferAddLit(buf, "/>\n"); - } else { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - for (n =3D 0; n < def->clock.ntimers; n++) { - virDomainTimerDefFormat(buf, def->clock.timers[n]); - } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } + virDomainClockDefFormat(buf, &def->clock, flags); =20 if (virDomainEventActionDefFormat(buf, def->onPoweroff, "on_poweroff", --=20 2.34.1