[libvirt] [PATCH 03/34] conf: Introduce virDomainStorageSourceFormatFull

Ján Tomko jtomko at redhat.com
Mon Mar 18 17:40:26 UTC 2019


On Mon, Mar 18, 2019 at 04:54:52PM +0100, Peter Krempa wrote:
>The new function formats a virStorageSource into an XML element which
>already contains type and format for simpler handling.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/conf/domain_conf.c   | 39 +++++++++++++++++++++++++++++++++++++++
> src/conf/domain_conf.h   |  8 ++++++++
> src/libvirt_private.syms |  1 +
> 3 files changed, 48 insertions(+)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index 4083839fc8..9f1f46c905 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -23857,6 +23857,45 @@ virDomainStorageSourceFormat(virBufferPtr attrBuf,
> }
>
>
>+/**
>+ * virDomainStorageSourceFormatFull:
>+ * @buf: output buffer
>+ * @src: storage source to format
>+ * @elemname: name of the top level element to use
>+ * @status: output status-XML style private data
>+ * @xmlopt: formatter callback data structure
>+ *
>+ * Formats @src into a XML element called @elemname. The element has both 'type'
>+ * and 'format' attributes and thus is fully standalone.
>+ */
>+int
>+virDomainStorageSourceFormatFull(virBufferPtr buf,
>+                                 virStorageSourcePtr src,
>+                                 const char *elemname,
>+                                 bool status,
>+                                 virDomainXMLOptionPtr xmlopt)
>+{
>+    VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
>+    VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
>+    unsigned int flags = 0;
>+
>+    if (status)
>+        flags |= VIR_DOMAIN_DEF_FORMAT_STATUS;
>+
>+    virBufferSetChildIndent(&childBuf, buf);
>+
>+    virBufferAsprintf(&attrBuf, " type='%s' format='%s'",
>+                      virStorageTypeToString(src->type),
>+                      virStorageFileFormatTypeToString(src->format));
>+
>+    if (virDomainStorageSourceFormat(&attrBuf, &childBuf, src, flags,
>+                                     true, true, 0, xmlopt) < 0)

Everything is formatted, including the index attribute.

>+        return -1;
>+
>+    return virXMLFormatElement(buf, elemname, &attrBuf, &childBuf);
>+}
>+
>+
> static int
> virDomainDiskSourceFormatInternal(virBufferPtr buf,
>                                   virStorageSourcePtr src,

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190318/270ab7ba/attachment-0001.sig>


More information about the libvir-list mailing list