From: Peter Krempa Date: Wed, 13 Dec 2017 16:04:54 +0000 (+0100) Subject: util: storage: Add helpers to parse and format relPath into privateData X-Git-Tag: v4.0.0-rc1~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd31709351142a2770d2b9baa7755eaed672710a;p=thirdparty%2Flibvirt.git util: storage: Add helpers to parse and format relPath into privateData This will be the first private piece of data that will need to be stored in the XML for some drivers. Add helpers which will do it. --- diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b4b72c0734..d5c3b9abb5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2734,6 +2734,8 @@ virStorageSourceParseRBDColonString; virStorageSourcePoolDefFree; virStorageSourcePoolModeTypeFromString; virStorageSourcePoolModeTypeToString; +virStorageSourcePrivateDataFormatRelPath; +virStorageSourcePrivateDataParseRelPath; virStorageSourceUpdateBackingSizes; virStorageSourceUpdateCapacity; virStorageSourceUpdatePhysicalSize; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 6594715e5e..5780180a94 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4086,3 +4086,23 @@ virStorageSourceNetworkAssignDefaultPorts(virStorageSourcePtr src) src->hosts[i].port = virStorageSourceNetworkDefaultPort(src->protocol); } } + + +int +virStorageSourcePrivateDataParseRelPath(xmlXPathContextPtr ctxt, + virStorageSourcePtr src) +{ + src->relPath = virXPathString("string(./relPath)", ctxt); + return 0; +} + + +int +virStorageSourcePrivateDataFormatRelPath(virStorageSourcePtr src, + virBufferPtr buf) +{ + if (src->relPath) + virBufferEscapeString(buf, "%s\n", src->relPath); + + return 0; +} diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 24382a0a6b..ecd806c93f 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -441,4 +441,12 @@ bool virStorageSourceHasBacking(const virStorageSource *src); +int +virStorageSourcePrivateDataParseRelPath(xmlXPathContextPtr ctxt, + virStorageSourcePtr src); +int +virStorageSourcePrivateDataFormatRelPath(virStorageSourcePtr src, + virBufferPtr buf); + + #endif /* __VIR_STORAGE_FILE_H__ */