From patchwork Tue May 31 00:41:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 9143127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9517760777 for ; Tue, 31 May 2016 00:58:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71BDA20120 for ; Tue, 31 May 2016 00:58:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5255228183; Tue, 31 May 2016 00:58:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 8095420120 for ; Tue, 31 May 2016 00:58:21 +0000 (UTC) Received: from localhost ([::1]:33825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7Y0i-0001XA-2J for patchwork-qemu-devel@patchwork.kernel.org; Mon, 30 May 2016 20:58:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7XkS-0003N3-GV for qemu-devel@nongnu.org; Mon, 30 May 2016 20:41:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7XkM-0002sM-Vd for qemu-devel@nongnu.org; Mon, 30 May 2016 20:41:32 -0400 Received: from ozlabs.org ([103.22.144.67]:41914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7XkM-0002qz-Kj; Mon, 30 May 2016 20:41:26 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3rJZRh720Nz9t8C; Tue, 31 May 2016 10:41:20 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1464655280; bh=3DvO7hWAKZ27u6X5mnSddrakeYUSNEbZaKrZ0P+B/BM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QYV39ZS6fHUD+D30pM+iAPi9SjpRmJqqqzBaVdoqLH+iiKvkIMmrovIE4sk0AsIeB WdRFn/jZwHV/ukKyz3+qmuUYW0ErZ7GQInpvKlGoSNix94Iw6v2kTBR8oJDP1/XXdP HqsvxfB2U8p+ekOH6iAT/nCI26d4CWsxlSsIi3Pk= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 31 May 2016 10:41:15 +1000 Message-Id: <1464655277-14748-11-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464655277-14748-1-git-send-email-david@gibson.dropbear.id.au> References: <1464655277-14748-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 10/12] exec: Do vmstate unregistration from cpu_exec_exit() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bharata B Rao , qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, bharata.rao@gmail.com, pbonzini@redhat.com, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Bharata B Rao cpu_exec_init() does vmstate_register for the CPU device. This needs to be undone from cpu_exec_exit(). This change is needed to support CPU hot removal. Signed-off-by: Bharata B Rao Reviewed-by: Thomas Huth Reviewed-by: David Gibson Acked-by: Paolo Bonzini [dwg: added missing include to fix compile on some archs] Signed-off-by: David Gibson --- exec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/exec.c b/exec.c index a1dfc01..7261172 100644 --- a/exec.c +++ b/exec.c @@ -57,6 +57,8 @@ #include "exec/ram_addr.h" #include "exec/log.h" +#include "migration/vmstate.h" + #include "qemu/range.h" #ifndef _WIN32 #include "qemu/mmap-alloc.h" @@ -637,6 +639,8 @@ static void cpu_release_index(CPUState *cpu) void cpu_exec_exit(CPUState *cpu) { + CPUClass *cc = CPU_GET_CLASS(cpu); + #if defined(CONFIG_USER_ONLY) cpu_list_lock(); #endif @@ -654,6 +658,13 @@ void cpu_exec_exit(CPUState *cpu) #if defined(CONFIG_USER_ONLY) cpu_list_unlock(); #endif + + if (cc->vmsd != NULL) { + vmstate_unregister(NULL, cc->vmsd, cpu); + } + if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { + vmstate_unregister(NULL, &vmstate_cpu_common, cpu); + } } void cpu_exec_init(CPUState *cpu, Error **errp)