From nobody Thu May 15 14:10:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526296560349723.1562616827918; Mon, 14 May 2018 04:16:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC16630CE3A4; Mon, 14 May 2018 11:15:58 +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 970E230001EE; Mon, 14 May 2018 11:15:58 +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 50DB8180124C; Mon, 14 May 2018 11:15:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4EBFn0S009779 for ; Mon, 14 May 2018 07:15:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5893D5E7DE; Mon, 14 May 2018 11:15:49 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E702A17D57; Mon, 14 May 2018 11:15:45 +0000 (UTC) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 915C2388832; Mon, 14 May 2018 11:15:34 +0000 (UTC) Received: by mail-pf0-f194.google.com with SMTP id e9-v6so5867623pfi.4; Mon, 14 May 2018 04:15:34 -0700 (PDT) Received: from ps-f25-dev.eng.nutanix.com ([205.209.132.2]) by smtp.gmail.com with ESMTPSA id d4-v6sm13292667pgv.73.2018.05.14.04.15.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 May 2018 04:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3eugIJX3/Nq3wSpD8iQg4+OLPInbDjSmQDH8IUIcJmY=; b=OrMEtd3hv3vRArnoimzIp3FmjX+h2sSbmgX6BFT0VlV2c+qnZJBOUCgIHGUaWiKqQN K9pvXn7+FEDxCts44kii+a7X36lV1CUchVISUIiLy23jxOeAhfZxpfBV4M4fujKRAyVF ciVC62ct5pVSw82efx3w0U8HJbtNTGqYTanq2AqTG6djBhso59l3TBxtwMHUdn9D0X/o R6Ga9df5zaO5tIf7710R5YAxCIdoud3f0+8w4rvgfe78LrF/zVHj+6AKMdVGZThELw/a /y8EoXanBbagRZoE2yC7tSsXhMbzeoPlOI5o2BGaWmVEultao51jDKPaMeSETOzIsRTp zGgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3eugIJX3/Nq3wSpD8iQg4+OLPInbDjSmQDH8IUIcJmY=; b=MpHmI+OHq6gGiYVJPnHg1W79uj9SQIQREjZZR/PMbOgBmi2LO4i1Zn9oDYAeMZNw5I w+CDi0c3dEfTa1pJNBc+wbig/r+5BmiV7f2vT6G9gk9KxFBsGotJpt8fA6lp8wjWLjq0 pkwP8soXb67sOoPSUDFOGtn3Q2yOsJeFmxDgGsY8XRVT13RqVeUqIE0lBy2oY5ipsuik hJSgD/agshO0k0rbcA9bHrs6HOoe5wVyBHVtcn1o2EDhD9d4lsOqVjD88ng0bIOAQYug /2+U/zwScXoy2kwcSzV/+p2sLgYRH29pBzCzK6TViylNOw2Ht2C99tU9T1pZoIE3FI2W FyHQ== X-Gm-Message-State: ALKqPwcmMtdCWlt8hTjHvQvF2m382+U+fi7nu359vG7pByT8UgTPORA+ //XGuRScYFBw+lDyozNq9dRZaA== X-Google-Smtp-Source: AB8JxZq8b6OAZPkJM0pp0nvYMGWy1TxGviG1xFJW7/i6pQN/cxY7XaC/17wWtGWk/2SiW81xbppQKQ== X-Received: by 2002:a65:4bc6:: with SMTP id p6-v6mr6762740pgr.24.1526296533833; Mon, 14 May 2018 04:15:33 -0700 (PDT) From: Prerna Saxena To: libvir-list@redhat.com Date: Mon, 14 May 2018 04:15:14 -0700 Message-Id: <20180514111522.4363-5-saxenap.ltc@gmail.com> In-Reply-To: <20180514111522.4363-1-saxenap.ltc@gmail.com> References: <20180514111522.4363-1-saxenap.ltc@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 14 May 2018 11:15:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 14 May 2018 11:15:34 +0000 (UTC) for IP:'209.85.192.194' DOMAIN:'mail-pf0-f194.google.com' HELO:'mail-pf0-f194.google.com' FROM:'saxenap.ltc@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.696 (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.194 mail-pf0-f194.google.com 209.85.192.194 mail-pf0-f194.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: pkrempa@redhat.com, mprivozn@redhat.com Subject: [libvirt] [PATCH 04/12] Format the loader source appropriately. 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 14 May 2018 11:15:59 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If the initial XML used the old-style declaration as follows: /path/to/file we format it as was read. However, if it used new-style declaration: The formatter identifies that this is a new-style format and renders it likewise. Signed-off-by: Prerna Saxena --- src/conf/domain_conf.c | 86 ++++++++++++++++++++++++++++++++++++++++++++--= ---- 1 file changed, 76 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index be43695..d59a579 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18094,7 +18094,7 @@ virDomainLoaderNvramDefParseXML(xmlNodePtr node, } =20 loader->nvram->type =3D VIR_STORAGE_TYPE_LAST; - loader->nvram->oldStyleNvram =3D false; + loader->oldStyleNvram =3D false; =20 if ((tmp =3D virXMLPropString(node, "backing")) && (loader->nvram->type =3D virStorageTypeFromString(tmp)) <=3D 0) { @@ -26212,11 +26212,19 @@ virDomainHugepagesFormat(virBufferPtr buf, =20 static void virDomainLoaderDefFormat(virBufferPtr buf, - virDomainLoaderDefPtr loader) + virDomainLoaderDefPtr loader, + unsigned int flags) { const char *readonly =3D virTristateBoolTypeToString(loader->readonly); const char *secure =3D virTristateBoolTypeToString(loader->secure); const char *type =3D virDomainLoaderTypeToString(loader->type); + const char *backing =3D NULL; + + virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; + virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; + + virBufferSetChildIndent(&childBuf, buf); + =20 virBufferAddLit(buf, "secure) virBufferAsprintf(buf, " secure=3D'%s'", secure); =20 - virBufferAsprintf(buf, " type=3D'%s'>", type); + virBufferAsprintf(buf, " type=3D'%s'", type); + if (loader->src && + loader->src->type < VIR_STORAGE_TYPE_LAST) { + if (!loader->oldStyleLoader) { + /* Format this in the new style, using the + * sub-element */ + if (virDomainStorageSourceFormat(&attrBuf, &childBuf, loader->= src, + flags, 0) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot format loader source")); + goto cleanup; + } + + backing =3D virStorageTypeToString(loader->src->type); + virBufferAsprintf(buf, " backing=3D'%s'>", backing); + + if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < = 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot format loader source")); + goto cleanup; + } + + } else + /* Format this in the old-style, using absolute paths directly= . */ + virBufferAsprintf(buf, ">%s", loader->src->path); + } else + virBufferAddLit(buf, ">\n"); + + virBufferAddLit(buf, "\n"); =20 - virBufferEscapeString(buf, "%s\n", loader->path); if (loader->nvram || loader->templt) { + ignore_value(virBufferContentAndReset(&attrBuf)); + ignore_value(virBufferContentAndReset(&childBuf)); + virBufferSetChildIndent(&childBuf, buf); + virBufferAddLit(buf, "templt); - if (loader->nvram) - virBufferEscapeString(buf, ">%s\n", loader->nvram); - else - virBufferAddLit(buf, "/>\n"); + + if (loader->templt) + virBufferEscapeString(buf, " template=3D'%s'", loader->templt); + + if (loader->nvram) { + backing =3D virStorageTypeToString(loader->nvram->type); + if (!loader->oldStyleNvram) { + if (virDomainStorageSourceFormat(&attrBuf, &childBuf, + loader->nvram, flags, 0) < 0)= { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot format NVRAM source")); + virBufferAddLit(buf, ">\n\n"); + goto cleanup; + } + + virBufferEscapeString(buf, " backing=3D'%s'>", backing); + if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf= ) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot format NVRAM source")); + virBufferAddLit(buf, "\n"); + goto cleanup; + } + } else { + /* old-style NVRAM declaration found */ + virBufferAsprintf(buf, ">%s", loader->nvram->path); + } + virBufferAddLit(buf, "\n\n"); + } } +cleanup: + virBufferFreeAndReset(&attrBuf); + virBufferFreeAndReset(&childBuf); + return; } =20 static void @@ -26899,7 +26965,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, virBufferAsprintf(buf, "%s\n", def->os.init= group); =20 if (def->os.loader) - virDomainLoaderDefFormat(buf, def->os.loader); + virDomainLoaderDefFormat(buf, def->os.loader, flags); virBufferEscapeString(buf, "%s\n", def->os.kernel); virBufferEscapeString(buf, "%s\n", --=20 1.8.1.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list