From nobody Fri Apr 19 15:51:06 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507659638381800.7851790856269; Tue, 10 Oct 2017 11:20:38 -0700 (PDT) Received: from localhost ([::1]:36560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z8l-0001uS-4i for importer@patchew.org; Tue, 10 Oct 2017 14:20:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z4K-00073R-O1 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1z4H-0002HB-7G for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1z4H-0002Ge-1w for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27EE2C04AC7E for ; Tue, 10 Oct 2017 18:15:48 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1560817B8F; Tue, 10 Oct 2017 18:15:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 27EE2C04AC7E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 20:15:33 +0200 Message-Id: <20171010181542.24168-2-quintela@redhat.com> In-Reply-To: <20171010181542.24168-1-quintela@redhat.com> References: <20171010181542.24168-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 10 Oct 2017 18:15:48 +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 01/10] migration: Fix migrate_test_apply for multifd parameters 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" They were missing when introduced on the tree Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/migration.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 98429dc843..fb62a639d8 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -865,6 +865,12 @@ static void migrate_params_test_apply(MigrateSetParame= ters *params, if (params->has_block_incremental) { dest->block_incremental =3D params->block_incremental; } + if (params->has_x_multifd_channels) { + dest->x_multifd_channels =3D params->x_multifd_channels; + } + if (params->has_x_multifd_page_count) { + dest->x_multifd_page_count =3D params->x_multifd_page_count; + } } =20 static void migrate_params_apply(MigrateSetParameters *params) --=20 2.13.6 From nobody Fri Apr 19 15:51:06 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507659479976993.095569751488; Tue, 10 Oct 2017 11:17:59 -0700 (PDT) Received: from localhost ([::1]:36553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z64-0008CU-Ky for importer@patchew.org; Tue, 10 Oct 2017 14:17:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z4K-00073Q-Nr for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1z4J-0002IG-H3 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45874) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1z4J-0002Ht-Bf for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D16380B2A for ; Tue, 10 Oct 2017 18:15:50 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C4AC675EB; Tue, 10 Oct 2017 18:15:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7D16380B2A Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 20:15:34 +0200 Message-Id: <20171010181542.24168-3-quintela@redhat.com> In-Reply-To: <20171010181542.24168-1-quintela@redhat.com> References: <20171010181542.24168-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 10 Oct 2017 18:15:50 +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 02/10] migratiom: Remove max_item_age parameter 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_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It was not used at all since commit: 27af7d6ea5015e5ef1f7985eab94a8a218267a2b which replaced its use by the dirty sync count. Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/page_cache.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/migration/page_cache.c b/migration/page_cache.c index ba984c4858..381e555ddb 100644 --- a/migration/page_cache.c +++ b/migration/page_cache.c @@ -41,7 +41,6 @@ struct PageCache { CacheItem *page_cache; unsigned int page_size; int64_t max_num_items; - uint64_t max_item_age; int64_t num_items; }; =20 @@ -69,7 +68,6 @@ PageCache *cache_init(int64_t num_pages, unsigned int pag= e_size) } cache->page_size =3D page_size; cache->num_items =3D 0; - cache->max_item_age =3D 0; cache->max_num_items =3D num_pages; =20 DPRINTF("Setting cache buckets to %" PRId64 "\n", cache->max_num_items= ); --=20 2.13.6 From nobody Fri Apr 19 15:51:06 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507659475313985.5012492596964; Tue, 10 Oct 2017 11:17:55 -0700 (PDT) Received: from localhost ([::1]:36554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z6D-0008HV-GE for importer@patchew.org; Tue, 10 Oct 2017 14:17:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z4O-00075A-1A for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1z4L-0002JU-Mz for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39646) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1z4L-0002J5-HW for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FF5E50EE3 for ; Tue, 10 Oct 2017 18:15:52 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE84A17BB0; Tue, 10 Oct 2017 18:15:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9FF5E50EE3 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=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 20:15:35 +0200 Message-Id: <20171010181542.24168-4-quintela@redhat.com> In-Reply-To: <20171010181542.24168-1-quintela@redhat.com> References: <20171010181542.24168-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 10 Oct 2017 18:15:52 +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 03/10] migration: Make cache size elements use the right types 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" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/page_cache.c | 8 ++++---- migration/page_cache.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/page_cache.c b/migration/page_cache.c index 381e555ddb..6b2dd77cf0 100644 --- a/migration/page_cache.c +++ b/migration/page_cache.c @@ -39,12 +39,12 @@ struct CacheItem { =20 struct PageCache { CacheItem *page_cache; - unsigned int page_size; - int64_t max_num_items; - int64_t num_items; + size_t page_size; + size_t max_num_items; + size_t num_items; }; =20 -PageCache *cache_init(int64_t num_pages, unsigned int page_size) +PageCache *cache_init(size_t num_pages, size_t page_size) { int64_t i; =20 diff --git a/migration/page_cache.h b/migration/page_cache.h index 4fadd0c501..931868b857 100644 --- a/migration/page_cache.h +++ b/migration/page_cache.h @@ -28,7 +28,7 @@ typedef struct PageCache PageCache; * @num_pages: cache maximal number of cached pages * @page_size: cache page size */ -PageCache *cache_init(int64_t num_pages, unsigned int page_size); +PageCache *cache_init(size_t num_pages, size_t page_size); =20 /** * cache_fini: free all cache resources --=20 2.13.6 From nobody Fri Apr 19 15:51:06 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15076594827081019.8857922021614; Tue, 10 Oct 2017 11:18:02 -0700 (PDT) Received: from localhost ([::1]:36555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z6D-0008HY-Ng for importer@patchew.org; Tue, 10 Oct 2017 14:17:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z4O-00075k-I3 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1z4N-0002KE-FF for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37194) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1z4N-0002Jr-6X for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 552AF4ACA5 for ; Tue, 10 Oct 2017 18:15:54 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id F175C17BBE; Tue, 10 Oct 2017 18:15:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 552AF4ACA5 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=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 20:15:36 +0200 Message-Id: <20171010181542.24168-5-quintela@redhat.com> In-Reply-To: <20171010181542.24168-1-quintela@redhat.com> References: <20171010181542.24168-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 10 Oct 2017 18:15:54 +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 04/10] migration: Move xbzrle cache resize error handling to xbzrle_cache_resize 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" Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/migration.c | 18 +----------------- migration/ram.c | 22 ++++++++++++++++++++-- migration/ram.h | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index fb62a639d8..3feffb5e26 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1373,24 +1373,8 @@ void qmp_migrate_set_cache_size(int64_t value, Error= **errp) MigrationState *s =3D migrate_get_current(); int64_t new_size; =20 - /* Check for truncation */ - if (value !=3D (size_t)value) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", - "exceeding address space"); - return; - } - - /* Cache should not be larger than guest ram size */ - if (value > ram_bytes_total()) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", - "exceeds guest ram size "); - return; - } - - new_size =3D xbzrle_cache_resize(value); + new_size =3D xbzrle_cache_resize(value, errp); if (new_size < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", - "is smaller than page size"); return; } =20 diff --git a/migration/ram.c b/migration/ram.c index b83f8977c5..7c3acad029 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -42,6 +42,7 @@ #include "postcopy-ram.h" #include "migration/page_cache.h" #include "qemu/error-report.h" +#include "qapi/qmp/qerror.h" #include "trace.h" #include "exec/ram_addr.h" #include "qemu/rcu_queue.h" @@ -113,13 +114,30 @@ static void XBZRLE_cache_unlock(void) * Returns the new_size or negative in case of error. * * @new_size: new cache size + * @errp: set *errp if the check failed, with reason */ -int64_t xbzrle_cache_resize(int64_t new_size) +int64_t xbzrle_cache_resize(int64_t new_size, Error **errp) { PageCache *new_cache; int64_t ret; =20 + /* Check for truncation */ + if (new_size !=3D (size_t)new_size) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", + "exceeding address space"); + return -1; + } + + /* Cache should not be larger than guest ram size */ + if (new_size > ram_bytes_total()) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", + "exceeds guest ram size"); + return -1; + } + if (new_size < TARGET_PAGE_SIZE) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", + "is smaller than one target page size"); return -1; } =20 @@ -132,7 +150,7 @@ int64_t xbzrle_cache_resize(int64_t new_size) new_cache =3D cache_init(new_size / TARGET_PAGE_SIZE, TARGET_PAGE_SIZE); if (!new_cache) { - error_report("Error creating cache"); + error_setg(errp, "Error creating cache"); ret =3D -1; goto out; } diff --git a/migration/ram.h b/migration/ram.h index 4a72d66503..511b3dc582 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -35,7 +35,7 @@ extern MigrationStats ram_counters; extern XBZRLECacheStats xbzrle_counters; =20 -int64_t xbzrle_cache_resize(int64_t new_size); +int64_t xbzrle_cache_resize(int64_t new_size, Error **errp); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_total(void); =20 --=20 2.13.6 From nobody Fri Apr 19 15:51:06 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507659641191342.68178597618567; Tue, 10 Oct 2017 11:20:41 -0700 (PDT) Received: from localhost ([::1]:36563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z8v-00023t-9h for importer@patchew.org; Tue, 10 Oct 2017 14:20:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z4Q-000774-6O for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1z4P-0002LB-5h for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1z4O-0002Kd-TM for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B899C04AC71 for ; Tue, 10 Oct 2017 18:15:56 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA83717B8F; Tue, 10 Oct 2017 18:15:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0B899C04AC71 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 20:15:37 +0200 Message-Id: <20171010181542.24168-6-quintela@redhat.com> In-Reply-To: <20171010181542.24168-1-quintela@redhat.com> References: <20171010181542.24168-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 10 Oct 2017 18:15:56 +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 05/10] migration: Make cache_init() take an error parameter 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, take a total size instead of the size of the pages. We move the check that the new_size is bigger than one page from xbzrle_cache_resize(). Signed-off-by: Juan Quintela Reviewed-by: Peter Xu --- migration/page_cache.c | 17 +++++++++++------ migration/page_cache.h | 7 +++---- migration/ram.c | 18 +++++------------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/migration/page_cache.c b/migration/page_cache.c index 6b2dd77cf0..9a9d13d6a2 100644 --- a/migration/page_cache.c +++ b/migration/page_cache.c @@ -14,6 +14,8 @@ =20 #include "qemu/osdep.h" =20 +#include "qapi/qmp/qerror.h" +#include "qapi/error.h" #include "qemu-common.h" #include "qemu/host-utils.h" #include "migration/page_cache.h" @@ -44,21 +46,23 @@ struct PageCache { size_t num_items; }; =20 -PageCache *cache_init(size_t num_pages, size_t page_size) +PageCache *cache_init(int64_t new_size, size_t page_size, Error **errp) { int64_t i; - + size_t num_pages =3D new_size / page_size; PageCache *cache; =20 - if (num_pages <=3D 0) { - DPRINTF("invalid number of pages\n"); + if (new_size < page_size) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", + "is smaller than one target page size"); return NULL; } =20 /* We prefer not to abort if there is no memory */ cache =3D g_try_malloc(sizeof(*cache)); if (!cache) { - DPRINTF("Failed to allocate cache\n"); + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", + "Failed to allocate cache"); return NULL; } /* round down to the nearest power of 2 */ @@ -76,7 +80,8 @@ PageCache *cache_init(size_t num_pages, size_t page_size) cache->page_cache =3D g_try_malloc((cache->max_num_items) * sizeof(*cache->page_cache)); if (!cache->page_cache) { - DPRINTF("Failed to allocate cache->page_cache\n"); + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", + "Failed to allocate page cache"); g_free(cache); return NULL; } diff --git a/migration/page_cache.h b/migration/page_cache.h index 931868b857..4596496416 100644 --- a/migration/page_cache.h +++ b/migration/page_cache.h @@ -24,12 +24,11 @@ typedef struct PageCache PageCache; * * Returns new allocated cache or NULL on error * - * @cache pointer to the PageCache struct - * @num_pages: cache maximal number of cached pages + * @cache_size: cache size in byets * @page_size: cache page size + * @errp: set *errp if the check failed, with reason */ -PageCache *cache_init(size_t num_pages, size_t page_size); - +PageCache *cache_init(int64_t cache_size, size_t page_size, Error **errp); /** * cache_fini: free all cache resources * @cache pointer to the PageCache struct diff --git a/migration/ram.c b/migration/ram.c index 7c3acad029..47501460c8 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -135,22 +135,14 @@ int64_t xbzrle_cache_resize(int64_t new_size, Error *= *errp) return -1; } =20 - if (new_size < TARGET_PAGE_SIZE) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", - "is smaller than one target page size"); - return -1; - } - XBZRLE_cache_lock(); =20 if (XBZRLE.cache !=3D NULL) { if (pow2floor(new_size) =3D=3D migrate_xbzrle_cache_size()) { goto out_new_size; } - new_cache =3D cache_init(new_size / TARGET_PAGE_SIZE, - TARGET_PAGE_SIZE); + new_cache =3D cache_init(new_size, TARGET_PAGE_SIZE, errp); if (!new_cache) { - error_setg(errp, "Error creating cache"); ret =3D -1; goto out; } @@ -2028,6 +2020,7 @@ err: static int ram_state_init(RAMState **rsp) { *rsp =3D g_new0(RAMState, 1); + Error *local_err =3D NULL; =20 qemu_mutex_init(&(*rsp)->bitmap_mutex); qemu_mutex_init(&(*rsp)->src_page_req_mutex); @@ -2036,12 +2029,11 @@ static int ram_state_init(RAMState **rsp) if (migrate_use_xbzrle()) { XBZRLE_cache_lock(); XBZRLE.zero_target_page =3D g_malloc0(TARGET_PAGE_SIZE); - XBZRLE.cache =3D cache_init(migrate_xbzrle_cache_size() / - TARGET_PAGE_SIZE, - TARGET_PAGE_SIZE); + XBZRLE.cache =3D cache_init(migrate_xbzrle_cache_size(), + TARGET_PAGE_SIZE, &local_err); if (!XBZRLE.cache) { XBZRLE_cache_unlock(); - error_report("Error creating cache"); + error_report_err(local_err); g_free(*rsp); *rsp =3D NULL; return -1; --=20 2.13.6 From nobody Fri Apr 19 15:51:06 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1507659808598774.8390295925111; Tue, 10 Oct 2017 11:23:28 -0700 (PDT) Received: from localhost ([::1]:36575 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1zBP-0004A3-50 for importer@patchew.org; Tue, 10 Oct 2017 14:23:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z4V-0007D6-BV for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1z4Q-0002MK-Rw for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57274) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1z4Q-0002Li-LD for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:15:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BBD65C04AC73 for ; Tue, 10 Oct 2017 18:15:57 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FDFD60C9A; Tue, 10 Oct 2017 18:15:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BBD65C04AC73 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 20:15:38 +0200 Message-Id: <20171010181542.24168-7-quintela@redhat.com> In-Reply-To: <20171010181542.24168-1-quintela@redhat.com> References: <20171010181542.24168-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 10 Oct 2017 18:15:57 +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 06/10] migration: Make sure that we pass the right cache size 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_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of passing silently round down the number of pages, make it an error that the cache size is not a multiple of 2. Signed-off-by: Juan Quintela --- migration/page_cache.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/migration/page_cache.c b/migration/page_cache.c index 9a9d13d6a2..96268c3aea 100644 --- a/migration/page_cache.c +++ b/migration/page_cache.c @@ -58,6 +58,13 @@ PageCache *cache_init(int64_t new_size, size_t page_size= , Error **errp) return NULL; } =20 + /* round down to the nearest power of 2 */ + if (!is_power_of_2(num_pages)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", + "is not a power of two number of pages"); + return NULL; + } + /* We prefer not to abort if there is no memory */ cache =3D g_try_malloc(sizeof(*cache)); if (!cache) { @@ -65,11 +72,6 @@ PageCache *cache_init(int64_t new_size, size_t page_size= , Error **errp) "Failed to allocate cache"); return NULL; } - /* round down to the nearest power of 2 */ - if (!is_power_of_2(num_pages)) { - num_pages =3D pow2floor(num_pages); - DPRINTF("rounding down to %" PRId64 "\n", num_pages); - } cache->page_size =3D page_size; cache->num_items =3D 0; cache->max_num_items =3D num_pages; --=20 2.13.6 From nobody Fri Apr 19 15:51:06 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507659639540609.915234216991; Tue, 10 Oct 2017 11:20:39 -0700 (PDT) Received: from localhost ([::1]:36561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z8m-0001uY-SF for importer@patchew.org; Tue, 10 Oct 2017 14:20:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z4Y-0007Fw-Hd for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1z4U-0002Nk-OR for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54656) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1z4U-0002NM-I1 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADB1B552EA for ; Tue, 10 Oct 2017 18:16:01 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16A1B424E; Tue, 10 Oct 2017 18:15:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ADB1B552EA 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=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 20:15:39 +0200 Message-Id: <20171010181542.24168-8-quintela@redhat.com> In-Reply-To: <20171010181542.24168-1-quintela@redhat.com> References: <20171010181542.24168-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 10 Oct 2017 18:16:01 +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 07/10] migration: Don't play games with the requested cache size 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" Now that we check that the value passed is a power of 2, we don't need to play games when comparing what is the size that is going to take the cache. Signed-off-by: Juan Quintela --- migration/ram.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 47501460c8..c84f22d759 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -135,12 +135,14 @@ int64_t xbzrle_cache_resize(int64_t new_size, Error *= *errp) return -1; } =20 + if (new_size =3D=3D migrate_xbzrle_cache_size()) { + /* nothing to do */ + return new_size; + } + XBZRLE_cache_lock(); =20 if (XBZRLE.cache !=3D NULL) { - if (pow2floor(new_size) =3D=3D migrate_xbzrle_cache_size()) { - goto out_new_size; - } new_cache =3D cache_init(new_size, TARGET_PAGE_SIZE, errp); if (!new_cache) { ret =3D -1; @@ -151,8 +153,7 @@ int64_t xbzrle_cache_resize(int64_t new_size, Error **e= rrp) XBZRLE.cache =3D new_cache; } =20 -out_new_size: - ret =3D pow2floor(new_size); + ret =3D new_size; out: XBZRLE_cache_unlock(); return ret; --=20 2.13.6 From nobody Fri Apr 19 15:51:06 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507659649598924.1160212887365; Tue, 10 Oct 2017 11:20:49 -0700 (PDT) Received: from localhost ([::1]:36562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z8t-00021P-2Q for importer@patchew.org; Tue, 10 Oct 2017 14:20:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z4a-0007Hw-D9 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1z4Z-0002PF-H5 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54978) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1z4Z-0002Ov-B0 for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F49013A90 for ; Tue, 10 Oct 2017 18:16:06 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03DB2675F0; Tue, 10 Oct 2017 18:16:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6F49013A90 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=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 20:15:40 +0200 Message-Id: <20171010181542.24168-9-quintela@redhat.com> In-Reply-To: <20171010181542.24168-1-quintela@redhat.com> References: <20171010181542.24168-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 10 Oct 2017 18:16:06 +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 08/10] migration: No need to return the size of the cache 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" After the previous commits, we make sure that the value passed is right, or we just drop an error. So now we return if there is one error or we have setup correctly the value passed. Signed-off-by: Juan Quintela --- migration/migration.c | 6 ++---- migration/ram.c | 8 +++----- migration/ram.h | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 3feffb5e26..f3d4503ce2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1371,14 +1371,12 @@ void qmp_migrate_cancel(Error **errp) void qmp_migrate_set_cache_size(int64_t value, Error **errp) { MigrationState *s =3D migrate_get_current(); - int64_t new_size; =20 - new_size =3D xbzrle_cache_resize(value, errp); - if (new_size < 0) { + if (xbzrle_cache_resize(value, errp) < 0) { return; } =20 - s->xbzrle_cache_size =3D new_size; + s->xbzrle_cache_size =3D value; } =20 int64_t qmp_query_migrate_cache_size(Error **errp) diff --git a/migration/ram.c b/migration/ram.c index c84f22d759..ed4d3c6295 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -111,15 +111,15 @@ static void XBZRLE_cache_unlock(void) * migration may be using the cache and might finish during this call, * hence changes to the cache are protected by XBZRLE.lock(). * - * Returns the new_size or negative in case of error. + * Returns the 0 or negative in case of error. * * @new_size: new cache size * @errp: set *errp if the check failed, with reason */ -int64_t xbzrle_cache_resize(int64_t new_size, Error **errp) +int xbzrle_cache_resize(int64_t new_size, Error **errp) { PageCache *new_cache; - int64_t ret; + int64_t ret =3D 0; =20 /* Check for truncation */ if (new_size !=3D (size_t)new_size) { @@ -152,8 +152,6 @@ int64_t xbzrle_cache_resize(int64_t new_size, Error **e= rrp) cache_fini(XBZRLE.cache); XBZRLE.cache =3D new_cache; } - - ret =3D new_size; out: XBZRLE_cache_unlock(); return ret; diff --git a/migration/ram.h b/migration/ram.h index 511b3dc582..c8ae382b5b 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -35,7 +35,7 @@ extern MigrationStats ram_counters; extern XBZRLECacheStats xbzrle_counters; =20 -int64_t xbzrle_cache_resize(int64_t new_size, Error **errp); +int xbzrle_cache_resize(int64_t new_size, Error **errp); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_total(void); =20 --=20 2.13.6 From nobody Fri Apr 19 15:51:06 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 1507659817129378.4740490276115; Tue, 10 Oct 2017 11:23:37 -0700 (PDT) Received: from localhost ([::1]:36577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1zBa-0004IH-49 for importer@patchew.org; Tue, 10 Oct 2017 14:23:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z4h-0007OB-Qc for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1z4c-0002RI-NG for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55122) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1z4c-0002Q1-Cs for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:10 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B143550B0 for ; Tue, 10 Oct 2017 18:16:09 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB7E1675F0; Tue, 10 Oct 2017 18:16:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7B143550B0 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=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 20:15:41 +0200 Message-Id: <20171010181542.24168-10-quintela@redhat.com> In-Reply-To: <20171010181542.24168-1-quintela@redhat.com> References: <20171010181542.24168-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 10 Oct 2017 18:16:09 +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 09/10] migration: Make xbzrle_cache_size a migration parameter 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" Right now it is a variable in MigrationState instead of a MigrationParameter. The change allows to set it as the rest of the Migration parameters, from the command line, with query_migration_paramters, set_migrate_parameters, etc. Signed-off-by: Juan Quintela --- hmp.c | 14 ++++++++++++++ migration/migration.c | 39 ++++++++++++++++++++++++++++++--------- migration/migration.h | 1 - migration/ram.c | 7 ------- qapi/migration.json | 23 ++++++++++++++++++++--- 5 files changed, 64 insertions(+), 20 deletions(-) diff --git a/hmp.c b/hmp.c index 739d330f4e..f73232399a 100644 --- a/hmp.c +++ b/hmp.c @@ -342,6 +342,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) monitor_printf(mon, "%s: %" PRId64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUN= T), params->x_multifd_page_count); + monitor_printf(mon, "%s: %" PRId64 "\n", + MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), + params->xbzrle_cache_size); } =20 qapi_free_MigrationParameters(params); @@ -1560,6 +1563,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QD= ict *qdict) Visitor *v =3D string_input_visitor_new(valuestr); MigrateSetParameters *p =3D g_new0(MigrateSetParameters, 1); uint64_t valuebw =3D 0; + uint64_t cache_size; Error *err =3D NULL; int val, ret; =20 @@ -1635,6 +1639,16 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p->has_x_multifd_page_count =3D true; visit_type_int(v, param, &p->x_multifd_page_count, &err); break; + case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: + p->has_xbzrle_cache_size =3D true; + visit_type_size(v, param, &cache_size, &err); + if (err || cache_size > INT64_MAX + || (size_t)cache_size !=3D cache_size) { + error_setg(&err, "Invalid size %s", valuestr); + break; + } + p->xbzrle_cache_size =3D cache_size; + break; default: assert(0); } diff --git a/migration/migration.c b/migration/migration.c index f3d4503ce2..fcc0d64625 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -71,7 +71,7 @@ #define DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT 10 =20 /* Migration XBZRLE default cache size */ -#define DEFAULT_MIGRATE_CACHE_SIZE (64 * 1024 * 1024) +#define DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE (64 * 1024 * 1024) =20 /* The delay time (in ms) between two COLO checkpoints * Note: Please change this default value to 10000 when we support hybrid = mode. @@ -512,6 +512,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->x_multifd_channels =3D s->parameters.x_multifd_channels; params->has_x_multifd_page_count =3D true; params->x_multifd_page_count =3D s->parameters.x_multifd_page_count; + params->has_xbzrle_cache_size =3D true; + params->xbzrle_cache_size =3D s->parameters.xbzrle_cache_size; =20 return params; } @@ -810,6 +812,16 @@ static bool migrate_params_check(MigrationParameters *= params, Error **errp) return false; } =20 + if (params->has_xbzrle_cache_size && + (params->xbzrle_cache_size < qemu_target_page_size() || + !is_power_of_2(params->xbzrle_cache_size))) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, + "xbzrle_cache_size", + "is invalid, it should be bigger than target page size" + " and a power of two"); + return false; + } + return true; } =20 @@ -871,6 +883,9 @@ static void migrate_params_test_apply(MigrateSetParamet= ers *params, if (params->has_x_multifd_page_count) { dest->x_multifd_page_count =3D params->x_multifd_page_count; } + if (params->has_xbzrle_cache_size) { + dest->xbzrle_cache_size =3D params->xbzrle_cache_size; + } } =20 static void migrate_params_apply(MigrateSetParameters *params) @@ -939,6 +954,10 @@ static void migrate_params_apply(MigrateSetParameters = *params) if (params->has_x_multifd_page_count) { s->parameters.x_multifd_page_count =3D params->x_multifd_page_coun= t; } + if (params->has_xbzrle_cache_size) { + s->parameters.xbzrle_cache_size =3D params->xbzrle_cache_size; + xbzrle_cache_resize(params->xbzrle_cache_size, NULL); + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) @@ -1370,13 +1389,12 @@ void qmp_migrate_cancel(Error **errp) =20 void qmp_migrate_set_cache_size(int64_t value, Error **errp) { - MigrationState *s =3D migrate_get_current(); + MigrateSetParameters p =3D { + .has_xbzrle_cache_size =3D true, + .xbzrle_cache_size =3D value, + }; =20 - if (xbzrle_cache_resize(value, errp) < 0) { - return; - } - - s->xbzrle_cache_size =3D value; + qmp_migrate_set_parameters(&p, errp); } =20 int64_t qmp_query_migrate_cache_size(Error **errp) @@ -1542,7 +1560,7 @@ int64_t migrate_xbzrle_cache_size(void) =20 s =3D migrate_get_current(); =20 - return s->xbzrle_cache_size; + return s->parameters.xbzrle_cache_size; } =20 bool migrate_use_block(void) @@ -2312,6 +2330,9 @@ static Property migration_properties[] =3D { DEFINE_PROP_INT64("x-multifd-page-count", MigrationState, parameters.x_multifd_page_count, DEFAULT_MIGRATE_MULTIFD_PAGE_COUNT), + DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, + parameters.xbzrle_cache_size, + DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), =20 /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), @@ -2353,7 +2374,6 @@ static void migration_instance_init(Object *obj) MigrationParameters *params =3D &ms->parameters; =20 ms->state =3D MIGRATION_STATUS_NONE; - ms->xbzrle_cache_size =3D DEFAULT_MIGRATE_CACHE_SIZE; ms->mbps =3D -1; =20 params->tls_hostname =3D g_strdup(""); @@ -2371,6 +2391,7 @@ static void migration_instance_init(Object *obj) params->has_block_incremental =3D true; params->has_x_multifd_channels =3D true; params->has_x_multifd_page_count =3D true; + params->has_xbzrle_cache_size =3D true; } =20 /* diff --git a/migration/migration.h b/migration/migration.h index b83cceadc4..d2a8d319f1 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -107,7 +107,6 @@ struct MigrationState int64_t downtime; int64_t expected_downtime; bool enabled_capabilities[MIGRATION_CAPABILITY__MAX]; - int64_t xbzrle_cache_size; int64_t setup_time; =20 /* Flag set once the migration has been asked to enter postcopy */ diff --git a/migration/ram.c b/migration/ram.c index ed4d3c6295..78e3b80e39 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -128,13 +128,6 @@ int xbzrle_cache_resize(int64_t new_size, Error **errp) return -1; } =20 - /* Cache should not be larger than guest ram size */ - if (new_size > ram_bytes_total()) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", - "exceeds guest ram size"); - return -1; - } - if (new_size =3D=3D migrate_xbzrle_cache_size()) { /* nothing to do */ return new_size; diff --git a/qapi/migration.json b/qapi/migration.json index f8b365e3f5..830b2e4480 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -474,6 +474,10 @@ # @x-multifd-page-count: Number of pages sent together to a thread # The default value is 16 (since 2.11) # +# @xbzrle-cache-size: cache size to be used by XBZRLE migration. It +# needs to be a multiple of the target page size +# (Since 2.11) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -481,7 +485,8 @@ 'cpu-throttle-initial', 'cpu-throttle-increment', 'tls-creds', 'tls-hostname', 'max-bandwidth', 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', - 'x-multifd-channels', 'x-multifd-page-count' ] } + 'x-multifd-channels', 'x-multifd-page-count', + 'xbzrle-cache-size' ] } =20 ## # @MigrateSetParameters: @@ -545,6 +550,9 @@ # @x-multifd-page-count: Number of pages sent together to a thread # The default value is 16 (since 2.11) # +# @xbzrle-cache-size: cache size to be used by XBZRLE migration. It +# needs to be a multiple of the target page size +# (Since 2.11) # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -562,7 +570,8 @@ '*x-checkpoint-delay': 'int', '*block-incremental': 'bool', '*x-multifd-channels': 'int', - '*x-multifd-page-count': 'int' } } + '*x-multifd-page-count': 'int', + '*xbzrle-cache-size': 'size' } } =20 ## # @migrate-set-parameters: @@ -641,6 +650,9 @@ # @x-multifd-page-count: Number of pages sent together to a thread # The default value is 16 (since 2.11) # +# @xbzrle-cache-size: cache size to be used by XBZRLE migration. It +# needs to be a multiple of the target page size +# (Since 2.11) # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -656,7 +668,8 @@ '*x-checkpoint-delay': 'int', '*block-incremental': 'bool' , '*x-multifd-channels': 'int', - '*x-multifd-page-count': 'int' } } + '*x-multifd-page-count': 'int', + '*xbzrle-cache-size': 'size' } } =20 ## # @query-migrate-parameters: @@ -921,6 +934,8 @@ # # Returns: nothing on success # +# Notes: This command is deprecated in favor of 'migrate-set-parameters' +# # Since: 1.2 # # Example: @@ -939,6 +954,8 @@ # # Returns: XBZRLE cache size in bytes # +# Notes: This command is deprecated in favor of 'query-migrate-parameters' +# # Since: 1.2 # # Example: --=20 2.13.6 From nobody Fri Apr 19 15:51:06 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 1507659814989278.92546132030975; Tue, 10 Oct 2017 11:23:34 -0700 (PDT) Received: from localhost ([::1]:36578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1zBa-0004Iu-EC for importer@patchew.org; Tue, 10 Oct 2017 14:23:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1z4i-0007Oo-OW for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1z4g-0002T7-VR for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1z4g-0002Sk-MQ for qemu-devel@nongnu.org; Tue, 10 Oct 2017 14:16:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA675C059B60 for ; Tue, 10 Oct 2017 18:16:13 +0000 (UTC) Received: from secure.mitica (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAC64675F0; Tue, 10 Oct 2017 18:16:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CA675C059B60 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 10 Oct 2017 20:15:42 +0200 Message-Id: <20171010181542.24168-11-quintela@redhat.com> In-Reply-To: <20171010181542.24168-1-quintela@redhat.com> References: <20171010181542.24168-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 10 Oct 2017 18:16:13 +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 10/10] migration: [RFC] Use proper types in json 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 use int for everything (int64_t), and then we check that value is between 0 and 255. Change it to the valid types. For qmp, the only real change is that now max_bandwidth allows to use the k/M/G suffixes. Signed-off-by: Juan Quintela --- hmp.c | 22 +++++++++++----------- migration/migration.c | 49 ++++++++++++++++++++---------------------------= -- qapi/migration.json | 20 ++++++++++---------- 3 files changed, 41 insertions(+), 50 deletions(-) diff --git a/hmp.c b/hmp.c index f73232399a..905dc93aef 100644 --- a/hmp.c +++ b/hmp.c @@ -293,23 +293,23 @@ void hmp_info_migrate_parameters(Monitor *mon, const = QDict *qdict) =20 if (params) { assert(params->has_compress_level); - monitor_printf(mon, "%s: %" PRId64 "\n", + monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL), params->compress_level); assert(params->has_compress_threads); - monitor_printf(mon, "%s: %" PRId64 "\n", + monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS), params->compress_threads); assert(params->has_decompress_threads); - monitor_printf(mon, "%s: %" PRId64 "\n", + monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS), params->decompress_threads); assert(params->has_cpu_throttle_initial); - monitor_printf(mon, "%s: %" PRId64 "\n", + monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIA= L), params->cpu_throttle_initial); assert(params->has_cpu_throttle_increment); - monitor_printf(mon, "%s: %" PRId64 "\n", + monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREM= ENT), params->cpu_throttle_increment); assert(params->has_tls_creds); @@ -321,28 +321,28 @@ void hmp_info_migrate_parameters(Monitor *mon, const = QDict *qdict) MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME), params->tls_hostname); assert(params->has_max_bandwidth); - monitor_printf(mon, "%s: %" PRId64 " bytes/second\n", + monitor_printf(mon, "%s: %" PRIu64 " bytes/second\n", MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH), params->max_bandwidth); assert(params->has_downtime_limit); - monitor_printf(mon, "%s: %" PRId64 " milliseconds\n", + monitor_printf(mon, "%s: %" PRIu64 " milliseconds\n", MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT), params->downtime_limit); assert(params->has_x_checkpoint_delay); - monitor_printf(mon, "%s: %" PRId64 "\n", + monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY), params->x_checkpoint_delay); assert(params->has_block_incremental); monitor_printf(mon, "%s: %s\n", MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL), params->block_incremental ? "on" : "off"); - monitor_printf(mon, "%s: %" PRId64 "\n", + monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_CHANNELS), params->x_multifd_channels); - monitor_printf(mon, "%s: %" PRId64 "\n", + monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUN= T), params->x_multifd_page_count); - monitor_printf(mon, "%s: %" PRId64 "\n", + monitor_printf(mon, "%s: %" PRIu64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); } diff --git a/migration/migration.c b/migration/migration.c index fcc0d64625..6d6dcc4e42 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -734,22 +734,20 @@ void qmp_migrate_set_capabilities(MigrationCapability= StatusList *params, static bool migrate_params_check(MigrationParameters *params, Error **errp) { if (params->has_compress_level && - (params->compress_level < 0 || params->compress_level > 9)) { + (params->compress_level > 9)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level", "is invalid, it should be in the range of 0 to 9"); return false; } =20 - if (params->has_compress_threads && - (params->compress_threads < 1 || params->compress_threads > 255)) { + if (params->has_compress_threads && (params->compress_threads < 1)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_threads", "is invalid, it should be in the range of 1 to 255"); return false; } =20 - if (params->has_decompress_threads && - (params->decompress_threads < 1 || params->decompress_threads > 25= 5)) { + if (params->has_decompress_threads && (params->decompress_threads < 1)= ) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "decompress_threads", "is invalid, it should be in the range of 1 to 255"); @@ -774,38 +772,31 @@ static bool migrate_params_check(MigrationParameters = *params, Error **errp) return false; } =20 - if (params->has_max_bandwidth && - (params->max_bandwidth < 0 || params->max_bandwidth > SIZE_MAX)) { + if (params->has_max_bandwidth && (params->max_bandwidth > SIZE_MAX)) { error_setg(errp, "Parameter 'max_bandwidth' expects an integer in = the" " range of 0 to %zu bytes/second", SIZE_MAX); return false; } =20 if (params->has_downtime_limit && - (params->downtime_limit < 0 || - params->downtime_limit > MAX_MIGRATE_DOWNTIME)) { + (params->downtime_limit > MAX_MIGRATE_DOWNTIME)) { error_setg(errp, "Parameter 'downtime_limit' expects an integer in= " "the range of 0 to %d milliseconds", MAX_MIGRATE_DOWNTIME); return false; } =20 - if (params->has_x_checkpoint_delay && (params->x_checkpoint_delay < 0)= ) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, - "x_checkpoint_delay", - "is invalid, it should be positive"); - return false; - } - if (params->has_x_multifd_channels && - (params->x_multifd_channels < 1 || params->x_multifd_channels > 25= 5)) { + /* x_checkpoint_delay is now always positive */ + + if (params->has_x_multifd_channels && (params->x_multifd_channels < 1)= ) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "multifd_channels", "is invalid, it should be in the range of 1 to 255"); return false; } if (params->has_x_multifd_page_count && - (params->x_multifd_page_count < 1 || - params->x_multifd_page_count > 10000)) { + (params->x_multifd_page_count < 1 || + params->x_multifd_page_count > 10000)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "multifd_page_count", "is invalid, it should be in the range of 1 to 10000"); @@ -2301,33 +2292,33 @@ static Property migration_properties[] =3D { send_section_footer, true), =20 /* Migration parameters */ - DEFINE_PROP_INT64("x-compress-level", MigrationState, + DEFINE_PROP_UINT8("x-compress-level", MigrationState, parameters.compress_level, DEFAULT_MIGRATE_COMPRESS_LEVEL), - DEFINE_PROP_INT64("x-compress-threads", MigrationState, + DEFINE_PROP_UINT8("x-compress-threads", MigrationState, parameters.compress_threads, DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT), - DEFINE_PROP_INT64("x-decompress-threads", MigrationState, + DEFINE_PROP_UINT8("x-decompress-threads", MigrationState, parameters.decompress_threads, DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT), - DEFINE_PROP_INT64("x-cpu-throttle-initial", MigrationState, + DEFINE_PROP_UINT8("x-cpu-throttle-initial", MigrationState, parameters.cpu_throttle_initial, DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL), - DEFINE_PROP_INT64("x-cpu-throttle-increment", MigrationState, + DEFINE_PROP_UINT8("x-cpu-throttle-increment", MigrationState, parameters.cpu_throttle_increment, DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT), - DEFINE_PROP_INT64("x-max-bandwidth", MigrationState, + DEFINE_PROP_SIZE("x-max-bandwidth", MigrationState, parameters.max_bandwidth, MAX_THROTTLE), - DEFINE_PROP_INT64("x-downtime-limit", MigrationState, + DEFINE_PROP_UINT64("x-downtime-limit", MigrationState, parameters.downtime_limit, DEFAULT_MIGRATE_SET_DOWNTIME), - DEFINE_PROP_INT64("x-checkpoint-delay", MigrationState, + DEFINE_PROP_UINT32("x-checkpoint-delay", MigrationState, parameters.x_checkpoint_delay, DEFAULT_MIGRATE_X_CHECKPOINT_DELAY), - DEFINE_PROP_INT64("x-multifd-channels", MigrationState, + DEFINE_PROP_UINT8("x-multifd-channels", MigrationState, parameters.x_multifd_channels, DEFAULT_MIGRATE_MULTIFD_CHANNELS), - DEFINE_PROP_INT64("x-multifd-page-count", MigrationState, + DEFINE_PROP_UINT32("x-multifd-page-count", MigrationState, parameters.x_multifd_page_count, DEFAULT_MIGRATE_MULTIFD_PAGE_COUNT), DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, diff --git a/qapi/migration.json b/qapi/migration.json index 830b2e4480..81bd979912 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -656,19 +656,19 @@ # Since: 2.4 ## { 'struct': 'MigrationParameters', - 'data': { '*compress-level': 'int', - '*compress-threads': 'int', - '*decompress-threads': 'int', - '*cpu-throttle-initial': 'int', - '*cpu-throttle-increment': 'int', + 'data': { '*compress-level': 'uint8', + '*compress-threads': 'uint8', + '*decompress-threads': 'uint8', + '*cpu-throttle-initial': 'uint8', + '*cpu-throttle-increment': 'uint8', '*tls-creds': 'str', '*tls-hostname': 'str', - '*max-bandwidth': 'int', - '*downtime-limit': 'int', - '*x-checkpoint-delay': 'int', + '*max-bandwidth': 'size', + '*downtime-limit': 'uint64', + '*x-checkpoint-delay': 'uint32', '*block-incremental': 'bool' , - '*x-multifd-channels': 'int', - '*x-multifd-page-count': 'int', + '*x-multifd-channels': 'uint8', + '*x-multifd-page-count': 'uint32', '*xbzrle-cache-size': 'size' } } =20 ## --=20 2.13.6