qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: andreas.niederl@iaik.tugraz.at, qemu-devel@nongnu.org, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH V13 1/7] Support for TPM command line	options
Date: Mon, 12 Dec 2011 21:16:10 -0500	[thread overview]
Message-ID: <4EE6B56A.7090508@linux.vnet.ibm.com> (raw)
In-Reply-To: <4EE68B56.30704@codemonkey.ws>

On 12/12/2011 06:16 PM, Anthony Liguori wrote:
> On 12/12/2011 01:12 PM, Stefan Berger wrote:
>> @@ -2735,6 +2736,15 @@ static mon_cmd_t info_cmds[] = {
>>           .help       = "show available trace-events&  their state",
>>           .mhandler.info = do_trace_print_events,
>>       },
>> +#if defined(CONFIG_TPM)
>> +    {
>> +        .name       = "tpm",
>> +        .args_type  = "",
>> +        .params     = "",
>> +        .help       = "show the TPM device",
>> +        .mhandler.info = do_info_tpm,
>> +    },
>> +#endif
>
> Please don't make monitor commands conditional.  Make it fail in a 
> predictable fashion if tpm isn't configured.
>

This will then require tpm.c to always be compiled. You'll find the 
CONFIG_TPM there then.
@@ -563,6 +582,7 @@ static QemuOptsList *vm_config_groups[32] = {
>> &qemu_option_rom_opts,
>> &qemu_machine_opts,
>> &qemu_boot_opts,
>> +&qemu_tpmdev_opts,
>
> I assume this is my mailer or is the whitespace munged here?
>

Must be your mailer.@@ -0,0 +1,167 @@
>> +/*
>> + * TPM configuration
>> + *
>> + * Copyright (C) 2011 IBM Corporation
>> + *
>> + * Authors:
>> + *  Stefan Berger<stefanb@us.ibm.com>
>> + *
>> + * This work is licensed under the terms of the GNU GPL, version 2.  
>> See
>> + * the COPYING file in the top-level directory.
>>
>
> v2 or later please.

ok.

>> +
>> +void tpm_display_backend_drivers(void)
>> +{
>> +    int i;
>> +
>> +    fprintf(stderr, "Supported TPM types (choose only one):\n");
>
> Having fprintfs to stderr is a sign something is wrong.
>
> In this case, we should have a programatic way to query the backends 
> (like via qmp_query_tpm) and then in the option handling code, we 
> should use that function and print to the screen from there.
>

Will try to convert but keep this function ?

>> +
>> +void do_info_tpm(Monitor *mon)
>> +{
>> +    TPMBackend *drv;
>> +    unsigned int c = 0;
>> +
>> +    monitor_printf(mon, "TPM device:\n");
>> +
>> +    QLIST_FOREACH(drv,&tpm_backends, list) {
>> +        monitor_printf(mon, " tpm%d: model=%s\n",
>> +                       c, drv->fe_model);
>> +        monitor_printf(mon, "  \\ %s: type=%s%s%s\n",
>> +                       drv->id, drv->ops->id,
>> +                       drv->parameters ? "," : "",
>> +                       drv->parameters ? drv->parameters : "");
>> +        c++;
>> +    }
>> +}
>
> We should do this through sure QAPI now that it's in the the tree with 
> a proper schema entry and an implementation in hmp.c.

True...

>> +void tpm_config_parse(QemuOptsList *opts_list, const char *optarg)
>> +{
>> +    QemuOpts *opts;
>> +
>> +    if (strcmp("none", optarg) != 0) {
>> +        if (*optarg == '?') {
>> +            tpm_display_backend_drivers();
>> +            exit(0);
>
> Don't exit from something other than vl.c.  Return an error code and 
> let vl.c exit.

I implemented this following along the lines of

qemu-system-x86_64 -soundhw ?

which then also shows and error code 0. What error code should it return 
to the shell ?


>
>> +        }
>> +        opts = qemu_opts_parse(opts_list, optarg, 1);
>> +        if (!opts) {
>> +            exit(1);
>> +        }
>> +    }
>> +}
>> diff --git a/tpm.h b/tpm.h
>> new file mode 100644
>> index 0000000..85c2a35
>> --- /dev/null
>> +++ b/tpm.h
>> @@ -0,0 +1,90 @@
>
> Needs a copyright.

Ok.

>> +static inline void tpm_dump_buffer(FILE *stream,
>> +                                   unsigned char *buffer, unsigned 
>> int len)
>> +{
>> +    int i;
>> +
>> +    for (i = 0; i<  len; i++) {
>> +        if (i&&  !(i % 16)) {
>> +            fprintf(stream, "\n");
>> +        }
>> +        fprintf(stream, "%.2X ", buffer[i]);
>> +    }
>> +    fprintf(stream, "\n");
>> +}
>
> This definitely shouldn't be static inline and it's questionable 
> whether it should exist in the first place.

Do you have an alternative for this function? Assuming it's useful for 
debugging, should I just move it into tpm.c ?


>
>> +#define TPM_DEFAULT_DEVICE_MODEL "tpm-tis"
>> +
>> +void tpm_config_parse(QemuOptsList *opts_list, const char *optarg);
>> +int tpm_init(void);
>> +void tpm_cleanup(void);
>> +TPMBackend *qemu_find_tpm(const char *id);
>> +void do_info_tpm(Monitor *mon);
>> +void tpm_display_backend_drivers(void);
>> +const TPMDriverOps *tpm_get_backend_driver(const char *id);
>
> Please document these functions.

Will document them in tpm.c where their implementation is.


@@ -2550,6 +2551,11 @@ int main(int argc, char **argv, char **envp)
>>                   ram_size = value;
>>                   break;
>>               }
>> +#ifdef CONFIG_TPM
>> +            case QEMU_OPTION_tpmdev:
>> +                tpm_config_parse(qemu_find_opts("tpmdev"), optarg);
>> +                break;
>> +#endif
>
> Don't make options conditional.

Can I have an #ifdef-#else-#endif construct there along the lines of 
CONFIG_SDL with an exit(1) in the #else branch?


    Stefan

  reply	other threads:[~2011-12-13  2:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-12 19:12 [Qemu-devel] [PATCH V13 0/7] Qemu Trusted Platform Module (TPM) integration Stefan Berger
2011-12-12 19:12 ` [Qemu-devel] [PATCH V13 1/7] Support for TPM command line options Stefan Berger
2011-12-12 23:16   ` Anthony Liguori
2011-12-13  2:16     ` Stefan Berger [this message]
2011-12-12 19:12 ` [Qemu-devel] [PATCH V13 2/7] Add TPM (frontend) hardware interface (TPM TIS) to Qemu Stefan Berger
2011-12-12 23:23   ` Anthony Liguori
2011-12-12 23:54     ` Stefan Berger
2011-12-12 19:12 ` [Qemu-devel] [PATCH V13 3/7] Add a debug register Stefan Berger
2011-12-12 19:12 ` [Qemu-devel] [PATCH V13 4/7] Build the TPM frontend code Stefan Berger
2011-12-12 23:24   ` Anthony Liguori
2011-12-12 23:56     ` Stefan Berger
2011-12-12 19:12 ` [Qemu-devel] [PATCH V13 5/7] Add a TPM Passthrough backend driver implementation Stefan Berger
2011-12-12 23:27   ` Anthony Liguori
2011-12-12 23:59     ` Stefan Berger
2011-12-12 19:12 ` [Qemu-devel] [PATCH V13 6/7] Introduce --enable-tpm-passthrough configure option Stefan Berger
2011-12-12 23:27   ` Anthony Liguori
2011-12-13  0:12     ` Stefan Berger
2011-12-13  4:51       ` Paul Brook
2011-12-13 12:51         ` Stefan Berger
2011-12-13 13:51           ` Michael S. Tsirkin
2011-12-13 17:41             ` Anthony Liguori
2011-12-13 17:48               ` Stefan Berger
2011-12-13 20:33                 ` Paul Brook
2011-12-13 17:25           ` Paul Brook
2011-12-12 19:12 ` [Qemu-devel] [PATCH V13 7/7] Add fd parameter for TPM passthrough driver Stefan Berger
2011-12-12 23:30   ` Anthony Liguori
2011-12-13  0:17     ` Stefan Berger
2011-12-13  5:45 ` [Qemu-devel] [PATCH V13 0/7] Qemu Trusted Platform Module (TPM) integration Stefan Weil
2011-12-13 12:43   ` Stefan Berger

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=4EE6B56A.7090508@linux.vnet.ibm.com \
    --to=stefanb@linux.vnet.ibm.com \
    --cc=andreas.niederl@iaik.tugraz.at \
    --cc=anthony@codemonkey.ws \
    --cc=mst@redhat.com \
    --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).