From patchwork Fri Mar 18 09:13:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baptiste Reynal X-Patchwork-Id: 8617411 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 722409F44D for ; Fri, 18 Mar 2016 09:16:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C00BB2035D for ; Fri, 18 Mar 2016 09:16:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14FA92034B for ; Fri, 18 Mar 2016 09:16:44 +0000 (UTC) Received: from localhost ([::1]:42385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agqWR-0007HI-D7 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Mar 2016 05:16:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agqUK-0004JJ-VV for qemu-devel@nongnu.org; Fri, 18 Mar 2016 05:14:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agqUJ-00043M-TR for qemu-devel@nongnu.org; Fri, 18 Mar 2016 05:14:32 -0400 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:36093) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agqUJ-000434-MP for qemu-devel@nongnu.org; Fri, 18 Mar 2016 05:14:31 -0400 Received: by mail-wm0-x235.google.com with SMTP id l124so22978571wmf.1 for ; Fri, 18 Mar 2016 02:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtualopensystems-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gJsX8C9dCt40X2e/6hs7KE2lLxJPziGBCftxr8L0dbg=; b=I+/lGYFI7OdIENrMndx5hDbq5HHuuZdHMF0KgwGJ5w0bK0Qj3EpTJgzy888UAXfrZ8 FaDYuR/aI698rarADmqJGLJ0LHcjbSfiSd9J/fKAaJwwfEb3T1AKuLEEqLEfof7igUly Tj8N1KALT0DsgoWeURP6mmzVt9vkabbkrSmo2066yc8PXUp0mZItrS5ZKBZUw0VO1HJY HPgpU2YrFcGOpIvImlH0/r0AfPG0PnIBTrFUpiQrtBMOcIz/NY4ZNuauxXqbdkREB6Oy fsea/dXnMmdx6PmAugbY2G97vXAUujroVMsi7Q/DAyaNAv/no3JcpjcTIcCiFM44KZBU ByrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gJsX8C9dCt40X2e/6hs7KE2lLxJPziGBCftxr8L0dbg=; b=XPLJ2gIQx/xVNjbmNx12X/ShtbGhrhSMHzpAeNAc36ke2dRLbJTR2JKzJm332vKhC+ bZxylEqPXUG12pqlPXbhzQ8W2cLn6AJ8X5mv4CnaUET2BmNsDqeDmM+MmeLLCyJIuGy8 ydpawuQQUk3Ro3EXT8KLmzoUpcNDZW/WemmpU0wOh3j/yqYBOHlNaM1ChxoX1SYvBxDx hnT3289uE8oJ5cxyC1gUEG8dTDdr/LOsdpSvGngabcc51vnemqZ8YX7mtU413CLIBAoW kYp4TV+aeJTz+IeY53TQivrDWbo9K741v17sCorbyHGjfBY0+I6B/sf/Ob7ljs4HpBfF A5uw== X-Gm-Message-State: AD7BkJLRRLotyEcggT+jkIdkPbSazIXPYvJ3qIJGt7iSH+vREv9HebWvBb0e0cs61/7zWw== X-Received: by 10.28.92.195 with SMTP id q186mr15113903wmb.37.1458292471158; Fri, 18 Mar 2016 02:14:31 -0700 (PDT) Received: from localhost (LMontsouris-657-1-4-224.w90-63.abo.wanadoo.fr. [90.63.239.224]) by smtp.gmail.com with ESMTPSA id x203sm11736825wmg.23.2016.03.18.02.14.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Mar 2016 02:14:30 -0700 (PDT) From: Baptiste Reynal To: qemu-devel@nongnu.org Date: Fri, 18 Mar 2016 10:13:58 +0100 Message-Id: <1458292438-13909-7-git-send-email-b.reynal@virtualopensystems.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1458292438-13909-1-git-send-email-b.reynal@virtualopensystems.com> References: <1458292438-13909-1-git-send-email-b.reynal@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::235 Cc: b.reynal@virtualopensystems.com, Jani.Kokkonen@huawei.com, tech@virtualopensystems.com, Claudio.Fontana@huawei.com, Christian Pinto Subject: [Qemu-devel] [RFC v2 6/6] qemu: numa 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christian Pinto This patch modifies the behavior of memory_region_allocate_system_memory, when the new shared memory backend is used from a slave qemu instance. In such case there is not yet a valid pointer for the memory region pointed by the backend (it will be innitilized later when received from the master.) and vmstate_register would fail. The patch skips the call to vmstate_register in case of slave shared memory backend, that will be performed later after the actual memory pointer is available. Signed-off-by: Christian Pinto --- numa.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/numa.c b/numa.c index e9b18f5..b39a892 100644 --- a/numa.c +++ b/numa.c @@ -33,6 +33,7 @@ #include "qapi/dealloc-visitor.h" #include "hw/boards.h" #include "sysemu/hostmem.h" +#include "sysemu/hostmem-shared.h" #include "qmp-commands.h" #include "hw/mem/pc-dimm.h" #include "qemu/option.h" @@ -442,6 +443,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, { uint64_t addr = 0; int i; + bool vmstate_register = true; if (nb_numa_nodes == 0 || !have_memdevs) { allocate_system_memory_nonnuma(mr, owner, name, ram_size); @@ -453,9 +455,18 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, Error *local_err = NULL; uint64_t size = numa_info[i].node_mem; HostMemoryBackend *backend = numa_info[i].node_memdev; + if (!backend) { continue; } + + if (IS_MEMORY_BACKEND_SHARED(backend)) { + HostMemoryBackendShared *shm = MEMORY_BACKEND_SHARED(backend); + if (!shm->master) { + vmstate_register = false; + } + } + MemoryRegion *seg = host_memory_backend_get_memory(backend, &local_err); if (local_err) { error_report_err(local_err); @@ -471,7 +482,11 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, } memory_region_add_subregion(mr, addr, seg); - vmstate_register_ram_global(seg); + + if (vmstate_register) { + vmstate_register_ram_global(seg); + } + addr += size; } }