From nobody Fri May 17 05:54:39 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1554099391777429.3071048210695; Sun, 31 Mar 2019 23:16:31 -0700 (PDT) Received: from localhost ([127.0.0.1]:59517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hAqEy-0003yu-Pq for importer@patchew.org; Mon, 01 Apr 2019 02:16:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hAqE7-0003EH-Bn for qemu-devel@nongnu.org; Mon, 01 Apr 2019 02:15:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hAqE6-00070z-Cj for qemu-devel@nongnu.org; Mon, 01 Apr 2019 02:15:23 -0400 Received: from mga07.intel.com ([134.134.136.100]:53896) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hAqE4-0006vB-Ps for qemu-devel@nongnu.org; Mon, 01 Apr 2019 02:15:22 -0400 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Mar 2019 23:15:17 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga007.fm.intel.com with ESMTP; 31 Mar 2019 23:15:16 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,295,1549958400"; d="scan'208";a="139068925" From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 1 Apr 2019 14:14:57 +0800 Message-Id: <20190401061457.9393-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [PATCH] migration: cleanup check on ops in savevm.handlers iteration 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: Wei Yang , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" During migration, there are several places to iterate on savevm.handlers. And on each iteration, we need to check its ops and related callbacks before invoke it. Generally, ops is the first element to check, and it is only necessary to check it once. This patch clean all the related part in savevm.c to check ops only once in those iterations. Signed-off-by: Wei Yang --- migration/savevm.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 5f0ca7fac2..92af2471cd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1096,10 +1096,9 @@ void qemu_savevm_state_setup(QEMUFile *f) if (!se->ops || !se->ops->save_setup) { continue; } - if (se->ops && se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { + if (se->ops->is_active && + !se->ops->is_active(se->opaque)) { continue; - } } save_section_header(f, se, QEMU_VM_SECTION_START); =20 @@ -1127,10 +1126,9 @@ int qemu_savevm_state_resume_prepare(MigrationState = *s) if (!se->ops || !se->ops->resume_prepare) { continue; } - if (se->ops && se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { + if (se->ops->is_active && + !se->ops->is_active(se->opaque)) { continue; - } } ret =3D se->ops->resume_prepare(s, se->opaque); if (ret < 0) { @@ -1223,10 +1221,9 @@ void qemu_savevm_state_complete_postcopy(QEMUFile *f) if (!se->ops || !se->ops->save_live_complete_postcopy) { continue; } - if (se->ops && se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { + if (se->ops->is_active && + !se->ops->is_active(se->opaque)) { continue; - } } trace_savevm_section_start(se->idstr, se->section_id); /* Section type */ @@ -1265,18 +1262,16 @@ int qemu_savevm_state_complete_precopy(QEMUFile *f,= bool iterable_only, cpu_synchronize_all_states(); =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || + if (!se->ops || !se->ops->save_live_complete_precopy || (in_postcopy && se->ops->has_postcopy && se->ops->has_postcopy(se->opaque)) || - (in_postcopy && !iterable_only) || - !se->ops->save_live_complete_precopy) { + (in_postcopy && !iterable_only)) { continue; } =20 - if (se->ops && se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { + if (se->ops->is_active && + !se->ops->is_active(se->opaque)) { continue; - } } trace_savevm_section_start(se->idstr, se->section_id); =20 @@ -1377,10 +1372,9 @@ void qemu_savevm_state_pending(QEMUFile *f, uint64_t= threshold_size, if (!se->ops || !se->ops->save_live_pending) { continue; } - if (se->ops && se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { + if (se->ops->is_active && + !se->ops->is_active(se->opaque)) { continue; - } } se->ops->save_live_pending(f, se->opaque, threshold_size, res_precopy_only, res_compatible, @@ -2276,10 +2270,9 @@ static int qemu_loadvm_state_setup(QEMUFile *f) if (!se->ops || !se->ops->load_setup) { continue; } - if (se->ops && se->ops->is_active) { - if (!se->ops->is_active(se->opaque)) { + if (se->ops->is_active && + !se->ops->is_active(se->opaque)) { continue; - } } =20 ret =3D se->ops->load_setup(f, se->opaque); --=20 2.19.1