File e4db4daf-remote-virNodeGetSEVInfo.patch of Package libvirt.11329

commit e4db4dafe92b0ffb4523d0d4ae8564866ec7b66c
Author: Brijesh Singh <brijesh.singh@amd.com>
Date:   Fri Jun 8 09:40:54 2018 -0500

    remote: Implement the remote protocol for virNodeGetSEVInfo()
    
    Add remote support for virNodeGetSEVInfo().
    
    Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
    Reviewed-by: Erik Skultety <eskultet@redhat.com>

Index: libvirt-4.0.0/src/remote/remote_driver.c
===================================================================
--- libvirt-4.0.0.orig/src/remote/remote_driver.c
+++ libvirt-4.0.0/src/remote/remote_driver.c
@@ -6825,6 +6825,45 @@ remoteNodeGetMemoryParameters(virConnect
     return rv;
 }
 
+
+static int
+remoteNodeGetSEVInfo(virConnectPtr conn,
+                     virTypedParameterPtr *params,
+                     int *nparams,
+                     unsigned int flags)
+{
+    int rv = -1;
+    remote_node_get_sev_info_args args;
+    remote_node_get_sev_info_ret ret;
+    struct private_data *priv = conn->privateData;
+
+    remoteDriverLock(priv);
+
+    args.flags = flags;
+
+    memset(&ret, 0, sizeof(ret));
+    if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_SEV_INFO,
+             (xdrproc_t) xdr_remote_node_get_sev_info_args, (char *) &args,
+             (xdrproc_t) xdr_remote_node_get_sev_info_ret, (char *) &ret) == -1)
+        goto done;
+
+    if (virTypedParamsDeserialize((virTypedParameterRemotePtr) ret.params.params_val,
+                                  ret.params.params_len,
+                                  REMOTE_NODE_SEV_INFO_MAX,
+                                  params,
+                                  nparams) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+ cleanup:
+    xdr_free((xdrproc_t) xdr_remote_node_get_sev_info_ret, (char *) &ret);
+ done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+
 static int
 remoteNodeGetCPUMap(virConnectPtr conn,
                     unsigned char **cpumap,
@@ -8497,7 +8536,8 @@ static virHypervisorDriver hypervisor_dr
     .domainSetGuestVcpus = remoteDomainSetGuestVcpus, /* 2.0.0 */
     .domainSetVcpu = remoteDomainSetVcpu, /* 3.1.0 */
     .domainSetBlockThreshold = remoteDomainSetBlockThreshold, /* 3.2.0 */
-    .domainSetLifecycleAction = remoteDomainSetLifecycleAction /* 3.9.0 */
+    .domainSetLifecycleAction = remoteDomainSetLifecycleAction, /* 3.9.0 */
+    .nodeGetSEVInfo = remoteNodeGetSEVInfo, /* 4.0.0 */
 };
 
 static virNetworkDriver network_driver = {
Index: libvirt-4.0.0/src/remote/remote_protocol.x
===================================================================
--- libvirt-4.0.0.orig/src/remote/remote_protocol.x
+++ libvirt-4.0.0/src/remote/remote_protocol.x
@@ -253,6 +253,9 @@ const REMOTE_DOMAIN_IP_ADDR_MAX = 2048;
 /* Upper limit on number of guest vcpu information entries */
 const REMOTE_DOMAIN_GUEST_VCPU_PARAMS_MAX = 64;
 
+/* Upper limit on number of SEV parameters */
+const REMOTE_NODE_SEV_INFO_MAX = 64;
+
 /* UUID.  VIR_UUID_BUFLEN definition comes from libvirt.h */
 typedef opaque remote_uuid[VIR_UUID_BUFLEN];
 
@@ -3440,6 +3443,17 @@ struct remote_domain_set_lifecycle_actio
     unsigned int flags;
 };
 
+struct remote_node_get_sev_info_args {
+    int nparams;
+    unsigned int flags;
+};
+
+struct remote_node_get_sev_info_ret {
+    remote_typed_param params<REMOTE_NODE_SEV_INFO_MAX>;
+    int nparams;
+};
+
+
 /*----- Protocol. -----*/
 
 /* Define the program number, protocol version and procedure numbers here. */
@@ -6120,5 +6134,11 @@ enum remote_procedure {
      * @generate: both
      * @acl: domain:write
      */
-    REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION = 390
+    REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION = 390,
+
+    /**
+     * @generate: none
+     * @acl: connect:read
+     */
+    REMOTE_PROC_NODE_GET_SEV_INFO = 395
 };
Index: libvirt-4.0.0/src/remote_protocol-structs
===================================================================
--- libvirt-4.0.0.orig/src/remote_protocol-structs
+++ libvirt-4.0.0/src/remote_protocol-structs
@@ -2871,6 +2871,17 @@ struct remote_domain_set_lifecycle_actio
         u_int                      action;
         u_int                      flags;
 };
+struct remote_node_get_sev_info_args {
+        int                        nparams;
+        u_int                      flags;
+};
+struct remote_node_get_sev_info_ret {
+        struct {
+                u_int              params_len;
+                remote_typed_param * params_val;
+        } params;
+        int                        nparams;
+};
 enum remote_procedure {
         REMOTE_PROC_CONNECT_OPEN = 1,
         REMOTE_PROC_CONNECT_CLOSE = 2,
@@ -3262,4 +3273,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC = 388,
         REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML = 389,
         REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION = 390,
+        REMOTE_PROC_NODE_GET_SEV_INFO = 395,
 };
Index: libvirt-4.0.0/daemon/remote.c
===================================================================
--- libvirt-4.0.0.orig/daemon/remote.c
+++ libvirt-4.0.0/daemon/remote.c
@@ -4967,6 +4967,50 @@ remoteDispatchDomainGetDiskErrors(virNet
 
 
 static int
+remoteDispatchNodeGetSevInfo(virNetServerPtr server ATTRIBUTE_UNUSED,
+                             virNetServerClientPtr client ATTRIBUTE_UNUSED,
+                             virNetMessagePtr msg ATTRIBUTE_UNUSED,
+                             virNetMessageErrorPtr rerr,
+                             remote_node_get_sev_info_args *args,
+                             remote_node_get_sev_info_ret *ret)
+{
+    virTypedParameterPtr params = NULL;
+    int nparams = 0;
+    int rv = -1;
+    struct daemonClientPrivate *priv =
+        virNetServerClientGetPrivateData(client);
+
+    if (!priv->conn) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (virNodeGetSEVInfo(priv->conn, &params, &nparams, args->flags) < 0)
+        goto cleanup;
+
+    if (nparams > REMOTE_NODE_SEV_INFO_MAX) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+        goto cleanup;
+    }
+
+
+    if (virTypedParamsSerialize(params, nparams,
+                                (virTypedParameterRemotePtr *) &ret->params.params_val,
+                                &ret->params.params_len,
+                                args->flags) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+ cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    virTypedParamsFree(params, nparams);
+    return rv;
+}
+
+
+static int
 remoteDispatchNodeGetMemoryParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
                                       virNetServerClientPtr client ATTRIBUTE_UNUSED,
                                       virNetMessagePtr msg ATTRIBUTE_UNUSED,
openSUSE Build Service is sponsored by