From patchwork Thu Sep 29 13:47:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 116954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9116D1007D5 for ; Thu, 29 Sep 2011 23:48:13 +1000 (EST) Received: from localhost ([::1]:60810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9Gy0-0003de-QG for incoming@patchwork.ozlabs.org; Thu, 29 Sep 2011 09:48:00 -0400 Received: from eggs.gnu.org ([140.186.70.92]:58675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9Gxj-0003GX-Rg for qemu-devel@nongnu.org; Thu, 29 Sep 2011 09:47:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9Gxf-0004Au-RP for qemu-devel@nongnu.org; Thu, 29 Sep 2011 09:47:43 -0400 Received: from gw.ac.upc.edu ([147.83.30.3]:50998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9Gxf-0004Ap-Cb for qemu-devel@nongnu.org; Thu, 29 Sep 2011 09:47:39 -0400 Received: from localhost (unknown [84.88.53.92]) by gw.ac.upc.edu (Postfix) with ESMTP id 24A7F6B0246; Thu, 29 Sep 2011 15:47:38 +0200 (CEST) To: qemu-devel@nongnu.org From: =?utf-8?b?TGx1w61z?= Vilanova Date: Thu, 29 Sep 2011 15:47:38 +0200 Message-ID: <20110929134738.19559.86414.stgit@ginnungagap.bsc.es> In-Reply-To: <20110929134727.19559.54734.stgit@ginnungagap.bsc.es> References: <20110929134727.19559.54734.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.15 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 147.83.30.3 Cc: Zhi Yong Wu Subject: [Qemu-devel] [PATCH 2/5] backdoor: Add build infrastructure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Lluís Vilanova --- Makefile | 3 ++- Makefile.objs | 18 ++++++++++++++++++ Makefile.target | 4 +++- backdoor/qemu/qemu-backdoor.h | 29 +++++++++++++++++++++++++++++ configure | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 backdoor/qemu/qemu-backdoor.h diff --git a/Makefile b/Makefile index 6ed3194..fd7d9d9 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,8 @@ else DOCS= endif -SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory) BUILD_DIR=$(BUILD_DIR) +SUBDIR_MAKEFLAGS_=$(if $(V),,--no-print-directory) BUILD_DIR=$(BUILD_DIR) +SUBDIR_MAKEFLAGS=$(SUBDIR_MAKEFLAGS_) SUBDIR_MAKEFLAGS="$(SUBDIR_MAKEFLAGS_)" SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS)) SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %/config-devices.mak.d, $(TARGET_DIRS)) diff --git a/Makefile.objs b/Makefile.objs index 1c65087..2493e59 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -395,6 +395,24 @@ trace-obj-y += $(addprefix trace/, $(trace-nested-y)) $(trace-obj-y): $(GENERATED_HEADERS) ###################################################################### +# backdoor + +backdoor-obj-y += $(addprefix backdoor/qemu/, $(backdoor-nested-y)) + +ifdef CONFIG_BACKDOOR +LIBBACKDOOR = libbackdoor/libbackdoor.a + +.PHONY: force +force: + +$(LIBBACKDOOR): $(dir $(LIBBACKDOOR))/Makefile force + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) \ + QEMU_CFLAGS="$(QEMU_CFLAGS)" \ + TARGET_DIR="$(TARGET_DIR)$(dir $@)/" VPATH="$(VPATH)" \ + SRC_PATH="$(SRC_PATH)" V="$(V)" "$(notdir $@)") +endif + +###################################################################### # smartcard libcacard-y = cac.o event.o vcard.o vreader.o vcard_emul_nss.o vcard_emul_type.o card_7816.o diff --git a/Makefile.target b/Makefile.target index b00ff4e..565d0a8 100644 --- a/Makefile.target +++ b/Makefile.target @@ -79,6 +79,8 @@ libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o libobj-y += disas.o +libobj-$(CONFIG_BACKDOOR) += $(backdoor-obj-y) + $(libobj-y): $(GENERATED_HEADERS) # libqemu @@ -397,7 +399,7 @@ endif # CONFIG_LINUX_USER obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o -$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) +$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(LIBBACKDOOR) $(call LINK,$^) diff --git a/backdoor/qemu/qemu-backdoor.h b/backdoor/qemu/qemu-backdoor.h new file mode 100644 index 0000000..95cb53f --- /dev/null +++ b/backdoor/qemu/qemu-backdoor.h @@ -0,0 +1,29 @@ +/* + * QEMU-side user-provided callbacks for the backdoor communication channel. + * + * Copyright (C) 2011 Lluís Vilanova + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include +#include + + +/* Initialize the backdoor channel. + * + * @param data_size Size of the data channel. + */ +void qemu_backdoor_init(uint64_t data_size); + +/* Handle an invocation of the backdoor channel. + * + * The command argument can be used to achieve concurrency among different + * clients (e.g., threads in the guest system) of the backdoor channel (e.g., + * different clients write to different parts of the data channel). + * + * @param cmd Command to invoke. + * @param data Pointer to the beginning of the data channel. + */ +void qemu_backdoor(uint64_t cmd, void *data); diff --git a/configure b/configure index 24b8df4..e2be271 100755 --- a/configure +++ b/configure @@ -174,6 +174,7 @@ user_pie="no" zero_malloc="" trace_backend="nop" trace_file="trace" +backdoor="" spice="" rbd="" smartcard="" @@ -540,6 +541,8 @@ for opt do ;; --with-trace-file=*) trace_file="$optarg" ;; + --with-backdoor=*) backdoor="$optarg" + ;; --enable-gprof) gprof="yes" ;; --static) @@ -1037,6 +1040,7 @@ echo " --enable-trace-backend=B Set trace backend" echo " Available backends:" $("$source_path"/scripts/tracetool --list-backends) echo " --with-trace-file=NAME Full PATH,NAME of file to store traces" echo " Default:trace-" +echo " --with-backdoor=PATH Directory to build user-provided backdoor library" echo " --disable-spice disable spice" echo " --enable-spice enable spice" echo " --enable-rbd enable building the rados block device (rbd)" @@ -2514,6 +2518,20 @@ if test "$trace_backend" = "dtrace"; then fi ########################################## +# check for a valid directory for backdoor +if test -n "$backdoor"; then + if test ! -f "$backdoor/Makefile"; then + echo + echo "Error: cannot make into '$backdoor'" + echo "Please choose a directory where I can run 'make'" + echo + exit 1 + fi + backdoor=`readlink -f "$backdoor"` +fi + + +########################################## # __sync_fetch_and_and requires at least -march=i486. Many toolchains # use i686 as default anyway, but for those that don't, an explicit # specification is necessary @@ -2707,6 +2725,9 @@ echo "uuid support $uuid" echo "vhost-net support $vhost_net" echo "Trace backend $trace_backend" echo "Trace output file $trace_file-" +if test -n "$backdoor"; then + echo "Backdoor lib dir $backdoor" +fi echo "spice support $spice" echo "rbd support $rbd" echo "xfsctl support $xfs" @@ -3072,6 +3093,13 @@ if test "$trace_default" = "yes"; then echo "CONFIG_TRACE_DEFAULT=y" >> $config_host_mak fi +# backdoor channel +if test -n "$backdoor"; then + echo "CONFIG_BACKDOOR=y" >> $config_host_mak + echo "BACKDOOR_PATH=\"$backdoor\"" >> $config_host_mak + QEMU_CFLAGS="-I\"$backdoor\" $QEMU_CFLAGS" +fi + echo "TOOLS=$tools" >> $config_host_mak echo "ROMS=$roms" >> $config_host_mak echo "MAKE=$make" >> $config_host_mak @@ -3185,6 +3213,10 @@ if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$targ mkdir -p $target_dir/nwfpe fi symlink $source_path/Makefile.target $target_dir/Makefile +if test -n "$backdoor"; then + mkdir -p $target_dir/libbackdoor + symlink $backdoor/Makefile $target_dir/libbackdoor/Makefile +fi echo "# Automatically generated by configure - do not modify" > $config_target_mak