From nobody Fri May 3 03:40:26 2024 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.zohomail.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 1517845094800983.9079927543818; Mon, 5 Feb 2018 07:38:14 -0800 (PST) Received: from localhost ([::1]:54037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiqU-00078g-0J for importer@patchew.org; Mon, 05 Feb 2018 10:38:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiiCj-0006Ol-Kp for qemu-devel@nongnu.org; Mon, 05 Feb 2018 09:57:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiiCg-0005JY-ER for qemu-devel@nongnu.org; Mon, 05 Feb 2018 09:57:09 -0500 Received: from mga04.intel.com ([192.55.52.120]:20501) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eiiCg-0005Hq-4Q for qemu-devel@nongnu.org; Mon, 05 Feb 2018 09:57:06 -0500 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2018 06:57:04 -0800 Received: from dpdk06.sh.intel.com ([10.67.110.196]) by fmsmga005.fm.intel.com with ESMTP; 05 Feb 2018 06:57:03 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,465,1511856000"; d="scan'208";a="201306368" From: Jianfeng Tan To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 14:58:55 +0000 Message-Id: <1517842735-9011-1-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.120 Subject: [Qemu-devel] [RFC] exec: eliminate ram naming issue as migration 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: Jianfeng Tan , Paolo Bonzini , Jason Wang , Maxime Coquelin , "Michael S . Tsirkin" 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" Existing VMs with virtio devices and vhost-kernel as the backend are always started with mem config: "-m xG" (with a ram block named "pc.ram") while new VMs with virtio devices and vhost-user as the backend are always started with mem config: "-m xG -numa node,memdev=3Dpc.ram -object memory-backend-file,id=3Dpc.ram= ,..." (with a ram block named "/object/pc.ram") As we migrate from vhost-kernel to vhost-user, it failes as: Unknown ramblock "pc.ram", cannot accept migration error while loading state for instance 0x0 of device 'ram' load of migration failed: Invalid argument Here are some options to fix this: 1. When we do ram name comparison, we truncate the prefix as this patch sho= ws. It cannot cover the corner case: the source VM could have two ram blocks with name of "pc.ram" and "/object/pc.ram". 2. We add an alias name to RAMBlock; when we do name comparison, not only idstr is compared, but also compared to the alias. But this will add more complexity to upper layer stack OpenStack/libvirt. Any thoughts? Cc: Jason Wang Cc: Michael S. Tsirkin Cc: Maxime Coquelin Cc: Paolo Bonzini Suggested-by: Michael S. Tsirkin Signed-off-by: Jianfeng Tan --- exec.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 4722e52..d294e5c 100644 --- a/exec.c +++ b/exec.c @@ -2334,13 +2334,24 @@ found: RAMBlock *qemu_ram_block_by_name(const char *name) { RAMBlock *block; + char *name1, *id1; + char *name2, *id2; + + name1 =3D strdup(name); + id1 =3D basename(name1); =20 RAMBLOCK_FOREACH(block) { - if (!strcmp(name, block->idstr)) { + name2 =3D strdup(block->idstr); + id2 =3D basename(name2); + if (!strcmp(id1, id2)) { + free(name1); + free(name2); return block; } + free(name2); } =20 + free(name1); return NULL; } =20 --=20 2.7.4