[libvirt] [libvirt-go PATCH 1/2] Add support for AMD SEV launch security info
Daniel P. Berrangé
berrange at redhat.com
Thu Jun 14 15:49:26 UTC 2018
On Thu, Jun 14, 2018 at 04:30:00PM +0200, Erik Skultety wrote:
> Signed-off-by: Erik Skultety <eskultet at redhat.com>
> ---
> domain.go | 41 +++++++++++++++++++++++++++++++++++++++++
> domain_compat.go | 13 +++++++++++++
> domain_compat.h | 6 ++++++
> 3 files changed, 60 insertions(+)
>
> diff --git a/domain.go b/domain.go
> index a3049aa..6499cfa 100644
> --- a/domain.go
> +++ b/domain.go
> @@ -4573,3 +4573,44 @@ func (d *Domain) SetLifecycleAction(lifecycleType uint32, action uint32, flags u
>
> return nil
> }
> +
> +type DomainLaunchSecurityParameters struct {
> + SevMeasurementSet bool
> + SevMeasurement string
> +}
Since we just changed main libvirt code to use "SEV" instead of "Sev",
lets use SEV here too.
> +
> +func getDomainLaunchSecurityFieldInfo(params *DomainLaunchSecurityParameters) map[string]typedParamsFieldInfo {
> + return map[string]typedParamsFieldInfo{
> + C.VIR_DOMAIN_LAUNCH_SECURITY_SEV_MEASUREMENT: typedParamsFieldInfo{
> + set: ¶ms.SevMeasurementSet,
> + s: ¶ms.SevMeasurement,
> + },
> + }
> +}
> +
> +// See also https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetLaunchSecurityInfo
> +func (d *Domain) GetLaunchSecurityInfo(flags uint32) (*DomainLaunchSecurityParameters, error) {
> + if C.LIBVIR_VERSION_NUMBER < 4005000 {
> + return nil, GetNotImplementedError("virDomainGetLaunchSecurityInfo")
> + }
> +
> + params := &DomainLaunchSecurityParameters{}
> + info := getDomainLaunchSecurityFieldInfo(params)
> +
> + var cparams *C.virTypedParameter
> + var nparams C.int
> +
> + ret := C.virDomainGetLaunchSecurityInfoCompat(d.ptr, (*C.virTypedParameterPtr)(unsafe.Pointer(&cparams)), &nparams, C.uint(flags))
> + if ret == -1 {
> + return nil, GetLastError()
> + }
> +
> + defer C.virTypedParamsFree(cparams, nparams)
> +
> + _, err := typedParamsUnpackLen(cparams, int(nparams), info)
> + if err != nil {
> + return nil, err
> + }
> +
> + return params, nil
> +}
> diff --git a/domain_compat.go b/domain_compat.go
> index a46a9c7..73a6db9 100644
> --- a/domain_compat.go
> +++ b/domain_compat.go
> @@ -367,5 +367,18 @@ int virDomainDetachDeviceAliasCompat(virDomainPtr domain,
> return virDomainDetachDeviceAlias(domain, alias, flags);
> #endif
> }
> +
> +int virDomainGetLaunchSecurityInfoCompat(virDomainPtr domain,
> + virTypedParameterPtr *params,
> + int *nparams,
> + unsigned int flags)
> +{
> +#if LIBVIR_VERSION_NUMBER < 4005000
> + assert(0); // Caller should have checked version
> +#else
> + return virDomainGetLaunchSecurityInfo(domain, params, nparams, flags);
> +#endif
> +}
> +
> */
> import "C"
> diff --git a/domain_compat.h b/domain_compat.h
> index 55d7e13..5c93ef5 100644
> --- a/domain_compat.h
> +++ b/domain_compat.h
> @@ -1035,5 +1035,11 @@ int virDomainDetachDeviceAliasCompat(virDomainPtr domain,
> const char *alias,
> unsigned int flags);
>
> +/* 4.5.0 */
> +
> +int virDomainGetLaunchSecurityInfoCompat(virDomainPtr domain,
> + virTypedParameterPtr *params,
> + int *nparams,
> + unsigned int flags);
>
> #endif /* LIBVIRT_GO_DOMAIN_COMPAT_H__ */
With the s/Sev/SEV/, then
Reviewed-by: Daniel P. Berrangé <berrange at redhat.com>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
More information about the libvir-list
mailing list