From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 From: Alexey Kardashevskiy Date: Mon, 25 Aug 2014 20:22:01 +1000 Message-Id: <1408962121-8867-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [RFC PATCH] vmstate: Enable custom migration block name check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , Alexander Graf 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; } -- 2.0.0