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

[libvirt] [PATCH 3/8] remote_driver: Implement virDomainNormalizeXML



Signed-off-by: Michal Privoznik <mprivozn redhat com>
---
 daemon/remote.c              | 50 ++++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_driver.c   | 40 +++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x | 20 +++++++++++++++++-
 3 files changed, 109 insertions(+), 1 deletion(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 2aff7c1..1acbbfb 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -5304,3 +5304,53 @@ error:
     }
     return -1;
 }
+
+static int
+remoteDispatchDomainNormalizeXML(virNetServerPtr server ATTRIBUTE_UNUSED,
+                                 virNetServerClientPtr client,
+                                 virNetMessagePtr msg ATTRIBUTE_UNUSED,
+                                 virNetMessageErrorPtr rerr,
+                                 remote_domain_normalize_xml_args *args,
+                                 remote_domain_normalize_xml_ret *ret)
+{
+    int rv = -1;
+    int norm_ret;
+    virDomainPtr dom = NULL;
+    char *xmlOut = NULL;
+    char **xmlOut_p = NULL;
+    struct daemonClientPrivate *priv =
+        virNetServerClientGetPrivateData(client);
+
+    if (!priv->conn) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+        goto cleanup;
+
+    norm_ret = virDomainNormalizeXML(dom,
+                                     args->xmlIn,
+                                     args->need_xmlOut ? &xmlOut : NULL,
+                                     args->flags);
+    if (norm_ret < 0)
+        goto cleanup;
+
+    if (args->need_xmlOut) {
+        if (VIR_ALLOC(xmlOut_p) < 0)
+            goto cleanup;
+        *xmlOut_p = xmlOut;
+        xmlOut = NULL;
+    }
+
+    ret->ret = norm_ret;
+    ret->xmlOut = xmlOut_p;
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    return rv;
+}
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 62e77a5..9128699 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -6605,6 +6605,45 @@ remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event)
     virDomainEventStateQueue(priv->domainEventState, event);
 }
 
+static int
+remoteDomainNormalizeXML(virDomainPtr dom,
+                         const char *xmlIn,
+                         char **xmlOut,
+                         unsigned int flags)
+{
+    int rv = -1;
+    struct private_data *priv = dom->conn->privateData;
+    remote_domain_normalize_xml_args args;
+    remote_domain_normalize_xml_ret ret;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain(&args.dom, dom);
+    args.xmlIn = (char *) xmlIn;
+    args.need_xmlOut = !!xmlOut;
+    args.flags = flags;
+
+    memset(&ret, 0, sizeof(ret));
+
+    if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_NORMALIZE_XML,
+             (xdrproc_t) xdr_remote_domain_normalize_xml_args, (char *) &args,
+             (xdrproc_t) xdr_remote_domain_normalize_xml_ret, (char *) &ret) == -1)
+        goto done;
+
+    rv = ret.ret;
+
+    if (rv == 0 && xmlOut) {
+        *xmlOut = *ret.xmlOut;
+        *ret.xmlOut = NULL;
+    }
+
+done:
+    xdr_free((xdrproc_t) xdr_remote_domain_normalize_xml_ret, (char *) &ret);
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+
 /* get_nonnull_domain and get_nonnull_network turn an on-wire
  * (name, uuid) pair into virDomainPtr or virNetworkPtr object.
  * These can return NULL if underlying memory allocations fail,
@@ -6933,6 +6972,7 @@ static virDriver remote_driver = {
     .domainMigratePerform3Params = remoteDomainMigratePerform3Params, /* 1.1.0 */
     .domainMigrateFinish3Params = remoteDomainMigrateFinish3Params, /* 1.1.0 */
     .domainMigrateConfirm3Params = remoteDomainMigrateConfirm3Params, /* 1.1.0 */
+    .domainNormalizeXML = remoteDomainNormalizeXML, /* 1.1.3 */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 85ad9ba..d5539eb 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2835,6 +2835,18 @@ struct remote_domain_event_device_removed_msg {
     remote_nonnull_string devAlias;
 };
 
+struct remote_domain_normalize_xml_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string xmlIn;
+    int need_xmlOut;
+    unsigned int flags;
+};
+
+struct remote_domain_normalize_xml_ret {
+    remote_string xmlOut;
+    int ret;
+};
+
 /*----- Protocol. -----*/
 
 /* Define the program number, protocol version and procedure numbers here. */
@@ -4998,5 +5010,11 @@ enum remote_procedure {
      * @generate: both
      * @acl: none
      */
-    REMOTE_PROC_DOMAIN_EVENT_DEVICE_REMOVED = 311
+    REMOTE_PROC_DOMAIN_EVENT_DEVICE_REMOVED = 311,
+
+    /**
+     * @generate: none
+     * @acl: domain:read
+     */
+    REMOTE_PROC_DOMAIN_NORMALIZE_XML = 312
 };
-- 
1.8.1.5


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