From nobody Sun Apr 28 00:06:33 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.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 1496355453762319.698542851555; Thu, 1 Jun 2017 15:17:33 -0700 (PDT) Received: from localhost ([::1]:46889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYPL-0004Yw-B2 for importer@patchew.org; Thu, 01 Jun 2017 18:17:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYNu-0003jB-Fh for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGYNt-0005qo-5Q for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36494) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGYNs-0005qZ-Ri for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:01 -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 D5DD0804F2 for ; Thu, 1 Jun 2017 22:15:59 +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 5B92287966; Thu, 1 Jun 2017 22:15:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D5DD0804F2 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D5DD0804F2 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 2 Jun 2017 00:15:48 +0200 Message-Id: <20170601221552.30628-2-quintela@redhat.com> In-Reply-To: <20170601221552.30628-1-quintela@redhat.com> References: <20170601221552.30628-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.27]); Thu, 01 Jun 2017 22:16:00 +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] [PATCH 1/5] migration: Rename save_live_setup() to save_setup() 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" We are going to use it now for more than save live regions. Signed-off-by: Juan Quintela --- hw/ppc/spapr.c | 2 +- include/migration/register.h | 2 +- migration/block.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0aadde6..d51a361 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1873,7 +1873,7 @@ static void htab_cleanup(void *opaque) } =20 static SaveVMHandlers savevm_htab_handlers =3D { - .save_live_setup =3D htab_save_setup, + .save_setup =3D htab_save_setup, .save_live_iterate =3D htab_save_iterate, .save_live_complete_precopy =3D htab_save_complete, .cleanup =3D htab_cleanup, diff --git a/include/migration/register.h b/include/migration/register.h index 844afaf..6cb27f4 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -36,7 +36,7 @@ typedef struct SaveVMHandlers { int (*save_live_iterate)(QEMUFile *f, void *opaque); =20 /* This runs outside the iothread lock! */ - int (*save_live_setup)(QEMUFile *f, void *opaque); + int (*save_setup)(QEMUFile *f, void *opaque); void (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t threshold_size, uint64_t *non_postcopiable_pending, diff --git a/migration/block.c b/migration/block.c index 14a8a84..976c42e 100644 --- a/migration/block.c +++ b/migration/block.c @@ -995,7 +995,7 @@ static bool block_is_active(void *opaque) } =20 static SaveVMHandlers savevm_block_handlers =3D { - .save_live_setup =3D block_save_setup, + .save_setup =3D block_save_setup, .save_live_iterate =3D block_save_iterate, .save_live_complete_precopy =3D block_save_complete, .save_live_pending =3D block_save_pending, diff --git a/migration/ram.c b/migration/ram.c index 1164f14..f2c13e2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2597,7 +2597,7 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) } =20 static SaveVMHandlers savevm_ram_handlers =3D { - .save_live_setup =3D ram_save_setup, + .save_setup =3D ram_save_setup, .save_live_iterate =3D ram_save_iterate, .save_live_complete_postcopy =3D ram_save_complete, .save_live_complete_precopy =3D ram_save_complete, diff --git a/migration/savevm.c b/migration/savevm.c index 8489abf..67c9c39 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -606,7 +606,7 @@ int register_savevm_live(DeviceState *dev, se->opaque =3D opaque; se->vmsd =3D NULL; /* if this is a live_savem then set is_ram */ - if (ops->save_live_setup !=3D NULL) { + if (ops->save_setup !=3D NULL) { se->is_ram =3D 1; } =20 @@ -1000,7 +1000,7 @@ void qemu_savevm_state_begin(QEMUFile *f) =20 trace_savevm_state_begin(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || !se->ops->save_live_setup) { + if (!se->ops || !se->ops->save_setup) { continue; } if (se->ops && se->ops->is_active) { @@ -1010,7 +1010,7 @@ void qemu_savevm_state_begin(QEMUFile *f) } save_section_header(f, se, QEMU_VM_SECTION_START); =20 - ret =3D se->ops->save_live_setup(f, se->opaque); + ret =3D se->ops->save_setup(f, se->opaque); save_section_footer(f, se); if (ret < 0) { qemu_file_set_error(f, ret); --=20 2.9.4 From nobody Sun Apr 28 00:06:33 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.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 1496355455740573.6452201457654; Thu, 1 Jun 2017 15:17:35 -0700 (PDT) Received: from localhost ([::1]:46890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYPN-0004bq-8O for importer@patchew.org; Thu, 01 Jun 2017 18:17:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYNw-0003jQ-Jz for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGYNv-0005tI-Ic for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35910) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGYNv-0005rx-6i for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:03 -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 3C6847F3F8 for ; Thu, 1 Jun 2017 22:16:02 +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 31A4C87963; Thu, 1 Jun 2017 22:16:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C6847F3F8 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3C6847F3F8 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 2 Jun 2017 00:15:49 +0200 Message-Id: <20170601221552.30628-3-quintela@redhat.com> In-Reply-To: <20170601221552.30628-1-quintela@redhat.com> References: <20170601221552.30628-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.25]); Thu, 01 Jun 2017 22:16:02 +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] [PATCH 2/5] migration: Rename cleanup() to save_cleanup() 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" We need a cleanup for loads. Signed-off-by: Juan Quintela --- hw/ppc/spapr.c | 2 +- include/migration/register.h | 2 +- migration/block.c | 2 +- migration/ram.c | 2 +- migration/savevm.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d51a361..0c11613 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1876,7 +1876,7 @@ static SaveVMHandlers savevm_htab_handlers =3D { .save_setup =3D htab_save_setup, .save_live_iterate =3D htab_save_iterate, .save_live_complete_precopy =3D htab_save_complete, - .cleanup =3D htab_cleanup, + .save_cleanup =3D htab_cleanup, .load_state =3D htab_load, }; =20 diff --git a/include/migration/register.h b/include/migration/register.h index 6cb27f4..8e37185 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -21,7 +21,7 @@ typedef struct SaveVMHandlers { /* This runs inside the iothread lock. */ SaveStateHandler *save_state; =20 - void (*cleanup)(void *opaque); + void (*save_cleanup)(void *opaque); int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); =20 diff --git a/migration/block.c b/migration/block.c index 976c42e..efa0805 100644 --- a/migration/block.c +++ b/migration/block.c @@ -1000,7 +1000,7 @@ static SaveVMHandlers savevm_block_handlers =3D { .save_live_complete_precopy =3D block_save_complete, .save_live_pending =3D block_save_pending, .load_state =3D block_load, - .cleanup =3D block_migration_cleanup, + .save_cleanup =3D block_migration_cleanup, .is_active =3D block_is_active, }; =20 diff --git a/migration/ram.c b/migration/ram.c index f2c13e2..d3d2ef1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2603,7 +2603,7 @@ static SaveVMHandlers savevm_ram_handlers =3D { .save_live_complete_precopy =3D ram_save_complete, .save_live_pending =3D ram_save_pending, .load_state =3D ram_load, - .cleanup =3D ram_migration_cleanup, + .save_cleanup =3D ram_migration_cleanup, }; =20 void ram_mig_init(void) diff --git a/migration/savevm.c b/migration/savevm.c index 67c9c39..0ec2cb0 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1242,8 +1242,8 @@ void qemu_savevm_state_cleanup(void) =20 trace_savevm_state_cleanup(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (se->ops && se->ops->cleanup) { - se->ops->cleanup(se->opaque); + if (se->ops && se->ops->save_cleanup) { + se->ops->save_cleanup(se->opaque); } } } --=20 2.9.4 From nobody Sun Apr 28 00:06:33 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.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 1496355611772382.2392685352062; Thu, 1 Jun 2017 15:20:11 -0700 (PDT) Received: from localhost ([::1]:46898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYRu-0006sg-10 for importer@patchew.org; Thu, 01 Jun 2017 18:20:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYNz-0003mH-SI for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGYNy-0005uf-TA for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32862) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGYNy-0005uB-E7 for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:06 -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 71327232050 for ; Thu, 1 Jun 2017 22:16:05 +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 8DA1353CC2; Thu, 1 Jun 2017 22:16:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 71327232050 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 71327232050 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 2 Jun 2017 00:15:50 +0200 Message-Id: <20170601221552.30628-4-quintela@redhat.com> In-Reply-To: <20170601221552.30628-1-quintela@redhat.com> References: <20170601221552.30628-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.38]); Thu, 01 Jun 2017 22:16:05 +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] [PATCH 3/5] migration: Create load_setup()/cleanup() methods 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" We need to do things at load time. Signed-off-by: Juan Quintela --- include/migration/register.h | 2 ++ migration/savevm.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/migration/register.h b/include/migration/register.h index 8e37185..0862bb8 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -42,6 +42,8 @@ typedef struct SaveVMHandlers { uint64_t *non_postcopiable_pending, uint64_t *postcopiable_pending); LoadStateHandler *load_state; + int (*load_setup)(QEMUFile *f, void *opaque); + int (*load_cleanup)(void *opaque); } SaveVMHandlers; =20 int register_savevm(DeviceState *dev, diff --git a/migration/savevm.c b/migration/savevm.c index 0ec2cb0..1e5dfad 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1928,6 +1928,31 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationI= ncomingState *mis) return 0; } =20 +static int qemu_savevm_load_state_begin(QEMUFile *f) +{ + SaveStateEntry *se; + int ret; + + trace_savevm_state_begin(); + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (!se->ops || !se->ops->load_setup) { + continue; + } + if (se->ops && se->ops->is_active) { + if (!se->ops->is_active(se->opaque)) { + continue; + } + } + + ret =3D se->ops->load_setup(f, se->opaque); + if (ret < 0) { + qemu_file_set_error(f, ret); + return ret; + } + } + return 0; +} + static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) { uint8_t section_type; @@ -2000,6 +2025,12 @@ int qemu_loadvm_state(QEMUFile *f) return -ENOTSUP; } =20 + + if (qemu_savevm_load_state_begin(f) !=3D 0) { + error_report("Load state of one device failed"); + return -EINVAL; + } + if (!savevm_state.skip_configuration || enforce_config_section()) { if (qemu_get_byte(f) !=3D QEMU_VM_CONFIGURATION) { error_report("Configuration section missing"); --=20 2.9.4 From nobody Sun Apr 28 00:06:33 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.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 1496355570886349.6138235507477; Thu, 1 Jun 2017 15:19:30 -0700 (PDT) Received: from localhost ([::1]:46897 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYRF-0006Sc-33 for importer@patchew.org; Thu, 01 Jun 2017 18:19:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYOF-0003yX-I5 for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGYOC-00060P-CB for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42604) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGYOC-0005zr-3J for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:20 -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 22D9423E6C1 for ; Thu, 1 Jun 2017 22:16:19 +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 C1C3D87963; Thu, 1 Jun 2017 22:16:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 22D9423E6C1 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 22D9423E6C1 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 2 Jun 2017 00:15:51 +0200 Message-Id: <20170601221552.30628-5-quintela@redhat.com> In-Reply-To: <20170601221552.30628-1-quintela@redhat.com> References: <20170601221552.30628-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.29]); Thu, 01 Jun 2017 22:16:19 +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] [PATCH 4/5] migration: Convert ram to use new load_setup()/load_cleanup() 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" Once there, I rename ram_migration_cleanup() to ram_save_cleanup(). Notice that this is the first pass, and I only passed XBZRLE to the new scheme. Moved decoded_buf to inside XBZRLE struct. As a bonus, I don't have to export xbzrle functions from ram.c. Signed-off-by: Juan Quintela --- migration/migration.c | 3 --- migration/ram.c | 52 +++++++++++++++++++++++++++++++++++------------= ---- migration/ram.h | 1 - 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 331cab7..b75aebc 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -350,9 +350,6 @@ static void process_incoming_migration_co(void *opaque) migrate_decompress_threads_join(); exit(EXIT_FAILURE); } - - free_xbzrle_decoded_buf(); - mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); qemu_bh_schedule(mis->bh); } diff --git a/migration/ram.c b/migration/ram.c index d3d2ef1..3349116 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -85,11 +85,10 @@ static struct { QemuMutex lock; /* it will store a page full of zeros */ uint8_t *zero_target_page; + /* buffer used for XBZRLE decoding */ + uint8_t *decoded_buf; } XBZRLE; =20 -/* buffer used for XBZRLE decoding */ -static uint8_t *xbzrle_decoded_buf; - static void XBZRLE_cache_lock(void) { if (migrate_use_xbzrle()) @@ -1343,13 +1342,18 @@ uint64_t ram_bytes_total(void) return total; } =20 -void free_xbzrle_decoded_buf(void) +static void xbzrle_load_setup(void) { - g_free(xbzrle_decoded_buf); - xbzrle_decoded_buf =3D NULL; + XBZRLE.decoded_buf =3D g_malloc(TARGET_PAGE_SIZE); } =20 -static void ram_migration_cleanup(void *opaque) +static void xbzrle_load_cleanup(void) +{ + g_free(XBZRLE.decoded_buf); + XBZRLE.decoded_buf =3D NULL; +} + +static void ram_save_cleanup(void *opaque) { RAMState **rsp =3D opaque; RAMBlock *block; @@ -2068,12 +2072,6 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr,= void *host) { unsigned int xh_len; int xh_flags; - uint8_t *loaded_data; - - if (!xbzrle_decoded_buf) { - xbzrle_decoded_buf =3D g_malloc(TARGET_PAGE_SIZE); - } - loaded_data =3D xbzrle_decoded_buf; =20 /* extract RLE header */ xh_flags =3D qemu_get_byte(f); @@ -2089,10 +2087,10 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr= , void *host) return -1; } /* load data and decode */ - qemu_get_buffer_in_place(f, &loaded_data, xh_len); + qemu_get_buffer_in_place(f, &XBZRLE.decoded_buf, xh_len); =20 /* decode RLE */ - if (xbzrle_decode_buffer(loaded_data, xh_len, host, + if (xbzrle_decode_buffer(XBZRLE.decoded_buf, xh_len, host, TARGET_PAGE_SIZE) =3D=3D -1) { error_report("Failed to load XBZRLE page - decode error!"); return -1; @@ -2296,6 +2294,26 @@ static void decompress_data_with_multi_threads(QEMUF= ile *f, } =20 /** + * ram_load_setup: Setup RAM for migration incoming side + * + * Returns zero to indicate success and negative for error + * + * @f: QEMUFile where to receive the data + * @opaque: RAMState pointer + */ +static int ram_load_setup(QEMUFile *f, void *opaque) +{ + xbzrle_load_setup(); + return 0; +} + +static int ram_load_cleanup(void *opaque) +{ + xbzrle_load_cleanup(); + return 0; +} + +/** * ram_postcopy_incoming_init: allocate postcopy data structures * * Returns 0 for success and negative if there was one error @@ -2603,7 +2621,9 @@ static SaveVMHandlers savevm_ram_handlers =3D { .save_live_complete_precopy =3D ram_save_complete, .save_live_pending =3D ram_save_pending, .load_state =3D ram_load, - .save_cleanup =3D ram_migration_cleanup, + .save_cleanup =3D ram_save_cleanup, + .load_setup =3D ram_load_setup, + .load_cleanup =3D ram_load_cleanup, }; =20 void ram_mig_init(void) diff --git a/migration/ram.h b/migration/ram.h index 9eadc8c..e49dd3f 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -46,7 +46,6 @@ void migrate_decompress_threads_join(void); uint64_t ram_pagesize_summary(void); int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t = len); void acct_update_position(QEMUFile *f, size_t size, bool zero); -void free_xbzrle_decoded_buf(void); void ram_debug_dump_bitmap(unsigned long *todump, bool expected, unsigned long pages); void ram_postcopy_migrated_memory_release(MigrationState *ms); --=20 2.9.4 From nobody Sun Apr 28 00:06:33 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.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 149635566270866.00468880482936; Thu, 1 Jun 2017 15:21:02 -0700 (PDT) Received: from localhost ([::1]:46908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYSj-0007Wq-Cm for importer@patchew.org; Thu, 01 Jun 2017 18:21:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYOJ-00041y-Ey for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGYOI-00063t-9a for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37548) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGYOI-00063A-0b for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:16:26 -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 194BA804F7 for ; Thu, 1 Jun 2017 22:16:25 +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 7425787957; Thu, 1 Jun 2017 22:16:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 194BA804F7 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 194BA804F7 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 2 Jun 2017 00:15:52 +0200 Message-Id: <20170601221552.30628-6-quintela@redhat.com> In-Reply-To: <20170601221552.30628-1-quintela@redhat.com> References: <20170601221552.30628-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.27]); Thu, 01 Jun 2017 22:16:25 +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] [PATCH 5/5] migration: Make compression_threads use save/load_setup/cleanup() 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" Once there, be consistent and use compress_thread_{save,load}_{setup,cleanup}. Signed-off-by: Juan Quintela --- migration/migration.c | 5 ----- migration/ram.c | 12 ++++++++---- migration/ram.h | 5 ----- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index b75aebc..4040b33 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -284,7 +284,6 @@ static void process_incoming_migration_bh(void *opaque) } else { runstate_set(global_state_get_runstate()); } - migrate_decompress_threads_join(); /* * This must happen after any state changes since as soon as an extern= al * observer sees this event they might start to prod at the VM assuming @@ -347,7 +346,6 @@ static void process_incoming_migration_co(void *opaque) migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_FAILED); error_report("load of migration failed: %s", strerror(-ret)); - migrate_decompress_threads_join(); exit(EXIT_FAILURE); } mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); @@ -358,7 +356,6 @@ void migration_fd_process_incoming(QEMUFile *f) { Coroutine *co =3D qemu_coroutine_create(process_incoming_migration_co,= f); =20 - migrate_decompress_threads_create(); qemu_file_set_blocking(f, false); qemu_coroutine_enter(co); } @@ -823,7 +820,6 @@ static void migrate_fd_cleanup(void *opaque) } qemu_mutex_lock_iothread(); =20 - migrate_compress_threads_join(); qemu_fclose(s->to_dst_file); s->to_dst_file =3D NULL; } @@ -1974,7 +1970,6 @@ void migrate_fd_connect(MigrationState *s) } } =20 - migrate_compress_threads_create(); qemu_thread_create(&s->thread, "live_migration", migration_thread, s, QEMU_THREAD_JOINABLE); s->migration_thread_running =3D true; diff --git a/migration/ram.c b/migration/ram.c index 3349116..e9d97d9 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -299,7 +299,7 @@ static inline void terminate_compression_threads(void) } } =20 -void migrate_compress_threads_join(void) +static void compress_threads_save_cleanup(void) { int i, thread_count; =20 @@ -322,7 +322,7 @@ void migrate_compress_threads_join(void) comp_param =3D NULL; } =20 -void migrate_compress_threads_create(void) +static void compress_threads_save_setup(void) { int i, thread_count; =20 @@ -1383,6 +1383,7 @@ static void ram_save_cleanup(void *opaque) } XBZRLE_cache_unlock(); migration_page_queue_free(*rsp); + compress_threads_save_cleanup(); g_free(*rsp); *rsp =3D NULL; } @@ -1915,6 +1916,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } =20 rcu_read_unlock(); + compress_threads_save_setup(); =20 ram_control_before_iterate(f, RAM_CONTROL_SETUP); ram_control_after_iterate(f, RAM_CONTROL_SETUP); @@ -2220,7 +2222,7 @@ static void wait_for_decompress_done(void) qemu_mutex_unlock(&decomp_done_lock); } =20 -void migrate_decompress_threads_create(void) +static void compress_threads_load_setup(void) { int i, thread_count; =20 @@ -2241,7 +2243,7 @@ void migrate_decompress_threads_create(void) } } =20 -void migrate_decompress_threads_join(void) +static void compress_threads_load_cleanup(void) { int i, thread_count; =20 @@ -2304,12 +2306,14 @@ static void decompress_data_with_multi_threads(QEMU= File *f, static int ram_load_setup(QEMUFile *f, void *opaque) { xbzrle_load_setup(); + compress_threads_load_setup(); return 0; } =20 static int ram_load_cleanup(void *opaque) { xbzrle_load_cleanup(); + compress_threads_load_cleanup(); return 0; } =20 diff --git a/migration/ram.h b/migration/ram.h index e49dd3f..bfb7b04 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -38,11 +38,6 @@ extern XBZRLECacheStats xbzrle_counters; int64_t xbzrle_cache_resize(int64_t new_size); uint64_t ram_bytes_total(void); =20 -void migrate_compress_threads_create(void); -void migrate_compress_threads_join(void); -void migrate_decompress_threads_create(void); -void migrate_decompress_threads_join(void); - uint64_t ram_pagesize_summary(void); int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t = len); void acct_update_position(QEMUFile *f, size_t size, bool zero); --=20 2.9.4