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@xxxxxxxxxx> --- 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@xxxxxxxxxx> Jano
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list