From nobody Mon Feb 9 07:23:26 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=1643018962; cv=none; d=zohomail.com; s=zohoarc; b=HXgNvXZFvyFijJAoO/K6WjsNHmVSDQw99Uhg7EjSikydcoOYjwGy1tUS30cF9OFI0L0c9yu7Sr4ns2jeDRv5r91bUPMucxmGzRMy8+IYjAlvklWb+j08eSjVafO4wHVExc+6gRZSsDREe7t0LKLTBf+jWcKZVA75alfMjhW95CU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643018962; 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=WpOqb9hiq5vCWP5csbTTt8S43pM8uGz0QyGoRAxdZ3w=; b=XGhdDx5YKSyhPX4ZCaAO+ztb8RoATBTZ0XrISkQtPLZ3XwjMb8IW8m59VFyl4+5TDLusj+mLOLOEiVRs8h5rBmAk0JiibU0IzvbtUhrh865LHanDTyb8BYPVWk8vh3sWcZRWclNI647EM0sWYSd4hklAQ2jjmKhk+Ds9ffYOHlM= 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 1643018962365694.6898799248085; Mon, 24 Jan 2022 02:09:22 -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-622-PhgZgJtRPf-ksbhMaMXb3A-1; Mon, 24 Jan 2022 05:09:18 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 429CC1091DBA; Mon, 24 Jan 2022 10:09:13 +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 E70C41F420; Mon, 24 Jan 2022 10:09:12 +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 A803F4A7CB; Mon, 24 Jan 2022 10:09:12 +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 20OA8ra9021310 for ; Mon, 24 Jan 2022 05:08:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id A1CC76F119; Mon, 24 Jan 2022 10:08:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1324C6D03D for ; Mon, 24 Jan 2022 10:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643018961; 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=WpOqb9hiq5vCWP5csbTTt8S43pM8uGz0QyGoRAxdZ3w=; b=do40/yZ4gSbpWqjgLwfeWfMN93lz58wSj/75HD8Hyewn4Z3Ae0o/Crm86piEhboNNLAPyJ zwjvB/chWOEf0nIO4jd1ZbX2ZfLmaazewjs8DfNZZZLDkm/sWYMoU5x3AvvWxd7jNRDBOQ mPWEsP28qn9OTezN2cZoM9LAt3reyKI= X-MC-Unique: PhgZgJtRPf-ksbhMaMXb3A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 09/11] conf: Rework virDomainTimerDefFormat() Date: Mon, 24 Jan 2022 11:07:31 +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.84 on 10.5.11.23 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: 1643018965408100001 Content-Type: text/plain; charset="utf-8" Use virXMLFormatElement() to simplify virDomainTimerDefFormat(). Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 48 +++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c0851f4f60..55626a6d01 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26104,57 +26104,47 @@ static int virDomainTimerDefFormat(virBuffer *buf, virDomainTimerDef *def) { - const char *name =3D virDomainTimerNameTypeToString(def->name); + virBuffer timerAttr =3D VIR_BUFFER_INITIALIZER; + virBuffer timerChld =3D VIR_BUFFER_INIT_CHILD(buf); + virBuffer catchupAttr =3D VIR_BUFFER_INITIALIZER; =20 - if (!name) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected timer name %d"), def->name); - return -1; - } - virBufferAsprintf(buf, "name)); =20 if (def->present) { - virBufferAsprintf(buf, " present=3D'%s'", + virBufferAsprintf(&timerAttr, " present=3D'%s'", virTristateBoolTypeToString(def->present)); } =20 if (def->tickpolicy) { - virBufferAsprintf(buf, " tickpolicy=3D'%s'", + virBufferAsprintf(&timerAttr, " tickpolicy=3D'%s'", virDomainTimerTickpolicyTypeToString(def->tickpo= licy)); } =20 if (def->track !=3D VIR_DOMAIN_TIMER_TRACK_NONE) { - virBufferAsprintf(buf, " track=3D'%s'", + virBufferAsprintf(&timerAttr, " track=3D'%s'", virDomainTimerTrackTypeToString(def->track)); } =20 if (def->name =3D=3D VIR_DOMAIN_TIMER_NAME_TSC) { if (def->frequency > 0) - virBufferAsprintf(buf, " frequency=3D'%llu'", def->frequency); + virBufferAsprintf(&timerAttr, " frequency=3D'%llu'", def->freq= uency); =20 if (def->mode) { - virBufferAsprintf(buf, " mode=3D'%s'", + virBufferAsprintf(&timerAttr, " mode=3D'%s'", virDomainTimerModeTypeToString(def->mode)); } } =20 - if (def->catchup.threshold =3D=3D 0 && def->catchup.slew =3D=3D 0 && - def->catchup.limit =3D=3D 0) { - virBufferAddLit(buf, "/>\n"); - } else { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferAddLit(buf, "catchup.threshold > 0) - virBufferAsprintf(buf, " threshold=3D'%lu'", def->catchup.thre= shold); - if (def->catchup.slew > 0) - virBufferAsprintf(buf, " slew=3D'%lu'", def->catchup.slew); - if (def->catchup.limit > 0) - virBufferAsprintf(buf, " limit=3D'%lu'", def->catchup.limit); - virBufferAddLit(buf, "/>\n"); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } + if (def->catchup.threshold > 0) + virBufferAsprintf(&catchupAttr, " threshold=3D'%lu'", def->catchup= .threshold); + if (def->catchup.slew > 0) + virBufferAsprintf(&catchupAttr, " slew=3D'%lu'", def->catchup.slew= ); + if (def->catchup.limit > 0) + virBufferAsprintf(&catchupAttr, " limit=3D'%lu'", def->catchup.lim= it); + + virXMLFormatElement(&timerChld, "catchup", &catchupAttr, NULL); + virXMLFormatElement(buf, "timer", &timerAttr, &timerChld); =20 return 0; } --=20 2.34.1