Re: [PATCH v5 04/11] Helper functions for host TPM support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 12, 2013 at 08:40:18AM -0400, Stefan Berger wrote:
> On 04/12/2013 06:24 AM, Daniel P. Berrange wrote:
> >On Thu, Apr 11, 2013 at 04:04:46PM -0400, Stefan Berger wrote:
> >>Implement helper functions to find the TPM's sysfs cancel file.
> >>
> >>Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>
> >>Reviewed-by: Corey Bryant <coreyb@xxxxxxxxxxxxxxxxxx>
> >>Tested-by: Corey Bryant <coreyb@xxxxxxxxxxxxxxxxxx>
> >>
> >>Hmm, actually on second thoughts the entirely approach for this
> >>method is just flawed.
> >>
> >>In the XML description you have:
> >>
> >>         <device path='/dev/tpm0'/>
> >>
> >>So we should not be iterating over /sys/fs/misc/tpmNNN at all.
> >>We know exactly which TPM device we want - it is 'tpm0'. Just
> >>kill all this pointless readdir code & pass in the device name
> >>we want to get the cancel path for.
> 
> Indeed, the following is better:
> 
> /**
>  * virTPMFindCancelPath:
>  * @devpath: Path to the TPM device
>  *
>  * Find the cancel path given the path to the TPM device
>  */
> char *
> virTPMFindCancelPath(const char *devpath)
> {
>     char *basepath = NULL;
>     char *path = NULL;
>     const char *dev;
> 
>     if (devpath) {
>         dev = rindex(devpath, '/');

rindex is deprecated by POSIX - strrchr is preferred.

>         if (dev) {
>             dev++;
>             if (virAsprintf(&basepath, "/sys/class/misc/%s/device",
>                             dev) < 0) {
>                 virReportOOMError();
>                 goto cleanup;
>             }
>             path = virTPMCheckSysfsCancel(basepath);
>         } 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:
>     VIR_FREE(basepath);
> 
>     return path;
> }


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]