From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579006660; cv=none; d=zohomail.com; s=zohoarc; b=njCvhRIQeRMLTLIug5SQyqrFJagEfx98VVr88BXCZEvuxE44kyRT7EGDT2LJKoC7pX8GQ/8xbpf05SoU/or1791C8YIH5Qf65q5dJ5dIbH2GfSogzqt6EmICU9L5LvVzMskJqBcQSPuM5uzgpoiE11Sv+eJa0xWiFH37+mHL2IQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579006660; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c7WNsWxyp42yO9QERGARx6XOOlE/u8t3t0eSsw+Cvvk=; b=kkZALK1SfwFZ+4h0ErUEqxT16Eks4XdZS2H6vB0kJUmp9A/xBZF7ciZK2bvQXvRJpYKY7afL3HagJWHuvDTPU1rwg0m0WNto3y0Wh7YXCC22+jk+tZiccxoRnZ07/Ms3ta7gc2n9p7qlsnHSH0GZAf8loGsJVSzQhhVzNTvnMus= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579006660938604.8653514026795; Tue, 14 Jan 2020 04:57:40 -0800 (PST) Received: from localhost ([::1]:38894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLlL-0004su-Da for importer@patchew.org; Tue, 14 Jan 2020 07:57:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40504) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLh6-00008j-HV for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLh2-0001MQ-M5 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:16 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:38023 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLh2-0001MA-Ic for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-202-qfxjeemzNRKos2vIunwP_w-1; Tue, 14 Jan 2020 07:53:11 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2F640477; Tue, 14 Jan 2020 12:53:09 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87B0F5D9E5; Tue, 14 Jan 2020 12:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c7WNsWxyp42yO9QERGARx6XOOlE/u8t3t0eSsw+Cvvk=; b=jIj2n9M4gaZofR91PEb6GWBU0+2KqLAmQi1EBp2KJ1hubhgM24YGhy7fjGrhsrP2850s1A USS2pmJU/2S8nh0cZPKcHbPH3/lmLu6N43P3M+kXAitrpsvCo+TCGt+jhVaR6ixYGlbeM5 8AANDe14QXUXhqqnFh2yXMiar3DP9Z8= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 01/30] multifd: Initialize local variable Date: Tue, 14 Jan 2020 13:52:25 +0100 Message-Id: <20200114125254.4515-2-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: qfxjeemzNRKos2vIunwP_w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Fill everything with zero, so the padding fields are also initialized. Signed-off-by: Juan Quintela Reviewed-by: Daniel P. Berrang=C3=A9 --- migration/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 96feb4062c..b9147bcca3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -703,7 +703,7 @@ typedef struct { =20 static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp) { - MultiFDInit_t msg; + MultiFDInit_t msg =3D {}; int ret; =20 msg.magic =3D cpu_to_be32(MULTIFD_MAGIC); --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579006839; cv=none; d=zohomail.com; s=zohoarc; b=nqI8vzsn4KiDnAsBZTZQNTYNkwkJdDoO5I96bzKRhZN+Zg+zMoPmFzCzET1Fm1u9RG0QoHpHEajNQEGTx6hMyS66IrvWpebnLeAaAyQCC/rkAq5865eMwYSD9JwuWfoe6R7PDE3xjx1haIGhD0Isbk+UR/wAWsFuJUTA94QvsQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579006839; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HOrGW8LuVzt2VaYoxKrtGmG3psdB8aiMxVKzHfUx3hk=; b=nOcit1nDm/P4EfRho4X+6l1h5rPk7hGrm69RAXcDNky42s8cTAguPPMzJPnP9obJEa9ooFbQKyVA+pvPNCqAUNQPGmlfdCZH0xvKv6Fs6OmAWZpdS09ArQdlSYQS0BMYhVXrYbSMP7SauODt+Z9ue+aIyI+NdTu6iWox7yRjCc0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579006839896788.6701619027822; Tue, 14 Jan 2020 05:00:39 -0800 (PST) Received: from localhost ([::1]:38926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLoE-00009o-Cr for importer@patchew.org; Tue, 14 Jan 2020 08:00:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40550) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLhB-0000FA-1q for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLh7-0001Nt-46 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:20 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:51370 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLh7-0001NR-11 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:17 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-97-iUqI8d_wOZCOK_dlnqgc3A-1; Tue, 14 Jan 2020 07:53:15 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C7205DBA3; Tue, 14 Jan 2020 12:53:13 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 847065D9E5; Tue, 14 Jan 2020 12:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HOrGW8LuVzt2VaYoxKrtGmG3psdB8aiMxVKzHfUx3hk=; b=hyIr7CWUW3E709Au3AabiHG64USzMB+nqKOB42liKl1cVI/ycJ6Uj1dul7FjZg+RWAQ92q Y4gWAH8WSesx1MzwGlxXHomWmHY2OdeVcAaiIQ6QTAGULjv/UuaCj0+DdlSfMk+DsrvigG wbeh5jQGonEMEHkfgTFU14uoG5aJsHA= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 02/30] multifd: Allocate uint64_t instead of ram_addr_t Date: Tue, 14 Jan 2020 13:52:26 +0100 Message-Id: <20200114125254.4515-3-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: iUqI8d_wOZCOK_dlnqgc3A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We receive that value over the network, and ram_addr_t depends of architecture. Just make enough space for 64bit. Signed-off-by: Juan Quintela Reviewed-by: Daniel P. Berrang=C3=A9 --- migration/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index b9147bcca3..d003538f06 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1236,7 +1236,7 @@ int multifd_save_setup(void) p->id =3D i; p->pages =3D multifd_pages_init(page_count); p->packet_len =3D sizeof(MultiFDPacket_t) - + sizeof(ram_addr_t) * page_count; + + sizeof(uint64_t) * page_count; p->packet =3D g_malloc0(p->packet_len); p->packet->magic =3D cpu_to_be32(MULTIFD_MAGIC); p->packet->version =3D cpu_to_be32(MULTIFD_VERSION); --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007045; cv=none; d=zohomail.com; s=zohoarc; b=AyAnM31MZRGrz6Zzff7tWIFHqKV8Ls8CP2rqiyewAvjIpFhK8wvFSWO1MMahe4ohbsKdlv/v3qtByvQnNg3MrRRp7JN1VmU19bD1ok8oeQ6aO6HKLLZcma6tsNGnsd3hkWdAAUvLyD/1EnaN1QIVjUZzmayq7dh7rvEAnj4p254= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007045; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OFbuBsfI2hdknoUqcqxf7Pz5nXpd3viWe9nVgMcqFyk=; b=VrXn29kRImA2JE+KA6Do/1EVP6CanfFu/o5D9mlCFknLHqQ/s//Mi7mA0Mjn9hWZtPOHqtwG7YZERzkZhQ/vs3qCUJV+VWi9HtTCfDvtH0HvQgc33/oJta7lxkfs4vODynjyZOVhRCV06fRns/nC/8bx/7rfdWRBaPhasmzV8SM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007045463929.2354099473514; Tue, 14 Jan 2020 05:04:05 -0800 (PST) Received: from localhost ([::1]:38994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLrW-0004Te-PE for importer@patchew.org; Tue, 14 Jan 2020 08:04:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40586) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLhK-0000UN-7l for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLhI-0001PZ-C6 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:30 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:46270 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLhI-0001PP-8z for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-rtLsel4uMG6elYtC9xo37g-1; Tue, 14 Jan 2020 07:53:25 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64B2CDBAB; Tue, 14 Jan 2020 12:53:23 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2858C5D9E5; Tue, 14 Jan 2020 12:53:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OFbuBsfI2hdknoUqcqxf7Pz5nXpd3viWe9nVgMcqFyk=; b=CiDeFvbwH08EVz+xotrW1KGItgj2sXKmAOThYIMAXZgzRgSWu2mctg31H/T48tVprq4mlp Y0hEt4hHIWyepd08h/6WzP4s6ViS/EGtv9keh6P8VunOMCQHoOs5PzJ62jJnEtnJjcNFzT 5eYfc9h3BhnhE0GfcRYn8v0zp22rXRo= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 03/30] migration-test: Add migration multifd test Date: Tue, 14 Jan 2020 13:52:27 +0100 Message-Id: <20200114125254.4515-4-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: rtLsel4uMG6elYtC9xo37g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We set multifd-channels. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Thomas Huth Tested-by: Wei Yang --- tests/qtest/migration-test.c | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 53afec4395..fb70214f44 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1202,6 +1202,61 @@ static void test_migrate_auto_converge(void) test_migrate_end(from, to, true); } =20 +static void test_multifd_tcp(void) +{ + MigrateStart *args =3D migrate_start_new(); + QTestState *from, *to; + QDict *rsp; + char *uri; + + if (test_migrate_start(&from, &to, "defer", args)) { + return; + } + + /* + * We want to pick a speed slow enough that the test completes + * quickly, but that it doesn't complete precopy even on a slow + * machine, so also set the downtime. + */ + /* 1 ms should make it not converge*/ + migrate_set_parameter_int(from, "downtime-limit", 1); + /* 1GB/s */ + migrate_set_parameter_int(from, "max-bandwidth", 1000000000); + + migrate_set_parameter_int(from, "multifd-channels", 16); + migrate_set_parameter_int(to, "multifd-channels", 16); + + migrate_set_capability(from, "multifd", "true"); + migrate_set_capability(to, "multifd", "true"); + + /* Start incoming migration from the 1st socket */ + rsp =3D wait_command(to, "{ 'execute': 'migrate-incoming'," + " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}"); + qobject_unref(rsp); + + /* Wait for the first serial output from the source */ + wait_for_serial("src_serial"); + + uri =3D migrate_get_socket_address(to, "socket-address"); + + migrate_qmp(from, uri, "{}"); + + wait_for_migration_pass(from); + + /* 300ms it should converge */ + migrate_set_parameter_int(from, "downtime-limit", 300); + + if (!got_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + qtest_qmp_eventwait(to, "RESUME"); + + wait_for_serial("dest_serial"); + wait_for_migration_complete(from); + test_migrate_end(from, to, true); + free(uri); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -1266,6 +1321,7 @@ int main(int argc, char **argv) test_validate_uuid_dst_not_set); =20 qtest_add_func("/migration/auto_converge", test_migrate_auto_converge); + qtest_add_func("/migration/multifd/tcp", test_multifd_tcp); =20 ret =3D g_test_run(); =20 --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579006716; cv=none; d=zohomail.com; s=zohoarc; b=i88Plo6jhD7pkTE/e4D6NvA0Y4YlukV9PjyiqhGNJHUN/UnbjBuOoRVbQvoy/tHGHnNmrBTkmqCBrYtd8cs1HEnnP0W6Dy5QJiEbjDXy0uw5tpPeivmCprZVQ5eCcFl4yss/kICOGtRzQqa41C4ZEYhVosbvfxQGIdq/ZFX+xVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579006716; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JqNxX14HW/WLivX9UNa9yxrv0SVTGvB61OAO+BVcZaw=; b=eNIw330KrKMiSpkTqYytiVVsOl5FcDgdgI/Nw3mdjFyLeJKyAHbMOPUPnw5RGYjji7OJfdCPwKa+IWNS7/I4/RwC2WIUdVmpECGn4jeVRw+XjaGTBsFj3wczCRtySpu2QeTbX9hcHWuBdULCdf+J2Sb+qIlP+Kf2amg2I0YfOyA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579006716844751.6423488594239; Tue, 14 Jan 2020 04:58:36 -0800 (PST) Received: from localhost ([::1]:38906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLmF-0006N0-B8 for importer@patchew.org; Tue, 14 Jan 2020 07:58:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40628) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLhR-0000fx-Jp for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLhN-0001Qk-MB for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:37 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:31774 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLhN-0001QY-Ix for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:53:33 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-308-sprUiLntNBi18fyCMww_3Q-1; Tue, 14 Jan 2020 07:53:32 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 647CF800D54; Tue, 14 Jan 2020 12:53:30 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id C68F15D9E5; Tue, 14 Jan 2020 12:53:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JqNxX14HW/WLivX9UNa9yxrv0SVTGvB61OAO+BVcZaw=; b=R7YiBBRAc8vmFfUU5YwWWTnEcUe7ZxFxH9WwMrAG5uIm3SS7bz5YsEijPO+eZ1LgXphPgm +sk+7ec1ra5cpoPwpe8pj68OqAyrVCZBtDvsP8Kff/0L1TJ+qv4XKPl2axbHpVvq9WsDvW 61iQ8TOKgFdT8UkxCBAlkVAQw73gkeY= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 04/30] migration: Make sure that we don't call write() in case of error Date: Tue, 14 Jan 2020 13:52:28 +0100 Message-Id: <20200114125254.4515-5-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: sprUiLntNBi18fyCMww_3Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If we are exiting due to an error/finish/.... Just don't try to even touch the channel with one IO operation. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index d003538f06..39e7b922ff 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -900,6 +900,12 @@ struct { uint64_t packet_num; /* send channels ready */ QemuSemaphore channels_ready; + /* + * Have we already run terminate threads. There is a race when it + * happens that we got one error while we are exiting. + * We will use atomic operations. Only valid values are 0 and 1. + */ + int exiting; } *multifd_send_state; =20 /* @@ -928,6 +934,10 @@ static int multifd_send_pages(RAMState *rs) MultiFDPages_t *pages =3D multifd_send_state->pages; uint64_t transferred; =20 + if (atomic_read(&multifd_send_state->exiting)) { + return -1; + } + qemu_sem_wait(&multifd_send_state->channels_ready); for (i =3D next_channel;; i =3D (i + 1) % migrate_multifd_channels()) { p =3D &multifd_send_state->params[i]; @@ -1009,6 +1019,16 @@ static void multifd_send_terminate_threads(Error *er= r) } } =20 + /* + * We don't want to exit each threads twice. Depending on where + * we get the error, or if there are two independent errors in two + * threads at the same time, we can end calling this function + * twice. + */ + if (atomic_xchg(&multifd_send_state->exiting, 1)) { + return; + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 @@ -1118,6 +1138,10 @@ static void *multifd_send_thread(void *opaque) =20 while (true) { qemu_sem_wait(&p->sem); + + if (atomic_read(&multifd_send_state->exiting)) { + break; + } qemu_mutex_lock(&p->mutex); =20 if (p->pending_job) { @@ -1224,6 +1248,7 @@ int multifd_save_setup(void) multifd_send_state->params =3D g_new0(MultiFDSendParams, thread_count); multifd_send_state->pages =3D multifd_pages_init(page_count); qemu_sem_init(&multifd_send_state->channels_ready, 0); + atomic_set(&multifd_send_state->exiting, 0); =20 for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007124; cv=none; d=zohomail.com; s=zohoarc; b=DSrUFbx0SPXFnYv0Hl9bhIaJ8UcoTe1Zzna7Ckr9bACeNVndQx3HKaBWaXU2XGi5clyymHnBALpAhyl0BF/3qWL98wOUzlOWriBb8NKsfmUZ9uAxt9BEGKMEMZS7QI01fNhxNQh5/F0YnQCohX+ufBHXGmRl/WD9VppSbJZSJzU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007124; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WncZoYQhc4fyVcSeQQg7aX50Ge+MvO1i8vxboNCbIRE=; b=Hff6u1LgNJixitvNv4I8PNVg0XEdhv4sOv0PBC1PJJ/xdZNeie/YjrL7WBMTdHNT04owVb82rIzDr8UNiMDsY4uh04j9xJbKz1BHEkrzzVbclhm6XuCOpjkhHJRITLdToYJB9CzNsa3R3JEWD90tVhUs2GEWZByfZHt8OVliPYU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007124021107.7841403246299; Tue, 14 Jan 2020 05:05:24 -0800 (PST) Received: from localhost ([::1]:39010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLsn-0006Lr-KH for importer@patchew.org; Tue, 14 Jan 2020 08:05:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40707) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLht-0001Oo-C4 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLhp-0001UW-E6 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:05 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:44073 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLhp-0001U9-AZ for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:01 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-309-4F9FB2kjM-SG4yMSqcjNRA-1; Tue, 14 Jan 2020 07:53:59 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67E20802C89; Tue, 14 Jan 2020 12:53:57 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6DDE5D9E5; Tue, 14 Jan 2020 12:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WncZoYQhc4fyVcSeQQg7aX50Ge+MvO1i8vxboNCbIRE=; b=KJQb1nBQL0Ekc0LC+unHqsdCpZpVff9MOT+dpniBcCEz9WXbl9U2tZBqTG7VmAjV1Bztep tGAlZ8RTr4L9eAnj0MgU/KDHR5t8Vaa7brJT/bf/ZgRF3gYHuTolGR7zQer2VDkDMraY0r zY4OA/8i70LUuJmKdLRQeUnJelcQZjs= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 05/30] migration-test: introduce functions to handle string parameters Date: Tue, 14 Jan 2020 13:52:29 +0100 Message-Id: <20200114125254.4515-6-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 4F9FB2kjM-SG4yMSqcjNRA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- tests/qtest/migration-test.c | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index fb70214f44..b0580dd541 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -356,6 +356,43 @@ static void migrate_set_parameter_int(QTestState *who,= const char *parameter, migrate_check_parameter_int(who, parameter, value); } =20 +static char *migrate_get_parameter_str(QTestState *who, + const char *parameter) +{ + QDict *rsp; + char *result; + + rsp =3D wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + result =3D g_strdup(qdict_get_str(rsp, parameter)); + qobject_unref(rsp); + return result; +} + +static void migrate_check_parameter_str(QTestState *who, const char *param= eter, + const char *value) +{ + char *result; + + result =3D migrate_get_parameter_str(who, parameter); + g_assert_cmpstr(result, =3D=3D, value); + g_free(result); +} + +__attribute__((unused)) +static void migrate_set_parameter_str(QTestState *who, const char *paramet= er, + const char *value) +{ + QDict *rsp; + + rsp =3D qtest_qmp(who, + "{ 'execute': 'migrate-set-parameters'," + "'arguments': { %s: %s } }", + parameter, value); + g_assert(qdict_haskey(rsp, "return")); + qobject_unref(rsp); + migrate_check_parameter_str(who, parameter, value); +} + static void migrate_pause(QTestState *who) { QDict *rsp; --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579006628; cv=none; d=zohomail.com; s=zohoarc; b=jRQZlxv3ndt5I4CHxUBeuJv6vkdZoF4cNe1KYCqQWVLIV8c/5spNouOHaok4IgxtUgI4OFG6gxjSD9TAloNZd+aAIuvnisiHPT8U6Sxx7wthsCO80OvCTiQga7Ga8bB3LgPrmsTgV4/GIsaldA88nsvtKvy9e9XIFTiLLboD6aM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579006628; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BrX1W4PqQfRCqbcGSErGINbVpX+XYhnN1Q3v/xMRPg4=; b=ScA/MSG5kVpJNB8WaNlrlr41GTCGSX+yH8F2L08Ivxcyb6l0WQ1ogRzhJfUwbnCoOyKaYSJxE0fGcfUh34AON01s0nAajY8SCro139PwJ5BMq2Iu6oqewJQDLlENGnhUTmrixhYKfaWoxrmM10P9job+wiNgvSH7lhkObDMpsSg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579006628901321.9894186863063; Tue, 14 Jan 2020 04:57:08 -0800 (PST) Received: from localhost ([::1]:38852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLkp-00047A-0o for importer@patchew.org; Tue, 14 Jan 2020 07:57:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40758) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLi0-0001ay-Ve for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLhw-0001Xh-Ak for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:11 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40249 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLhw-0001XP-7a for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:08 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-hHF51gW1OHyAWdDl-MgE8Q-1; Tue, 14 Jan 2020 07:54:06 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 95DB5189CD13; Tue, 14 Jan 2020 12:54:04 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE94E5D9E5; Tue, 14 Jan 2020 12:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006447; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BrX1W4PqQfRCqbcGSErGINbVpX+XYhnN1Q3v/xMRPg4=; b=bYzbLCIyXH1UC3yJVRF5KE6qHwPjvXZiYpwmZt/rxTGpkjXGHLXpYwwrTGJo0uVYRMqjj9 v59VIKxi+LOPe2u4joQC+y5j/2DVj6WUCUBvkpjULo5qvE0IDiGmO5yeEFSESE5gav/OOv Lgr7VcLU0w26c8Ffm3Qz0hjv1neuYlU= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 06/30] migration-test: ppc64: fix FORTH test program Date: Tue, 14 Jan 2020 13:52:30 +0100 Message-Id: <20200114125254.4515-7-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: hHF51gW1OHyAWdDl-MgE8Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , wei@redhat.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Commit e51e711b1bef has moved the initialization of start_address and end_address after the definition of the command line argument, where the nvramrc is initialized, and thus the loop is between 0 and 0 rather than 1 MiB and 100 MiB. It doesn't affect the result of the test if all the tests are run in sequence because the two first tests don't run the loop, so the values are correctly initialized when we actually need them. But it hangs when we ask to run only one test, for instance: QTEST_QEMU_BINARY=3Dppc64-softmmu/qemu-system-ppc64 \ tests/migration-test -m=3Dquick -p /ppc64/migration/validate_uuid_error Fixes: e51e711b1bef ("tests/migration: Add migration-test header file") Cc: wei@redhat.com Signed-off-by: Laurent Vivier Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Reviewed-by: David Gibson Signed-off-by: Juan Quintela --- tests/qtest/migration-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index b0580dd541..26e2e77289 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -517,14 +517,14 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, } else if (strcmp(arch, "ppc64") =3D=3D 0) { machine_opts =3D "vsmt=3D8"; memory_size =3D "256M"; + start_address =3D PPC_TEST_MEM_START; + end_address =3D PPC_TEST_MEM_END; arch_source =3D g_strdup_printf("-nodefaults " "-prom-env 'use-nvramrc?=3Dtrue' -pr= om-env " "'nvramrc=3Dhex .\" _\" begin %x %x " "do i c@ 1 + i c! 1000 +loop .\" B\"= 0 " "until'", end_address, start_address= ); arch_target =3D g_strdup(""); - start_address =3D PPC_TEST_MEM_START; - end_address =3D PPC_TEST_MEM_END; } else if (strcmp(arch, "aarch64") =3D=3D 0) { init_bootfile(bootpath, aarch64_kernel, sizeof(aarch64_kernel)); machine_opts =3D "virt,gic-version=3Dmax"; --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007246; cv=none; d=zohomail.com; s=zohoarc; b=PLT/BM134F682qGAd9cPxx/0SGCJLso4FBBk/47KI2txgUrIxYKXEXAovD5oIsGESR6vEN0fcOZwOvTkZh8wCYwnGro7bX4w7/7vkPg0tR11wLlWvfRLhfaR+/vl4bdi2bkIodvRVdUBxCt5KaUNb5NXp2g310COIKOz27H98GI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007246; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ep/mdFe58oIx18pwRhWkg/D1I02FCTVyA7jE4yQkeXs=; b=Jv72w/gTPKQQvibA1b9jTy4UVeIbfs8XElAb+p0q3QNquK1NfXSEVHQlyPpDVDlaQ4YsPGBoRsRf1Evn/3Gtqesr0GTFuIhrTrJEaD0Fa9GwqcIkFVh2SNdysJq0uwYTvYSHCD9W84UhBZYkyhnY3VchJY+vL8x0SYgN+CXnOcQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007246317148.5998088126314; Tue, 14 Jan 2020 05:07:26 -0800 (PST) Received: from localhost ([::1]:39064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLum-0000k2-Ow for importer@patchew.org; Tue, 14 Jan 2020 08:07:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40785) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLi4-0001i2-IY for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLi3-0001Z0-Dq for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:16 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:54356 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLi3-0001Yl-9t for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:15 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-173-zv9B_jHhPuOdtm39MNB3WA-1; Tue, 14 Jan 2020 07:54:13 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A07F2802B6E; Tue, 14 Jan 2020 12:54:11 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB51B5D9E5; Tue, 14 Jan 2020 12:54:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ep/mdFe58oIx18pwRhWkg/D1I02FCTVyA7jE4yQkeXs=; b=Xkk1bZQ0RW4pzigj6SiVnkNrk9qOppsLU3Nd2B5cQYOSzpeqy7Z/GgrD36QmGhzo/liUfV zaOxRnxafwzcCzgpYHhQnGld0pVYwaN2DPjNKZcfhIP7oCRwyY9E2fpoPKvX6taHjsBkFM 29+OAHYzaSlnSgj9ncOQMUdQyZMBw8w= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 07/30] runstate: ignore finishmigrate -> prelaunch transition Date: Tue, 14 Jan 2020 13:52:31 +0100 Message-Id: <20200114125254.4515-8-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: zv9B_jHhPuOdtm39MNB3WA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Commit 1bd71dce4bf2 tries to prevent a finishmigrate -> prelaunch transition by exiting at the beginning of the main_loop_should_exit() function if the state is already finishmigrate. As the finishmigrate state is set in the migration thread it can happen concurrently to the function. The migration thread and the function are normally protected by the iothread mutex and thus the state should no evolve between the start of the function and its end. Unfortunately during the function life the lock is released by pause_all_vcpus() just before the point we need to be sure we are not in finishmigrate state and if the migration thread is waiting for the lock it will take the opportunity to change the state to finishmigrate. The only way to be sure we are not in the finishmigrate state when we need is to check the state after the pause_all_vcpus() function. Fixes: 1bd71dce4bf2 ("runstate: ignore exit request in finish migrate state= ") Signed-off-by: Laurent Vivier Signed-off-by: Juan Quintela --- vl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vl.c b/vl.c index 158a05ed32..ba3e176094 100644 --- a/vl.c +++ b/vl.c @@ -1604,9 +1604,6 @@ static bool main_loop_should_exit(void) RunState r; ShutdownCause request; =20 - if (runstate_check(RUN_STATE_FINISH_MIGRATE)) { - return false; - } if (preconfig_exit_requested) { if (runstate_check(RUN_STATE_PRECONFIG)) { runstate_set(RUN_STATE_PRELAUNCH); @@ -1635,8 +1632,13 @@ static bool main_loop_should_exit(void) pause_all_vcpus(); qemu_system_reset(request); resume_all_vcpus(); + /* + * runstate can change in pause_all_vcpus() + * as iothread mutex is unlocked + */ if (!runstate_check(RUN_STATE_RUNNING) && - !runstate_check(RUN_STATE_INMIGRATE)) { + !runstate_check(RUN_STATE_INMIGRATE) && + !runstate_check(RUN_STATE_FINISH_MIGRATE)) { runstate_set(RUN_STATE_PRELAUNCH); } } --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007405; cv=none; d=zohomail.com; s=zohoarc; b=hOMnMz6nM9f2v8zr8iDiulb+/xFSrtlQllX3N0/KxdvnPaQSkvQ+8/BeVah/xAM8q7ibA+f1C3nsojioAeQM9Arr9j9P7bTVUjAKCpkBcIQoxp9NuboBgMuvFw5iC6+EgH+Zh3zV0M40dY0V2vM5fuFcXSZzKsVEjKSPj50v2Gw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007405; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bIen48VEgN5ricZM78g+5CpDXy/43yfUT0QPLJh3txA=; b=CDxO1n1uBelb1emXDYKOIfA4sAYHqlZKkEjEKwj/VYvW785sagXPebLyCAlPdPPi7y8vRlnnhL8MweiTHdP4S4Fcj179DfFAlpFMbd56G7kTyfpKN5uFs1sYX1wfJ1nk03PmlP6f0n7wyallqIHgIa0C+qk+AxffifkX96FlfIk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007405790572.7239110479086; Tue, 14 Jan 2020 05:10:05 -0800 (PST) Received: from localhost ([::1]:39112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLxM-0004Ub-Lk for importer@patchew.org; Tue, 14 Jan 2020 08:10:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40822) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLiH-00023k-DZ for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLiD-0001ap-D0 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:29 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44626 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLiD-0001aZ-9P for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:25 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141--GQXRzP1PRK-4_Xq5DoynQ-1; Tue, 14 Jan 2020 07:54:21 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B6D39800A02; Tue, 14 Jan 2020 12:54:18 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04F745D9E5; Tue, 14 Jan 2020 12:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bIen48VEgN5ricZM78g+5CpDXy/43yfUT0QPLJh3txA=; b=dsJ4wAN3KBOgvrlTKrFDNGy5/69eQNkkG+6zfBdImqN9fKvsX1oFU62cWNwwzPGAoL9YcU kcwjmMCGnrQPoEyaDdc36rgnyDTcqUvGSftowYi98OURFkw1aRfMLOVZJoLgpsNZTryvq8 1Axmhbuoei1oIHIyEX0UCE6bnHJo6J8= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 08/30] ram.c: remove unneeded labels Date: Tue, 14 Jan 2020 13:52:32 +0100 Message-Id: <20200114125254.4515-9-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: -GQXRzP1PRK-4_Xq5DoynQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Daniel Henrique Barboza , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza ram_save_queue_pages() has an 'err' label that can be replaced by 'return -1' instead. Same thing with ram_discard_range(), and in this case we can also get rid of the 'ret' variable and return either '-1' on error or the result of ram_block_discard_range(). CC: Juan Quintela CC: Dr. David Alan Gilbert Signed-off-by: Daniel Henrique Barboza Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 39e7b922ff..825f47f517 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2459,7 +2459,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr= _t start, ram_addr_t len) * it's the 1st request. */ error_report("ram_save_queue_pages no previous block"); - goto err; + return -1; } } else { ramblock =3D qemu_ram_block_by_name(rbname); @@ -2467,7 +2467,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr= _t start, ram_addr_t len) if (!ramblock) { /* We shouldn't be asked for a non-existent RAMBlock */ error_report("ram_save_queue_pages no block '%s'", rbname); - goto err; + return -1; } rs->last_req_rb =3D ramblock; } @@ -2476,7 +2476,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr= _t start, ram_addr_t len) error_report("%s request overrun start=3D" RAM_ADDR_FMT " len=3D" RAM_ADDR_FMT " blocklen=3D" RAM_ADDR_FMT, __func__, start, len, ramblock->used_length); - goto err; + return -1; } =20 struct RAMSrcPageRequest *new_entry =3D @@ -2492,9 +2492,6 @@ int ram_save_queue_pages(const char *rbname, ram_addr= _t start, ram_addr_t len) qemu_mutex_unlock(&rs->src_page_req_mutex); =20 return 0; - -err: - return -1; } =20 static bool save_page_use_compression(RAMState *rs) @@ -3097,8 +3094,6 @@ int ram_postcopy_send_discard_bitmap(MigrationState *= ms) */ int ram_discard_range(const char *rbname, uint64_t start, size_t length) { - int ret =3D -1; - trace_ram_discard_range(rbname, start, length); =20 RCU_READ_LOCK_GUARD(); @@ -3106,7 +3101,7 @@ int ram_discard_range(const char *rbname, uint64_t st= art, size_t length) =20 if (!rb) { error_report("ram_discard_range: Failed to find block '%s'", rbnam= e); - goto err; + return -1; } =20 /* @@ -3118,10 +3113,7 @@ int ram_discard_range(const char *rbname, uint64_t s= tart, size_t length) length >> qemu_target_page_bits()); } =20 - ret =3D ram_block_discard_range(rb, start, length); - -err: - return ret; + return ram_block_discard_range(rb, start, length); } =20 /* --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579006824; cv=none; d=zohomail.com; s=zohoarc; b=jFmvn58q0czmVJSb7BL7K4gUtRrspQjHvLvrJXCPG0cORNAAlR7oeVfL9fx9CWURw8ZI8xtYUQXNaNGKL21LfqV2ne77s1hR7h+lgFUimuHulpSmLZze66cf3sLWfdNGxG6k32aqX07zpYNRZiCN3OAQhBNR4Nu4yF7kAdnOHQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579006824; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iGtOvyEUGfifsxxl01xh+gxn1N24J9QLDuYgx3ZYdPU=; b=VOTLblpzdeCfHAiAIvEpqvJK4ZEVW8IdNKCDoFlYgkwVKlyB31x8cpKEPwn0547+AwvgiFDsKExgvkfl9BfKC2fz7HZWXKK8OFFODtQgn2PYo8u2NGvs/LuEkjEWGhpGvlINbWpvd6W+ho6FLnhYAV0G+EGqNebLd5bKYXj7bpU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157900682402239.073177863935484; Tue, 14 Jan 2020 05:00:24 -0800 (PST) Received: from localhost ([::1]:38918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLny-0008Ia-0c for importer@patchew.org; Tue, 14 Jan 2020 08:00:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40879) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLiL-0002AH-PY for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLiI-0001br-2Z for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:30583 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLiH-0001bj-Tz for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:30 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-128-y3znGWDzNZaSpFMACrMSDQ-1; Tue, 14 Jan 2020 07:54:27 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A3C9801E77; Tue, 14 Jan 2020 12:54:26 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 165B95D9E5; Tue, 14 Jan 2020 12:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iGtOvyEUGfifsxxl01xh+gxn1N24J9QLDuYgx3ZYdPU=; b=I/JnRG/W/VjxN0U5DUQKGTCubqFx5Ew7k8D3B8/Zh5RLa4HYk/t91+fsu+mH+C+tfB5EC7 UAwwHX0DGQVOGnEgOlT5BKTW/xqjd/jLJF0E43+3vqZ+Tm77/U3moS2ZKAbmPqjl1CBpRe 9b7aTxRsG1VupCiyLLeZcByzhEzDO/g= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 09/30] migration: Rate limit inside host pages Date: Tue, 14 Jan 2020 13:52:33 +0100 Message-Id: <20200114125254.4515-10-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: y3znGWDzNZaSpFMACrMSDQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Corey Minyard , Jason Wang , Peter Xu , Juan Quintela , "Michael S. Tsirkin" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Gibson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Lin Ma , Paolo Bonzini , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" When using hugepages, rate limiting is necessary within each huge page, since a 1G huge page can take a significant time to send, so you end up with bursty behaviour. Fixes: 4c011c37ecb3 ("postcopy: Send whole huge pages") Reported-by: Lin Ma Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Signed-off-by: Juan Quintela --- migration/migration.c | 57 ++++++++++++++++++++++++------------------ migration/migration.h | 1 + migration/ram.c | 2 ++ migration/trace-events | 4 +-- 4 files changed, 37 insertions(+), 27 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 354ad072fa..27500d09a9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3224,6 +3224,37 @@ void migration_consume_urgent_request(void) qemu_sem_wait(&migrate_get_current()->rate_limit_sem); } =20 +/* Returns true if the rate limiting was broken by an urgent request */ +bool migration_rate_limit(void) +{ + int64_t now =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + MigrationState *s =3D migrate_get_current(); + + bool urgent =3D false; + migration_update_counters(s, now); + if (qemu_file_rate_limit(s->to_dst_file)) { + /* + * Wait for a delay to do rate limiting OR + * something urgent to post the semaphore. + */ + int ms =3D s->iteration_start_time + BUFFER_DELAY - now; + trace_migration_rate_limit_pre(ms); + if (qemu_sem_timedwait(&s->rate_limit_sem, ms) =3D=3D 0) { + /* + * We were woken by one or more urgent things but + * the timedwait will have consumed one of them. + * The service routine for the urgent wake will dec + * the semaphore itself for each item it consumes, + * so add this one we just eat back. + */ + qemu_sem_post(&s->rate_limit_sem); + urgent =3D true; + } + trace_migration_rate_limit_post(urgent); + } + return urgent; +} + /* * Master migration thread on the source VM. * It drives the migration and pumps the data down the outgoing channel. @@ -3290,8 +3321,6 @@ static void *migration_thread(void *opaque) trace_migration_thread_setup_complete(); =20 while (migration_is_active(s)) { - int64_t current_time; - if (urgent || !qemu_file_rate_limit(s->to_dst_file)) { MigIterateState iter_state =3D migration_iteration_run(s); if (iter_state =3D=3D MIG_ITERATE_SKIP) { @@ -3318,29 +3347,7 @@ static void *migration_thread(void *opaque) update_iteration_initial_status(s); } =20 - current_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); - - migration_update_counters(s, current_time); - - urgent =3D false; - if (qemu_file_rate_limit(s->to_dst_file)) { - /* Wait for a delay to do rate limiting OR - * something urgent to post the semaphore. - */ - int ms =3D s->iteration_start_time + BUFFER_DELAY - current_ti= me; - trace_migration_thread_ratelimit_pre(ms); - if (qemu_sem_timedwait(&s->rate_limit_sem, ms) =3D=3D 0) { - /* We were worken by one or more urgent things but - * the timedwait will have consumed one of them. - * The service routine for the urgent wake will dec - * the semaphore itself for each item it consumes, - * so add this one we just eat back. - */ - qemu_sem_post(&s->rate_limit_sem); - urgent =3D true; - } - trace_migration_thread_ratelimit_post(urgent); - } + urgent =3D migration_rate_limit(); } =20 trace_migration_thread_after_loop(); diff --git a/migration/migration.h b/migration/migration.h index 79b3dda146..aa9ff6f27b 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -341,5 +341,6 @@ int foreach_not_ignored_block(RAMBlockIterFunc func, vo= id *opaque); =20 void migration_make_urgent_request(void); void migration_consume_urgent_request(void); +bool migration_rate_limit(void); =20 #endif diff --git a/migration/ram.c b/migration/ram.c index 825f47f517..aa6cc7d47a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2639,6 +2639,8 @@ static int ram_save_host_page(RAMState *rs, PageSearc= hStatus *pss, =20 pages +=3D tmppages; pss->page++; + /* Allow rate limiting to happen in the middle of huge pages */ + migration_rate_limit(); } while ((pss->page & (pagesize_bits - 1)) && offset_in_ramblock(pss->block, pss->page << TARGET_PAGE_BITS)= ); =20 diff --git a/migration/trace-events b/migration/trace-events index 6dee7b5389..2f9129e213 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -138,12 +138,12 @@ migrate_send_rp_recv_bitmap(char *name, int64_t size)= "block '%s' size 0x%"PRIi6 migration_completion_file_err(void) "" migration_completion_postcopy_end(void) "" migration_completion_postcopy_end_after_complete(void) "" +migration_rate_limit_pre(int ms) "%d ms" +migration_rate_limit_post(int urgent) "urgent: %d" migration_return_path_end_before(void) "" migration_return_path_end_after(int rp_error) "%d" migration_thread_after_loop(void) "" migration_thread_file_err(void) "" -migration_thread_ratelimit_pre(int ms) "%d ms" -migration_thread_ratelimit_post(int urgent) "urgent: %d" migration_thread_setup_complete(void) "" open_return_path_on_source(void) "" open_return_path_on_source_continue(void) "" --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007029; cv=none; d=zohomail.com; s=zohoarc; b=C4FuGO1b8vQlIoaxHmujEoMaBh8FIGFEH5/bwcoFYhmzX361h3ov9Jgr/+QpyWzDou6mlXmJULN5OneRnDYb69805iN4YtoW9f0tQC3tk1Ez9/a6nHYfBrbNL4x8pLhYvY4sMdCF6fSeYONC8XcTWXlWMa8XEuz9M5W/QIEVSpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007029; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YenyR+cDlGnKbLpY/elkWxAa8k3PezuARzjo1X24+Yw=; b=c9TUJOJW0JJiDutUT43YbsT4F3IWujvc9v5BOXcKTV+Xg8NrvA2oNamEMacy3VGWW2Co2AcClhCxzMJEcUseeOQOK0GkYZgwVdbDEbkqpT+M3nIm9aH3/QimEoux6xE97InYzgT6EW5Dvh5qK0ZBdWz4AlxpJUdXcBUiREEXx4k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007029018274.57126076097165; Tue, 14 Jan 2020 05:03:49 -0800 (PST) Received: from localhost ([::1]:38986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLrH-00047Q-I8 for importer@patchew.org; Tue, 14 Jan 2020 08:03:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40967) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLia-0002Qy-MV for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLiS-0001ek-5n for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:43 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:54475 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLiS-0001eO-2A for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:40 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-404-ZwI5FY7SOLWJaulyg04m6w-1; Tue, 14 Jan 2020 07:54:38 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1EEB7800D4C; Tue, 14 Jan 2020 12:54:36 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EA8F5D9E5; Tue, 14 Jan 2020 12:54:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YenyR+cDlGnKbLpY/elkWxAa8k3PezuARzjo1X24+Yw=; b=RtDf57RNBD2c8gfGsap+RsQZjUq12M2AiGXMEhqmMPWvo+GpIQzX9PJjzMv300DsAaDRbs U/blMGWAXa7g+EDLxKu/82IsiCz2JlLNx/Ay0g7BLWAg0Xik+mKs+pUgSIlt0/DYyvN2vM xqs3sPUxOXK9wTlAZO6VL/3nW13CYwA= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 10/30] migration: Fix incorrect integer->float conversion caught by clang Date: Tue, 14 Jan 2020 13:52:34 +0100 Message-Id: <20200114125254.4515-11-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: ZwI5FY7SOLWJaulyg04m6w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Corey Minyard , Jason Wang , Juan Quintela , "Michael S. Tsirkin" , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Gibson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , Richard Henderson , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fangrui Song , qemu-ppc@nongnu.org, Paolo Bonzini , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Fangrui Song Clang does not like qmp_migrate_set_downtime()'s code to clamp double @value to 0..INT64_MAX: qemu/migration/migration.c:2038:24: error: implicit conversion from 'lo= ng' to 'double' changes value from 9223372036854775807 to 92233720368547758= 08 [-Werror,-Wimplicit-int-float-conversion] The warning will be enabled by default in clang 10. It is not available for clang <=3D 9. The clamp is actually useless; @value is checked to be within 0..MAX_MIGRATE_DOWNTIME_SECONDS immediately before. Delete it. While there, make the conversion from double to int64_t explicit. Signed-off-by: Fangrui Song Reviewed-by: Markus Armbruster Reviewed-by: Juan Quintela Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 [Patch split, commit message improved] Signed-off-by: Markus Armbruster Signed-off-by: Juan Quintela --- migration/migration.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 27500d09a9..f79d0bf89a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2035,11 +2035,10 @@ void qmp_migrate_set_downtime(double value, Error *= *errp) } =20 value *=3D 1000; /* Convert to milliseconds */ - value =3D MAX(0, MIN(INT64_MAX, value)); =20 MigrateSetParameters p =3D { .has_downtime_limit =3D true, - .downtime_limit =3D value, + .downtime_limit =3D (int64_t)value, }; =20 qmp_migrate_set_parameters(&p, errp); --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579006720; cv=none; d=zohomail.com; s=zohoarc; b=gsusssOypui0Iikm0Owl1Bxm9U7zGYlOCihRibnmXCmZCDhE5uD7P4A7JUnJsmlfRNgXmLdPN+KAbSalw2HEJYzjLRcvb5avX83BmGumB9tgRj9JxE5BJdpDB3CR+mBCZ6sFKW9LO9A8YrhAIN0zUw7Chs+0GpE8JvT4yxsQ1iU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579006720; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IK9e0vaf6oFJwdDH1Z3FkKjQHviZuSu3zT8Gr5xF4kk=; b=NiAsGPbhmeV/kxPmobxMNTQxHGqVJln3lIsGca0ZzrUenpLx1FIYw7xdqARNZX8FRdv/C7NI/7RtOFkNJN/iCDU+xD1zn6oDBk/k0YT0vPTPitPS2mWxy5KEC98x/20r7gWMROAtlLSgokFcnXxvoAd8Zb7QWQi1ty7SkQZT4iI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579006720230407.5981404975581; Tue, 14 Jan 2020 04:58:40 -0800 (PST) Received: from localhost ([::1]:38910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLmI-0006SC-KB for importer@patchew.org; Tue, 14 Jan 2020 07:58:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41032) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLif-0002Vr-9d for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLic-0001gw-U4 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:53 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45836 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLic-0001g3-R3 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:50 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-296-HeT-VFWWPm6jTKxaZw-e-w-1; Tue, 14 Jan 2020 07:54:45 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0345800A02; Tue, 14 Jan 2020 12:54:43 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73E4C5D9E5; Tue, 14 Jan 2020 12:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IK9e0vaf6oFJwdDH1Z3FkKjQHviZuSu3zT8Gr5xF4kk=; b=NjupBErHhL8iLKd6/W7iELNE7Xnu/UXD3d/azhXswCIYaGQDpU6VpUD2Kg2cyUSWztJr8f Ygwgfl3GGrkIYn7L+Ymy5VOv+iDgPXdch3zP58EtD3aVVPRPwIfCIBGozVibbtA4NvBxur 59OagYu+Wr/sZnCYx+n6yRpU4i50ej0= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 11/30] migration: Fix the re-run check of the migrate-incoming command Date: Tue, 14 Jan 2020 13:52:35 +0100 Message-Id: <20200114125254.4515-12-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: HeT-VFWWPm6jTKxaZw-e-w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Corey Minyard , Jason Wang , Juan Quintela , "Michael S. Tsirkin" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Gibson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , "Dr. David Alan Gilbert" , Yury Kotov , Darren Kenny , qemu-arm@nongnu.org, Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Yury Kotov The current check sets an error but doesn't fail the command. This may cause a problem if new connection attempt by the same URI affects the first connection. Signed-off-by: Yury Kotov Reviewed-by: Juan Quintela Reviewed-by: Darren Kenny Signed-off-by: Juan Quintela --- migration/migration.c | 1 + 1 file changed, 1 insertion(+) diff --git a/migration/migration.c b/migration/migration.c index f79d0bf89a..e55edee606 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1784,6 +1784,7 @@ void qmp_migrate_incoming(const char *uri, Error **er= rp) } if (!once) { error_setg(errp, "The incoming migration has already been started"= ); + return; } =20 qemu_start_incoming_migration(uri, &local_err); --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007639; cv=none; d=zohomail.com; s=zohoarc; b=NbdH1601jjvYwh5WzcTsky9KfpiopaRv/G/67S1h5VJqVRuBQkQZ1XnV9ztX6+uF2O0PelyhaIeypU5EcTvNM7a6hAnD7sqdeJsEo1uFW1qKYRy6jS9zA6Nv9jVE2ZwIf3VB3AvHFdYyceGLoD0PkDUYVAVG93xoc0F3bR0Uy7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007639; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2p0QKCeBS4+LZOVYBokhIHTSESXgTmLYzL/BOFYcXF4=; b=Sqvm+nymDiceFSu6TozYOjcgFXw20v9YY8ESkO1AqtRJdLfA2lx/Cb80sfb6ZqGOSIlm/gDB49QBKnlqmED8kYyJ5GVhxdSnTMKMtefvrYYOVUBwwzPJWrPutwvt6WqWaTOT06EXOdXwmk9datyrmv/+APuSvcQz5Kz7sgD+ceA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007639612450.06729800623884; Tue, 14 Jan 2020 05:13:59 -0800 (PST) Received: from localhost ([::1]:39176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irM18-0001FK-2L for importer@patchew.org; Tue, 14 Jan 2020 08:13:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41054) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLii-0002Yw-Kn for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLie-0001hd-Kl for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:56 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:28492 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLie-0001h7-HV for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:52 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-yW1AwKWMN0CH7NG-r7Y-GQ-1; Tue, 14 Jan 2020 07:54:50 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89D901800D78; Tue, 14 Jan 2020 12:54:48 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11E235D9E5; Tue, 14 Jan 2020 12:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2p0QKCeBS4+LZOVYBokhIHTSESXgTmLYzL/BOFYcXF4=; b=ZsUGgav3Le0PgSzl/5ZEt8x9yEKC1I6ZiO5ij1Jl6IsEyfpZO/YM3uWGxD+MpscXBuYwE7 yJkp/v+Uuh9jDOT6VTqCj/cMF4Wo+bEOTZOwo+iGbQy/rtlu5vgsw9ELhB3x7Nm6do2rWs oY0Y2tcZNeIH0IIVVfYeKVAhvdWMVWw= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 12/30] misc: use QEMU_IS_ALIGNED Date: Tue, 14 Jan 2020 13:52:36 +0100 Message-Id: <20200114125254.4515-13-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: yW1AwKWMN0CH7NG-r7Y-GQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Juan Quintela Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Berger Reviewed-by: Paolo Bonzini Signed-off-by: Juan Quintela --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index d4b769d0d4..1feda49ca1 100644 --- a/exec.c +++ b/exec.c @@ -3895,7 +3895,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t st= art, size_t length) =20 uint8_t *host_startaddr =3D rb->host + start; =20 - if ((uintptr_t)host_startaddr & (rb->page_size - 1)) { + if (!QEMU_PTR_IS_ALIGNED(host_startaddr, rb->page_size)) { error_report("ram_block_discard_range: Unaligned start address: %p= ", host_startaddr); goto err; @@ -3903,7 +3903,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t st= art, size_t length) =20 if ((start + length) <=3D rb->used_length) { bool need_madvise, need_fallocate; - if (length & (rb->page_size - 1)) { + if (!QEMU_IS_ALIGNED(length, rb->page_size)) { error_report("ram_block_discard_range: Unaligned length: %zx", length); goto err; --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007210; cv=none; d=zohomail.com; s=zohoarc; b=m+YiISDdiSmGy1J5UUO/mtSw2JZunb3mZBveDtWBdesEYF4YNbrnhu+ymbPgWrm7SVo+XqlPS43hnww9+DHGUjlZatQmgygA7iv9PsUvSx6p2dZighCWfcEcgEGPyi0+fWVw+wS3ZgMpYkfDbZljUJOX2Ti7IslP/saaqEQGPPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007210; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8PL3njRMZwxs9uKSpCL5NJoIzl7l80qAcMLLGRwuXdY=; b=B2tzIzbI6m90eX0S/Y5NsdDt+bJkPFPVw2/J5HqZAuYaOsgPnM1PdH+6ucPYdclZLiljwWmAv6PX7lli6hpU4fX3TTPytVmZ3xRt661HwJau46SWA1Z2CxVUdTfSZGqI4XHz6CE2F5AHFIefhH/lWpVKr6MVoV6lrAGwZfuHzgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007210725978.0733635434484; Tue, 14 Jan 2020 05:06:50 -0800 (PST) Received: from localhost ([::1]:39054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLuD-00007h-Aj for importer@patchew.org; Tue, 14 Jan 2020 08:06:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41092) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLip-0002eg-Hc for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLil-0001ix-KH for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:03 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:43994 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLil-0001il-H5 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:54:59 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-167-CY-nTp_YNpCGSH-nt3m7Yw-1; Tue, 14 Jan 2020 07:54:57 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0776189DF43; Tue, 14 Jan 2020 12:54:55 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF08F5D9E5; Tue, 14 Jan 2020 12:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8PL3njRMZwxs9uKSpCL5NJoIzl7l80qAcMLLGRwuXdY=; b=EXnRBssPexGp136GwJ6d57n4WVev8UTfFjxSa9gF7vBhwXavz9YRVmmDbVepmqLAhvtPVn 8w0rUpWUiKRy9I7abArdMOkz+z6nT7ev+/3BH5qVuO6JzPSSa9PYTb8w5qx0GaZ1FEWabV VbrzR+gjE6OTXQEXw3quNr/RHPiyN0Y= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 13/30] migration: add savevm_state_handler_remove() Date: Tue, 14 Jan 2020 13:52:37 +0100 Message-Id: <20200114125254.4515-14-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: CY-nTp_YNpCGSH-nt3m7Yw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Scott Cheloha , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Scott Cheloha Create a function to abstract common logic needed when removing a SaveStateEntry element from the savevm_state.handlers queue. For now we just remove the element. Soon it will involve additional cleanup. Signed-off-by: Scott Cheloha Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/savevm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 59efc1981d..30d980caa2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -725,6 +725,11 @@ static void savevm_state_handler_insert(SaveStateEntry= *nse) } } =20 +static void savevm_state_handler_remove(SaveStateEntry *se) +{ + QTAILQ_REMOVE(&savevm_state.handlers, se, entry); +} + /* TODO: Individual devices generally have very little idea about the rest of the system, so instance_id should be removed/replaced. Meanwhile pass -1 as instance_id if you do not already have a clearly @@ -777,7 +782,7 @@ void unregister_savevm(VMStateIf *obj, const char *idst= r, void *opaque) =20 QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) { if (strcmp(se->idstr, id) =3D=3D 0 && se->opaque =3D=3D opaque) { - QTAILQ_REMOVE(&savevm_state.handlers, se, entry); + savevm_state_handler_remove(se); g_free(se->compat); g_free(se); } @@ -841,7 +846,7 @@ void vmstate_unregister(VMStateIf *obj, const VMStateDe= scription *vmsd, =20 QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) { if (se->vmsd =3D=3D vmsd && se->opaque =3D=3D opaque) { - QTAILQ_REMOVE(&savevm_state.handlers, se, entry); + savevm_state_handler_remove(se); g_free(se->compat); g_free(se); } --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579006997; cv=none; d=zohomail.com; s=zohoarc; b=CP35Azy7X0dOU/7X3qXiq/Yuw3Mtw9xHV133BDDOpziGq1bXId+NjUjaNLDIfh+JYCMwSqE90efpUQwRvlcqQqKgHdOmhId0K4iraip+Mq2vmOW7veRURtanaseZGjeOgtDBcZ65vH3yb1kiHhCT04g3J8BEJ1bdh3sUC+bydnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579006997; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=52j2mgmiA4z5vA2yqyRSfUxDIXdlaCqV+gsG8XIQ6+k=; b=dFv170FnuzHfj0RUI83ruPoCCFoQJj8HvZ38XWTiHCCxqVJSsMSxvS7hnMu6bfEKBYuaDk5CtNc01IPG1kLxgtZnCneulr9i2DqRUy5PWN2H+czyf96PeH7TZvKWVZy2q20BTxVGjoVyCc9iplI6bFFy0BywbUwrbrYrYOzcUwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157900699761260.67121524864467; Tue, 14 Jan 2020 05:03:17 -0800 (PST) Received: from localhost ([::1]:38984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLql-0003I4-J9 for importer@patchew.org; Tue, 14 Jan 2020 08:03:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41137) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLix-0002oh-2S for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLit-0001m3-4j for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:10 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54178 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLit-0001le-0s for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:07 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-qWwRMI4uPa20JK2lf4T8_Q-1; Tue, 14 Jan 2020 07:55:04 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E60FB800D50; Tue, 14 Jan 2020 12:55:02 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0260D5D9E5; Tue, 14 Jan 2020 12:54:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=52j2mgmiA4z5vA2yqyRSfUxDIXdlaCqV+gsG8XIQ6+k=; b=aXzdqvVb+mZjpSr0IZXAGDFku0iYOyUee1IxQcVGfmU6f8ZrmO+BPdjBDggUBmC+ji75Qq yQ7B1tOb9pKTWBI/KS+AVg85Z0am1VMmp3Oy9JS5LKI01X8JEWKKrhk6wU+WWN8/+hwleM prZzNK+p5QS72tS8dTg7umtp0mlqgjI= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 14/30] migration: savevm_state_handler_insert: constant-time element insertion Date: Tue, 14 Jan 2020 13:52:38 +0100 Message-Id: <20200114125254.4515-15-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: qWwRMI4uPa20JK2lf4T8_Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Scott Cheloha , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Scott Cheloha savevm_state's SaveStateEntry TAILQ is a priority queue. Priority sorting is maintained by searching from head to tail for a suitable insertion spot. Insertion is thus an O(n) operation. If we instead keep track of the head of each priority's subqueue within that larger queue we can reduce this operation to O(1) time. savevm_state_handler_remove() becomes slightly more complex to accomodate these gains: we need to replace the head of a priority's subqueue when removing it. With O(1) insertion, booting VMs with many SaveStateEntry objects is more plausible. For example, a ppc64 VM with maxmem=3D8T has 40000 such objects to insert. Signed-off-by: Scott Cheloha Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/savevm.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 30d980caa2..e57686bca7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -250,6 +250,7 @@ typedef struct SaveStateEntry { =20 typedef struct SaveState { QTAILQ_HEAD(, SaveStateEntry) handlers; + SaveStateEntry *handler_pri_head[MIG_PRI_MAX + 1]; int global_section_id; uint32_t len; const char *name; @@ -261,6 +262,7 @@ typedef struct SaveState { =20 static SaveState savevm_state =3D { .handlers =3D QTAILQ_HEAD_INITIALIZER(savevm_state.handlers), + .handler_pri_head =3D { [MIG_PRI_DEFAULT ... MIG_PRI_MAX] =3D NULL }, .global_section_id =3D 0, }; =20 @@ -709,24 +711,42 @@ static void savevm_state_handler_insert(SaveStateEntr= y *nse) { MigrationPriority priority =3D save_state_priority(nse); SaveStateEntry *se; + int i; =20 assert(priority <=3D MIG_PRI_MAX); =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (save_state_priority(se) < priority) { + for (i =3D priority - 1; i >=3D 0; i--) { + se =3D savevm_state.handler_pri_head[i]; + if (se !=3D NULL) { + assert(save_state_priority(se) < priority); break; } } =20 - if (se) { + if (i >=3D 0) { QTAILQ_INSERT_BEFORE(se, nse, entry); } else { QTAILQ_INSERT_TAIL(&savevm_state.handlers, nse, entry); } + + if (savevm_state.handler_pri_head[priority] =3D=3D NULL) { + savevm_state.handler_pri_head[priority] =3D nse; + } } =20 static void savevm_state_handler_remove(SaveStateEntry *se) { + SaveStateEntry *next; + MigrationPriority priority =3D save_state_priority(se); + + if (se =3D=3D savevm_state.handler_pri_head[priority]) { + next =3D QTAILQ_NEXT(se, entry); + if (next !=3D NULL && save_state_priority(next) =3D=3D priority) { + savevm_state.handler_pri_head[priority] =3D next; + } else { + savevm_state.handler_pri_head[priority] =3D NULL; + } + } QTAILQ_REMOVE(&savevm_state.handlers, se, entry); } =20 --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007179; cv=none; d=zohomail.com; s=zohoarc; b=bkp090XbQ48/iAIiLxgBn0XpVFs1EK0GLFu73hFp/fB8XVshjomU0+6+Votq/L8p6L4Z7AHTUXgNR4uvuH2gDYWRpZ+pk5bO7TcLI2jqJk+LLk3XkPryPZoRNwShPKSDwm0OzACJlBSMJktUGXj1JBgqYp0vAy1vcMaDOo7Qfz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007179; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a+D0Jhjaw7oJJMu/pHqSxLnV5MGTcL/XHY7MlyuPryQ=; b=LGYVqEDEkDwYYGRGzAXPIANgpprNGaiE6I3SsBuC7lVDFB2jLvXodOsFzZa1LRD22+uLebS0PqTGLa8kYf2aQaPWwa+/MWRRtZH424u6vKai0T+oYx2+X38u8CGmFt1F95hwzHJCSEVI9p5aNVYUSAXNh7UMT+fOTddahOYzReQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007179910218.48183791558608; Tue, 14 Jan 2020 05:06:19 -0800 (PST) Received: from localhost ([::1]:39036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLti-0007h3-Cm for importer@patchew.org; Tue, 14 Jan 2020 08:06:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41187) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLj3-00033t-Vs for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLj0-0001nb-59 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:17 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:35343 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLj0-0001n7-0A for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:14 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-cATNDCvfOGqZhOhtdNQrfw-1; Tue, 14 Jan 2020 07:55:12 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E05AA107ACC4; Tue, 14 Jan 2020 12:55:09 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 441175DA76; Tue, 14 Jan 2020 12:55:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a+D0Jhjaw7oJJMu/pHqSxLnV5MGTcL/XHY7MlyuPryQ=; b=emyApK6axfJWsHQKDHWQ7fcEZ6pc1XpFvvEuXPM5f3iGbZDLtqj5Fh4WbkyWsj5AZ8zPxA g+S1GNn9Z3CYhJAlrKVXn1oorPkfkbkArrKnFffak1psIiGBMpSroe+5Cn/EnVczw9xqmc ssGUzTTokniUKgNi/hLMg28oUs1v0bw= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 15/30] migration/ram: Yield periodically to the main loop Date: Tue, 14 Jan 2020 13:52:39 +0100 Message-Id: <20200114125254.4515-16-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: cATNDCvfOGqZhOhtdNQrfw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , Yury Kotov , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Yury Kotov Usually, incoming migration coroutine yields to the main loop while its IO-channel is waiting for data to receive. But there is a case when RAM migration and data receive have the same speed: VM with huge zeroed RAM. In this case, IO-channel won't read and thus the main loop is stuck and for instance, it doesn't respond to QMP commands. For this case, yield periodically, but not too often, so as not to affect the speed of migration. Signed-off-by: Yury Kotov Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index aa6cc7d47a..0c6992db9a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4246,7 +4246,7 @@ static void colo_flush_ram_cache(void) */ static int ram_load_precopy(QEMUFile *f) { - int flags =3D 0, ret =3D 0, invalid_flags =3D 0, len =3D 0; + int flags =3D 0, ret =3D 0, invalid_flags =3D 0, len =3D 0, i =3D 0; /* ADVISE is earlier, it shows the source has the postcopy capability = on */ bool postcopy_advised =3D postcopy_is_advised(); if (!migrate_use_compression()) { @@ -4258,6 +4258,17 @@ static int ram_load_precopy(QEMUFile *f) void *host =3D NULL; uint8_t ch; =20 + /* + * Yield periodically to let main loop run, but an iteration of + * the main loop is expensive, so do it each some iterations + */ + if ((i & 32767) =3D=3D 0 && qemu_in_coroutine()) { + aio_co_schedule(qemu_get_current_aio_context(), + qemu_coroutine_self()); + qemu_coroutine_yield(); + } + i++; + addr =3D qemu_get_be64(f); flags =3D addr & ~TARGET_PAGE_MASK; addr &=3D TARGET_PAGE_MASK; --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007911; cv=none; d=zohomail.com; s=zohoarc; b=EU8BH8VExyc/9ppq+GI+4EGcd/+cDazvI1QolNPFGvEwiHCc2A2lAaHnHIJGyZ2Oujf/4l4VfRJo0NPTYmUWgEaNCORMi5lJt1eG1GZJ59GXQ71cj/bdTvsuTuiU0xNCYV+LRUFaqN2kWuNIIGMD3texUWNlyye0iGZSyt1rJTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007911; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oNoOcpNKbORBNMo8pTjxpAVl930KpRyU4zX90PB6zXk=; b=H1pC9U2+G15Mm0D6Z68wzwahycRu/7+Nt/wofWa5nZiEo7f72R7YXBvzQUag5945xugHBvFj62LnKOayzRsFWcgEjQehsucBvlHyjs9xzgooUUU70AW8whwZU3Js9LRpVEvWal2KA6OXY4caxkj5fIfUDsigPqEHOtFf4tFnf/4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007911619345.5780563179452; Tue, 14 Jan 2020 05:18:31 -0800 (PST) Received: from localhost ([::1]:39292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irM5V-0006vB-WD for importer@patchew.org; Tue, 14 Jan 2020 08:18:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41256) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLjB-0003Bx-7X for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLj9-0001pq-D4 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:25 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:55630 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLj9-0001oz-4B for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:23 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-111-sX2xQhEuOnaU-QkTdre-cg-1; Tue, 14 Jan 2020 07:55:19 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40AB9DB61; Tue, 14 Jan 2020 12:55:17 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C3F95DA70; Tue, 14 Jan 2020 12:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006520; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oNoOcpNKbORBNMo8pTjxpAVl930KpRyU4zX90PB6zXk=; b=cLkwpEwjDUe+5nbjQRWJ4IIx1A43peQ4tB0+XFh8zBeYq86qndRe1x15Uxz3PW/1jqgJBI j7LiwK2uzdgBI+idWGuAz/wv0FwWDgGYc0HmriHQSQSURHqGOcCnSGGMZYOnqHOFNSSTEl zq+gxUimUHLC89BB0ZNvbUk/rPbBoM0= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 16/30] migration/postcopy: reduce memset when it is zero page and matches_target_page_size Date: Tue, 14 Jan 2020 13:52:40 +0100 Message-Id: <20200114125254.4515-17-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: sX2xQhEuOnaU-QkTdre-cg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Wei Yang In this case, page_buffer content would not be used. Skip this to save some time. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 0c6992db9a..885cd31191 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4126,7 +4126,13 @@ static int ram_load_postcopy(QEMUFile *f) switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { case RAM_SAVE_FLAG_ZERO: ch =3D qemu_get_byte(f); - memset(page_buffer, ch, TARGET_PAGE_SIZE); + /* + * Can skip to set page_buffer when + * this is a zero page and (block->page_size =3D=3D TARGET_PAG= E_SIZE). + */ + if (ch || !matches_target_page_size) { + memset(page_buffer, ch, TARGET_PAGE_SIZE); + } if (ch) { all_zero =3D false; } --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007407; cv=none; d=zohomail.com; s=zohoarc; b=HH+C6j4nmYtqMFqXG7NxP8MpjgboDsT8Xbkl1TNtX9kphgzx7lFRng8SfvqgldaiZyfSCFTwFhygnO+rfHHv7ftqKwzCXDQV1feebzJ/8u2O3pYBqL9LdFpgmyqvYnTcs5kvFl+dzp3P8itjg/A99pXcjzb9bPejtkPcVXNKzBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007407; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=txp30bk6lnx4ZDZWjaeq5Ei+4l4HBfTBbEkHUu8TwT0=; b=Uauwu3e7DPn2Xh3lDLQx28eNGgud/OLyBkO2qqRpQ1HIMlHyzPDDLl/7NwbXpLYQxWdMjVC5MuOpMxhLAFAfpU11XWXzUs1DINUOTaiLp5n73DYAgv/KDNs9PJiT+fum9qshQlkmxEfjzFvIF2m8zreDj1CqDFYsWhFTI4EnnGs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157900740753436.91069279509679; Tue, 14 Jan 2020 05:10:07 -0800 (PST) Received: from localhost ([::1]:39114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLxO-0004Wq-Dl for importer@patchew.org; Tue, 14 Jan 2020 08:10:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41318) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLjJ-0003Ee-9G for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLjF-0001tF-8x for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:33 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:30401 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLjE-0001s7-TE for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:29 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-258-bd16-JYfNQ2_c7z7VN0tSA-1; Tue, 14 Jan 2020 07:55:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 65E571800D78; Tue, 14 Jan 2020 12:55:24 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91B7A5D9E5; Tue, 14 Jan 2020 12:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=txp30bk6lnx4ZDZWjaeq5Ei+4l4HBfTBbEkHUu8TwT0=; b=QPNatHIoAZ7bRP0VWIqJ4J019V19rmiRmbNJj5v7N+DdEGuXJXdLMRb6Wv28DopE/oIJx3 OsU+kDTSVufeNLXHvkYR1nJGEepM9xoX59/Do24E8W/YfxPDsTM3I4rDlOae+7xg725bEv wsKsW8/BkmJ3kzi4YsRmU5gVaBnwMOQ= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 17/30] migration/postcopy: wait for decompress thread in precopy Date: Tue, 14 Jan 2020 13:52:41 +0100 Message-Id: <20200114125254.4515-18-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: bd16-JYfNQ2_c7z7VN0tSA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Wei Yang Compress is not supported with postcopy, it is safe to wait for decompress thread just in precopy. This is a preparation for later patch. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 885cd31191..1cd845b9a7 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4421,6 +4421,7 @@ static int ram_load_precopy(QEMUFile *f) } } =20 + ret |=3D wait_for_decompress_done(); return ret; } =20 @@ -4452,8 +4453,6 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) } else { ret =3D ram_load_precopy(f); } - - ret |=3D wait_for_decompress_done(); } trace_ram_load_complete(ret, seq_iter); =20 --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007385; cv=none; d=zohomail.com; s=zohoarc; b=gVIe0jJsinx5Ky9k5pTYrVtWJZdKBgEbB7N5AW7LVrzWIL3kNXhN3F4lv0/yvF8FcJflfs5aSKNS2hLUv+XHmLZQN7LlTUgjfuf6kbNhlWoLVkiygWaodCH4kUDtOqVwneR6SQ9YkcuuuL7E8tj4T5zWWeJ2mhp7L7jo86YQmuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007385; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LJSMz5QW+0OSt4n+d/miL7pbnhHIR5QQ1bSr8mrk7S8=; b=h2vMr8/dxLHzqZ1ZP4BkcMZmClZfSzg53lsS+smRgBA3PiUoJmHMG8z4eRnA0WaPmLt/TtbLA/2Y7tCXybSHfFa3OSPSn5eYaGjneJLLt/11RJkCQBeSOYUfP9k0Hyvpe5zTS08qGb95apQfMbC8KfeQITpHhI2K2u66CuQuVWI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007385332464.65972140354756; Tue, 14 Jan 2020 05:09:45 -0800 (PST) Received: from localhost ([::1]:39110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLx1-00045z-NP for importer@patchew.org; Tue, 14 Jan 2020 08:09:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41356) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLjR-0003M5-Rv for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLjO-00020R-8I for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:41 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:49963 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLjO-0001wo-4E for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-106-EBaYeIXxN92H62z_qsN30A-1; Tue, 14 Jan 2020 07:55:33 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 753BF107ACE6; Tue, 14 Jan 2020 12:55:31 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA1935D9E5; Tue, 14 Jan 2020 12:55:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LJSMz5QW+0OSt4n+d/miL7pbnhHIR5QQ1bSr8mrk7S8=; b=eppj9m6Yu9sXxGFhi3S2Tc5HH/91C0jPUwq1YpVdpSrw7zOr/zBqKqcLdpMwSWeARwrSkh eQtl0xDlurLmj4FzVW+OOZFhO86I911iodDgFDHi/DiCpG5/2zGLJtgYSXpW76T5DRer+b 4kbt38O/tokEoegqwbtj+9zn3aQw5D0= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 18/30] migration/postcopy: count target page number to decide the place_needed Date: Tue, 14 Jan 2020 13:52:42 +0100 Message-Id: <20200114125254.4515-19-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: EBaYeIXxN92H62z_qsN30A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Wei Yang In postcopy, it requires to place whole host page instead of target page. Currently, it relies on the page offset to decide whether this is the last target page. We also can count the target page number during the iteration. When the number of target page equals (host page size / target page size), this means it is the last target page in the host page. This is a preparation for non-ordered target page transmission. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 1cd845b9a7..391fe6e0e4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4052,6 +4052,7 @@ static int ram_load_postcopy(QEMUFile *f) void *postcopy_host_page =3D mis->postcopy_tmp_page; void *last_host =3D NULL; bool all_zero =3D false; + int target_pages =3D 0; =20 while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) { ram_addr_t addr; @@ -4086,6 +4087,7 @@ static int ram_load_postcopy(QEMUFile *f) ret =3D -EINVAL; break; } + target_pages++; matches_target_page_size =3D block->page_size =3D=3D TARGET_PA= GE_SIZE; /* * Postcopy requires that we place whole host pages atomically; @@ -4117,8 +4119,10 @@ static int ram_load_postcopy(QEMUFile *f) * If it's the last part of a host page then we place the host * page */ - place_needed =3D (((uintptr_t)host + TARGET_PAGE_SIZE) & - (block->page_size - 1)) =3D=3D 0; + if (target_pages =3D=3D (block->page_size / TARGET_PAGE_SIZE))= { + place_needed =3D true; + target_pages =3D 0; + } place_source =3D postcopy_host_page; } last_host =3D host; --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007380; cv=none; d=zohomail.com; s=zohoarc; b=IkajLiyoBMWt3xPK+egNuJPOsz1zBp500j7lj1UwBWkTCByMm/5dC4S6dqSysnCpH7mW+9Nn1k31/35WUlHU2NDb4ZZ8CC1Je+qYtXy6kd+/FoDxEHKEJd+qt8T+TbAaPNQOw3ZEC3qMmaAfuS6zVuxJsn3D/BdwPk+ZIFbgDMM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007380; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rjws/5txbKS/2cquBIMj15bFbdqcM/emabrksowPxSI=; b=VmRa1SUircv2JEVdqfZL8tChpPeWxIFpFL8t8Wc6nxdfJWLDX+D8KLLfNMjaSWX7/kzzv3Gbmjap6Bl9u052wCkz/lYE2JZlKz4OP2VyQ+85ackWu8fbo0eGxGknAmuc3WD2iZ93YDy31X71gVYP44qpowVLu34NmfJhBGfdIKY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007380119990.5493868584031; Tue, 14 Jan 2020 05:09:40 -0800 (PST) Received: from localhost ([::1]:39108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLww-0003vb-5z for importer@patchew.org; Tue, 14 Jan 2020 08:09:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41420) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLjb-0003V7-7f for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLjW-00023W-Lj for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:51 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41321 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLjW-000239-GD for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-388-wac73iPTPHOMXIwd8wUebw-1; Tue, 14 Jan 2020 07:55:44 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C1363189DF4B; Tue, 14 Jan 2020 12:55:42 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA2965D9E5; Tue, 14 Jan 2020 12:55:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rjws/5txbKS/2cquBIMj15bFbdqcM/emabrksowPxSI=; b=SRs8LC/bncJ+/xhb6YuSHM3fIuMm5ApUit18xzTbW9L/JY5rnKbqb/XiFuN0dEMjXKvea5 fR4fzCvnH3BzAghc7CNbeqLV39zNPwTGJ8nN40ATXWygATIyGdRKNsutMtneAu8ijxSaMX AfxJLeP2ikeq1fchnqOPJD8MofpyV0E= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 19/30] migration/postcopy: set all_zero to true on the first target page Date: Tue, 14 Jan 2020 13:52:43 +0100 Message-Id: <20200114125254.4515-20-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: wac73iPTPHOMXIwd8wUebw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Wei Yang For the first target page, all_zero is set to true for this round check. After target_pages introduced, we could leverage this variable instead of checking the address offset. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 391fe6e0e4..40c3fdd766 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4102,7 +4102,7 @@ static int ram_load_postcopy(QEMUFile *f) page_buffer =3D postcopy_host_page + ((uintptr_t)host & (block->page_size - 1)); /* If all TP are zero then we can optimise the place */ - if (!((uintptr_t)host & (block->page_size - 1))) { + if (target_pages =3D=3D 1) { all_zero =3D true; } else { /* not the 1st TP within the HP */ --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579008077; cv=none; d=zohomail.com; s=zohoarc; b=OOBIE5QQWGkKeU/Wl2yNhMXvEb6wSrxoZW62JVMoWTheFsy0//oIyieE0HX0F90+07dLTOKOH684xNp/N+UQgw2ztiVLxeIS0OEaecBcfSPn6IrxBMMls1Po2A/qIBo0rXUarDiszH0YYSnL03lulkv4mgPGz6dJq8gq01/xGjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579008077; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ya1F0mvUWk8XyhM6v0oEY3/vFxdIpuuT2eEdeU07i9U=; b=OicorP5/D6jrObAVuki8cTVRg8IcYcwkxA2ZGkWIp6kru4COBMFQXPPCz09lurZYjHN/ML8f/g7FNtpSasQvOUYjdFdhwzwHVfPdVIZIqhDiu+VYYclOcPVnZ6HzhLhU9H4kp65Ger6osrbwVb671sPHwqmRkJb2MjgVwVNKAz0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579008077918979.4174944522588; Tue, 14 Jan 2020 05:21:17 -0800 (PST) Received: from localhost ([::1]:39426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irM8C-0002mq-Mr for importer@patchew.org; Tue, 14 Jan 2020 08:21:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41484) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLjh-0003cV-3E for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLjd-00026A-BH for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:56 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:48520 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLjd-00025h-83 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:53 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-ooXaJcDQNCKrHAhYZ5NwTw-1; Tue, 14 Jan 2020 07:55:51 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 575311800D78; Tue, 14 Jan 2020 12:55:49 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2710B5D9E5; Tue, 14 Jan 2020 12:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ya1F0mvUWk8XyhM6v0oEY3/vFxdIpuuT2eEdeU07i9U=; b=YomcFaLPNqTDgpjBK2KMmZbhvekGQxXI4rc/jUm4muArv3fptZlBDbCUaDxzqCWQlsr8PZ N0xNLKrZy7SM/x5OuhuhpMpbLYzVQquP9P3LfnESo4R2qr39MfMOp44kBimMREavzX36uW bzzuhXJXwEfJrK5e0nszKY8LFvLpmDs= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 20/30] migration/postcopy: enable random order target page arrival Date: Tue, 14 Jan 2020 13:52:44 +0100 Message-Id: <20200114125254.4515-21-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: ooXaJcDQNCKrHAhYZ5NwTw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Wei Yang After using number of target page received to track one host page, we could have the capability to handle random order target page arrival in one host page. This is a preparation for enabling compress during postcopy. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 40c3fdd766..cbf8ab6a51 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4050,7 +4050,7 @@ static int ram_load_postcopy(QEMUFile *f) MigrationIncomingState *mis =3D migration_incoming_get_current(); /* Temporary page that is later 'placed' */ void *postcopy_host_page =3D mis->postcopy_tmp_page; - void *last_host =3D NULL; + void *this_host =3D NULL; bool all_zero =3D false; int target_pages =3D 0; =20 @@ -4097,24 +4097,26 @@ static int ram_load_postcopy(QEMUFile *f) * that's moved into place later. * The migration protocol uses, possibly smaller, target-pages * however the source ensures it always sends all the componen= ts - * of a host page in order. + * of a host page in one chunk. */ page_buffer =3D postcopy_host_page + ((uintptr_t)host & (block->page_size - 1)); /* If all TP are zero then we can optimise the place */ if (target_pages =3D=3D 1) { all_zero =3D true; + this_host =3D (void *)QEMU_ALIGN_DOWN((uintptr_t)host, + block->page_size); } else { /* not the 1st TP within the HP */ - if (host !=3D (last_host + TARGET_PAGE_SIZE)) { - error_report("Non-sequential target page %p/%p", - host, last_host); + if (QEMU_ALIGN_DOWN((uintptr_t)host, block->page_size) != =3D + (uintptr_t)this_host) { + error_report("Non-same host page %p/%p", + host, this_host); ret =3D -EINVAL; break; } } =20 - /* * If it's the last part of a host page then we place the host * page @@ -4125,7 +4127,6 @@ static int ram_load_postcopy(QEMUFile *f) } place_source =3D postcopy_host_page; } - last_host =3D host; =20 switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { case RAM_SAVE_FLAG_ZERO: @@ -4178,7 +4179,8 @@ static int ram_load_postcopy(QEMUFile *f) =20 if (!ret && place_needed) { /* This gets called at the last target page in the host page */ - void *place_dest =3D host + TARGET_PAGE_SIZE - block->page_siz= e; + void *place_dest =3D (void *)QEMU_ALIGN_DOWN((uintptr_t)host, + block->page_size); =20 if (all_zero) { ret =3D postcopy_place_page_zero(mis, place_dest, --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007635; cv=none; d=zohomail.com; s=zohoarc; b=PFaEZYWDaZzjHPJ/ZBK00WLWf6KeID3C42s1Kl6OtjK7uEfPyamC1nZRENMTtc06DcGRxNcv+J8fbts5n+Ue6T7Ul93fBvznh6Bkz/8bUgYJXouB7tp57JcuRO46ZcFe94c+kd4WQZUATdwsru52ZD/APMObjCBNL6cR5jocFy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007635; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oe58z+C2bpPm4Fcg7P0TTleKqyKaDn7LOjM/RsnZovA=; b=UA/5Z8ZxE/M6Phpd5NidAm5FbqPH0HS+KcxfFVpN+mNmg2oH2Mjick5fsaQkl96NUKo88Bq7zLudyWcYQhBYfSxpEMmw0HdUR84k3+UiO2xzrcvNGXOR/zkbUM6NLky+0Qyylu9MKMlmwqBThN6N5dIK3e7aMGw2lCFtw6VHCwc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007635905151.51659709767682; Tue, 14 Jan 2020 05:13:55 -0800 (PST) Received: from localhost ([::1]:39174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irM14-0001AR-Hj for importer@patchew.org; Tue, 14 Jan 2020 08:13:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41536) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLjs-0003g4-0z for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLji-00027k-0w for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:02 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51957 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLjh-00027T-Tc for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:55:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-151-nsBCqY-9PX6bvTFUcUd0Fw-1; Tue, 14 Jan 2020 07:55:56 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 336001005512; Tue, 14 Jan 2020 12:55:54 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABE5E5D9E5; Tue, 14 Jan 2020 12:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oe58z+C2bpPm4Fcg7P0TTleKqyKaDn7LOjM/RsnZovA=; b=D4q9RsT3X0FSvsQ+byQn8kEmYl3GYTRCpkaJHabcuJVBXF2RrajyD452r+jDuIvdvOBKhN ccFsdk+GeqGwaguR4HIPwdBZDp3sHR/t6arRgufkQYYfl9TseNMaY8suB9vS473hXgIGjW h+MnHMP3znVYWrFcraccAov7Jm7qH/o= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 21/30] migration/postcopy: enable compress during postcopy Date: Tue, 14 Jan 2020 13:52:45 +0100 Message-Id: <20200114125254.4515-22-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: nsBCqY-9PX6bvTFUcUd0Fw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Wei Yang postcopy requires to place a whole host page, while migration thread migrate memory in target page size. This makes postcopy need to collect all target pages in one host page before placing via userfaultfd. To enable compress during postcopy, there are two problems to solve: 1. Random order for target page arrival 2. Target pages in one host page arrives without interrupt by target page from other host page The first one is handled by previous cleanup patch. This patch handles the second one by: 1. Flush compress thread for each host page 2. Wait for decompress thread for before placing host page Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/migration.c | 11 ----------- migration/ram.c | 28 +++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index e55edee606..990bff00c0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1005,17 +1005,6 @@ static bool migrate_caps_check(bool *cap_list, #endif =20 if (cap_list[MIGRATION_CAPABILITY_POSTCOPY_RAM]) { - if (cap_list[MIGRATION_CAPABILITY_COMPRESS]) { - /* The decompression threads asynchronously write into RAM - * rather than use the atomic copies needed to avoid - * userfaulting. It should be possible to fix the decompressi= on - * threads for compatibility in future. - */ - error_setg(errp, "Postcopy is not currently compatible " - "with compression"); - return false; - } - /* This check is reasonably expensive, so only when it's being * set the first time, also it's only the destination that needs * special support. diff --git a/migration/ram.c b/migration/ram.c index cbf8ab6a51..fd1155f735 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3469,6 +3469,14 @@ static int ram_save_iterate(QEMUFile *f, void *opaqu= e) =20 rs->target_page_count +=3D pages; =20 + /* + * During postcopy, it is necessary to make sure one whole host + * page is sent in one chunk. + */ + if (migrate_postcopy_ram()) { + flush_compressed_data(rs); + } + /* * we want to check in the 1st loop, just in case it was the 1= st * time and we had to sync the dirty bitmap. @@ -4061,6 +4069,7 @@ static int ram_load_postcopy(QEMUFile *f) void *place_source =3D NULL; RAMBlock *block =3D NULL; uint8_t ch; + int len; =20 addr =3D qemu_get_be64(f); =20 @@ -4078,7 +4087,8 @@ static int ram_load_postcopy(QEMUFile *f) =20 trace_ram_load_postcopy_loop((uint64_t)addr, flags); place_needed =3D false; - if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE)) { + if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE | + RAM_SAVE_FLAG_COMPRESS_PAGE)) { block =3D ram_block_from_stream(f, flags); =20 host =3D host_from_ram_block_offset(block, addr); @@ -4161,6 +4171,17 @@ static int ram_load_postcopy(QEMUFile *f) TARGET_PAGE_SIZE); } break; + case RAM_SAVE_FLAG_COMPRESS_PAGE: + all_zero =3D false; + len =3D qemu_get_be32(f); + if (len < 0 || len > compressBound(TARGET_PAGE_SIZE)) { + error_report("Invalid compressed data length: %d", len); + ret =3D -EINVAL; + break; + } + decompress_data_with_multi_threads(f, page_buffer, len); + break; + case RAM_SAVE_FLAG_EOS: /* normal exit */ multifd_recv_sync_main(); @@ -4172,6 +4193,11 @@ static int ram_load_postcopy(QEMUFile *f) break; } =20 + /* Got the whole host page, wait for decompress before placing. */ + if (place_needed) { + ret |=3D wait_for_decompress_done(); + } + /* Detect for any possible file errors */ if (!ret && qemu_file_get_error(f)) { ret =3D qemu_file_get_error(f); --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579008196; cv=none; d=zohomail.com; s=zohoarc; b=PMv4l/RVzTW1I2n2laDJNnNyObPY+d7Uqz0C/3YJ0I8v4AN29qS54Vrt7KBFjqMPh7cl2FfqCitHqUatiuGBncXVkNFuxv5T7rk0VVdH5Xsa26uo/tIAdPMGSdTYKqdCeWAt4jO208vlM4hOGo1HuDRzS89eKDJnqiaKcqbVzmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579008196; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WKNiJnjAFJa2vhNGxGRB9XZG1JZ0UkZB55Yk7BZwoSE=; b=ZBM33Os0f5BBD2hUD2arVp3xMMMRyvOgsBRlu5sxYFLXNKkgum0FroZVk84xlnhLeM70yAm6Ku0Rpa76TPD/vPtqOUeKfb2v5ROPxmp7JQwrWru0y7Y3B4WL6IVO6yvZ+HAnLkD1t1PNw4uDHpKNWIpf5T+8ZPe/yta9XZbCtlg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579008196662435.8274797811655; Tue, 14 Jan 2020 05:23:16 -0800 (PST) Received: from localhost ([::1]:39460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irMA7-0005KM-95 for importer@patchew.org; Tue, 14 Jan 2020 08:23:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41630) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLk2-0003sn-6j for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLjy-0002Cq-FW for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:18 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23167 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLjv-0002CU-F9 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:11 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-72-Ktts2onxOGG8-Gr9j2VFlw-1; Tue, 14 Jan 2020 07:56:09 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E01C107ACCC; Tue, 14 Jan 2020 12:56:07 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 853E55D9E5; Tue, 14 Jan 2020 12:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WKNiJnjAFJa2vhNGxGRB9XZG1JZ0UkZB55Yk7BZwoSE=; b=TDUylQMHJLcEHDBtBH11iMbmbHUTOFW2d1jlt2uGxIGlhKuvp1BDoh4EBj8Kxb91Cd/y9q /xNm174O/CjzvIafh3a87imgFEwzWyIBmv0DJUC9PdLCW4Tg7e9+PK5hPYJRspOoKV2u9+ 5ncJaPvGpppGY1XGyCS52MRUdsYXWlo= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 22/30] migration/multifd: clean pages after filling packet Date: Tue, 14 Jan 2020 13:52:46 +0100 Message-Id: <20200114125254.4515-23-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: Ktts2onxOGG8-Gr9j2VFlw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Wei Yang This is a preparation for the next patch: not use multifd during postcopy. Without enabling postcopy, everything looks good. While after enabling postcopy, migration may fail even not use multifd during postcopy. The reason is the pages is not properly cleared and *old* target page will continue to be transferred. After clean pages, migration succeeds. Signed-off-by: Wei Yang Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index fd1155f735..561961ef24 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -955,10 +955,10 @@ static int multifd_send_pages(RAMState *rs) } qemu_mutex_unlock(&p->mutex); } - p->pages->used =3D 0; + assert(!p->pages->used); + assert(!p->pages->block); =20 p->packet_num =3D multifd_send_state->packet_num++; - p->pages->block =3D NULL; multifd_send_state->pages =3D p->pages; p->pages =3D pages; transferred =3D ((uint64_t) pages->used) * TARGET_PAGE_SIZE + p->packe= t_len; @@ -1154,6 +1154,8 @@ static void *multifd_send_thread(void *opaque) p->flags =3D 0; p->num_packets++; p->num_pages +=3D used; + p->pages->used =3D 0; + p->pages->block =3D NULL; qemu_mutex_unlock(&p->mutex); =20 trace_multifd_send(p->id, packet_num, used, flags, --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579008311; cv=none; d=zohomail.com; s=zohoarc; b=YvhoYLuK0wsI8xr1dFDTbG6eCFVSSuSMPyx1DWkfpISI3Uvjmkj0ccRk0HTcK1jJhea5LLMcrHqaTJ4rXBEnqdh8dPk/7IBVZjvrOxiAb0irbFtKfRxvIBQqzK7QkUKGDd+2R/NPIAY8a/eDVOjOWIXqYTsuclr6USQovCO+tyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579008311; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XK5ACN6K3OKAgei9Uux+P4frL0jlH3g3VMOxRzWVmRg=; b=DiMzY2oT3wQUbudqa3OCMxRjQ22pEq2MO3MJs8ybaTDedzVMJuJlL7HfdrMc6I2PUtNbDrnttp78Uw40bBEK6TyVlaMd1ui+m/saDgamrzJ+Om3EwY4Gh0bFPDxu51VNlW/TvkL3hMVwQ2aLzgNU/a/gHUL4Xj0S2867kzex2FI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579008311254507.9072966791292; Tue, 14 Jan 2020 05:25:11 -0800 (PST) Received: from localhost ([::1]:39504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irMBy-0008O3-5U for importer@patchew.org; Tue, 14 Jan 2020 08:25:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41649) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLk3-0003vP-P8 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLk0-0002De-5v for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:19 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:24491 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLk0-0002DL-24 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:16 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-117-V-4i7RvKOn6pcCaUYKAg_w-1; Tue, 14 Jan 2020 07:56:14 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68817189DF40; Tue, 14 Jan 2020 12:56:12 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2D985D9E5; Tue, 14 Jan 2020 12:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XK5ACN6K3OKAgei9Uux+P4frL0jlH3g3VMOxRzWVmRg=; b=UNsZVfsqMlOU3674GNO+Us9mg2K5056PQiYFz636HxLs9rXABsvaw9Ue5ccoiyMjzH8ZdR Ogp5DLVYd7CILZ9bJadqdOuu7CCfWW03/Soh62dAIgaC733m21Mfbev2KZDYwqXZBR7jvd Jmgh+p1oNhzpImGZmUE72UGYkINpHaY= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 23/30] migration/multifd: not use multifd during postcopy Date: Tue, 14 Jan 2020 13:52:47 +0100 Message-Id: <20200114125254.4515-24-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: V-4i7RvKOn6pcCaUYKAg_w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Wei Yang We don't support multifd during postcopy, but user still could enable both multifd and postcopy. This leads to migration failure. Skip multifd during postcopy. Signed-off-by: Wei Yang Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 561961ef24..aee057f7da 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2587,10 +2587,13 @@ static int ram_save_target_page(RAMState *rs, PageS= earchStatus *pss, } =20 /* - * do not use multifd for compression as the first page in the new - * block should be posted out before sending the compressed page + * Do not use multifd for: + * 1. Compression as the first page in the new block should be posted = out + * before sending the compressed page + * 2. In postcopy as one whole host page should be placed */ - if (!save_page_use_compression(rs) && migrate_use_multifd()) { + if (!save_page_use_compression(rs) && migrate_use_multifd() + && !migration_in_postcopy()) { return ram_save_multifd_page(rs, block, offset); } =20 --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007760; cv=none; d=zohomail.com; s=zohoarc; b=CfKEHPb166XCypN5FNQBFsN8t8OAIPn282BP5AoTSXVNY86Jb+n5lD2hWoOPhAf2uSOLLh16PcpLyJY2yx7CEhrySYNlFZdtfs5zaBt2q7g+UlNa0OLpcoYPpxHMhAviYZ5Uy4YGrEJfrlEtU4tcTRcJh9WpfabOXkfbiMrI4QU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007760; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UCvNgXqg3YNciEEz4bwYVicJE+TkN+xTZTIh75LexRo=; b=QQf0BR4L7xtp+L/ZFkc0ahGBmqDYL39BaIINgNd7Kl9CcktYblfTKdgoakAFcHokRpUuNMmfZhLy6Md1kX1N59X0EgefAel5QB9QgzwcOpJeTCDlgRmOBnIPkiz6ZviNKVKwFykniFtRsReN5AebwK013rrXZl8P7A0AAb2q+kI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15790077607754.206588196890948; Tue, 14 Jan 2020 05:16:00 -0800 (PST) Received: from localhost ([::1]:39208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irM34-0003m2-OA for importer@patchew.org; Tue, 14 Jan 2020 08:15:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41696) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLkB-00041a-Vb for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLk5-0002FS-J9 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:27 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:24398 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLk5-0002FD-E1 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:21 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-234-LgSCKFThNZqpzVtJSuMUPA-1; Tue, 14 Jan 2020 07:56:19 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68A85801E72; Tue, 14 Jan 2020 12:56:17 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFA415D9E5; Tue, 14 Jan 2020 12:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UCvNgXqg3YNciEEz4bwYVicJE+TkN+xTZTIh75LexRo=; b=NhDBw/9FkzHVHOZllh9jPOAHOVXP2XLTBEglvmYYar+JJwBbnIYVNOUuGMcHcQdUiWlD7a 1iV1CZo8iyGKBw4wGoTor/A8nWWKfLDJFM7dYOn6Vr/xt/HuxFFOC24MF89UnRnDhXmZc0 QD4ZSqWO/5ZAiAW46crrZL1gY6cWUKY= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 24/30] migration/multifd: fix nullptr access in terminating multifd threads Date: Tue, 14 Jan 2020 13:52:48 +0100 Message-Id: <20200114125254.4515-25-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: LgSCKFThNZqpzVtJSuMUPA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Corey Minyard , Jason Wang , Jiahui Cen , Juan Quintela , "Michael S. Tsirkin" , Ying Fang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Gibson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jiahui Cen One multifd channel will shutdown all the other multifd's IOChannel when it fails to receive an IOChannel. In this senario, if some multifds had not received its IOChannel yet, it would try to shutdown its IOChannel which co= uld cause nullptr access at qio_channel_shutdown. Here is the coredump stack: #0 object_get_class (obj=3Dobj@entry=3D0x0) at qom/object.c:908 #1 0x00005563fdbb8f4a in qio_channel_shutdown (ioc=3D0x0, how=3DQIO_CH= ANNEL_SHUTDOWN_BOTH, errp=3D0x0) at io/channel.c:355 #2 0x00005563fd7b4c5f in multifd_recv_terminate_threads (err=3D) at migration/ram.c:1280 #3 0x00005563fd7bc019 in multifd_recv_new_channel (ioc=3Dioc@entry=3D0= x556400255610, errp=3Derrp@entry=3D0x7ffec07dce00) at migration/ram.c:1478 #4 0x00005563fda82177 in migration_ioc_process_incoming (ioc=3Dioc@ent= ry=3D0x556400255610, errp=3Derrp@entry=3D0x7ffec07dce30) at migration/migra= tion.c:605 #5 0x00005563fda8567d in migration_channel_process_incoming (ioc=3D0x5= 56400255610) at migration/channel.c:44 #6 0x00005563fda83ee0 in socket_accept_incoming_migration (listener=3D= 0x5563fff6b920, cioc=3D0x556400255610, opaque=3D) at migrati= on/socket.c:166 #7 0x00005563fdbc25cd in qio_net_listener_channel_func (ioc=3D, condition=3D, opaque=3D) at io/net-l= istener.c:54 #8 0x00007f895b6fe9a9 in g_main_context_dispatch () from /usr/lib64/li= bglib-2.0.so.0 #9 0x00005563fdc18136 in glib_pollfds_poll () at util/main-loop.c:218 #10 0x00005563fdc181b5 in os_host_main_loop_wait (timeout=3D1000000000)= at util/main-loop.c:241 #11 0x00005563fdc183a2 in main_loop_wait (nonblocking=3Dnonblocking@ent= ry=3D0) at util/main-loop.c:517 #12 0x00005563fd8edb37 in main_loop () at vl.c:1791 #13 0x00005563fd74fd45 in main (argc=3D, argv=3D, envp=3D) at vl.c:4473 To fix it up, let's check p->c before calling qio_channel_shutdown. Signed-off-by: Jiahui Cen Signed-off-by: Ying Fang Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index aee057f7da..e7cd522173 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1308,7 +1308,9 @@ static void multifd_recv_terminate_threads(Error *err) - normal quit, i.e. everything went fine, just finished - error quit: We close the channels so the channel threads finish the qio_channel_read_all_eof() */ - qio_channel_shutdown(p->c, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); + if (p->c) { + qio_channel_shutdown(p->c, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); + } qemu_mutex_unlock(&p->mutex); } } --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007876; cv=none; d=zohomail.com; s=zohoarc; b=lBSGDFu9WW8A+yEztOeSckdsK+kR2cIZdELDpLiiaFU6FOT0U6LWUt3pnNCviamydThY07ksRLeKyFrONzsUCLdYHFsU5pEIV7/15e20FaoaPbBBDu37GMVg/7i/mcCZPkC0vGVBcpeligHIqwsnbqVG1WTfFUlW+4/nPk+3YEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007876; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=azmff3g63Gao3cs+yHo3xGmhj/W5RQxUAEcQQoDb+6Q=; b=cxwBSmaKMY2ssNrEhgvhzo1ukblwX3NxsnLkkGLU5LU0+7M6DIAoclEyEA6js5UWDUvpGQMOpkVsiBryg2t8uokBN3chl+tYArFVznqGY4djDr9N6EHmCHLzv716JLTEJKFuCTOTsOauHDgjfuhNuatvIdHGu1vlFvUcV9zRpDU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007876162312.48140581173436; Tue, 14 Jan 2020 05:17:56 -0800 (PST) Received: from localhost ([::1]:39286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irM4w-00062j-FV for importer@patchew.org; Tue, 14 Jan 2020 08:17:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41726) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLkK-0004Fh-5s for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLkG-0002HX-FI for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:36 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:51242 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLkG-0002HL-An for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:32 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-352-utxBCeqyM4mRT4l9YtoHlg-1; Tue, 14 Jan 2020 07:56:29 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1EF931005502; Tue, 14 Jan 2020 12:56:27 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEBF15D9E5; Tue, 14 Jan 2020 12:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=azmff3g63Gao3cs+yHo3xGmhj/W5RQxUAEcQQoDb+6Q=; b=C+djihjVl2euExtmyDYP4ZOA0S/IxxqvnHvEG13/UonNmyVu+sxHf6phStx1qOE2lui+JZ 9d9vjTVzwOBRRL1uhGQ0lyKWYmUmwZCWTlLt4CTYJOTtiHItEbFb/g9EBnCn8B7TJS4AnR Ophl5eKuUE10wPVB/dRz5HQdauCTMqQ= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 25/30] migration/multifd: fix destroyed mutex access in terminating multifd threads Date: Tue, 14 Jan 2020 13:52:49 +0100 Message-Id: <20200114125254.4515-26-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: utxBCeqyM4mRT4l9YtoHlg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Corey Minyard , Jason Wang , Jiahui Cen , Juan Quintela , "Michael S. Tsirkin" , Ying Fang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Gibson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jiahui Cen One multifd will lock all the other multifds' IOChannel mutex to inform them to quit by setting p->quit or shutting down p->c. In this senario, if some multifds had already been terminated and multifd_load_cleanup/multifd_save_= cleanup had destroyed their mutex, it could cause destroyed mutex access when trying lock their mutex. Here is the coredump stack: #0 0x00007f81a2794437 in raise () from /usr/lib64/libc.so.6 #1 0x00007f81a2795b28 in abort () from /usr/lib64/libc.so.6 #2 0x00007f81a278d1b6 in __assert_fail_base () from /usr/lib64/libc.so= .6 #3 0x00007f81a278d262 in __assert_fail () from /usr/lib64/libc.so.6 #4 0x000055eb1bfadbd3 in qemu_mutex_lock_impl (mutex=3D0x55eb1e2d1988,= file=3D, line=3D) at util/qemu-thread-posix.= c:64 #5 0x000055eb1bb4564a in multifd_send_terminate_threads (err=3D) at migration/ram.c:1015 #6 0x000055eb1bb4bb7f in multifd_send_thread (opaque=3D0x55eb1e2d19f8)= at migration/ram.c:1171 #7 0x000055eb1bfad628 in qemu_thread_start (args=3D0x55eb1e170450) at = util/qemu-thread-posix.c:502 #8 0x00007f81a2b36df5 in start_thread () from /usr/lib64/libpthread.so= .0 #9 0x00007f81a286048d in clone () from /usr/lib64/libc.so.6 To fix it up, let's destroy the mutex after all the other multifd threads h= ad been terminated. Signed-off-by: Jiahui Cen Signed-off-by: Ying Fang Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index e7cd522173..0e1d95cd73 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1053,6 +1053,10 @@ void multifd_save_cleanup(void) if (p->running) { qemu_thread_join(&p->thread); } + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { + MultiFDSendParams *p =3D &multifd_send_state->params[i]; + socket_send_channel_destroy(p->c); p->c =3D NULL; qemu_mutex_destroy(&p->mutex); @@ -1336,6 +1340,10 @@ int multifd_load_cleanup(Error **errp) qemu_sem_post(&p->sem_sync); qemu_thread_join(&p->thread); } + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { + MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + object_unref(OBJECT(p->c)); p->c =3D NULL; qemu_mutex_destroy(&p->mutex); --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579008044; cv=none; d=zohomail.com; s=zohoarc; b=AYUJT3r+pAIhdGJkyjUPdbzxMYw9saSqvnQ/GP8oUQDYdun07qqWHigCl5HKzucuFhdG3Q/8fAGPxgPKJcqCGbIpeLHh+TUS5uBRYqvDec34FicCU8YZWdOGYiFBpj/7X7Wwibny2zc1IZQPPXuFNsjBt1lTG3K55bFyZTubx2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579008043; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pWrM4tTgAcr3IjSP+Dc3j+8p78JiYlrCeLYCKUIobhM=; b=UCfsi7WyG8jxH1/kkiy798wXOhkUQ5ZW1qOVHgiv7rkWsJQXbBreELpFhfLQchThShS4YdfitYaTR9DfefDTrWt+mvzXUuCUcILbWaENcAh78G4H5iXtK/RahFF80tSOXgM9V1hagMItU5wSh77cqLUs+2v5OEVqfQL9GBUGi4c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579008043996372.76532662369857; Tue, 14 Jan 2020 05:20:43 -0800 (PST) Received: from localhost ([::1]:39316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irM7e-0001bz-RF for importer@patchew.org; Tue, 14 Jan 2020 08:20:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41781) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLkT-0004Os-Jg for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLkP-0002Jn-Iz for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:45 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:57873 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLkP-0002JP-Eo for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:41 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-CR6ExrTCPHGusxRqTBDgxA-1; Tue, 14 Jan 2020 07:56:36 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D27D800D41; Tue, 14 Jan 2020 12:56:34 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FD7C5D9E5; Tue, 14 Jan 2020 12:56:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pWrM4tTgAcr3IjSP+Dc3j+8p78JiYlrCeLYCKUIobhM=; b=KceVoNVEul9Brse1pcHtE2SimWRToWyFYd6qPXc5ctShyFonpdq0QO6LPpBCTDv8+aWMCz kYp5S9mKeb/nUrqhhyCrhcXvaMwJjcoTca2IY59UGIeKA+XyGtZ1fSmhw1TtqK/FmMBus1 CDpjDmQW2YbjRMJG0tVUV5igOVDrTjA= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 26/30] Bug #1829242 correction. Date: Tue, 14 Jan 2020 13:52:50 +0100 Message-Id: <20200114125254.4515-27-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: CR6ExrTCPHGusxRqTBDgxA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , Alexey Romko , "Dr. David Alan Gilbert" , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alexey Romko Added type conversions to ram_addr_t before all left shifts of page indexes to TARGET_PAGE_BITS, to correct overflows when the page address was 4Gb and more. Signed-off-by: Alexey Romko Reviewed-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela --- migration/ram.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 0e1d95cd73..ba6e0eea15 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1768,7 +1768,7 @@ static inline bool migration_bitmap_clear_dirty(RAMSt= ate *rs, if (rb->clear_bmap && clear_bmap_test_and_clear(rb, page)) { uint8_t shift =3D rb->clear_bmap_shift; hwaddr size =3D 1ULL << (TARGET_PAGE_BITS + shift); - hwaddr start =3D (page << TARGET_PAGE_BITS) & (-size); + hwaddr start =3D (((ram_addr_t)page) << TARGET_PAGE_BITS) & (-size= ); =20 /* * CLEAR_BITMAP_SHIFT_MIN should always guarantee this... this @@ -2005,7 +2005,7 @@ static void ram_release_pages(const char *rbname, uin= t64_t offset, int pages) return; } =20 - ram_discard_range(rbname, offset, pages << TARGET_PAGE_BITS); + ram_discard_range(rbname, offset, ((ram_addr_t)pages) << TARGET_PAGE_B= ITS); } =20 /* @@ -2093,7 +2093,7 @@ static int ram_save_page(RAMState *rs, PageSearchStat= us *pss, bool last_stage) uint8_t *p; bool send_async =3D true; RAMBlock *block =3D pss->block; - ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; + ram_addr_t offset =3D ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; ram_addr_t current_addr =3D block->offset + offset; =20 p =3D block->host + offset; @@ -2280,7 +2280,8 @@ static bool find_dirty_block(RAMState *rs, PageSearch= Status *pss, bool *again) *again =3D false; return false; } - if ((pss->page << TARGET_PAGE_BITS) >=3D pss->block->used_length) { + if ((((ram_addr_t)pss->page) << TARGET_PAGE_BITS) + >=3D pss->block->used_length) { /* Didn't find anything in this RAM Block */ pss->page =3D 0; pss->block =3D QLIST_NEXT_RCU(pss->block, next); @@ -2571,7 +2572,7 @@ static int ram_save_target_page(RAMState *rs, PageSea= rchStatus *pss, bool last_stage) { RAMBlock *block =3D pss->block; - ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; + ram_addr_t offset =3D ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; int res; =20 if (control_save_page(rs, block, offset, &res)) { @@ -2657,7 +2658,8 @@ static int ram_save_host_page(RAMState *rs, PageSearc= hStatus *pss, /* Allow rate limiting to happen in the middle of huge pages */ migration_rate_limit(); } while ((pss->page & (pagesize_bits - 1)) && - offset_in_ramblock(pss->block, pss->page << TARGET_PAGE_BITS)= ); + offset_in_ramblock(pss->block, + ((ram_addr_t)pss->page) << TARGET_PAGE_BIT= S)); =20 /* The offset we leave with is the last one we looked at */ pss->page--; @@ -2874,8 +2876,10 @@ void ram_postcopy_migrated_memory_release(MigrationS= tate *ms) =20 while (run_start < range) { unsigned long run_end =3D find_next_bit(bitmap, range, run_sta= rt + 1); - ram_discard_range(block->idstr, run_start << TARGET_PAGE_BITS, - (run_end - run_start) << TARGET_PAGE_BITS); + ram_discard_range(block->idstr, + ((ram_addr_t)run_start) << TARGET_PAGE_BITS, + ((ram_addr_t)(run_end - run_start)) + << TARGET_PAGE_BITS); run_start =3D find_next_zero_bit(bitmap, range, run_end + 1); } } @@ -4273,13 +4277,16 @@ static void colo_flush_ram_cache(void) while (block) { offset =3D migration_bitmap_find_dirty(ram_state, block, offse= t); =20 - if (offset << TARGET_PAGE_BITS >=3D block->used_length) { + if (((ram_addr_t)offset) << TARGET_PAGE_BITS + >=3D block->used_length) { offset =3D 0; block =3D QLIST_NEXT_RCU(block, next); } else { migration_bitmap_clear_dirty(ram_state, block, offset); - dst_host =3D block->host + (offset << TARGET_PAGE_BITS); - src_host =3D block->colo_cache + (offset << TARGET_PAGE_BI= TS); + dst_host =3D block->host + + (((ram_addr_t)offset) << TARGET_PAGE_BITS); + src_host =3D block->colo_cache + + (((ram_addr_t)offset) << TARGET_PAGE_BITS); memcpy(dst_host, src_host, TARGET_PAGE_SIZE); } } --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579008158; cv=none; d=zohomail.com; s=zohoarc; b=AhrrJwsk5LKYkQDybfHjY46vzcAoLKfk4CFIa2P6+nzgUBcgC2SI79LoGBpbDbwiWppPZQCUgVufGlpFnuCwoamovC1YsMaXPA5fyCFcKQP4c8UosAwhFkWgThzV8lc7ddZO+Z/dJ8zcovC3l4w6bKe2C26W/5ez4dnPPbwJmY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579008158; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A9ILjMmGuIyM1P2hRnpWbTP5WXqnScSgd+A/btvZYmk=; b=I64LjWzBQR1/A0h18ZpgsspngGj/ib2kq6vsoPyMcWwp6s0DCdbgNs70q67acftm+CQ3we51IF/mXVcWnzCDMQ1GJNj/9NoekcoIi5Dn7qtNOerN2rvvZpfohgTYQPL0HwlNlNZnHzTBkoDKZ765XEmxcsmL/Bmj951h955HMIE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579008158560168.48249551708534; Tue, 14 Jan 2020 05:22:38 -0800 (PST) Received: from localhost ([::1]:39454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irM9V-0004Kt-5M for importer@patchew.org; Tue, 14 Jan 2020 08:22:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41844) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLkb-0004ZL-Rm for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLka-0002Nz-2B for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:53 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:26956 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLkZ-0002NR-Uo for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:51 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-ct9GR9yINdSwSFjUmuvLYg-1; Tue, 14 Jan 2020 07:56:50 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 665D58024CE; Tue, 14 Jan 2020 12:56:48 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73F525D9E5; Tue, 14 Jan 2020 12:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A9ILjMmGuIyM1P2hRnpWbTP5WXqnScSgd+A/btvZYmk=; b=Nu+TJRyVdCgoPONg/yBy9e2pI0R5CKAHLDHR881fpedDURf231Z/GkKWV2Qp4dBkc3mEAg x2dc4TpshpZ37LtBu67QeGieMKPoTjXaQvOpfTRDzsz+ZlG54apV3rguh3ydCAxRNtMNOr tPM4aH6AYIKdhybe24CX8J0Vmc0Cjkk= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 27/30] migration: Define VMSTATE_INSTANCE_ID_ANY Date: Tue, 14 Jan 2020 13:52:51 +0100 Message-Id: <20200114125254.4515-28-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: ct9GR9yINdSwSFjUmuvLYg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Peter Xu , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Xu Define the new macro VMSTATE_INSTANCE_ID_ANY for callers who wants to auto-generate the vmstate instance ID. Previously it was hard coded as -1 instead of this macro. It helps to change this default value in the follow up patches. No functional change. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- backends/dbus-vmstate.c | 3 ++- hw/arm/stellaris.c | 2 +- hw/core/qdev.c | 3 ++- hw/display/ads7846.c | 2 +- hw/i2c/core.c | 2 +- hw/input/stellaris_input.c | 3 ++- hw/intc/apic_common.c | 2 +- hw/misc/max111x.c | 3 ++- hw/net/eepro100.c | 3 ++- hw/pci/pci.c | 2 +- hw/ppc/spapr.c | 2 +- hw/timer/arm_timer.c | 2 +- hw/tpm/tpm_emulator.c | 3 ++- include/migration/vmstate.h | 2 ++ migration/savevm.c | 8 ++++---- 15 files changed, 25 insertions(+), 17 deletions(-) diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c index 56b482a7d6..cc594a722e 100644 --- a/backends/dbus-vmstate.c +++ b/backends/dbus-vmstate.c @@ -412,7 +412,8 @@ dbus_vmstate_complete(UserCreatable *uc, Error **errp) return; } =20 - if (vmstate_register(VMSTATE_IF(self), -1, &dbus_vmstate, self) < 0) { + if (vmstate_register(VMSTATE_IF(self), VMSTATE_INSTANCE_ID_ANY, + &dbus_vmstate, self) < 0) { error_setg(errp, "Failed to register vmstate"); } } diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index b198066b54..bb025e0bd0 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellaris.c @@ -708,7 +708,7 @@ static int stellaris_sys_init(uint32_t base, qemu_irq i= rq, memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x0000100= 0); memory_region_add_subregion(get_system_memory(), base, &s->iomem); ssys_reset(s); - vmstate_register(NULL, -1, &vmstate_stellaris_sys, s); + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_stellaris_sys= , s); return 0; } =20 diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 9f1753f5cf..58e87d336d 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -879,7 +879,8 @@ static void device_set_realized(Object *obj, bool value= , Error **errp) =20 if (qdev_get_vmsd(dev)) { if (vmstate_register_with_alias_id(VMSTATE_IF(dev), - -1, qdev_get_vmsd(dev), dev, + VMSTATE_INSTANCE_ID_ANY, + qdev_get_vmsd(dev), dev, dev->instance_id_alias, dev->alias_required_for_ver= sion, &local_err) < 0) { diff --git a/hw/display/ads7846.c b/hw/display/ads7846.c index c12272ae72..9228b40b1a 100644 --- a/hw/display/ads7846.c +++ b/hw/display/ads7846.c @@ -154,7 +154,7 @@ static void ads7846_realize(SSISlave *d, Error **errp) =20 ads7846_int_update(s); =20 - vmstate_register(NULL, -1, &vmstate_ads7846, s); + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_ads7846, s); } =20 static void ads7846_class_init(ObjectClass *klass, void *data) diff --git a/hw/i2c/core.c b/hw/i2c/core.c index 92cd489069..d770035ba0 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -61,7 +61,7 @@ I2CBus *i2c_init_bus(DeviceState *parent, const char *nam= e) =20 bus =3D I2C_BUS(qbus_create(TYPE_I2C_BUS, parent, name)); QLIST_INIT(&bus->current_devs); - vmstate_register(NULL, -1, &vmstate_i2c_bus, bus); + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_i2c_bus, bus); return bus; } =20 diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c index 59892b07fc..e6ee5e11f1 100644 --- a/hw/input/stellaris_input.c +++ b/hw/input/stellaris_input.c @@ -88,5 +88,6 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const i= nt *keycode) } s->num_buttons =3D n; qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s); - vmstate_register(NULL, -1, &vmstate_stellaris_gamepad, s); + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, + &vmstate_stellaris_gamepad, s); } diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 375cb6abe9..f2c3a7f309 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -284,7 +284,7 @@ static void apic_common_realize(DeviceState *dev, Error= **errp) } =20 if (s->legacy_instance_id) { - instance_id =3D -1; + instance_id =3D VMSTATE_INSTANCE_ID_ANY; } vmstate_register_with_alias_id(NULL, instance_id, &vmstate_apic_common, s, -1, 0, NULL); diff --git a/hw/misc/max111x.c b/hw/misc/max111x.c index 211008ce02..2b87bdee5b 100644 --- a/hw/misc/max111x.c +++ b/hw/misc/max111x.c @@ -146,7 +146,8 @@ static int max111x_init(SSISlave *d, int inputs) s->input[7] =3D 0x80; s->com =3D 0; =20 - vmstate_register(VMSTATE_IF(dev), -1, &vmstate_max111x, s); + vmstate_register(VMSTATE_IF(dev), VMSTATE_INSTANCE_ID_ANY, + &vmstate_max111x, s); return 0; } =20 diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index cc71a7a036..6cc97769d9 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -1874,7 +1874,8 @@ static void e100_nic_realize(PCIDevice *pci_dev, Erro= r **errp) =20 s->vmstate =3D g_memdup(&vmstate_eepro100, sizeof(vmstate_eepro100)); s->vmstate->name =3D qemu_get_queue(s->nic)->model; - vmstate_register(VMSTATE_IF(&pci_dev->qdev), -1, s->vmstate, s); + vmstate_register(VMSTATE_IF(&pci_dev->qdev), VMSTATE_INSTANCE_ID_ANY, + s->vmstate, s); } =20 static void eepro100_instance_init(Object *obj) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e3d310365d..3ac7961451 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -122,7 +122,7 @@ static void pci_bus_realize(BusState *qbus, Error **err= p) bus->machine_done.notify =3D pcibus_machine_done; qemu_add_machine_init_done_notifier(&bus->machine_done); =20 - vmstate_register(NULL, -1, &vmstate_pcibus, bus); + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_pcibus, bus); } =20 static void pcie_bus_realize(BusState *qbus, Error **errp) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 30a5fbd3be..02cf53fc5b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2948,7 +2948,7 @@ static void spapr_machine_init(MachineState *machine) * interface, this is a legacy from the sPAPREnvironment structure * which predated MachineState but had a similar function */ vmstate_register(NULL, 0, &vmstate_spapr, spapr); - register_savevm_live("spapr/htab", -1, 1, + register_savevm_live("spapr/htab", VMSTATE_INSTANCE_ID_ANY, 1, &savevm_htab_handlers, spapr); =20 qbus_set_hotplug_handler(sysbus_get_default(), OBJECT(machine), diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c index af524fabf7..beaa285685 100644 --- a/hw/timer/arm_timer.c +++ b/hw/timer/arm_timer.c @@ -180,7 +180,7 @@ static arm_timer_state *arm_timer_init(uint32_t freq) s->control =3D TIMER_CTRL_IE; =20 s->timer =3D ptimer_init(arm_timer_tick, s, PTIMER_POLICY_DEFAULT); - vmstate_register(NULL, -1, &vmstate_arm_timer, s); + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_arm_timer, s); return s; } =20 diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index 10d587ed40..3a0fc442f3 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -914,7 +914,8 @@ static void tpm_emulator_inst_init(Object *obj) tpm_emu->cur_locty_number =3D ~0; qemu_mutex_init(&tpm_emu->mutex); =20 - vmstate_register(NULL, -1, &vmstate_tpm_emulator, obj); + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, + &vmstate_tpm_emulator, obj); } =20 /* diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 4aef72c426..ed74dd5624 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1157,6 +1157,8 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDe= scription *vmsd, =20 bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque); =20 +#define VMSTATE_INSTANCE_ID_ANY -1 + /* Returns: 0 on success, -1 on failure */ int vmstate_register_with_alias_id(VMStateIf *obj, int instance_id, const VMStateDescription *vmsd, diff --git a/migration/savevm.c b/migration/savevm.c index e57686bca7..8dab99efc4 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -775,7 +775,7 @@ int register_savevm_live(const char *idstr, =20 pstrcat(se->idstr, sizeof(se->idstr), idstr); =20 - if (instance_id =3D=3D -1) { + if (instance_id =3D=3D VMSTATE_INSTANCE_ID_ANY) { se->instance_id =3D calculate_new_instance_id(se->idstr); } else { se->instance_id =3D instance_id; @@ -842,14 +842,14 @@ int vmstate_register_with_alias_id(VMStateIf *obj, in= t instance_id, =20 se->compat =3D g_new0(CompatEntry, 1); pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->na= me); - se->compat->instance_id =3D instance_id =3D=3D -1 ? + se->compat->instance_id =3D instance_id =3D=3D VMSTATE_INSTANC= E_ID_ANY ? calculate_compat_instance_id(vmsd->name) : instan= ce_id; - instance_id =3D -1; + instance_id =3D VMSTATE_INSTANCE_ID_ANY; } } pstrcat(se->idstr, sizeof(se->idstr), vmsd->name); =20 - if (instance_id =3D=3D -1) { + if (instance_id =3D=3D VMSTATE_INSTANCE_ID_ANY) { se->instance_id =3D calculate_new_instance_id(se->idstr); } else { se->instance_id =3D instance_id; --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007681; cv=none; d=zohomail.com; s=zohoarc; b=AlSHFT05s4Lcy10IWp0JimDs589nRrdqezzxXY/q+GHqnOKJoBnHe6tcHWCAJ0RBk5zYYhJztYVClkYGn9HhQrEaz9ik5mAveAEiEnVuZsbed4NzpLUC8+pn8D0nPdZBJgjRqcq77kgiX/HuQMWAl2x5Veseb9yF9iT+E8VxOcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007681; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dsd8GjCW5JufmDMdCUSgML54euu3q/B4ZPKHuX8cV3A=; b=jv8BMEK7+3inyZryxCuhytSb6O1gmH2unUi2XZUf+UJ+WT7YL8esnX6bshsQgDxWW1uzRW29WtSo+jPgow2CTd1GMeoddYhuiOyPMSkIyWCtNMli6KNQUQNEyrbmN9/NsEI/krVPp/USjyobCTLDPIFdpZZNhXZuWfn/HmeJXG0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157900768136175.78233757519365; Tue, 14 Jan 2020 05:14:41 -0800 (PST) Received: from localhost ([::1]:39184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irM1n-0002In-M6 for importer@patchew.org; Tue, 14 Jan 2020 08:14:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41884) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLkg-0004h5-Kh for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:57:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLkf-0002Pc-2g for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:58 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:28256 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLke-0002PP-Vn for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:56:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-335-UclLMH50NFKGIUnvUxD3Jg-1; Tue, 14 Jan 2020 07:56:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36B801005502; Tue, 14 Jan 2020 12:56:53 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id BADDE5E240; Tue, 14 Jan 2020 12:56:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006616; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dsd8GjCW5JufmDMdCUSgML54euu3q/B4ZPKHuX8cV3A=; b=jGEh2MMGk8jCWQVe3bLPtqVSlhZAU+yQ5kPQqp9C/n17xGUR4sMiYSEAqn+yJYBuKWCvcJ t6x4b89K2w6tMzxb5aw1jDXy5PPU78PKcKcoMpkitzbAHZL71Ik8uh46qEuBinZJgB0FKu D7k9OqZyZYe3ApkUcDopmJ9XT3bY0Ck= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 28/30] migration: Change SaveStateEntry.instance_id into uint32_t Date: Tue, 14 Jan 2020 13:52:52 +0100 Message-Id: <20200114125254.4515-29-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: UclLMH50NFKGIUnvUxD3Jg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Peter Xu , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Xu It was always used as 32bit, so define it as used to be clear. Instead of using -1 as the auto-gen magic value, we switch to UINT32_MAX. We also make sure that we don't auto-gen this value to avoid overflowed instance IDs without being noticed. Suggested-by: Juan Quintela Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- hw/intc/apic_common.c | 2 +- include/migration/register.h | 2 +- include/migration/vmstate.h | 2 +- migration/savevm.c | 18 ++++++++++-------- stubs/vmstate.c | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index f2c3a7f309..54b8731fca 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -268,7 +268,7 @@ static void apic_common_realize(DeviceState *dev, Error= **errp) APICCommonState *s =3D APIC_COMMON(dev); APICCommonClass *info; static DeviceState *vapic; - int instance_id =3D s->id; + uint32_t instance_id =3D s->id; =20 info =3D APIC_COMMON_GET_CLASS(s); info->realize(dev, errp); diff --git a/include/migration/register.h b/include/migration/register.h index 00c38ebe9f..c1dcff0f90 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -71,7 +71,7 @@ typedef struct SaveVMHandlers { } SaveVMHandlers; =20 int register_savevm_live(const char *idstr, - int instance_id, + uint32_t instance_id, int version_id, const SaveVMHandlers *ops, void *opaque); diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index ed74dd5624..01790b8d9b 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1160,7 +1160,7 @@ bool vmstate_save_needed(const VMStateDescription *vm= sd, void *opaque); #define VMSTATE_INSTANCE_ID_ANY -1 =20 /* Returns: 0 on success, -1 on failure */ -int vmstate_register_with_alias_id(VMStateIf *obj, int instance_id, +int vmstate_register_with_alias_id(VMStateIf *obj, uint32_t instance_id, const VMStateDescription *vmsd, void *base, int alias_id, int required_for_version, diff --git a/migration/savevm.c b/migration/savevm.c index 8dab99efc4..adfdca26ac 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -233,7 +233,7 @@ typedef struct CompatEntry { typedef struct SaveStateEntry { QTAILQ_ENTRY(SaveStateEntry) entry; char idstr[256]; - int instance_id; + uint32_t instance_id; int alias_id; int version_id; /* version id read from the stream */ @@ -667,10 +667,10 @@ void dump_vmstate_json_to_file(FILE *out_file) fclose(out_file); } =20 -static int calculate_new_instance_id(const char *idstr) +static uint32_t calculate_new_instance_id(const char *idstr) { SaveStateEntry *se; - int instance_id =3D 0; + uint32_t instance_id =3D 0; =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (strcmp(idstr, se->idstr) =3D=3D 0 @@ -678,6 +678,8 @@ static int calculate_new_instance_id(const char *idstr) instance_id =3D se->instance_id + 1; } } + /* Make sure we never loop over without being noticed */ + assert(instance_id !=3D VMSTATE_INSTANCE_ID_ANY); return instance_id; } =20 @@ -755,7 +757,7 @@ static void savevm_state_handler_remove(SaveStateEntry = *se) Meanwhile pass -1 as instance_id if you do not already have a clearly distinguishing id for all instances of your device class. */ int register_savevm_live(const char *idstr, - int instance_id, + uint32_t instance_id, int version_id, const SaveVMHandlers *ops, void *opaque) @@ -809,7 +811,7 @@ void unregister_savevm(VMStateIf *obj, const char *idst= r, void *opaque) } } =20 -int vmstate_register_with_alias_id(VMStateIf *obj, int instance_id, +int vmstate_register_with_alias_id(VMStateIf *obj, uint32_t instance_id, const VMStateDescription *vmsd, void *opaque, int alias_id, int required_for_version, @@ -1625,7 +1627,7 @@ int qemu_save_device_state(QEMUFile *f) return qemu_file_get_error(f); } =20 -static SaveStateEntry *find_se(const char *idstr, int instance_id) +static SaveStateEntry *find_se(const char *idstr, uint32_t instance_id) { SaveStateEntry *se; =20 @@ -2292,7 +2294,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migration= IncomingState *mis) /* Find savevm section */ se =3D find_se(idstr, instance_id); if (se =3D=3D NULL) { - error_report("Unknown savevm section or instance '%s' %d. " + error_report("Unknown savevm section or instance '%s' %"PRIu32". " "Make sure that your current VM setup matches your " "saved VM setup, including any hotplugged devices", idstr, instance_id); @@ -2316,7 +2318,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migration= IncomingState *mis) =20 ret =3D vmstate_load(f, se); if (ret < 0) { - error_report("error while loading state for instance 0x%x of" + error_report("error while loading state for instance 0x%"PRIx32" o= f" " device '%s'", instance_id, idstr); return ret; } diff --git a/stubs/vmstate.c b/stubs/vmstate.c index 6951d9fdc5..cc4fe41dfc 100644 --- a/stubs/vmstate.c +++ b/stubs/vmstate.c @@ -4,7 +4,7 @@ const VMStateDescription vmstate_dummy =3D {}; =20 int vmstate_register_with_alias_id(VMStateIf *obj, - int instance_id, + uint32_t instance_id, const VMStateDescription *vmsd, void *base, int alias_id, int required_for_version, --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579008266; cv=none; d=zohomail.com; s=zohoarc; b=e6SX+u+rGaXej4ukyU832uQ/NDOIt8e2dmNyq8mw4QP15eTyysnqUPlHTUv0zW9pP6E+wSgWSmWeRUZ/KnKOKkl6wjZTwcdOvr8MpLm9JGIjTB97o/cRc3e1GISgjmozgKzuIbgvLZrHRSiILTAaDLz3l+h5U+v+nZqDkyxcHGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579008266; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/qRvnKikU/zZW4H4BQbW8b5TjzE8O1lK0e+sh7nSqVM=; b=Zg9Q5sexElz1Zb3mVH5QFeBTEPJxpvpktw66+YMixjWYE5tWdyKds9J73WAn/EVo8FB0BLR942sARWM1fdsDTz1nfsXlkkWdWlzpd/Xu6hUbjRv/Dm5QBvedCLVBnrhI9qyPlKmAt5QutsaHAdYG6nPFOmrQvwjJdlo4kmY1BjU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579008266926215.16505907736496; Tue, 14 Jan 2020 05:24:26 -0800 (PST) Received: from localhost ([::1]:39486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irMBF-0006zg-IE for importer@patchew.org; Tue, 14 Jan 2020 08:24:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41917) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLkl-0004og-7U for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:57:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLkk-0002RG-2Q for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:57:03 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:48472 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLkj-0002R0-Uw for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:57:02 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-eu_y-ZhUOB6BQ1OrlV706Q-1; Tue, 14 Jan 2020 07:57:00 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 067A8801E72; Tue, 14 Jan 2020 12:56:58 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A4555DA70; Tue, 14 Jan 2020 12:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/qRvnKikU/zZW4H4BQbW8b5TjzE8O1lK0e+sh7nSqVM=; b=OIdMvT6xYk5tbWo4o/BOAlaboDfZEQ3hXKJdaALZQ+i99dNSXwMDm2H98QdTu2xEZYSwnG 84/0P2xk/u8l4uYL6+6naZnRNFapbKgDu+QmJiXwAJ2nQQHuztxkSKvUQReH/Ole0kxcsJ fzxckVGyTZ6eQ+y7HF2za7zcTWz7UnI= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 29/30] apic: Use 32bit APIC ID for migration instance ID Date: Tue, 14 Jan 2020 13:52:53 +0100 Message-Id: <20200114125254.4515-30-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: eu_y-ZhUOB6BQ1OrlV706Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Corey Minyard , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Peter Xu , Stefan Berger , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Xu Migration is silently broken now with x2apic config like this: -smp 200,maxcpus=3D288,sockets=3D2,cores=3D72,threads=3D2 \ -device intel-iommu,intremap=3Don,eim=3Don After migration, the guest kernel could hang at anything, due to x2apic bit not migrated correctly in IA32_APIC_BASE on some vcpus, so any operations related to x2apic could be broken then (e.g., RDMSR on x2apic MSRs could fail because KVM would think that the vcpu hasn't enabled x2apic at all). The issue is that the x2apic bit was never applied correctly for vcpus whose ID > 255 when migrate completes, and that's because when we migrate APIC we use the APICCommonState.id as instance ID of the migration stream, while that's too short for x2apic. Let's use the newly introduced initial_apic_id for that. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Reviewed-by: Eduardo Habkost Signed-off-by: Juan Quintela --- hw/intc/apic_common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 54b8731fca..b5dbeb6206 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -268,7 +268,10 @@ static void apic_common_realize(DeviceState *dev, Erro= r **errp) APICCommonState *s =3D APIC_COMMON(dev); APICCommonClass *info; static DeviceState *vapic; - uint32_t instance_id =3D s->id; + uint32_t instance_id =3D s->initial_apic_id; + + /* Normally initial APIC ID should be no more than hundreds */ + assert(instance_id !=3D VMSTATE_INSTANCE_ID_ANY); =20 info =3D APIC_COMMON_GET_CLASS(s); info->realize(dev, errp); --=20 2.24.1 From nobody Thu Apr 25 09:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) 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; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579007968; cv=none; d=zohomail.com; s=zohoarc; b=if4naEkk0RsZymHOPBioZ5vWcWWdz8GqeGesoOd+KPew9DUmQn2l1sd/ROL2d9rzFfC3NOdmPzPX1oKQGX2m5DLEL/yt6Lt+dWu3zv6AZ63yrnZdV5ZIWo7/QQ2lwEdJbaykeKuW/tbc3+ZDK4JSiZyvvUynvRBzhyt1E7lrga0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579007968; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=POlrnJtHqYzTPgz26FEG9BNU0bYXsBrc8l+YGLA2QjU=; b=TElj9A0yhfezRL1CB1hqRDZm4O6FrvwO5kOPx9nieZjYBRcrkqUPiKfvW6fHc/mZU2ZOATANsAhoTokwxTKajvaeJ1VcAh1CRsC9kOMC+dtdAf1eT04pSDc/LEcDqSMNsQvvN5J+oXRrF+dI/zwE989bRqV9pXfbhm5TDgDSJHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579007968560704.4095262369996; Tue, 14 Jan 2020 05:19:28 -0800 (PST) Received: from localhost ([::1]:39298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irM6Q-00081Y-Qy for importer@patchew.org; Tue, 14 Jan 2020 08:19:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41984) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irLl2-000595-Tr for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:57:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irLl0-0002Vz-MD for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:57:20 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:57966 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1irLl0-0002VU-HK for qemu-devel@nongnu.org; Tue, 14 Jan 2020 07:57:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-187-LdaORtSzOQaAv0gCLGp5jw-1; Tue, 14 Jan 2020 07:57:17 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 095581800D78; Tue, 14 Jan 2020 12:57:15 +0000 (UTC) Received: from secure.mitica (ovpn-116-207.ams2.redhat.com [10.36.116.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AE255D9E5; Tue, 14 Jan 2020 12:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579006638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=POlrnJtHqYzTPgz26FEG9BNU0bYXsBrc8l+YGLA2QjU=; b=KR5xn7QuUVeCl0nH85zdWBC24qqNDbhWhRUo2lw3epaJc6g0aH0r8EfT9YzewP+A433cNx 7JG4KeblvYmHwW64TWu5tNywSYhm0pwyd/yaXiFqTlHNNVONXlR0uI1QxW2rM/kXnjx/PY O116x0lxVNmuf1Zf9bYn5c/3HmKQb6Q= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 30/30] migration: Support QLIST migration Date: Tue, 14 Jan 2020 13:52:54 +0100 Message-Id: <20200114125254.4515-31-quintela@redhat.com> In-Reply-To: <20200114125254.4515-1-quintela@redhat.com> References: <20200114125254.4515-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: LdaORtSzOQaAv0gCLGp5jw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Corey Minyard , Jason Wang , Peter Xu , Juan Quintela , "Michael S. Tsirkin" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Gibson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , "Dr. David Alan Gilbert" , Eric Auger , qemu-arm@nongnu.org, Richard Henderson , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Eric Auger Support QLIST migration using the same principle as QTAILQ: 94869d5c52 ("migration: migrate QTAILQ"). The VMSTATE_QLIST_V macro has the same proto as VMSTATE_QTAILQ_V. The change mainly resides in QLIST RAW macros: QLIST_RAW_INSERT_HEAD and QLIST_RAW_REVERSE. Tests also are provided. Signed-off-by: Eric Auger Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/migration/vmstate.h | 21 +++++ include/qemu/queue.h | 39 +++++++++ migration/trace-events | 5 ++ migration/vmstate-types.c | 70 +++++++++++++++ tests/test-vmstate.c | 170 ++++++++++++++++++++++++++++++++++++ 5 files changed, 305 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 01790b8d9b..30667631bc 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -229,6 +229,7 @@ extern const VMStateInfo vmstate_info_tmp; extern const VMStateInfo vmstate_info_bitmap; extern const VMStateInfo vmstate_info_qtailq; extern const VMStateInfo vmstate_info_gtree; +extern const VMStateInfo vmstate_info_qlist; =20 #define type_check_2darray(t1,t2,n,m) ((t1(*)[n][m])0 - (t2*)0) /* @@ -798,6 +799,26 @@ extern const VMStateInfo vmstate_info_gtree; .offset =3D offsetof(_state, _field), = \ } =20 +/* + * For migrating a QLIST + * Target QLIST needs be properly initialized. + * _type: type of QLIST element + * _next: name of QLIST_ENTRY entry field in QLIST element + * _vmsd: VMSD for QLIST element + * size: size of QLIST element + * start: offset of QLIST_ENTRY in QTAILQ element + */ +#define VMSTATE_QLIST_V(_field, _state, _version, _vmsd, _type, _next) \ +{ \ + .name =3D (stringify(_field)), = \ + .version_id =3D (_version), = \ + .vmsd =3D &(_vmsd), = \ + .size =3D sizeof(_type), = \ + .info =3D &vmstate_info_qlist, = \ + .offset =3D offsetof(_state, _field), = \ + .start =3D offsetof(_type, _next), = \ +} + /* _f : field name _f_n : num of elements field_name _n : num of elements diff --git a/include/qemu/queue.h b/include/qemu/queue.h index 4764d93ea3..4d4554a7ce 100644 --- a/include/qemu/queue.h +++ b/include/qemu/queue.h @@ -501,4 +501,43 @@ union { = \ QTAILQ_RAW_TQH_CIRC(head)->tql_prev =3D QTAILQ_RAW_TQE_CIRC(elm, e= ntry); \ } while (/*CONSTCOND*/0) =20 +#define QLIST_RAW_FIRST(head) = \ + field_at_offset(head, 0, void *) + +#define QLIST_RAW_NEXT(elm, entry) = \ + field_at_offset(elm, entry, void *) + +#define QLIST_RAW_PREVIOUS(elm, entry) = \ + field_at_offset(elm, entry + sizeof(void *), void *) + +#define QLIST_RAW_FOREACH(elm, head, entry) = \ + for ((elm) =3D *QLIST_RAW_FIRST(head); = \ + (elm); = \ + (elm) =3D *QLIST_RAW_NEXT(elm, entry)) + +#define QLIST_RAW_INSERT_HEAD(head, elm, entry) do { = \ + void *first =3D *QLIST_RAW_FIRST(head); = \ + *QLIST_RAW_FIRST(head) =3D elm; = \ + *QLIST_RAW_PREVIOUS(elm, entry) =3D QLIST_RAW_FIRST(head); = \ + if (first) { = \ + *QLIST_RAW_NEXT(elm, entry) =3D first; = \ + *QLIST_RAW_PREVIOUS(first, entry) =3D QLIST_RAW_NEXT(elm, entr= y); \ + } else { = \ + *QLIST_RAW_NEXT(elm, entry) =3D NULL; = \ + } = \ +} while (0) + +#define QLIST_RAW_REVERSE(head, elm, entry) do { = \ + void *iter =3D *QLIST_RAW_FIRST(head), *prev =3D NULL, *next; = \ + while (iter) { = \ + next =3D *QLIST_RAW_NEXT(iter, entry); = \ + *QLIST_RAW_PREVIOUS(iter, entry) =3D QLIST_RAW_NEXT(next, entr= y); \ + *QLIST_RAW_NEXT(iter, entry) =3D prev; = \ + prev =3D iter; = \ + iter =3D next; = \ + } = \ + *QLIST_RAW_FIRST(head) =3D prev; = \ + *QLIST_RAW_PREVIOUS(prev, entry) =3D QLIST_RAW_FIRST(head); = \ +} while (0) + #endif /* QEMU_SYS_QUEUE_H */ diff --git a/migration/trace-events b/migration/trace-events index 2f9129e213..4ab0a503d2 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -76,6 +76,11 @@ get_gtree_end(const char *field_name, const char *key_vm= sd_name, const char *val put_gtree(const char *field_name, const char *key_vmsd_name, const char *v= al_vmsd_name, uint32_t nnodes) "%s(%s/%s) nnodes=3D%d" put_gtree_end(const char *field_name, const char *key_vmsd_name, const cha= r *val_vmsd_name, int ret) "%s(%s/%s) %d" =20 +get_qlist(const char *field_name, const char *vmsd_name, int version_id) "= %s(%s v%d)" +get_qlist_end(const char *field_name, const char *vmsd_name) "%s(%s)" +put_qlist(const char *field_name, const char *vmsd_name, int version_id) "= %s(%s v%d)" +put_qlist_end(const char *field_name, const char *vmsd_name) "%s(%s)" + # qemu-file.c qemu_file_fclose(void) "" =20 diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 7236cf92bc..1eee36773a 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -843,3 +843,73 @@ const VMStateInfo vmstate_info_gtree =3D { .get =3D get_gtree, .put =3D put_gtree, }; + +static int put_qlist(QEMUFile *f, void *pv, size_t unused_size, + const VMStateField *field, QJSON *vmdesc) +{ + const VMStateDescription *vmsd =3D field->vmsd; + /* offset of the QTAILQ entry in a QTAILQ element*/ + size_t entry_offset =3D field->start; + void *elm; + int ret; + + trace_put_qlist(field->name, vmsd->name, vmsd->version_id); + QLIST_RAW_FOREACH(elm, pv, entry_offset) { + qemu_put_byte(f, true); + ret =3D vmstate_save_state(f, vmsd, elm, vmdesc); + if (ret) { + error_report("%s: failed to save %s (%d)", field->name, + vmsd->name, ret); + return ret; + } + } + qemu_put_byte(f, false); + trace_put_qlist_end(field->name, vmsd->name); + + return 0; +} + +static int get_qlist(QEMUFile *f, void *pv, size_t unused_size, + const VMStateField *field) +{ + int ret =3D 0; + const VMStateDescription *vmsd =3D field->vmsd; + /* size of a QLIST element */ + size_t size =3D field->size; + /* offset of the QLIST entry in a QLIST element */ + size_t entry_offset =3D field->start; + int version_id =3D field->version_id; + void *elm; + + trace_get_qlist(field->name, vmsd->name, vmsd->version_id); + if (version_id > vmsd->version_id) { + error_report("%s %s", vmsd->name, "too new"); + return -EINVAL; + } + if (version_id < vmsd->minimum_version_id) { + error_report("%s %s", vmsd->name, "too old"); + return -EINVAL; + } + + while (qemu_get_byte(f)) { + elm =3D g_malloc(size); + ret =3D vmstate_load_state(f, vmsd, elm, version_id); + if (ret) { + error_report("%s: failed to load %s (%d)", field->name, + vmsd->name, ret); + g_free(elm); + return ret; + } + QLIST_RAW_INSERT_HEAD(pv, elm, entry_offset); + } + QLIST_RAW_REVERSE(pv, elm, entry_offset); + trace_get_qlist_end(field->name, vmsd->name); + + return ret; +} + +const VMStateInfo vmstate_info_qlist =3D { + .name =3D "qlist", + .get =3D get_qlist, + .put =3D put_qlist, +}; diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index 8f184f3556..cea363dd69 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -926,6 +926,28 @@ static const VMStateDescription vmstate_domain =3D { } }; =20 +/* test QLIST Migration */ + +typedef struct TestQListElement { + uint32_t id; + QLIST_ENTRY(TestQListElement) next; +} TestQListElement; + +typedef struct TestQListContainer { + uint32_t id; + QLIST_HEAD(, TestQListElement) list; +} TestQListContainer; + +static const VMStateDescription vmstate_qlist_element =3D { + .name =3D "test/queue list", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(id, TestQListElement), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_iommu =3D { .name =3D "iommu", .version_id =3D 1, @@ -939,6 +961,18 @@ static const VMStateDescription vmstate_iommu =3D { } }; =20 +static const VMStateDescription vmstate_container =3D { + .name =3D "test/container/qlist", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(id, TestQListContainer), + VMSTATE_QLIST_V(list, TestQListContainer, 1, vmstate_qlist_element, + TestQListElement, next), + VMSTATE_END_OF_LIST() + } +}; + uint8_t first_domain_dump[] =3D { /* id */ 0x00, 0x0, 0x0, 0x6, @@ -1229,6 +1263,140 @@ static void test_gtree_load_iommu(void) qemu_fclose(fload); } =20 +static uint8_t qlist_dump[] =3D { + 0x00, 0x00, 0x00, 0x01, /* container id */ + 0x1, /* start of a */ + 0x00, 0x00, 0x00, 0x0a, + 0x1, /* start of b */ + 0x00, 0x00, 0x0b, 0x00, + 0x1, /* start of c */ + 0x00, 0x0c, 0x00, 0x00, + 0x1, /* start of d */ + 0x0d, 0x00, 0x00, 0x00, + 0x0, /* end of list */ + QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */ +}; + +static TestQListContainer *alloc_container(void) +{ + TestQListElement *a =3D g_malloc(sizeof(TestQListElement)); + TestQListElement *b =3D g_malloc(sizeof(TestQListElement)); + TestQListElement *c =3D g_malloc(sizeof(TestQListElement)); + TestQListElement *d =3D g_malloc(sizeof(TestQListElement)); + TestQListContainer *container =3D g_malloc(sizeof(TestQListContainer)); + + a->id =3D 0x0a; + b->id =3D 0x0b00; + c->id =3D 0xc0000; + d->id =3D 0xd000000; + container->id =3D 1; + + QLIST_INIT(&container->list); + QLIST_INSERT_HEAD(&container->list, d, next); + QLIST_INSERT_HEAD(&container->list, c, next); + QLIST_INSERT_HEAD(&container->list, b, next); + QLIST_INSERT_HEAD(&container->list, a, next); + return container; +} + +static void free_container(TestQListContainer *container) +{ + TestQListElement *iter, *tmp; + + QLIST_FOREACH_SAFE(iter, &container->list, next, tmp) { + QLIST_REMOVE(iter, next); + g_free(iter); + } + g_free(container); +} + +static void compare_containers(TestQListContainer *c1, TestQListContainer = *c2) +{ + TestQListElement *first_item_c1, *first_item_c2; + + while (!QLIST_EMPTY(&c1->list)) { + first_item_c1 =3D QLIST_FIRST(&c1->list); + first_item_c2 =3D QLIST_FIRST(&c2->list); + assert(first_item_c2); + assert(first_item_c1->id =3D=3D first_item_c2->id); + QLIST_REMOVE(first_item_c1, next); + QLIST_REMOVE(first_item_c2, next); + g_free(first_item_c1); + g_free(first_item_c2); + } + assert(QLIST_EMPTY(&c2->list)); +} + +/* + * Check the prev & next fields are correct by doing list + * manipulations on the container. We will do that for both + * the source and the destination containers + */ +static void manipulate_container(TestQListContainer *c) +{ + TestQListElement *prev =3D NULL, *iter =3D QLIST_FIRST(&c->list); + TestQListElement *elem; + + elem =3D g_malloc(sizeof(TestQListElement)); + elem->id =3D 0x12; + QLIST_INSERT_AFTER(iter, elem, next); + + elem =3D g_malloc(sizeof(TestQListElement)); + elem->id =3D 0x13; + QLIST_INSERT_HEAD(&c->list, elem, next); + + while (iter) { + prev =3D iter; + iter =3D QLIST_NEXT(iter, next); + } + + elem =3D g_malloc(sizeof(TestQListElement)); + elem->id =3D 0x14; + QLIST_INSERT_BEFORE(prev, elem, next); + + elem =3D g_malloc(sizeof(TestQListElement)); + elem->id =3D 0x15; + QLIST_INSERT_AFTER(prev, elem, next); + + QLIST_REMOVE(prev, next); + g_free(prev); +} + +static void test_save_qlist(void) +{ + TestQListContainer *container =3D alloc_container(); + + save_vmstate(&vmstate_container, container); + compare_vmstate(qlist_dump, sizeof(qlist_dump)); + free_container(container); +} + +static void test_load_qlist(void) +{ + QEMUFile *fsave, *fload; + TestQListContainer *orig_container =3D alloc_container(); + TestQListContainer *dest_container =3D g_malloc0(sizeof(TestQListConta= iner)); + char eof; + + QLIST_INIT(&dest_container->list); + + fsave =3D open_test_file(true); + qemu_put_buffer(fsave, qlist_dump, sizeof(qlist_dump)); + g_assert(!qemu_file_get_error(fsave)); + qemu_fclose(fsave); + + fload =3D open_test_file(false); + vmstate_load_state(fload, &vmstate_container, dest_container, 1); + eof =3D qemu_get_byte(fload); + g_assert(!qemu_file_get_error(fload)); + g_assert_cmpint(eof, =3D=3D, QEMU_VM_EOF); + manipulate_container(orig_container); + manipulate_container(dest_container); + compare_containers(orig_container, dest_container); + free_container(orig_container); + free_container(dest_container); +} + typedef struct TmpTestStruct { TestStruct *parent; int64_t diff; @@ -1353,6 +1521,8 @@ int main(int argc, char **argv) g_test_add_func("/vmstate/gtree/load/loaddomain", test_gtree_load_doma= in); g_test_add_func("/vmstate/gtree/save/saveiommu", test_gtree_save_iommu= ); g_test_add_func("/vmstate/gtree/load/loadiommu", test_gtree_load_iommu= ); + g_test_add_func("/vmstate/qlist/save/saveqlist", test_save_qlist); + g_test_add_func("/vmstate/qlist/load/loadqlist", test_load_qlist); g_test_add_func("/vmstate/tmp_struct", test_tmp_struct); g_test_run(); =20 --=20 2.24.1