From patchwork Tue Jun 19 19:15:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 165853 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AB1B3B7047 for ; Wed, 20 Jun 2012 07:18:13 +1000 (EST) Received: from localhost ([::1]:44022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sh3us-0003pN-6Z for incoming@patchwork.ozlabs.org; Tue, 19 Jun 2012 15:16:42 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sh3tp-0001eV-PK for qemu-devel@nongnu.org; Tue, 19 Jun 2012 15:15:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sh3tm-0004gG-SL for qemu-devel@nongnu.org; Tue, 19 Jun 2012 15:15:37 -0400 Received: from cantor2.suse.de ([195.135.220.15]:48209 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sh3tm-0004eT-Df; Tue, 19 Jun 2012 15:15:34 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 2042AA4A7C; Tue, 19 Jun 2012 21:15:33 +0200 (CEST) From: Alexander Graf To: qemu-devel qemu-devel Date: Tue, 19 Jun 2012 21:15:14 +0200 Message-Id: <1340133324-352-22-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1340133324-352-1-git-send-email-agraf@suse.de> References: <1340133324-352-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: qemu-ppc Mailing List Subject: [Qemu-devel] [PATCH 21/31] dt: Add -machine dumpdtb option to dump the current dtb 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 Now that we are dynamically creating the dtb, it's really useful to be able to dump the created blob for debugging. This patch implements a -machine dumpdtb= option for e500 that dumps the dtb exactly in the form the guest would get it to disk. It can then be analyzed by dtc to get information about the guest configuration. Signed-off-by: Alexander Graf --- hw/ppce500_mpc8544ds.c | 18 ++++++++++++++++++ qemu-config.c | 4 ++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c index 880ed55..7c6edc2 100644 --- a/hw/ppce500_mpc8544ds.c +++ b/hw/ppce500_mpc8544ds.c @@ -111,6 +111,8 @@ static int mpc8544_load_device_tree(CPUPPCState *env, uint32_t pci_ranges[12] = { 0x2000000, 0x0, 0xc0000000, 0xc0000000, 0x0, 0x20000000, 0x1000000, 0x0, 0x0, 0xe1000000, 0x0, 0x10000 }; + QemuOpts *machine_opts; + const char *dumpdtb = NULL; fdt = create_device_tree(&fdt_size); if (fdt == NULL) { @@ -300,6 +302,22 @@ static int mpc8544_load_device_tree(CPUPPCState *env, qemu_devtree_setprop_cell(fdt, pci, "#address-cells", 3); qemu_devtree_setprop_string(fdt, "/aliases", "pci0", pci); + machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0); + if (machine_opts) { + dumpdtb = qemu_opt_get(machine_opts, "dumpdtb"); + } + if (dumpdtb) { + /* Dump the dtb to a file and quit */ + FILE *f = fopen(dumpdtb, "wb"); + size_t len; + len = fwrite(fdt, fdt_size, 1, f); + fclose(f); + if (len != fdt_size) { + exit(1); + } + exit(0); + } + ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); if (ret < 0) { goto out; diff --git a/qemu-config.c b/qemu-config.c index bb3bff4..5bbebaf 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -583,6 +583,10 @@ static QemuOptsList qemu_machine_opts = { .name = "dtb", .type = QEMU_OPT_STRING, .help = "Linux kernel device tree file", + }, { + .name = "dumpdtb", + .type = QEMU_OPT_STRING, + .help = "Dump current dtb to a file and quit", }, { /* End of list */ } },