[libvirt] [PATCHv2 25/62] conf: Implement private data formatting and parsing for disks

Ján Tomko jtomko at redhat.com
Wed Aug 15 12:47:12 UTC 2018


On Mon, Aug 13, 2018 at 05:59:59PM +0200, Peter Krempa wrote:
>Allow storing of private data in the status XML for disks.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/conf/domain_conf.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
> src/conf/domain_conf.h |  7 ++++++
> 2 files changed, 67 insertions(+)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index 93d745bb74..c10e0a9eca 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -9676,6 +9676,30 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
> }
>
>
>+static int
>+virDomainDiskDefParsePrivateData(xmlXPathContextPtr ctxt,
>+                                 virDomainDiskDefPtr disk,
>+                                 virDomainXMLOptionPtr xmlopt)
>+{
>+    xmlNodePtr save_node = ctxt->node;
>+    int ret = 0;

Unusual to default to success.

Consider:
xmlNodePtr private_node = virXPathNode("./privateData", ctxt);
if (!private_node)
    return 0;

before overwriting ctxt->node

>+
>+    if (!xmlopt ||
>+        !xmlopt->privateData.diskParse)
>+        return 0;
>+
>+    if (!(ctxt->node = virXPathNode("./privateData", ctxt)))
>+        goto cleanup;
>+
>+    if (xmlopt->privateData.diskParse(ctxt, disk) < 0)
>+        ret = -1;
>+

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: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180815/b06a817b/attachment-0001.sig>


More information about the libvir-list mailing list