The API can be used to get platform specific key supported info --- include/libvirt/libvirt-host.h | 18 +++++++++++++ src/driver-hypervisor.h | 7 +++++ src/libvirt-host.c | 49 ++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 ++++ 4 files changed, 79 insertions(+) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 7debb5f829..292cbbc388 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -473,6 +473,24 @@ int virNodeGetSEVInfo (virConnectPtr conn, int *nparams, unsigned int flags); +/** +* +* MKTME Parameters +*/ + +/** +* VIR_NODE_MKTME_KEYS_SUPPORTED: +* +* Macro represents the number of keys supported, when MKTME is enabled in the guest. +*/ +# define VIR_NODE_MKTME_KEYS_SUPPORTED "keys_supported" + +int virNodeGetMKTMEInfo(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags); + + /** * virConnectFlags * diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 5315e33dde..0bbb90b321 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1322,6 +1322,12 @@ typedef int int *nparams, unsigned int flags); +typedef int +(*virDrvNodeGetMKTMEInfo)(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags); + typedef int (*virDrvDomainGetLaunchSecurityInfo)(virDomainPtr domain, virTypedParameterPtr *params, @@ -1580,6 +1586,7 @@ struct _virHypervisorDriver { virDrvConnectBaselineHypervisorCPU connectBaselineHypervisorCPU; virDrvNodeGetSEVInfo nodeGetSEVInfo; virDrvDomainGetLaunchSecurityInfo domainGetLaunchSecurityInfo; + virDrvNodeGetMKTMEInfo nodeGetMKTMEInfo; }; diff --git a/src/libvirt-host.c b/src/libvirt-host.c index e20d6ee250..92b9973560 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -1688,3 +1688,52 @@ virNodeGetSEVInfo(virConnectPtr conn, virDispatchError(conn); return -1; } + + +/* + * virNodeGetMKTMEInfo: + * @conn: pointer to the hypervisor connection + * @params: where to store mktme information + * @nparams: pointer to number of MKTME parameters returned in @params + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * If hypervisor supports Intel's MKTME feature, then @params will contain various + * platform specific information like number of keys supported. Caller is + * responsible for freeing @params. + * + * Returns 0 in case of success, and -1 in case of failure. + */ +int +virNodeGetMKTMEInfo(virConnectPtr conn, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + VIR_DEBUG("conn=%p, params=%p, nparams=%p, flags=0x%x", + conn, params, nparams, flags); + + virResetLastError(); + + virCheckConnectReturn(conn, -1); + virCheckNonNullArgGoto(nparams, error); + virCheckNonNegativeArgGoto(*nparams, error); + virCheckReadOnlyGoto(conn->flags, error); + + if (VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, + VIR_DRV_FEATURE_TYPED_PARAM_STRING)) + flags |= VIR_TYPED_PARAM_STRING_OKAY; + + if (conn->driver->nodeGetMKTMEInfo) { + int ret; + ret = conn->driver->nodeGetMKTMEInfo(conn, params, nparams, flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index dbce3336d5..7aa6a60b11 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -819,4 +819,9 @@ LIBVIRT_5.2.0 { virConnectGetStoragePoolCapabilities; } LIBVIRT_4.10.0; +LIBVIRT_5.3.0 { + global: + virNodeGetMKTMEInfo; +} LIBVIRT_5.2.0; + # .... define new API here using predicted next version number .... -- 2.21.0.windows.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list