[libvirt] [PATCH v6 04/11] Helper functions for host TPM support

Eric Blake eblake at redhat.com
Fri Apr 12 19:40:35 UTC 2013


On 04/12/2013 12:47 PM, Stefan Berger wrote:
> After a further simplification the patch now looks like this:
> 
> 
> Implement helper function to create the TPM's sysfs cancel file.
> 
> Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
> Reviewed-by: Corey Bryant <coreyb at linux.vnet.ibm.com>
> Tested-by: Corey Bryant <coreyb at linux.vnet.ibm.com>
> 
> ---

> +char *
> +virTPMCreateCancelPath(const char *devpath)
> +{
> +    char *path = NULL;
> +    const char *dev;
> +
> +    if (devpath) {
> +        dev = strrchr(devpath, '/');
> +        if (dev) {
> +            dev++;
> +            if (virAsprintf(&path, "/sys/class/misc/%s/device/cancel",
> +                            dev) < 0) {

Do we need to worry about systems that don't mount sysfs at /sys?  But
if there is someone in such a situation, they can provide a patch for
further configuration tuning.

> +                virReportOOMError();
> +                goto cleanup;
> +            }
> +        } else {
> +            virReportError(VIR_ERR_INTERNAL_ERROR,
> +                           _("TPM device path %s is invalid"), devpath);
> +        }
> +    } else {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Missing TPM device path"));
> +    }
> +
> +cleanup:
> +    return path;
> +}

Looks okay to me.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130412/519be617/attachment-0001.sig>


More information about the libvir-list mailing list