Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx> --- 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 +} + +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__ */ -- 2.14.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list