diff options
author | Brijesh Singh <brijesh.singh@amd.com> | 2018-06-08 09:40:53 -0500 |
---|---|---|
committer | Erik Skultety <eskultet@redhat.com> | 2018-06-12 09:52:00 +0200 |
commit | 45422935c38c4d22fb2320767092c166d190a68b (patch) | |
tree | b66f0bb4c5daf46cbba939041810e3e0abba0c28 /src/libvirt-host.c | |
parent | 5dca09c170e26d572cab9b7b80a4347d4dc1907e (diff) | |
download | libvirt-45422935c38c4d22fb2320767092c166d190a68b.tar.gz |
libvirt: Introduce virNodeGetSEVInfo public API
The API can be used by application to retrieve the Platform Diffie-Hellman
Key and Platform Certificate chain.
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Diffstat (limited to 'src/libvirt-host.c')
-rw-r--r-- | src/libvirt-host.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/libvirt-host.c b/src/libvirt-host.c index 3aaf558cac..e20d6ee250 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -1639,3 +1639,52 @@ virNodeAllocPages(virConnectPtr conn, virDispatchError(conn); return -1; } + + +/* + * virNodeGetSEVInfo: + * @conn: pointer to the hypervisor connection + * @params: where to store SEV information + * @nparams: pointer to number of SEV parameters returned in @params + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * If hypervisor supports AMD's SEV feature, then @params will contain various + * platform specific information like PDH and certificate chain. Caller is + * responsible for freeing @params. + * + * Returns 0 in case of success, and -1 in case of failure. + */ +int +virNodeGetSEVInfo(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->nodeGetSEVInfo) { + int ret; + ret = conn->driver->nodeGetSEVInfo(conn, params, nparams, flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} |