[PATCH 13/16] virnwfilterobj: Add virNWFilterObjGetMetadata()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: K Shiva Kiran <shiva_kr@xxxxxxxxxx>
---
 src/conf/virnwfilterobj.c | 46 +++++++++++++++++++++++++++++++++++++++
 src/conf/virnwfilterobj.h |  5 +++++
 src/libvirt_private.syms  |  1 +
 3 files changed, 52 insertions(+)

diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index 6456add593..eab864fe2e 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -635,3 +635,49 @@ virNWFilterObjUnlock(virNWFilterObj *obj)
 {
     virMutexUnlock(&obj->lock);
 }
+
+
+char *
+virNWFilterObjGetMetadata(virNWFilterObj *obj,
+                          int type,
+                          const char *uri)
+{
+    virNWFilterDef *def;
+    char *ret = NULL;
+
+    if (type >= VIR_NWFILTER_METADATA_LAST) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("unknown metadata type '%1$d'"), type);
+        return NULL;
+    }
+
+    if (!(def = virNWFilterObjGetDef(obj)))
+        return NULL;
+
+    switch ((virNWFilterMetadataType) type) {
+    case VIR_NWFILTER_METADATA_DESCRIPTION:
+        ret = g_strdup(def->description);
+        break;
+
+    case VIR_NWFILTER_METADATA_TITLE:
+        ret = g_strdup(def->title);
+        break;
+
+    case VIR_NWFILTER_METADATA_ELEMENT:
+        if (!def->metadata)
+            break;
+
+        if (virXMLExtractNamespaceXML(def->metadata, uri, &ret) < 0)
+            return NULL;
+        break;
+
+    case VIR_NWFILTER_METADATA_LAST:
+        break;
+    }
+
+    if (!ret)
+        virReportError(VIR_ERR_NO_NWFILTER_METADATA, "%s",
+                       _("Requested metadata element is not present"));
+
+    return ret;
+}
diff --git a/src/conf/virnwfilterobj.h b/src/conf/virnwfilterobj.h
index b67dc017c5..dd4dd63cee 100644
--- a/src/conf/virnwfilterobj.h
+++ b/src/conf/virnwfilterobj.h
@@ -117,3 +117,8 @@ virNWFilterObjLock(virNWFilterObj *obj);
 
 void
 virNWFilterObjUnlock(virNWFilterObj *obj);
+
+char *
+virNWFilterObjGetMetadata(virNWFilterObj *obj,
+                          int type,
+                          const char *uri);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1e3e407097..8c4983ae17 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1408,6 +1408,7 @@ virNWFilterBindingObjListRemove;
 
 # conf/virnwfilterobj.h
 virNWFilterObjGetDef;
+virNWFilterObjGetMetadata;
 virNWFilterObjGetNewDef;
 virNWFilterObjListAssignDef;
 virNWFilterObjListExport;
-- 
2.42.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux