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

[libvirt] [PATCH 2/6] normalize_xml: Implement the new API



---
 src/libvirt.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 896d151..223f07b 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -17867,3 +17867,55 @@ error:
     virDispatchError(dom->conn);
     return -1;
 }
+
+/**
+ * virDomainNormalizeDeviceXML:
+ * @dom: Pointer to domain object
+ * @device_xml: Description of the device XML to be normalized
+ * @flags: currently unused, pass 0
+ *
+ * Normalize the incoming device XML, and returned the formated XML.
+ *
+ * The mainly use of this function is to format the incoming device
+ * XML as what the device is represented internally.
+ *
+ * Returns NULL in case of error, or the formated XML in case of success.
+ */
+char *
+virDomainNormalizeDeviceXML(virDomainPtr dom,
+                            const char *device_xml,
+                            unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(dom, "device_xml=%p, flags=%x",
+                     NULLSTR(device_xml), flags);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
+        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        goto error;
+    }
+
+    if (device_xml == NULL) {
+        virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+        goto error;
+    }
+
+    conn = dom->conn;
+
+    if (conn->driver->domainNormalizeDeviceXML) {
+        char *ret = NULL;
+        ret = conn->driver->domainNormalizeDeviceXML(dom, device_xml, flags);
+        if (!ret)
+            goto error;
+        return ret;
+    }
+
+    virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(dom->conn);
+    return NULL;
+}
-- 
1.7.7.3


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