From patchwork Tue May 21 10:57:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 245275 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 D79D82C00BF for ; Tue, 21 May 2013 21:06:13 +1000 (EST) Received: from localhost ([::1]:56598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UekOQ-0007FO-GT for incoming@patchwork.ozlabs.org; Tue, 21 May 2013 07:06:10 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UekHH-0005eT-0K for qemu-devel@nongnu.org; Tue, 21 May 2013 06:58:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UekHF-0005oV-IW for qemu-devel@nongnu.org; Tue, 21 May 2013 06:58:46 -0400 Received: from mail-ee0-f53.google.com ([74.125.83.53]:44516) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UekHF-0005mj-42 for qemu-devel@nongnu.org; Tue, 21 May 2013 06:58:45 -0400 Received: by mail-ee0-f53.google.com with SMTP id c1so299160eek.12 for ; Tue, 21 May 2013 03:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=tzJS/nQKl36Abf9/+IyjKYFF4X8bQCNqahATgG+WPwI=; b=0llumKZIrkQauDxwllGu8w1rrWmB+GtScUqjnKHIRyV6eBxXVeRNYu9rJ8Xm+WzyQH I8A9Dc54Up69p8WMjdW4MywHEVF64vHTOB7tHe6zvE6oY6+XTIq/3EooevNDFgHBqDje QKZcjBzU5UklMAMVOJ5STbXC8fGVejjJmY9DibZttOR6CPxXEnniw5LSUW7r3kpkH7u7 rLXtXupwfWdMp76qkCFSI3HwAHABgBXjaNhRmWIE4SM83NPe+bE/rnG/yyNNt6UxxV5Y iNRP9dQScB5ZFbTsTszUrn7O9mR7lo35MwWOEGUR+n/jBfTeobqnltQhJrXb8GUNoMW2 uLUg== X-Received: by 10.14.7.198 with SMTP id 46mr5319439eep.17.1369133924353; Tue, 21 May 2013 03:58:44 -0700 (PDT) Received: from playground.lan (net-37-116-223-193.cust.dsl.vodafone.it. [37.116.223.193]) by mx.google.com with ESMTPSA id a5sm2754398ees.6.2013.05.21.03.58.42 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 21 May 2013 03:58:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 May 2013 12:57:31 +0200 Message-Id: <1369133851-1894-31-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1369133851-1894-1-git-send-email-pbonzini@redhat.com> References: <1369133851-1894-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.83.53 Cc: Alexey Kardashevskiy , peter.maydell@linaro.org, jan.kiszka@gmail.com, David Gibson Subject: [Qemu-devel] [PATCH 30/30] memory: give name to every AddressSpace 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 From: Alexey Kardashevskiy The "info mtree" command in QEMU console prints only "memory" and "I/O" address spaces while there are actually a lot more other AddressSpace structs created by PCI and VIO devices. Those devices do not normally have names and therefore not present in "info mtree" output. The patch fixes this. Signed-off-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini --- exec.c | 6 ++---- hw/pci/pci.c | 3 ++- hw/ppc/spapr_vio.c | 2 +- include/exec/memory.h | 5 +++-- memory.c | 8 +++----- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/exec.c b/exec.c index f508a59..1610604 100644 --- a/exec.c +++ b/exec.c @@ -1846,13 +1846,11 @@ static void memory_map_init(void) { system_memory = g_malloc(sizeof(*system_memory)); memory_region_init(system_memory, "system", INT64_MAX); - address_space_init(&address_space_memory, system_memory); - address_space_memory.name = "memory"; + address_space_init(&address_space_memory, system_memory, "memory"); system_io = g_malloc(sizeof(*system_io)); memory_region_init(system_io, "io", 65536); - address_space_init(&address_space_io, system_io); - address_space_io.name = "I/O"; + address_space_init(&address_space_io, system_io, "I/O"); memory_listener_register(&core_memory_listener, &address_space_memory); memory_listener_register(&io_memory_listener, &address_space_io); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2b1bc6d..fa30110 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -815,7 +815,8 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, memory_region_init_alias(&pci_dev->bus_master_enable_region, "bus master", dma_as->root, 0, memory_region_size(dma_as->root)); memory_region_set_enabled(&pci_dev->bus_master_enable_region, false); - address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region); + address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, + name); pci_dev->devfn = devfn; pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index 5e72f1b..3cfa326 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -458,7 +458,7 @@ static int spapr_vio_busdev_init(DeviceState *qdev) if (pc->rtce_window_size) { uint32_t liobn = SPAPR_VIO_BASE_LIOBN | dev->reg; dev->tcet = spapr_tce_new_table(liobn, pc->rtce_window_size); - address_space_init(&dev->as, spapr_tce_get_iommu(dev->tcet)); + address_space_init(&dev->as, spapr_tce_get_iommu(dev->tcet), qdev->id); } return pc->init(dev); diff --git a/include/exec/memory.h b/include/exec/memory.h index 05b9bb2..01b70ed 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -191,7 +191,7 @@ struct MemoryRegionPortio { */ struct AddressSpace { /* All fields are private. */ - const char *name; + char *name; MemoryRegion *root; struct FlatView *current_map; int ioeventfd_nb; @@ -858,8 +858,9 @@ void mtree_info(fprintf_function mon_printf, void *f); * * @as: an uninitialized #AddressSpace * @root: a #MemoryRegion that routes addesses for the address space + * @name: an address space name */ -void address_space_init(AddressSpace *as, MemoryRegion *root); +void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name); /** diff --git a/memory.c b/memory.c index e3970bf..66258e2 100644 --- a/memory.c +++ b/memory.c @@ -1605,7 +1605,7 @@ void memory_listener_unregister(MemoryListener *listener) QTAILQ_REMOVE(&memory_listeners, listener, link); } -void address_space_init(AddressSpace *as, MemoryRegion *root) +void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name) { memory_region_transaction_begin(); as->root = root; @@ -1614,7 +1614,7 @@ void address_space_init(AddressSpace *as, MemoryRegion *root) as->ioeventfd_nb = 0; as->ioeventfds = NULL; QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link); - as->name = NULL; + as->name = g_strdup(name?name:"anonymous"); address_space_init_dispatch(as); memory_region_update_pending |= root->enabled; memory_region_transaction_commit(); @@ -1629,6 +1629,7 @@ void address_space_destroy(AddressSpace *as) QTAILQ_REMOVE(&address_spaces, as, address_spaces_link); address_space_destroy_dispatch(as); flatview_destroy(as->current_map); + g_free(as->name); g_free(as->current_map); g_free(as->ioeventfds); } @@ -1755,9 +1756,6 @@ void mtree_info(fprintf_function mon_printf, void *f) QTAILQ_INIT(&ml_head); QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { - if (!as->name) { - continue; - } mon_printf(f, "%s\n", as->name); mtree_print_mr(mon_printf, f, as->root, 0, 0, &ml_head); }