From nobody Sun Nov 9 17:52:07 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551265888859496.69896515248695; Wed, 27 Feb 2019 03:11:28 -0800 (PST) Received: from localhost ([127.0.0.1]:42118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyx7M-0001NK-9t for importer@patchew.org; Wed, 27 Feb 2019 06:11:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyx5N-00006V-NX for qemu-devel@nongnu.org; Wed, 27 Feb 2019 06:09:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyx5M-0002dK-7P for qemu-devel@nongnu.org; Wed, 27 Feb 2019 06:09:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59018) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gyx5L-0002bq-U6 for qemu-devel@nongnu.org; Wed, 27 Feb 2019 06:09:12 -0500 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 3391C820E9 for ; Wed, 27 Feb 2019 11:09:10 +0000 (UTC) Received: from localhost.localdomain (ovpn-117-2.ams2.redhat.com [10.36.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45616183D9; Wed, 27 Feb 2019 11:09:08 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 27 Feb 2019 12:08:09 +0100 Message-Id: <20190227110812.2185-6-quintela@redhat.com> In-Reply-To: <20190227110812.2185-1-quintela@redhat.com> References: <20190227110812.2185-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 27 Feb 2019 11:09:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 5/8] multifd: Be flexible about packet 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: Laurent Vivier , Thomas Huth , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This way we can change the packet size in the future and everything will work. We choose an arbitrary big number (100 times configured size) as a limit about how big we will reallocate. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index e22d02760b..83025a7565 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -723,13 +723,13 @@ static void multifd_pages_clear(MultiFDPages_t *pages) static void multifd_send_fill_packet(MultiFDSendParams *p) { MultiFDPacket_t *packet =3D p->packet; - uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + uint32_t page_max =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); int i; =20 packet->magic =3D cpu_to_be32(MULTIFD_MAGIC); packet->version =3D cpu_to_be32(MULTIFD_VERSION); packet->flags =3D cpu_to_be32(p->flags); - packet->pages_alloc =3D cpu_to_be32(page_count); + packet->pages_alloc =3D cpu_to_be32(page_max); packet->pages_used =3D cpu_to_be32(p->pages->used); packet->next_packet_size =3D cpu_to_be32(p->next_packet_size); packet->packet_num =3D cpu_to_be64(p->packet_num); @@ -746,7 +746,7 @@ static void multifd_send_fill_packet(MultiFDSendParams = *p) static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) { MultiFDPacket_t *packet =3D p->packet; - uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + uint32_t pages_max =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); RAMBlock *block; int i; =20 @@ -769,12 +769,24 @@ static int multifd_recv_unfill_packet(MultiFDRecvPara= ms *p, Error **errp) p->flags =3D be32_to_cpu(packet->flags); =20 packet->pages_alloc =3D be32_to_cpu(packet->pages_alloc); - if (packet->pages_alloc > page_count) { + /* + * If we recevied a packet that is 100 times bigger than expected + * just stop migration. It is a magic number. + */ + if (packet->pages_alloc > pages_max * 100) { error_setg(errp, "multifd: received packet " - "with size %d and expected maximum size %d", - packet->pages_alloc, page_count) ; + "with size %d and expected a maximum size of %d", + packet->pages_alloc, pages_max * 100) ; return -1; } + /* + * We received a packet that is bigger than expected but inside + * reasonable limits (see previous comment). Just reallocate. + */ + if (packet->pages_alloc > p->pages->allocated) { + multifd_pages_clear(p->pages); + multifd_pages_init(packet->pages_alloc); + } =20 p->pages->used =3D be32_to_cpu(packet->pages_used); if (p->pages->used > packet->pages_alloc) { --=20 2.20.1