[PATCH 2/5] cpu_models: implement the remote protocol

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

 



Signed-off-by: Giuseppe Scrivano <gscrivan@xxxxxxxxxx>
---
 daemon/remote.c              | 37 ++++++++++++++++++++++++++++++++
 src/remote/remote_driver.c   | 51 ++++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x | 17 ++++++++++++++-
 src/remote_protocol-structs  | 11 ++++++++++
 4 files changed, 115 insertions(+), 1 deletion(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 03d5557..e33f616 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4923,6 +4923,43 @@ cleanup:
 }
 
 
+static int
+remoteDispatchConnectGetCPUModelNames(
+        virNetServerPtr server ATTRIBUTE_UNUSED,
+        virNetServerClientPtr client ATTRIBUTE_UNUSED,
+        virNetMessagePtr msg ATTRIBUTE_UNUSED,
+        virNetMessageErrorPtr rerr,
+        remote_connect_get_cpu_model_names_args *args,
+        remote_connect_get_cpu_model_names_ret *ret)
+{
+    int rv = -1;
+    char **models;
+    struct daemonClientPrivate *priv =
+        virNetServerClientGetPrivateData(client);
+
+    if (!priv->conn) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (virConnectGetCPUModelNames(priv->conn, args->arch, &models,
+                                   args->flags) < 0)
+        goto cleanup;
+
+    ret->models.models_val = models;
+    ret->models.models_len = 0;
+    while (*models++)
+        ret->models.models_len++;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    return rv;
+}
+
+
 static int remoteDispatchDomainCreateXMLWithFiles(
     virNetServerPtr server ATTRIBUTE_UNUSED,
     virNetServerClientPtr client,
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 71d0034..eb0bca2 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5485,6 +5485,56 @@ done:
 
 
 static int
+remoteConnectGetCPUModelNames(virConnectPtr conn,
+                              const char *arch,
+                              char ***models,
+                              unsigned int flags)
+{
+    int rv = -1;
+    size_t i;
+    char **retmodels;
+    remote_connect_get_cpu_model_names_args args;
+    remote_connect_get_cpu_model_names_ret ret;
+    struct private_data *priv = conn->privateData;
+    remoteDriverLock(priv);
+
+    memset(&args, 0, sizeof(args));
+    memset(&ret, 0, sizeof(ret));
+
+    args.arch = (char *) arch;
+    args.flags = flags;
+
+    if (call(conn, priv, 0, REMOTE_PROC_CONNECT_GET_CPU_MODEL_NAMES,
+             (xdrproc_t) xdr_remote_connect_get_cpu_model_names_args,
+             (char *) &args,
+             (xdrproc_t) xdr_remote_connect_get_cpu_model_names_ret,
+             (char *) &ret) < 0)
+        goto error;
+
+    if (VIR_ALLOC_N(retmodels, ret.models.models_len + 1) < 0)
+        goto error;
+
+    for (i = 0; i < ret.models.models_len; i++)
+        retmodels[i] = ret.models.models_val[i];
+
+    /* Caller frees MODELS.  */
+    *models = retmodels;
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+
+error:
+    rv = -1;
+    for (i = 0; i < ret.models.models_len; i++)
+        VIR_FREE(ret.models.models_val[i]);
+    VIR_FREE(ret.models.models_val);
+    goto done;
+}
+
+
+static int
 remoteDomainOpenGraphics(virDomainPtr dom,
                          unsigned int idx,
                          int fd,
@@ -6811,6 +6861,7 @@ static virDriver remote_driver = {
     .domainMigratePerform3Params = remoteDomainMigratePerform3Params, /* 1.1.0 */
     .domainMigrateFinish3Params = remoteDomainMigrateFinish3Params, /* 1.1.0 */
     .domainMigrateConfirm3Params = remoteDomainMigrateConfirm3Params, /* 1.1.0 */
+    .connectGetCPUModelNames = remoteConnectGetCPUModelNames, /* 1.1.2 */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 7cfebdf..924d629 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2837,6 +2837,15 @@ struct remote_domain_event_device_removed_msg {
     remote_nonnull_string devAlias;
 };
 
+struct remote_connect_get_cpu_model_names_args {
+    remote_nonnull_string arch;
+    unsigned int flags;
+};
+
+struct remote_connect_get_cpu_model_names_ret {
+    remote_nonnull_string models<>;
+};
+
 /*----- Protocol. -----*/
 
 /* Define the program number, protocol version and procedure numbers here. */
@@ -5000,5 +5009,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: connect:read
+     */
+    REMOTE_PROC_CONNECT_GET_CPU_MODEL_NAMES = 312
 };
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 4e27aae..9148202 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -2316,6 +2316,16 @@ struct remote_domain_event_device_removed_msg {
         remote_nonnull_domain      dom;
         remote_nonnull_string      devAlias;
 };
+struct remote_connect_get_cpu_model_names_args {
+        remote_nonnull_string      arch;
+        u_int                      flags;
+};
+struct remote_connect_get_cpu_model_names_ret {
+        struct {
+                u_int              models_len;
+                remote_nonnull_string * models_val;
+        } models;
+};
 enum remote_procedure {
         REMOTE_PROC_CONNECT_OPEN = 1,
         REMOTE_PROC_CONNECT_CLOSE = 2,
@@ -2628,4 +2638,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_CREATE_XML_WITH_FILES = 309,
         REMOTE_PROC_DOMAIN_CREATE_WITH_FILES = 310,
         REMOTE_PROC_DOMAIN_EVENT_DEVICE_REMOVED = 311,
+        REMOTE_PROC_CONNECT_GET_CPU_MODEL_NAMES = 312,
 };
-- 
1.8.3.1

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




[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]