From patchwork Wed May 24 04:53:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 766314 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wXg9V6njtz9sP5 for ; Wed, 24 May 2017 14:57:02 +1000 (AEST) Received: from localhost ([::1]:52729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDOM0-0002u0-Ji for incoming@patchwork.ozlabs.org; Wed, 24 May 2017 00:57:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDOJw-0001ba-Jz for qemu-devel@nongnu.org; Wed, 24 May 2017 00:54:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDOJt-0007C3-Un for qemu-devel@nongnu.org; Wed, 24 May 2017 00:54:52 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDOJt-0007BU-Lp for qemu-devel@nongnu.org; Wed, 24 May 2017 00:54:49 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4O4rnQ6141749 for ; Wed, 24 May 2017 00:54:48 -0400 Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142]) by mx0a-001b2d01.pphosted.com with ESMTP id 2an1m0khxp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 24 May 2017 00:54:48 -0400 Received: from localhost by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 24 May 2017 14:54:44 +1000 Received: from d23relay10.au.ibm.com (202.81.31.229) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 24 May 2017 14:54:42 +1000 Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4O4sX0m63045704; Wed, 24 May 2017 14:54:41 +1000 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v4O4s9UE022210; Wed, 24 May 2017 14:54:09 +1000 Received: from bharata.in.ibm.com ([9.124.35.203]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v4O4s4en021724; Wed, 24 May 2017 14:54:07 +1000 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:23:32 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495601614-18586-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1495601614-18586-1-git-send-email-bharata@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17052404-0052-0000-0000-00000243678F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052404-0053-0000-0000-0000081FEF47 Message-Id: <1495601614-18586-2-git-send-email-bharata@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-24_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705240022 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v3 1/3] migration: Introduce unregister_savevm_live() 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: rnsastry@linux.vnet.ibm.com, Juan Quintela , "Dr . David Alan Gilbert" , qemu-ppc@nongnu.org, sjitindarsingh@gmail.com, Bharata B Rao , sam.bobroff@au1.ibm.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Introduce a new function unregister_savevm_live() to unregister the vmstate handlers registered via register_savevm_live(). register_savevm() allocates SaveVMHandlers while register_savevm_live() gets passed with SaveVMHandlers. During unregistration, we want to free SaveVMHandlers in the former case but not free in the latter case. Hence this new API is needed to differentiate this. This new API will be needed by PowerPC to unregister the HTAB savevm handlers. Signed-off-by: Bharata B Rao Reviewed-by: David Gibson Cc: Juan Quintela Cc: Dr. David Alan Gilbert --- include/migration/vmstate.h | 1 + migration/savevm.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 8489659..02a1bac 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -79,6 +79,7 @@ int register_savevm_live(DeviceState *dev, void *opaque); void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); +void unregister_savevm_live(DeviceState *dev, const char *idstr, void *opaque); typedef struct VMStateInfo VMStateInfo; typedef struct VMStateDescription VMStateDescription; diff --git a/migration/savevm.c b/migration/savevm.c index f5e8194..4ef6fdc 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -630,7 +630,8 @@ int register_savevm(DeviceState *dev, ops, opaque); } -void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque) +static void unregister_savevm_common(DeviceState *dev, const char *idstr, + void *opaque, bool free_savevmhandlers) { SaveStateEntry *se, *new_se; char id[256] = ""; @@ -649,12 +650,24 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque) if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) { QTAILQ_REMOVE(&savevm_state.handlers, se, entry); g_free(se->compat); - g_free(se->ops); + if (free_savevmhandlers) { + g_free(se->ops); + } g_free(se); } } } +void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque) +{ + unregister_savevm_common(dev, idstr, opaque, true); +} + +void unregister_savevm_live(DeviceState *dev, const char *idstr, void *opaque) +{ + unregister_savevm_common(dev, idstr, opaque, false); +} + int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *opaque, int alias_id,