From patchwork Mon Aug 25 10:22:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 382679 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 C51AD1400EA for ; Mon, 25 Aug 2014 20:22:47 +1000 (EST) Received: from localhost ([::1]:47209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLrQD-0007oQ-Tb for incoming@patchwork.ozlabs.org; Mon, 25 Aug 2014 06:22:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLrPq-0007Y0-8w for qemu-devel@nongnu.org; Mon, 25 Aug 2014 06:22:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XLrPh-0004pW-Rw for qemu-devel@nongnu.org; Mon, 25 Aug 2014 06:22:22 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:35860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLrPh-0004pQ-7v for qemu-devel@nongnu.org; Mon, 25 Aug 2014 06:22:13 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Aug 2014 20:22:07 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 25 Aug 2014 20:22:06 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 47C622BB002D for ; Mon, 25 Aug 2014 20:22:06 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s7PAN5fc17563766 for ; Mon, 25 Aug 2014 20:23:07 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s7PAM35Y006906 for ; Mon, 25 Aug 2014 20:22:03 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.190.163.12]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s7PAM3bY006903; Mon, 25 Aug 2014 20:22:03 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.190.164.82]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 7E2A8A01FB; Mon, 25 Aug 2014 20:22:03 +1000 (EST) Received: from ka1.ozlabs.ibm.com (ka1.ozlabs.ibm.com [10.61.145.11]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 323A516AB88; Mon, 25 Aug 2014 20:22:03 +1000 (EST) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Mon, 25 Aug 2014 20:22:01 +1000 Message-Id: <1408962121-8867-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 2.0.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14082510-7014-0000-0000-0000001D8730 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 202.81.31.148 Cc: Alexey Kardashevskiy , Alexander Graf Subject: [Qemu-devel] [RFC PATCH] vmstate: Enable custom migration block name check 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 This adds a callback to support custom names for migration blocks. Signed-off-by: Alexey Kardashevskiy --- RFC! not a real patch! There was a problem a while ago how to migrate sPAPR TCE tables - they needed unique id + instance_id and there 2 approaches for that: 1. Put them on a virtual made-up TCE bus, LIOBN (logical bus number) is an unique ID and this would give TCE tables unique names like liobn@80000000/spapr_iommu, instance id would always be 0. vmstate_spapr_tce_table would be registered via DeviceClass::vmsd pointer. 2. Do not register vmsd via DeviceClass and use explicit call of vmstate_register() using LIOBN as an instance id. This way TCE tables would get "spapr_iommu" name and unique id == LIOBN. Approach 2 is used by upstream. Both 1 and 2 were suggested by maintainers :) However with 1 month delay and I started using 1) in our internal build of "powerkvm". In the current version of our internal "powerkvm" thing I used 2) as this is what upstream uses. The proposed patch is a part of a hack to allow migration liobn@80000000/spapr_iommu + 0 to spapr_iommu + 80000000. Is this too horrible to be considered as a patch for upstream? I am not going to push the second part of the hack anyway. Is there any other way to implement the hack I want without toching these files? Thanks! --- include/migration/vmstate.h | 1 + savevm.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 2759908..86afd9a 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -134,6 +134,7 @@ struct VMStateDescription { int (*pre_load)(void *opaque); int (*post_load)(void *opaque, int version_id); void (*pre_save)(void *opaque); + bool (*compat_name)(void *opaque, const char *idstr, int instance_id); VMStateField *fields; const VMStateSubsection *subsections; }; diff --git a/savevm.c b/savevm.c index 22123be..60e7dd8 100644 --- a/savevm.c +++ b/savevm.c @@ -731,6 +731,12 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) instance_id == se->alias_id)) return se; } + + /* Migrating from a weird custom version? */ + if (se->vmsd && se->vmsd->compat_name && + se->vmsd->compat_name(se->opaque, idstr, instance_id)) { + return se; + } } return NULL; }