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

[libvirt] [PATCH 06/20] Secret manipulation step 6: RPC dispatcher



---
 qemud/remote.c |  149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 149 insertions(+), 0 deletions(-)

diff --git a/qemud/remote.c b/qemud/remote.c
index d32d513..2ecf55b 100644
--- a/qemud/remote.c
+++ b/qemud/remote.c
@@ -4515,6 +4515,155 @@ error:
     VIR_FREE(msg);
 }
 
+static int
+remoteDispatchSecretAllocateId (struct qemud_server *server ATTRIBUTE_UNUSED,
+                                struct qemud_client *client ATTRIBUTE_UNUSED,
+                                virConnectPtr conn,
+                                remote_error *err,
+                                void *args ATTRIBUTE_UNUSED,
+                                remote_secret_allocate_id_ret *ret)
+{
+    char *secret_id;
+
+    secret_id = virSecretAllocateID (conn);
+    if (secret_id == NULL) {
+        remoteDispatchConnError (err, conn);
+        return -1;
+    }
+
+    ret->secretID = secret_id;
+    return 0;
+}
+
+static int
+remoteDispatchSecretDelete (struct qemud_server *server ATTRIBUTE_UNUSED,
+                            struct qemud_client *client ATTRIBUTE_UNUSED,
+                            virConnectPtr conn,
+                            remote_error *err, remote_secret_delete_args *args,
+                            void *ret ATTRIBUTE_UNUSED)
+{
+    if (virSecretDelete (conn, args->secretID) < 0) {
+        remoteDispatchConnError (err, conn);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int
+remoteDispatchSecretGetValue (struct qemud_server *server ATTRIBUTE_UNUSED,
+                              struct qemud_client *client ATTRIBUTE_UNUSED,
+                              virConnectPtr conn, remote_error *err,
+                              remote_secret_get_value_args *args,
+                              remote_secret_get_value_ret *ret)
+{
+    size_t secret_size;
+    void *secret;
+
+    secret = virSecretGetValue (conn, args->secretID, &secret_size);
+    if (secret == NULL) {
+        remoteDispatchConnError (err, conn);
+        return -1;
+    }
+
+    ret->value.value_len = secret_size;
+    ret->value.value_val = secret;
+
+    return 0;
+}
+
+static int
+remoteDispatchSecretGetXml (struct qemud_server *server ATTRIBUTE_UNUSED,
+                            struct qemud_client *client ATTRIBUTE_UNUSED,
+                            virConnectPtr conn, remote_error *err,
+                            remote_secret_get_xml_args *args,
+                            remote_secret_get_xml_ret *ret)
+{
+    ret->xml = virSecretGetXML (conn, args->secretID);
+    if (ret->xml == NULL) {
+        remoteDispatchConnError (err, conn);
+        return -1;
+    }
+    return 0;
+}
+
+static int
+remoteDispatchSecretListSecrets (struct qemud_server *server ATTRIBUTE_UNUSED,
+                                 struct qemud_client *client ATTRIBUTE_UNUSED,
+                                 virConnectPtr conn, remote_error *err,
+                                 remote_secret_list_secrets_args *args,
+                                 remote_secret_list_secrets_ret *ret)
+{
+    if (args->maxids > REMOTE_SECRET_ID_LIST_MAX) {
+        remoteDispatchFormatError (err, "%s",
+                                   _("maxids > REMOTE_SECRET_ID_LIST_MAX"));
+        return -1;
+    }
+
+    if (VIR_ALLOC_N (ret->ids.ids_val, args->maxids) < 0) {
+        remoteDispatchOOMError (err);
+        return -1;
+    }
+
+    ret->ids.ids_len = virSecretListSecrets (conn, ret->ids.ids_val,
+                                             args->maxids);
+    if (ret->ids.ids_len == -1) {
+        VIR_FREE (ret->ids.ids_val);
+        remoteDispatchConnError (err, conn);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int
+remoteDispatchSecretNumOfSecrets (struct qemud_server *server ATTRIBUTE_UNUSED,
+                                  struct qemud_client *client ATTRIBUTE_UNUSED,
+                                  virConnectPtr conn, remote_error *err,
+                                  void *args ATTRIBUTE_UNUSED,
+                                  remote_secret_num_of_secrets_ret *ret)
+{
+    ret->num = virSecretNumOfSecrets (conn);
+    if (ret->num == -1) {
+        remoteDispatchConnError (err, conn);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int
+remoteDispatchSecretSetValue (struct qemud_server *server ATTRIBUTE_UNUSED,
+                              struct qemud_client *client ATTRIBUTE_UNUSED,
+                              virConnectPtr conn, remote_error *err,
+                              remote_secret_set_value_args *args,
+                              void *ret ATTRIBUTE_UNUSED)
+{
+    if (virSecretSetValue (conn, args->secretID, args->value.value_val,
+                           args->value.value_len) < 0) {
+        remoteDispatchConnError (err, conn);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int
+remoteDispatchSecretSetXml (struct qemud_server *server ATTRIBUTE_UNUSED,
+                            struct qemud_client *client ATTRIBUTE_UNUSED,
+                            virConnectPtr conn, remote_error *err,
+                            remote_secret_set_xml_args *args,
+                            void *ret ATTRIBUTE_UNUSED)
+{
+    if (virSecretSetXML (conn, args->secretID, args->xml) < 0) {
+        remoteDispatchConnError (err, conn);
+        return -1;
+    }
+
+    return 0;
+}
+
+
 /*----- Helpers. -----*/
 
 /* get_nonnull_domain and get_nonnull_network turn an on-wire
-- 
1.6.2.5


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