[libvirt] [PATCH 03/14] conf: Don't require 'def' in virDomainDiskDefParse

Peter Krempa posted 14 patches 7 years, 1 month ago
[libvirt] [PATCH 03/14] conf: Don't require 'def' in virDomainDiskDefParse
Posted by Peter Krempa 7 years, 1 month ago
In some use cases (mostly in tests) it is not required to check the
seclabel definition validity. Add possibility to call
virDomainDiskDefParse without the domain definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/conf/domain_conf.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e2bad48cc8..ac3a3d9966 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15873,6 +15873,8 @@ virDomainDiskDefParse(const char *xmlStr,
     xmlDocPtr xml;
     xmlXPathContextPtr ctxt = NULL;
     virDomainDiskDefPtr disk = NULL;
+    virSecurityLabelDefPtr *seclabels = NULL;
+    size_t nseclabels = 0;

     if (!(xml = virXMLParseStringCtxt(xmlStr, _("(disk_definition)"), &ctxt)))
         goto cleanup;
@@ -15884,10 +15886,13 @@ virDomainDiskDefParse(const char *xmlStr,
         goto cleanup;
     }

+    if (def) {
+        seclabels = def->seclabels;
+        nseclabels = def->nseclabels;
+    }
+
     disk = virDomainDiskDefParseXML(xmlopt, ctxt->node, ctxt,
-                                    NULL, def->seclabels,
-                                    def->nseclabels,
-                                    flags);
+                                    NULL, seclabels, nseclabels, flags);

  cleanup:
     xmlFreeDoc(xml);
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 03/14] conf: Don't require 'def' in virDomainDiskDefParse
Posted by Ján Tomko 7 years, 1 month ago
On Thu, Mar 29, 2018 at 01:51:00PM +0200, Peter Krempa wrote:
>In some use cases (mostly in tests) it is not required to check the
>seclabel definition validity. Add possibility to call
>virDomainDiskDefParse without the domain definition.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/conf/domain_conf.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>

ACK

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list