From patchwork Fri Feb 18 15:33:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Niederl X-Patchwork-Id: 83611 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 07F42B7102 for ; Sat, 19 Feb 2011 02:43:32 +1100 (EST) Received: from localhost ([127.0.0.1]:37368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PqSTk-0005rb-C0 for incoming@patchwork.ozlabs.org; Fri, 18 Feb 2011 10:42:44 -0500 Received: from [140.186.70.92] (port=40188 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PqSKx-0002Dr-RQ for qemu-devel@nongnu.org; Fri, 18 Feb 2011 10:33:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PqSKu-000053-0f for qemu-devel@nongnu.org; Fri, 18 Feb 2011 10:33:39 -0500 Received: from mailrelay.tu-graz.ac.at ([129.27.2.202]:64704 helo=mailrelay.tugraz.at) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PqSKt-0008Aj-Ff for qemu-devel@nongnu.org; Fri, 18 Feb 2011 10:33:35 -0500 Received: from thor.iaik.tugraz.at (mail1.iaik.tugraz.at [129.27.152.30]) by mailrelay1.tugraz.at (8.14.4/8.14.4) with ESMTP id p1IFX49n004965 for ; Fri, 18 Feb 2011 16:33:04 +0100 (CET) X-DKIM: Sendmail DKIM Filter v2.8.3 mailrelay1.tugraz.at p1IFX49n004965 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tugraz.at; s=mailrelay; t=1298043186; i=@iaik.tugraz.at; bh=hZY2NlX8uD9ZzbO8msaqZQDEh9xc0N0cKh3HiDk/Ciw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=i27Fi5HxBygWzNI1avyu/CdKR+xAEFfnxzPeKabA5T2LUQMex3QBrpNl94JElrl1/ mCPJvX4lj7ndza4NAs8EIKeBppNOsuqMEvEpaEcXlfi+BEBcBu+mtrIfqzuO9VCSq2 HgnOknzkGlxiIqB+0KZ1PbAYRi99b7bIA4xsevd4= Received: from sirius.iaik.tugraz.at (sirius.iaik.tugraz.at [10.27.152.109]) by thor.iaik.tugraz.at (Postfix) with ESMTP id 63CFC1067B3B7; Fri, 18 Feb 2011 16:33:04 +0100 (CET) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.96.5 at mail1 From: Andreas Niederl To: qemu-devel@nongnu.org Date: Fri, 18 Feb 2011 16:33:34 +0100 Message-Id: <1298043215-10083-5-git-send-email-andreas.niederl@iaik.tugraz.at> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1298043215-10083-1-git-send-email-andreas.niederl@iaik.tugraz.at> References: <1298043215-10083-1-git-send-email-andreas.niederl@iaik.tugraz.at> X-TUG-Backscatter-control: V048+SNPHC2W9i+2rybNlw X-Scanned-By: MIMEDefang 2.70 on 129.27.10.18 X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 129.27.2.202 Cc: Andreas Niederl Subject: [Qemu-devel] [PATCH 4/5] Add configure script and command line options for TPM interface. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Andreas Niederl --- configure | 9 +++++++++ qemu-config.c | 16 ++++++++++++++++ qemu-config.h | 1 + qemu-options.hx | 6 ++++++ vl.c | 22 ++++++++++++++++++++++ 5 files changed, 54 insertions(+), 0 deletions(-) diff --git a/configure b/configure index a3f5345..7addec3 100755 --- a/configure +++ b/configure @@ -316,6 +316,7 @@ case "$cpu" in ;; esac +tpm="no" # OS specific if check_define __linux__ ; then targetos="Linux" @@ -455,6 +456,7 @@ Haiku) usb="linux" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then audio_possible_drivers="$audio_possible_drivers fmod" + tpm="yes" fi ;; esac @@ -713,6 +715,8 @@ for opt do ;; --enable-vhost-net) vhost_net="yes" ;; + --disable-tpm) tpm="no" + ;; --*dir) ;; --disable-rbd) rbd="no" @@ -914,6 +918,7 @@ echo " Default:trace-" echo " --disable-spice disable spice" echo " --enable-spice enable spice" echo " --enable-rbd enable building the rados block device (rbd)" +echo " --disable-tpm disable tpm passthrough device emulation" echo "" echo "NOTE: The object files are built at the place where configure is launched" exit 1 @@ -2478,6 +2483,7 @@ echo "Trace output file $trace_file-" echo "spice support $spice" echo "rbd support $rbd" echo "xfsctl support $xfs" +echo "tpm support $tpm" if test $sdl_too_old = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -2739,6 +2745,9 @@ fi if test "$fdatasync" = "yes" ; then echo "CONFIG_FDATASYNC=y" >> $config_host_mak fi +if test "$tpm" = "yes" ; then + echo "CONFIG_TPM=y" >> $config_host_mak +fi if test "$madvise" = "yes" ; then echo "CONFIG_MADVISE=y" >> $config_host_mak fi diff --git a/qemu-config.c b/qemu-config.c index 323d3c2..fe3a2ae 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -451,6 +451,22 @@ QemuOptsList qemu_option_rom_opts = { }, }; +QemuOptsList qemu_tpm_opts = { + .name = "tpm", + .implied_opt_name = "type", + .head = QTAILQ_HEAD_INITIALIZER(qemu_tpm_opts.head), + .desc = { + { + .name = "type", + .type = QEMU_OPT_STRING, + },{ + .name = "path", + .type = QEMU_OPT_STRING, + }, + { /*End of list */ } + }, +}; + static QemuOptsList *vm_config_groups[32] = { &qemu_drive_opts, &qemu_chardev_opts, diff --git a/qemu-config.h b/qemu-config.h index 20d707f..eed9b3f 100644 --- a/qemu-config.h +++ b/qemu-config.h @@ -4,6 +4,7 @@ extern QemuOptsList qemu_fsdev_opts; extern QemuOptsList qemu_virtfs_opts; extern QemuOptsList qemu_spice_opts; +extern QemuOptsList qemu_tpm_opts; QemuOptsList *qemu_find_opts(const char *group); void qemu_add_opts(QemuOptsList *list); diff --git a/qemu-options.hx b/qemu-options.hx index 945edf3..cf4494d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2339,6 +2339,12 @@ STEXI Specify a trace file to log output traces to. ETEXI #endif +#ifdef CONFIG_TPM +DEF("tpm", HAS_ARG, QEMU_OPTION_tpm, + "-tpm host,id=id,path=path\n" + " enable TPM support and forward commands to the given TPM device file\n", + QEMU_ARCH_I386) +#endif HXCOMM This is the last statement. Insert new options before this line! STEXI diff --git a/vl.c b/vl.c index f74f37a..4bafcce 100644 --- a/vl.c +++ b/vl.c @@ -1651,6 +1651,14 @@ static int fsdev_init_func(QemuOpts *opts, void *opaque) #endif #ifdef CONFIG_TPM +static int tpm_init_func(QemuOpts *opts, void *opaque) +{ + int ret; + ret = qemu_tpm_add(opts); + + return ret; +} + static int tpm_acpi_init_func(QemuOpts *opts, void *opaque) { int ret = 0; @@ -1993,6 +2001,10 @@ int main(int argc, char **argv, char **envp) tb_size = 0; autostart= 1; +#ifdef CONFIG_TPM + qemu_add_opts(&qemu_tpm_opts); +#endif + /* first pass of option parsing */ optind = 1; while (optind < argc) { @@ -2493,6 +2505,13 @@ int main(int argc, char **argv, char **envp) qemu_free(arg_9p); break; } + case QEMU_OPTION_tpm: + opts = qemu_opts_parse(qemu_find_opts("tpm"), optarg, 0); + if (!opts) { + fprintf(stderr, "parse error: %s\n", optarg); + exit(1); + } + break; case QEMU_OPTION_serial: add_device_config(DEV_SERIAL, optarg); default_serial = 0; @@ -2881,6 +2900,9 @@ int main(int argc, char **argv, char **envp) #endif #ifdef CONFIG_TPM + if (qemu_opts_foreach(qemu_find_opts("tpm"), tpm_init_func, NULL, 1) != 0) { + exit(1); + } /* register TPM acpi table before machine->init is called */ if (qemu_opts_foreach(qemu_find_opts("device"), tpm_acpi_init_func, NULL, 1) != 0) { exit(1);