From nobody Sun Feb 8 14:56:48 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=1629192430; cv=none; d=zohomail.com; s=zohoarc; b=b1GOwP7Mi2Z0GxYHK1F6q7D1mSCHaFj+RR8OCfo2xGkPQLeMujIYzYYPur/qZHdr9Ynz1i9pEebB7X1xfoH0Tviwf++SYR0jqHE37DKBPhBv1OoyhtKH2VV4K7MQ6rh/GSUqivxHCw8tP+xk2aAf30vZYd2Gwdmpy2gfMj1mo64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629192430; 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=FX4y/VBEwmGRbu6UmRcYtjZlpDIOQzy0D6gkaZk802A=; b=Ud6KBTJny8tJxIB1ifo9QjrBB92btPlNE5SEdoAosgec7F0QowQhEZHNAlrGPRQC9gfyZDGpha78c4jVa9woue27Zezsol5ICSBOD5SiIBV5wJJVofhGpcGFI+fEVpw0A2NHWoXJI93S1ui9hxOeWLGwegB3Gjyms7+nWz2EPXs= 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 1629192430073792.0097514300904; Tue, 17 Aug 2021 02:27:10 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-298-UdYDmcGXOoKNoEI7vL-wHw-1; Tue, 17 Aug 2021 05:27:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB465189CD05; Tue, 17 Aug 2021 09:27:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C86360FB8; Tue, 17 Aug 2021 09:27:02 +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 64F2F181A2AD; Tue, 17 Aug 2021 09:27:02 +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 17H9QoCa025120 for ; Tue, 17 Aug 2021 05:26:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E5B93A47; Tue, 17 Aug 2021 09:26:50 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.194.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0B875D6A8 for ; Tue, 17 Aug 2021 09:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629192429; 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=FX4y/VBEwmGRbu6UmRcYtjZlpDIOQzy0D6gkaZk802A=; b=hFdZCjp0bZ3osUL/+9hHYs0h4C4dUa63+VqXVQPWDmZcCJpFqDEeu1QiA31TkHCnylXWyv XqxRWffVQIcsvsEa0LM3aCZz3gEN2eQ0hylJI3PeEtkw6uaM1VivTbuyyNQpBrfs+YJ8lO mLA8LdKHURmRUO9EU+jqhRY6iJ2G7sw= X-MC-Unique: UdYDmcGXOoKNoEI7vL-wHw-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 3/5] conf: refactor virDomainResourceDefFormat Date: Tue, 17 Aug 2021 11:26:40 +0200 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.12 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: 1629192431630100005 Content-Type: text/plain; charset="utf-8" Prepare the function for additional sub-elements where all of the sub-elements are optional. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7dff6c8beb..571650bfd3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -26761,11 +26761,15 @@ static void virDomainResourceDefFormat(virBuffer *buf, virDomainResourceDef *def) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - virBufferEscapeString(buf, "%s\n", def->partiti= on); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + + if (!def) + return; + + if (def->partition) + virBufferEscapeString(&childBuf, "%s\n", de= f->partition); + + virXMLFormatElement(buf, "resource", NULL, &childBuf); } =20 =20 @@ -27918,8 +27922,7 @@ virDomainDefFormatInternalSetRootName(virDomainDef = *def, if (virDomainNumatuneFormatXML(buf, def->numa) < 0) return -1; =20 - if (def->resource) - virDomainResourceDefFormat(buf, def->resource); + virDomainResourceDefFormat(buf, def->resource); =20 for (i =3D 0; i < def->nsysinfo; i++) { if (virSysinfoFormat(buf, def->sysinfo[i]) < 0) --=20 2.31.1