From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IpUOU-00080Q-Lq for qemu-devel@nongnu.org; Tue, 06 Nov 2007 14:47:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IpUOT-0007x6-08 for qemu-devel@nongnu.org; Tue, 06 Nov 2007 14:47:26 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpUOS-0007wv-R2 for qemu-devel@nongnu.org; Tue, 06 Nov 2007 14:47:24 -0500 Received: from sp604002mt.neufgp.fr ([84.96.92.61] helo=sMtp.neuf.fr) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IpUOS-00088z-DI for qemu-devel@nongnu.org; Tue, 06 Nov 2007 14:47:24 -0500 Received: from [86.73.70.236] by sp604002mt.gpm.neuf.ld (Sun Java System Messaging Server 6.2-5.05 (built Feb 16 2006)) with ESMTP id <0JR300MU0OA5BWB0@sp604002mt.gpm.neuf.ld> for qemu-devel@nongnu.org; Tue, 06 Nov 2007 20:46:55 +0100 (CET) Date: Tue, 06 Nov 2007 20:46:31 +0100 From: Fabrice Bellard Subject: Re: [Qemu-devel] [PATCH] Add TPM support In-reply-to: <20071106080734.GB7621@thomas> Message-id: <4730C497.5070201@bellard.org> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7BIT References: <20071031120636.GA7567@thomas> <20071031125438.GG7712@networkno.de> <20071031141020.GC7567@thomas> <20071031161427.GI7712@networkno.de> <20071101155556.GC15568@thomas> <20071105141528.GE8650@thomas> <472F3966.1090206@bellard.org> <20071106080734.GB7621@thomas> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Thomas Bleher wrote: > * Fabrice Bellard [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.