From nobody Sun Feb 8 14:52:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493071853734200.2515052131455; Mon, 24 Apr 2017 15:10:53 -0700 (PDT) Received: from localhost ([::1]:46148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2mC4-00021x-2s for importer@patchew.org; Mon, 24 Apr 2017 18:10:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2mAL-0000uh-6F for qemu-devel@nongnu.org; Mon, 24 Apr 2017 18:09:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2mAI-0008Fi-K3 for qemu-devel@nongnu.org; Mon, 24 Apr 2017 18:09:05 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53136) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d2mAI-0008Ed-CG for qemu-devel@nongnu.org; Mon, 24 Apr 2017 18:09:02 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3OM3sb6122065 for ; Mon, 24 Apr 2017 18:09:00 -0400 Received: from e24smtp04.br.ibm.com (e24smtp04.br.ibm.com [32.104.18.25]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a1qnw4w31-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 24 Apr 2017 18:08:59 -0400 Received: from localhost by e24smtp04.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 24 Apr 2017 19:08:57 -0300 Received: from d24relay04.br.ibm.com (9.18.232.146) by e24smtp04.br.ibm.com (10.172.0.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 24 Apr 2017 19:08:55 -0300 Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3OM8s633539388; Mon, 24 Apr 2017 19:08:54 -0300 Received: from d24av04.br.ibm.com (localhost [127.0.0.1]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3OM8sMN024936; Mon, 24 Apr 2017 19:08:54 -0300 Received: from arthas.ibm.com ([9.80.236.3]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3OM8gkJ024871; Mon, 24 Apr 2017 19:08:52 -0300 From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Mon, 24 Apr 2017 19:08:25 -0300 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170424220828.1472-1-danielhb@linux.vnet.ibm.com> References: <20170424220828.1472-1-danielhb@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17042422-0028-0000-0000-000001ADC136 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17042422-0029-0000-0000-000014ADFF52 Message-Id: <20170424220828.1472-2-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-24_18:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704240371 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 1/4] migration: alternative way to set instance_id in SaveStateEntry 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: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jianjun Duan In QOM (QEMU Object Model) migrated objects are identified with instance_id which is calculated automatically using their path in the QOM composition tree. For some objects, this path could change from source to target in migration. To migrate such objects, we need to make sure the instance_id do= es not change from source to target. We add a hook in DeviceClass to do custom= ized instance_id calculation in such cases. As a result, in these cases compat will not be set in the concerned SaveStateEntry. This will prevent the inconsistent idstr to be sent over in migration. We could have set alias_id in a similar way. But that will be overloading the purpose of alias_id. The first application will be setting instance_id for pseries DRC objects u= sing its unique index. Doing this makes the instance_id of DRC to be consistent across migration and supports flexible management of DRC objects in migrati= on. Signed-off-by: Jianjun Duan Signed-off-by: Daniel Henrique Barboza --- include/hw/qdev-core.h | 6 ++++++ migration/savevm.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 4bf86b0..9b3914c 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -127,6 +127,12 @@ typedef struct DeviceClass { qdev_initfn init; /* TODO remove, once users are converted to realize = */ qdev_event exit; /* TODO remove, once users are converted to unrealize= */ const char *bus_type; + + /* When this field is set, qemu will use it to get an unique instance_= id + * instead of calculating an auto idstr and instance_id for the releva= nt + * SaveStateEntry + */ + int (*dev_get_instance_id)(DeviceState *dev); } DeviceClass; =20 typedef struct NamedGPIOList NamedGPIOList; diff --git a/migration/savevm.c b/migration/savevm.c index 03ae1bd..5d8135f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -606,6 +606,9 @@ int register_savevm_live(DeviceState *dev, calculate_compat_instance_id(idstr) : instance_id; instance_id =3D -1; } + if (DEVICE_GET_CLASS(dev)->dev_get_instance_id) { + instance_id =3D DEVICE_GET_CLASS(dev)->dev_get_instance_id(dev= ); + } } pstrcat(se->idstr, sizeof(se->idstr), idstr); =20 @@ -696,6 +699,9 @@ int vmstate_register_with_alias_id(DeviceState *dev, in= t instance_id, calculate_compat_instance_id(vmsd->name) : instan= ce_id; instance_id =3D -1; } + if (DEVICE_GET_CLASS(dev)->dev_get_instance_id) { + instance_id =3D DEVICE_GET_CLASS(dev)->dev_get_instance_id(dev= ); + } } pstrcat(se->idstr, sizeof(se->idstr), vmsd->name); =20 --=20 2.9.3