qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fabrice Bellard <fabrice@bellard.org>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Add TPM support
Date: Tue, 06 Nov 2007 20:46:31 +0100	[thread overview]
Message-ID: <4730C497.5070201@bellard.org> (raw)
In-Reply-To: <20071106080734.GB7621@thomas>

Thomas Bleher wrote:
> * Fabrice Bellard <fabrice@bellard.org> [2007-11-05 16:40]:
>> Thomas Bleher wrote:
>>> Thiemo Seufer told me that GPLv2 is fine for qemu, therefore I'd like to
>>> ask that this patch be included in qemu as I posted it (the second
>>> version with the clarified GPLv2 license).
>> I prefer that a BSD style license is used, especially if the code just 
>> contains wrappers.
> 
> Fine with me, too.

OK.

> +        result = write(s->tpm_fd, s->send_data, s->send_data_index);
> +        if (result < s->send_data_index) {
> +            fprintf(stderr, "WARNING: Failed to write data to tpm!\n");
> +            return ATML_STATUS_BUSY;
> +        }

You should handle EINTR and EAGAIN.

> +        s->send_data_index = 0;
> +        s->recv_data_pos = 0;
> +        s->recv_data_length = 0;
> +        s->data_to_send = 0;
> +        s->data_to_recv = 1;
> +    }
> +    if (s->data_to_recv) {
> +        if (poll(&(s->tpm_poll), 1, 0) > 0) {

poll is not needed as read will block.

> +            result = read(s->tpm_fd, s->recv_data, 2048);
> +            if (result < 6) { // a minimal packet is 6 bytes long
> +                fprintf(stderr, "WARNING: Not enough data from tpm!\n");
> +                return ATML_STATUS_BUSY;
> +            }

same comment as write().

> +    res = connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr_un));
> +    if (res < 0)
> +        return -1;

same comment for EINTR.

+/* should be called first, initializes all structures and connects to
the external emulator */
+void tpm_configure(const char* tpm_socket)
+{

Suppress this function (cf tpm_register).

> +/* split of from tpm_configure() so the configuration can be called earlier */
> +void tpm_register()

Ansi C requires void in parameters. Allocate the state and return it.
Suppress the global variable tpm_state. Pass the path to this function
and suppress the configure function. Add a global variable for the path
and register the device if it is not NULL.

Regards,

Fabrice.

  reply	other threads:[~2007-11-06 19:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-31 12:06 [Qemu-devel] [PATCH] Add TPM support Thomas Bleher
2007-10-31 12:54 ` Thiemo Seufer
2007-10-31 14:10   ` Thomas Bleher
2007-10-31 16:14     ` Thiemo Seufer
2007-11-01 15:55       ` Thomas Bleher
2007-11-05 14:15         ` Thomas Bleher
2007-11-05 15:40           ` Fabrice Bellard
2007-11-06  8:07             ` Thomas Bleher
2007-11-06 19:46               ` Fabrice Bellard [this message]
2007-11-07 12:05                 ` Thomas Bleher
2007-11-07 16:29                   ` Fabrice Bellard
2007-11-11 21:18                     ` Thomas Bleher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4730C497.5070201@bellard.org \
    --to=fabrice@bellard.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).