From nobody Tue Feb 10 04:14:38 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 1496345114264537.980290662382; Thu, 1 Jun 2017 12:25:14 -0700 (PDT) Received: from localhost ([::1]:46344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGVia-0005S6-NI for importer@patchew.org; Thu, 01 Jun 2017 15:25:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGVh2-0004NO-60 for qemu-devel@nongnu.org; Thu, 01 Jun 2017 15:23:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGVh0-0004qR-JH for qemu-devel@nongnu.org; Thu, 01 Jun 2017 15:23:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39516) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGVh0-0004px-9z for qemu-devel@nongnu.org; Thu, 01 Jun 2017 15:23:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56393BB9C1 for ; Thu, 1 Jun 2017 19:23:33 +0000 (UTC) Received: from secure.mitica (ovpn-117-3.ams2.redhat.com [10.36.117.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6D045C685; Thu, 1 Jun 2017 19:23:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 56393BB9C1 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 56393BB9C1 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 1 Jun 2017 21:23:13 +0200 Message-Id: <20170601192327.29712-2-quintela@redhat.com> In-Reply-To: <20170601192327.29712-1-quintela@redhat.com> References: <20170601192327.29712-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 01 Jun 2017 19:23:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/15] migration: Use savevm_handlers instead of loadvm copy 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com 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" There is no reason for having the loadvm_handlers at all. There is only one use, and we can use the savevm handlers. We will remove the loadvm handlers on a following patch. Signed-off-by: Juan Quintela Reviewed-by: Laurent Vivier Reviewed-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert -- - Added load_version_id: version_id read from the stream (laurent) - Added load_section_id: section_id read from the stream (dave) --- migration/savevm.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index a2d4f9c..07646f4 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -272,7 +272,11 @@ typedef struct SaveStateEntry { int instance_id; int alias_id; int version_id; + /* version id read from the stream */ + int load_version_id; int section_id; + /* section id read from the stream */ + int load_section_id; SaveVMHandlers *ops; const VMStateDescription *vmsd; void *opaque; @@ -1813,7 +1817,7 @@ struct LoadStateEntry { * Returns: true if the footer was good * false if there is a problem (and calls error_report to say why) */ -static bool check_section_footer(QEMUFile *f, LoadStateEntry *le) +static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) { uint8_t read_mark; uint32_t read_section_id; @@ -1826,15 +1830,15 @@ static bool check_section_footer(QEMUFile *f, LoadS= tateEntry *le) read_mark =3D qemu_get_byte(f); =20 if (read_mark !=3D QEMU_VM_SECTION_FOOTER) { - error_report("Missing section footer for %s", le->se->idstr); + error_report("Missing section footer for %s", se->idstr); return false; } =20 read_section_id =3D qemu_get_be32(f); - if (read_section_id !=3D le->section_id) { + if (read_section_id !=3D se->load_section_id) { error_report("Mismatched section id in footer for %s -" " read 0x%x expected 0x%x", - le->se->idstr, read_section_id, le->section_id); + se->idstr, read_section_id, se->load_section_id); return false; } =20 @@ -1887,6 +1891,8 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migration= IncomingState *mis) version_id, idstr, se->version_id); return -EINVAL; } + se->load_version_id =3D version_id; + se->load_section_id =3D section_id; =20 /* Validate if it is a device's state */ if (xen_enabled() && se->is_ram) { @@ -1902,13 +1908,13 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migrati= onIncomingState *mis) le->version_id =3D version_id; QLIST_INSERT_HEAD(&mis->loadvm_handlers, le, entry); =20 - ret =3D vmstate_load(f, le->se, le->version_id); + ret =3D vmstate_load(f, se, se->load_version_id); if (ret < 0) { error_report("error while loading state for instance 0x%x of" " device '%s'", instance_id, idstr); return ret; } - if (!check_section_footer(f, le)) { + if (!check_section_footer(f, se)) { return -EINVAL; } =20 @@ -1919,29 +1925,29 @@ static int qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) { uint32_t section_id; - LoadStateEntry *le; + SaveStateEntry *se; int ret; =20 section_id =3D qemu_get_be32(f); =20 trace_qemu_loadvm_state_section_partend(section_id); - QLIST_FOREACH(le, &mis->loadvm_handlers, entry) { - if (le->section_id =3D=3D section_id) { + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (se->load_section_id =3D=3D section_id) { break; } } - if (le =3D=3D NULL) { + if (se =3D=3D NULL) { error_report("Unknown savevm section %d", section_id); return -EINVAL; } =20 - ret =3D vmstate_load(f, le->se, le->version_id); + ret =3D vmstate_load(f, se, se->load_version_id); if (ret < 0) { error_report("error while loading state section id %d(%s)", - section_id, le->se->idstr); + section_id, se->idstr); return ret; } - if (!check_section_footer(f, le)) { + if (!check_section_footer(f, se)) { return -EINVAL; } =20 --=20 2.9.4