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

    libvirt: Introduce virDomainGetLaunchSecurityInfo public API
    
    The API can be used outside the libvirt to get the launch security
    information. When SEV is enabled, the API can be used to get the
    measurement of the launch process.
    
    Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
    Reviewed-by: Erik Skultety <eskultet@redhat.com>

Index: libvirt-4.0.0/include/libvirt/libvirt-domain.h
===================================================================
--- libvirt-4.0.0.orig/include/libvirt/libvirt-domain.h
+++ libvirt-4.0.0/include/libvirt/libvirt-domain.h
@@ -4756,4 +4756,21 @@ int virDomainSetLifecycleAction(virDomai
                                 unsigned int action,
                                 unsigned int flags);
 
+/**
+ * Launch Security API
+ */
+
+/**
+ * VIR_DOMAIN_LAUNCH_SECURITY_SEV_MEASUREMENT:
+ *
+ * Macro represents the launch measurement of the SEV guest,
+ * as VIR_TYPED_PARAM_STRING.
+ */
+# define VIR_DOMAIN_LAUNCH_SECURITY_SEV_MEASUREMENT "sev-measurement"
+
+int virDomainGetLaunchSecurityInfo(virDomainPtr domain,
+                                   virTypedParameterPtr *params,
+                                   int *nparams,
+                                   unsigned int flags);
+
 #endif /* __VIR_LIBVIRT_DOMAIN_H__ */
Index: libvirt-4.0.0/src/driver-hypervisor.h
===================================================================
--- libvirt-4.0.0.orig/src/driver-hypervisor.h
+++ libvirt-4.0.0/src/driver-hypervisor.h
@@ -1289,6 +1289,13 @@ typedef int
                         int *nparams,
                         unsigned int flags);
 
+typedef int
+(*virDrvDomainGetLaunchSecurityInfo)(virDomainPtr domain,
+                                        virTypedParameterPtr *params,
+                                        int *nparams,
+                                        unsigned int flags);
+
+
 typedef struct _virHypervisorDriver virHypervisorDriver;
 typedef virHypervisorDriver *virHypervisorDriverPtr;
 
@@ -1534,6 +1541,7 @@ struct _virHypervisorDriver {
     virDrvDomainSetBlockThreshold domainSetBlockThreshold;
     virDrvDomainSetLifecycleAction domainSetLifecycleAction;
     virDrvNodeGetSEVInfo nodeGetSEVInfo;    
+    virDrvDomainGetLaunchSecurityInfo domainGetLaunchSecurityInfo;
 };
 
 
Index: libvirt-4.0.0/src/libvirt-domain.c
===================================================================
--- libvirt-4.0.0.orig/src/libvirt-domain.c
+++ libvirt-4.0.0/src/libvirt-domain.c
@@ -12095,3 +12095,51 @@ int virDomainSetLifecycleAction(virDomai
     virDispatchError(domain->conn);
     return -1;
 }
+
+/**
+ * virDomainGetLaunchSecurityInfo:
+ * @domain: a domain object
+ * @params: where to store security info
+ * @nparams: number of items in @params
+ * @flags: currently used, set to 0.
+ *
+ * Get the launch security info. In case of the SEV guest, this will
+ * return the launch measurement.
+ *
+ * Returns -1 in case of failure, 0 in case of success.
+ */
+int virDomainGetLaunchSecurityInfo(virDomainPtr domain,
+                                   virTypedParameterPtr *params,
+                                   int *nparams,
+                                   unsigned int flags)
+{
+    virConnectPtr conn = domain->conn;
+
+    VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%p flags=0x%x",
+                     params, nparams, flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, -1);
+    virCheckNonNullArgGoto(params, error);
+    virCheckNonNullArgGoto(nparams, error);
+    virCheckReadOnlyGoto(conn->flags, error);
+
+    if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
+                                 VIR_DRV_FEATURE_TYPED_PARAM_STRING))
+        flags |= VIR_TYPED_PARAM_STRING_OKAY;
+
+    if (conn->driver->domainGetLaunchSecurityInfo) {
+        int ret;
+        ret = conn->driver->domainGetLaunchSecurityInfo(domain, params,
+                                                        nparams, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(domain->conn);
+    return -1;
+}
Index: libvirt-4.0.0/src/libvirt_public.syms
===================================================================
--- libvirt-4.0.0.orig/src/libvirt_public.syms
+++ libvirt-4.0.0/src/libvirt_public.syms
@@ -783,5 +783,6 @@ LIBVIRT_3.9.0 {
 LIBVIRT_4.0.0 {
     global:
         virNodeGetSEVInfo;
+        virDomainGetLaunchSecurityInfo;
 } LIBVIRT_3.9.0;
 # .... define new API here using predicted next version number ....
