From nobody Sat Apr 20 13:08:20 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=1578994268; cv=none; d=zohomail.com; s=zohoarc; b=jgGDlkb+JwdKJyq1NnBjoX1Ujtfu6Lem8oAyDHbIZe7l4xzWs/BkdARMsyShIScvJkQowPiANIqIuMgu4gZ/4J05licROjXfcZW4Ozg1wJ8PMjZHyebffu8YWTQtwKN8XI3sFvXVd/oez1oRSTAnkMvaQ4JdBX4xghnYhb3OpBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994268; 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=hpIUX2QQgZOlSnknd+MlnK1n1k3h6k92aBhVvhvSKXQ=; b=OVRWIJ+HoJ8KfYkTat1wpsOiH+1pLVAfZfJkVnTlCrElQ1e8CYlPkmU9owu+8uNjZ8rFuZ7sOdBVMUjDB4yjJjRVJX2xCpob8oN2H2aKQ2ysoRYJrPmzWlGS3z/S3MDpLf8aNol4T8HXrmCWyQ00mQwot+tgoiQItto9Gb4/XWg= 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 1578994268171488.31807025096316; Tue, 14 Jan 2020 01:31:08 -0800 (PST) Received: from localhost ([::1]:35184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIXS-0001nI-1q for importer@patchew.org; Tue, 14 Jan 2020 04:31:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57075) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irISv-0004H3-Vf for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irISv-0006Gf-1A for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:25 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53814 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 1irISu-0006GV-TF for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:24 -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-69-UGEan0HPN6OitLjCJvpXAw-1; Tue, 14 Jan 2020 04:26:23 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9A7B107ACCA; Tue, 14 Jan 2020 09:26:21 +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 75D01384; Tue, 14 Jan 2020 09:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578993984; 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=hpIUX2QQgZOlSnknd+MlnK1n1k3h6k92aBhVvhvSKXQ=; b=MJsj3cnmxxTIDgmWYYQINNSeaeXz2MXGxjCGE1jHKJ6C+yjREliZwDkluB+PU/Zqhz7pIy dv+e6qtOeY2KxBABUjXVGpqy0zz4iXhzv8PWYvsBDZ81/LsAeSANAU2B8tefbOf42dKKyK oPFwi377MaAzkNc/QRHPNKw9oXFWR3w= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 01/29] multifd: Initialize local variable Date: Tue, 14 Jan 2020 10:25:38 +0100 Message-Id: <20200114092606.1761-2-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: UGEan0HPN6OitLjCJvpXAw-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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" Fill everything with zero, so the padding fields are also initialized. --- 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 Sat Apr 20 13:08:20 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=1578994113; cv=none; d=zohomail.com; s=zohoarc; b=DxrBTPVzRofbupCbuhaFcsD5By1i1hfg8tjFmnh5OYZ9s6y2rmj6VtaFKFZ0mXv75HqsXzaqKIMA9JHW/Q4lrHq8e+ZV4UEOEZklCHUf4XAaRuBuZxVwq2cp2nr8gEOzxao4VwQRHwQM18wi3PB22810noNGz24oamHF7sN8Jqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994113; 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=FpbggV5bM1GWW0/Hg0N5WTnsehVpCubH+OeEDtTEdV14/DiRIobbCpPNoqpE7SvNPDrRkd58ntDqKk4rej8PrPnxTlWscScRW0wzg5roWd4GIjQEIHMWEksbMIo7G8DVb5jAHbROgVuvn1453jq/QJfJL7plPVBcMLhKogY4dw8= 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 1578994113487641.3936265133987; Tue, 14 Jan 2020 01:28:33 -0800 (PST) Received: from localhost ([::1]:35040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIUx-0006hn-Om for importer@patchew.org; Tue, 14 Jan 2020 04:28:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57138) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIT1-0004Pu-LW for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIT0-0006IW-Fm for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:31 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44615 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 1irIT0-0006IG-BU for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26: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-309-21RP2guBMx6Bwo4jE1J9gQ-1; Tue, 14 Jan 2020 04:26:28 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA768800D5A; Tue, 14 Jan 2020 09:26: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 28341384; Tue, 14 Jan 2020 09:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578993990; 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=K/GHJbAjuz9g2x2QQt3JXLJdT0CUqiDWamNpptoKJOY84xmeVLPlhmxKVVmjaMoOfJQiDy DxRNhD8rlJrn81z8gni3h+450IZtySveO3JKyTdxbc94CnrXX1KOdf4QL0Fwy8c1VXtjvn zcG9UMpoQwGRQZIjRmqhGonDKaykWNs= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 02/29] migration-test: Add migration multifd test Date: Tue, 14 Jan 2020 10:25:39 +0100 Message-Id: <20200114092606.1761-3-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 21RP2guBMx6Bwo4jE1J9gQ-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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" 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 Sat Apr 20 13:08:20 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=1578994349; cv=none; d=zohomail.com; s=zohoarc; b=OUZSlpIpNhKl1PzJHHFcXIm12XtdXw0kGUw4oavK7zImlCmH29Oog9GKNaPQPDBca8Jj0ciDgxRdWSZA7aHIHL+s1sVrewNuR4mfqWemkhBoaP7txAZ86XensXcx8eI64v2xQvsfadtbGxgbaodyWXKyDXyNQacFD/VlS9FO9D8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994349; 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=KP4JOgx0MH3utU/6sKW0BXPz8/EvSkOonQGNpzhU5Ck=; b=d0Du3+puGq7MNlauXjCmMAwE9JinH4lIW6NTfw4tp7IqwLTl52pE5C/JFt/pUI3d5kMhQ409aCxOu7QeSa731XQHXALlRI7vMOHRmahdy5q+D+Tz0vw2yVLh3S6IlfixLYC/OYxgHzYhDtbbHLRktv32taYt2XsCkKVsXZbM310= 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 1578994349039237.05408414151304; Tue, 14 Jan 2020 01:32:29 -0800 (PST) Received: from localhost ([::1]:35215 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIYl-0003dP-Fv for importer@patchew.org; Tue, 14 Jan 2020 04:32:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57233) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irITF-0004rh-V3 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irITE-0006Lc-CA for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:45 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47547 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 1irITE-0006LF-8u for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:44 -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-21-qOq3OrIYMoK77FdzsY6GQg-1; Tue, 14 Jan 2020 04:26:37 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA3A6107ACC4; Tue, 14 Jan 2020 09:26:35 +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 0DA2019757; Tue, 14 Jan 2020 09:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994003; 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=KP4JOgx0MH3utU/6sKW0BXPz8/EvSkOonQGNpzhU5Ck=; b=Jo8tlm4VKFQSUw5TSjnLIgE2lv1HhYv3o/kj+gpx8sgtTo5nt9EH4Cw5IYluHKnu75Odos 87HQu55HTpKxgj4sgIBThGtvYsCJeKePYsrZHwCF8WbKipWNIr8R1GWWXDINNODKSa//2L afYLLcLWwB/NkaIYEJ7iIZm+xONbElQ= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 03/29] migration: Make sure that we don't call write() in case of error Date: Tue, 14 Jan 2020 10:25:40 +0100 Message-Id: <20200114092606.1761-4-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: qOq3OrIYMoK77FdzsY6GQg-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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" 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 b9147bcca3..f946282adb 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 Sat Apr 20 13:08:20 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=1578994116; cv=none; d=zohomail.com; s=zohoarc; b=DLY9+Cvj0ceuScHdppsVCUOUvpKCDYpdhQAlG7Tfn47GSmFW9KHoZn+SHYi4HtZLeuy3YfKpFJv+NZagCWP730wy7u35LHxwBElEN/Js+V62uHtKeHfC6mxRtcIM3v1t3y/tcxzTxvvnj2Jjgrg9fVCy13z/ZZtvgZRP8QD5H9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994116; 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=OH3IgKijW5hldvpdQMQcNF8IL1ub3zZTtNRZ8F5BZfvQncRlDPGYcZ8P1HVsFCqwC8KzqT+Hkxy6Q73MNgs20hVWI5Sh/ROrcTFg0j6tYgZ5IRw9RwnaDZWOOcvepQE9P4pkxnMtc+9L67sZK48fFH11Tod4YI20sMURo8+g1zo= 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 1578994116110168.63397900843086; Tue, 14 Jan 2020 01:28:36 -0800 (PST) Received: from localhost ([::1]:35044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIV0-0006nj-En for importer@patchew.org; Tue, 14 Jan 2020 04:28:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57209) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irITF-0004pX-4i for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irITD-0006L5-Vx for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:44 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:57625 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 1irITD-0006Kp-SI for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:43 -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-383-kJc9N6jzMM-kaKH_ipJuNg-1; Tue, 14 Jan 2020 04:26:42 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 951C8800D41; Tue, 14 Jan 2020 09:26:40 +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 49151384; Tue, 14 Jan 2020 09:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994003; 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=Ub0aFWxph5uoKrdzopxo/2JwHD3gQ0ZyA8th1lCjL0zoq6B7izt5dCQjfrjoJOQwLr80XO OaiEe38KsxrhQ0UcO18AD+Pn0ZrOKktLUD/pnDG0t6EtQ0efB3BBoahRhT46Q/jXWAqmYg xCiAjxhV0hmjcWxP8ZVwaWODEBJVbYQ= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 04/29] migration-test: introduce functions to handle string parameters Date: Tue, 14 Jan 2020 10:25:41 +0100 Message-Id: <20200114092606.1761-5-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: kJc9N6jzMM-kaKH_ipJuNg-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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" 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 Sat Apr 20 13:08:20 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=1578994542; cv=none; d=zohomail.com; s=zohoarc; b=F1wWuls0f9ZNhmiTbkhH+vyHJ7DEwQ2Ik7dsS4xmL8L7XnAsUgL6WFaG1nA01Dz0UPEbkt/b6qLNH1RfeO4Eoq1FB0CdJClmHljgU9sVSA5QZXCCHk5hsI3RfJgOBiD/uRy95aejvJoFtNpNiVx2jjROGPGnhZdZQve4toN4YtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994542; 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=Oc7Au6eWVW8CdyhfiHZHb6aw/WxwfV2tShKtveEiN5ig+gI3waPWD2hblnFcAV9YjMQFIeflZINGVCpZCR/L21I+WsJCIUsmRE8QjUpYYV3nR8yqxeksEVvJh8Wsp+hDznT2zDQbnQpEHjqNc8oLFrXT2BaHk/zRa5s6gNkX+CU= 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 1578994542139454.06652508793445; Tue, 14 Jan 2020 01:35:42 -0800 (PST) Received: from localhost ([::1]:35262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIbs-000785-Of for importer@patchew.org; Tue, 14 Jan 2020 04:35:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57293) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irITR-0005CW-Rq for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irITO-0006NX-8c for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:57 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32699 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 1irITO-0006NI-5N for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:26:54 -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-erusUVLcOjG_Ld3aIiWqmA-1; Tue, 14 Jan 2020 04:26:49 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E5F3801E7B; Tue, 14 Jan 2020 09:26: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 EB08A384; Tue, 14 Jan 2020 09:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994013; 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=e0MqUZEDSMF+Dj70TwiEMzvLdj016cZssPqaJFDR88awp7nWRGXBPystIbrovutD/axMvx PqyBKaxHIY9kQMjj7O8/G6tpCh3LMvU8ma1SImn+Ns9X6yJP/Q15pNIYfjqASwvwTIlUeG HNEYNSMRQUfsu0i5wS0tX13GqU/A0ok= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 05/29] migration-test: ppc64: fix FORTH test program Date: Tue, 14 Jan 2020 10:25:42 +0100 Message-Id: <20200114092606.1761-6-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: erusUVLcOjG_Ld3aIiWqmA-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 , Corey Minyard , Thomas Huth , wei@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 Sat Apr 20 13:08:20 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=1578994133; cv=none; d=zohomail.com; s=zohoarc; b=U+h4oCWbKZyyTfTnBoNsHmw1X3WvmfvSmUZovSsacpbDGQC/WBjULNuDamI02oaGbIxOWJ7hikY7SLhVRtu/M6koxX3lJDgrVX6s//Dg0CF9x1bGRXkiBVTC8LHZUkXyJi8UziMIWrphG3Fc1zEcteYCtVs2PAse1U36cMdPXgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994133; 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=E0j7+zgQ8EhjxLtg4whjclAfstwx46tZhB3tinu4kkGCrOg8XYofPamkrAVXPhU1spWqSh7OjL29h7nAm86SlFhIHsPsI9L+OiqYM++HEFplnTaPcU4QhlbmuqFNIodrmOby4oU7Lh7YTlizzAV51pkkTITK4Oo4YyPZv3S/VIc= 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 1578994133743493.9148620035138; Tue, 14 Jan 2020 01:28:53 -0800 (PST) Received: from localhost ([::1]:35064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIVI-0007Gu-Bi for importer@patchew.org; Tue, 14 Jan 2020 04:28:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57320) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irITW-0005JZ-1b for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irITU-0006Oj-R8 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:01 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:39154 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 1irITU-0006OU-MN for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:00 -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-70-RULCHMoFOXqFDmpZtjKpZw-1; Tue, 14 Jan 2020 04:26:58 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2977A477; Tue, 14 Jan 2020 09:26: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 6267C384; Tue, 14 Jan 2020 09:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994020; 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=eexHpeV76s1IQTRyeiWXS1Oz2ZxZ/UzWJHjhNkYw/dwehWwngNQiGip9omv56MpU64ck4D DGypt5RG9fFjHRfyXtHJxQVXezXZyRnnGdVmAdDW6bOvUsCy8IX1L3EEXR79AipDMLWvWB Xj1fmCdogC5ekPIw/lisJVzJaWVXAPI= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 06/29] runstate: ignore finishmigrate -> prelaunch transition Date: Tue, 14 Jan 2020 10:25:43 +0100 Message-Id: <20200114092606.1761-7-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: RULCHMoFOXqFDmpZtjKpZw-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 Sat Apr 20 13:08:20 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=1578994716; cv=none; d=zohomail.com; s=zohoarc; b=Zt4Bs9k0gaF/z5C/GffXj21Dok8r0M5THfQxvkklhZZRTAcWSO5c1PJRodNquK3rglALlQtxw+oe6lWtNUFuYeCInVHuI2ogKTHojzavlGtcRV+e37269owVh3teVcyAy+pqiveSdolEy/MesR3/wSnby3WTOmhuRrD+JWTPdZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994716; 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=1X5yO7SYwJyW5YJ1Ti/f3xeheBlw3XFdVPw3SMbN8dw=; b=km3GWHw/aLlZhsmRzgKe/v4KT/CDRjDZW8lODdaXiHiGW+s1jmS+Eqnx7FZxC07p2o3c8BPga+ntkuA2TkiWP7PKv7Gl9gjwDShRf7m09c1w9ImsnBrSg60QWfRHUoZCGcGOVWcDdFNoly83rC4puPk2cWMQaFtEhW+GhFJGh+Q= 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 157899471644942.71433963322602; Tue, 14 Jan 2020 01:38:36 -0800 (PST) Received: from localhost ([::1]:35320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIeg-0002xZ-TK for importer@patchew.org; Tue, 14 Jan 2020 04:38:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57366) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irITb-0005SM-C8 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irITa-0006RS-1B for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:07 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:57746 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 1irITZ-0006R1-U4 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:05 -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-264-L3ND0_gYOp6ftbKX6R9esg-1; Tue, 14 Jan 2020 04:27:03 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 05055800A02; Tue, 14 Jan 2020 09:27: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 7DB29384; Tue, 14 Jan 2020 09:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994025; 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=1X5yO7SYwJyW5YJ1Ti/f3xeheBlw3XFdVPw3SMbN8dw=; b=GFh/uk01OY5cb4cPbThB9Xyywf84WcGlJUI1tr9c2qbA/8p7XUDAmsITgTWkXJ3LH0Yysn BfeSHqR6u7rauGyKou7BLt1D2oD/MqcC/YGcxFuVJgR0cW7pshA5IKn94rEYQUpqNvz/X2 plicxTsXKP7hiC/bE9rwUTTNUQFjrIM= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 07/29] ram.c: remove unneeded labels Date: Tue, 14 Jan 2020 10:25:44 +0100 Message-Id: <20200114092606.1761-8-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: L3ND0_gYOp6ftbKX6R9esg-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 , Corey Minyard , Thomas Huth , Daniel Henrique Barboza , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 f946282adb..17cd8d524b 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 Sat Apr 20 13:08:20 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=1578994318; cv=none; d=zohomail.com; s=zohoarc; b=SZUEgJfee/tgA7/X8iOO2CIZvSTU3hqGIu/XaBA5ODn1XArLh3rcbsL30Kbmwpag493nwEpF+ettDaXcHTGBtgpqAL1X90EoAE7rsFabNxCWbyOTxf8+kmbIIqejvTi5EOGXBaD6DmgvDHq+iPc8OMFrkdBBdUVTix2WSM+tN6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994318; 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=LsOB1plsrf+L0MjZkIhW9gkC1Fbo6Je4OwCPKg11rHk=; b=Jvjx734hB9YwlubouT4fS9YXgRgUgp/eIK9UXIRAT3AkaPiL0nTLFEtGb37e6H78dXaShIfcD2cBJSOg+SrCjDBbjVduJwdNiY/YwrE/4dd2hBgG65RpFgYGtnmS6Z9sGJMJvoiVMnOgg0NYuJI0Zjhugd2jk5WEK4hbHoyx7z4= 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 1578994318199355.95259824059167; Tue, 14 Jan 2020 01:31:58 -0800 (PST) Received: from localhost ([::1]:35212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIYG-00037k-JA for importer@patchew.org; Tue, 14 Jan 2020 04:31:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57422) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irITq-0005nC-5j for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irITo-0006Tb-N5 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:22 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:52281 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 1irITo-0006TL-IO for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:20 -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-285-ENoeIc8DNPCn29fr3Ms_JA-1; Tue, 14 Jan 2020 04:27:13 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 984B1107ACC4; Tue, 14 Jan 2020 09:27: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 5566E26181; Tue, 14 Jan 2020 09:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994040; 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=LsOB1plsrf+L0MjZkIhW9gkC1Fbo6Je4OwCPKg11rHk=; b=KCbDkXro6PYVoLhvpMA23bXVPbqf6JgQUq5QR8o17D7Nk4pQ7q0iO9ZygHgD9Lw8R9OMO1 ervvPorSFZr7/wS3kuNW5C0xHbUdc7HK29MO4tsYDAhB+XMwhYRn6NdR9QBJzBg5SaEeMG pDJWJuYqV1YXnTe0elVGrNhHcYnvUZ0= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 08/29] migration: Rate limit inside host pages Date: Tue, 14 Jan 2020 10:25:45 +0100 Message-Id: <20200114092606.1761-9-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: ENoeIc8DNPCn29fr3Ms_JA-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: Corey Minyard , "Michael S. Tsirkin" , Jason Wang , Peter Xu , Juan Quintela , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, David Gibson , =?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 17cd8d524b..1ec5c10561 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 Sat Apr 20 13:08:20 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=1578994521; cv=none; d=zohomail.com; s=zohoarc; b=VCORz/87UHZLgirUvnlf6CLtMWZtoq1SLhZaJRx0KKrtgJIpAq4uvSc54JzI94ljnLtQPfF5M2kOPhuJg9vQQehave+sCWW2bkjgbxyCA0JjTHp0TCmBuBtpPwlTxVsVr4MyuH7et5mAWegmyjc0rqx1UHSo+fFgFdL6rft/g+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994521; 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=AeJTTyG7Ez+sOoo+cw2Gm48VYWAtHP4OblpOXsJPwszaF+9MKRKNZtsbFaMmNQ18O6BDmGeLvC4uIi+F582cTYRXTFBoYjbT2Hi/BIg1AsNmYMkYFSj0LMfIDIpSKowhfZKOkyAU0N3poOku6le/MiMhGqYhaFitUsdOqjZbILQ= 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 1578994521435751.8726311026619; Tue, 14 Jan 2020 01:35:21 -0800 (PST) Received: from localhost ([::1]:35258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIbX-0006qR-V0 for importer@patchew.org; Tue, 14 Jan 2020 04:35:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57491) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irITz-00062D-8P for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irITy-0006Vl-2s for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:31 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:52237 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 1irITx-0006VW-Vp for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27: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-156-TOhUdYwWNdqnDGDv8DtL5Q-1; Tue, 14 Jan 2020 04:27:26 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E4ED8024EE; Tue, 14 Jan 2020 09:27: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 ED76C384; Tue, 14 Jan 2020 09:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994049; 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=BVZD3XWhenwJDUPiD2WnS8bANzO/VGbf12J7gh/nmRb6bJl3mOu7TQ2VS61huyIBVbDGM6 SkWr4rdUtE8Dwe1T7Vd1hAqpxG9YGQG38X/L5/2vtux6uEx+LewGEoY5iPjvHtFFsbonzX TrsKVhrS/bftIKQUA2utakMP48RhqpI= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 09/29] migration: Fix incorrect integer->float conversion caught by clang Date: Tue, 14 Jan 2020 10:25:46 +0100 Message-Id: <20200114092606.1761-10-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: TOhUdYwWNdqnDGDv8DtL5Q-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: Corey Minyard , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Peter Maydell , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , Richard Henderson , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, David Gibson , =?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 Sat Apr 20 13:08:20 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=1578994703; cv=none; d=zohomail.com; s=zohoarc; b=R3EFweqhoZbGYN9g1NtYMEGo/wdRiVeXmPTVhNkV8Zla/MAKByilYt+Lq/sYSyfnOLfU9IhaBIHGq4IoZGH+87QbtXn7DrQYK4xzI6T75isI3L6Hf7dtscCGRHPIn8xVPvo1CvKZTKTfr4Es2Pob2c8fHNPhNsLc9twJj0dbmrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994703; 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=VTRHrHcpmRBzEXaZ8w/fX5i/AxiteK7zCsK+68kcDPSJpEtqWTfIcRuD/EwNy8c+9btOytyDia+YzQwFRfLq0FAKOKa+fqqKPpj0PhuYAzQmgD1s6IBIgqJ/GI4JYMB9VoMOsmpVy/4Hws/1qP9YBZcOACCzyeHXwwHp2svKsWg= 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 1578994703637462.941017831502; Tue, 14 Jan 2020 01:38:23 -0800 (PST) Received: from localhost ([::1]:35318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIeU-0002ck-36 for importer@patchew.org; Tue, 14 Jan 2020 04:38:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57532) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIU4-00069V-C5 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIU3-0006X1-9D for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:36 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:27195 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 1irIU3-0006Wr-4i for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:35 -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-370-rtudPUvBPpq9cIsQ3uk1gg-1; Tue, 14 Jan 2020 04:27:33 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 561521005516; Tue, 14 Jan 2020 09:27: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 64D5C384; Tue, 14 Jan 2020 09:27:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994054; 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=iSLPs2ZI4A7ivqsaTYa/3O9f9ZsWAWEnsZROiJypqHC7wZYbfJvb6jF76HKUU7X6jxZMlL 1vOTPUXyiFJNWkJkHk6qy0HEYB5Ll/8+naP1gmqp4X2/D1HXCX/lkfVdxXKIkkQU0LFggC mPoOG9K0KyjvHeJAfeA2iYE/3AF5jk4= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 10/29] migration: Fix the re-run check of the migrate-incoming command Date: Tue, 14 Jan 2020 10:25:47 +0100 Message-Id: <20200114092606.1761-11-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: rtudPUvBPpq9cIsQ3uk1gg-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: Corey Minyard , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , "Dr. David Alan Gilbert" , Yury Kotov , Darren Kenny , qemu-arm@nongnu.org, David Gibson , =?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 Sat Apr 20 13:08:20 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=1578994849; cv=none; d=zohomail.com; s=zohoarc; b=E6FVlx6/nXR3HRfhkzmhicllMdQtgK+Fg5ogItU3xdWuykkBTEqNcPCqfVBr1hM5cG9g2j0wDzNeclPLtlvR4pRxNHNX1mfPfktlf24+2BDIRnBNurEplT6HYPhRF4426074tGuEXi0crh2A6EQR9WnpIPWyoA1mvQoKwzGj3jA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994849; 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=YdwIrMkyRZ8GbDjVO/iXkCajjB+7B5X8bBPdlg0UhXLvk2uTKOz4pb8tZ0XPAYYoPyLmvOYI6ueht5K2uxVxkf4nQifESK6u9A7vuRws/g3ZnM7keHGL56qTueTHFlk6rX9chBUZySbRoma77xd5t5Cw6GD87UxOOQkI0zxmlXc= 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 157899484908481.77765183366546; Tue, 14 Jan 2020 01:40:49 -0800 (PST) Received: from localhost ([::1]:35354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIgp-0006Xl-AF for importer@patchew.org; Tue, 14 Jan 2020 04:40:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57586) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIUJ-0006Np-Aq for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIUI-0006Z4-5I for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:51 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:48545 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 1irIUG-0006Ya-9n for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:49 -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-78--P1DntjqOB-9a_hfc6i3vg-1; Tue, 14 Jan 2020 04:27:45 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 299361951264; Tue, 14 Jan 2020 09:27: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 AB61D384; Tue, 14 Jan 2020 09:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994066; 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=F3WLBqrYk5m+8ySvy16xSS9O11/gJV0uJckkKbHyUT54g5RoM/GUB+/Wk5r/7lg9hAMYd1 DrkuERF2NSGlrElXWNLXzE+v/KSaj653rJzCODYaX4R6Bf6Jhx8Hj/GHJDTp1buGOPBjOk tnPn4q02o8CbjRVNEJnqbT5MFkOAo+k= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 11/29] misc: use QEMU_IS_ALIGNED Date: Tue, 14 Jan 2020 10:25:48 +0100 Message-Id: <20200114092606.1761-12-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: -P1DntjqOB-9a_hfc6i3vg-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 Sat Apr 20 13:08:20 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=1578994884; cv=none; d=zohomail.com; s=zohoarc; b=RqiQI22maHrdrlpG2EJe+aeSvjkh12H1Z3k5B/AosLlxBlmxSXS/EWD8WD4TPvu25HBg3PVrblenhM0D4MavH+8Hk8A/v6PdHOcFrN3oxUHrNcPY/4NKe5tV3bst2yqiBkzUfIBRQ1r//VXtSlZFcGHmHp8hta1nYNyEs96XvXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994884; 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=IWaHuLRZ50pvIYG1JuMlVKeaaNXPJ2+xehDDmJe/7Cvpz0mgGLlbQQ2x8YGIGxelFTG9UfN4xBn9WVx+vx6aZlMa2QA5pv2R5TOs5YXk/QREhwbnt0cDKjUs8OvLlgSl7jHmWp8siT1UkogPe7jYK7jFT3rTWr1IMBGYaxIOCwQ= 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 1578994884919259.97455067896715; Tue, 14 Jan 2020 01:41:24 -0800 (PST) Received: from localhost ([::1]:35368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIhP-0007CJ-9d for importer@patchew.org; Tue, 14 Jan 2020 04:41:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57618) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIUL-0006Qs-9K for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIUK-0006a4-6f for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:53 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47916 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 1irIUK-0006Zn-26 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27: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-59-V8m4RVr7NXyD9i9prgXVDg-1; Tue, 14 Jan 2020 04:27:50 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14E55801E6C; Tue, 14 Jan 2020 09:27: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 7E4B3384; Tue, 14 Jan 2020 09:27:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994071; 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=URtAKKJVfwjAFr7BcsB7aHHdbrqLEZlOrs/QKl/Xa6m71H1UFQrrDAk2b9yJNLeezPg2ce 8c7PncoLg6zSgIrEeePfLB9+01kAwvNlsC6tl33FpYLm48q3VbO+clR09UentYG90kAH6K 4vIsBuLKBq/4IN+gvwaMCcEOZcyORpM= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 12/29] migration: add savevm_state_handler_remove() Date: Tue, 14 Jan 2020 10:25:49 +0100 Message-Id: <20200114092606.1761-13-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: V8m4RVr7NXyD9i9prgXVDg-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Scott Cheloha , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 Sat Apr 20 13:08:20 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=1578994393; cv=none; d=zohomail.com; s=zohoarc; b=C6HG+bt+bOe7guN8z0EBpdxVHTSZRIg0YyBo0oKUt5SyF9/0rwFMs4ARq7CHqJNTmesgDWf4gg9JAXWOdZdtJP71xXLmbPO5bbCdktj8YgGDLoeNcXl6TuHXjdP4hdJXYEQR5GBRWegmhESnHiN6QciPbyyrjFAyUWxcExqM9ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994393; 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=d5IEOGqTkmmJZw273tTQPzg8kM2kzi2jP54OkGC1IyIrIZ4HgKjrcpPfcsqy3/QpQDSuwtcZ3mvFOH7hQbkfEtJWT5dfDP1libaDoYciwcPZdomeNrFVi1qfVinNtKh0aZKDncCGlZylEkwzWtoKq6pCX5PFRn46fM4vAztpxAA= 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 15789943932531012.6983910764603; Tue, 14 Jan 2020 01:33:13 -0800 (PST) Received: from localhost ([::1]:35226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIZT-0004Ig-KQ for importer@patchew.org; Tue, 14 Jan 2020 04:33:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57661) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIUQ-0006Yd-5z for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIUO-0006bP-RB for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:57 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:36674 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 1irIUO-0006b7-Mn for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:27:56 -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-171-ksFglZtpPySRjnltbFESMw-1; Tue, 14 Jan 2020 04:27:54 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E60EF107ACC5; Tue, 14 Jan 2020 09:27:52 +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 6D8D719756; Tue, 14 Jan 2020 09:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994076; 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=QouqnCnvru4AocsFeatY/EMK3kN57sZIQ2LLEQV2m2LCGkobx5ly3mh654JS85t9VnWJGN 1j/qcpdZoMcC3uNMSN73YrKsmgwbNZz1sptn8EY1FIJW76fczInYL8gm8aG4YHmJVq4nyD 5NlMfJoWzNNbUd5Uhd0ZnPzK782ccSA= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 13/29] migration: savevm_state_handler_insert: constant-time element insertion Date: Tue, 14 Jan 2020 10:25:50 +0100 Message-Id: <20200114092606.1761-14-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: ksFglZtpPySRjnltbFESMw-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Scott Cheloha , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 Sat Apr 20 13:08:20 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=1578994730; cv=none; d=zohomail.com; s=zohoarc; b=G4NGMFBAW1hg+h+TtNWs+z4NpqAGTMC4josyEM8Gt+jbe/WHu+E9Q6gYGazYag1Rdug/85aLn4cpU9ZBm9G1o/Rip6L7uoUrm/4Aum4OYStzJ10sT2Go6NefR7IkYfRGRUyxjVz5KI/KOv8hagIVyuMv0y3mo3CRvOKgJBhikzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994730; 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=ynLvDJfV4kUr7Pu6PZ24xc1KIuICA5kAdzwdWYoRAQo=; b=h1q5+/uS4ViYtDdj3Nzaj8LPybZ3O5zlG/TADtsmKP7hnPiVdZmhAngWLFn0j14IlYHQv/Vn+CNcDgJOPkSFMS3leewEolYk8jV/DupiLM73+9iJtDkk1LeH0hzqdi+4vH4CqxwkhmwtQyYp1LCqPy7apQqS/sDG6cRNlma07TQ= 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 1578994730899107.87851645307; Tue, 14 Jan 2020 01:38:50 -0800 (PST) Received: from localhost ([::1]:35326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIet-0003H7-Ty for importer@patchew.org; Tue, 14 Jan 2020 04:38:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57734) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIUb-0006qM-2F for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIUZ-0006ek-Ry for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:08 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:55454 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 1irIUZ-0006eS-Ni for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28: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-350-N1f5REKCMNKMnrWrZ18yCg-1; Tue, 14 Jan 2020 04:28:04 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63E3F1800D78; Tue, 14 Jan 2020 09:28: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 453B9384; Tue, 14 Jan 2020 09:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994087; 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=ynLvDJfV4kUr7Pu6PZ24xc1KIuICA5kAdzwdWYoRAQo=; b=eOFciKy5T9cQaVKD0x4SyvYAWpW3qB1Gteah84ZUksWf6/UpsXuyyKxXr80EeqpKLoKZ/c X90+vFAZk+z9KE37WB3l1RsyCMWX402R7rxnH5V4MYL4kMmaBd3WCEMXg5hqKr472lKeKS 7XgL99eOBWbYatH0L7lBhGulvY1k+g8= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 14/29] migration/ram: Yield periodically to the main loop Date: Tue, 14 Jan 2020 10:25:51 +0100 Message-Id: <20200114092606.1761-15-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: N1f5REKCMNKMnrWrZ18yCg-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , Yury Kotov , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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 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 1ec5c10561..5cd066467c 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 Sat Apr 20 13:08:20 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=1578995293; cv=none; d=zohomail.com; s=zohoarc; b=BRUFvfFyNyGAEz6Hf0Bc5hG6hRbUTpgwU63b5uZgVnjEtW96rMh6Oj2YMXRj+1iqZYSi11uQswqhhxCSvGdGYKV7qJyIIi+6ccNwB93yxOfmq3QM6/YY3cLIQyfkyBGG+LRGzIvEwZocFk6U8Dno7XqWFDaHk7ywlOjCyhfXbMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995293; 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=8qROkM+rasi7lNorWAKRMCcUO5bof/IxBRI/hTT2Oxs=; b=PVOvEJBMP4yHemQWQwENbtpY13SX/2W9h5qp+2+I8e51cJx/1tXJnUVqkV9EjkAy7PDaHojXEv3ezV6BAFNi1xIYed/SZj4a6wRgFXYiYSkRs7BcoutFyzlClVIVJwDbHAElqJvf95ivuTBi5yEi3qJMYd2d+NvqSq72/jbvqx8= 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 1578995293707252.50891285108082; Tue, 14 Jan 2020 01:48:13 -0800 (PST) Received: from localhost ([::1]:35482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIo0-0007VO-4W for importer@patchew.org; Tue, 14 Jan 2020 04:48:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57772) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIUe-0006wA-L1 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIUd-0006gf-3B for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:12 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:48212 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 1irIUc-0006gN-Vt for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28: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-83-OWPVwAgSPDuN590HxxzBGQ-1; Tue, 14 Jan 2020 04:28:09 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42705107ACCD; Tue, 14 Jan 2020 09:28: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 B5B9F26181; Tue, 14 Jan 2020 09:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994090; 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=8qROkM+rasi7lNorWAKRMCcUO5bof/IxBRI/hTT2Oxs=; b=dWuZY7qAyg5yTFZjDvP8PzNyg5ys+4TmnnBrY2H3l4METW/XHrrH9HEE8wv/hmnkO7evfG fpnVDDuJHLCw351GMXdLyrEOToQLIBv6mqvO080HHnrscYolAGE0qILQOKhTVRjZ5Z4vbI eGhPlHIjCBn2fR5vroIhnJmwzp1mOPA= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 15/29] migration/postcopy: reduce memset when it is zero page and matches_target_page_size Date: Tue, 14 Jan 2020 10:25:52 +0100 Message-Id: <20200114092606.1761-16-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: OWPVwAgSPDuN590HxxzBGQ-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 5cd066467c..bdb0316892 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 Sat Apr 20 13:08:20 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=1578995087; cv=none; d=zohomail.com; s=zohoarc; b=TSvJ3d395rPp3skxIdpq2EMFT/35jTpWIKextP4bkk8UqUXzYq62UbLT+fkoI+gO5qfuZgpPl8s8Zakgk4wwjmlss7N8CSnV9dBGNSsGa8oQoj2qhcbfqkQdXf4c28IUcw1Qvg8I0aPAgfboomIOeknKTriS5SGN4SpfY/1G7h8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995087; 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=500ZmFBEwikUlMIqphyR61O1txsRuYhX1wQe8tn04xA=; b=lUpIUXRBUVIJQc0jCSJC2PVGk44Oo4rtAomOQf6O8sV9Cnl8hfJmK3CgvDuOf5jq2tPYAiwiRh0xC5I71whkb010qFWmrxzls8L6np+Wk7occ4I5X83XoYotVJwHS4l8cJ0ChNgLpyKw69pZzarZ43tHT7NXiHunpJBxZQxWmTI= 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 1578995087882792.846418501839; Tue, 14 Jan 2020 01:44:47 -0800 (PST) Received: from localhost ([::1]:35412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIkg-00033q-4h for importer@patchew.org; Tue, 14 Jan 2020 04:44:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57815) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIUm-0007AZ-OL for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIUk-0006ho-PT for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:20 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:20999 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 1irIUk-0006hW-LN for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28: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-229-KilAbPkROj-XGZiDX_8CcA-1; Tue, 14 Jan 2020 04:28:16 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D539800A02; Tue, 14 Jan 2020 09:28:14 +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 963C6384; Tue, 14 Jan 2020 09:28:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994098; 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=500ZmFBEwikUlMIqphyR61O1txsRuYhX1wQe8tn04xA=; b=csxj8H0FXcQxk0lcbfooBhrl1PTtACd3MuB43+Rst7Cg5Zb95OfLyOYEouXN1rRJ38MtPZ AHxm5FeFEWUtMvtPG5QVrUc4MJe2cBt9j60kvAzyVqx8zapFtngXJ24q/cKHf9C2yy5QT1 /G3bOIEsqhLjsDuTNnJkjp8HYJLWtsI= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 16/29] migration/postcopy: wait for decompress thread in precopy Date: Tue, 14 Jan 2020 10:25:53 +0100 Message-Id: <20200114092606.1761-17-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: KilAbPkROj-XGZiDX_8CcA-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 bdb0316892..c13b44b4d9 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 Sat Apr 20 13:08:20 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=1578994907; cv=none; d=zohomail.com; s=zohoarc; b=Ep9SOVdRrQvyTgpsaH2gIKJFhL4rRXDQnG63f6qL0Kiv2JrviRKXoJaACnFuJlWjSuN8TMYRP66wE098kMVwyvKp5j2zvhAw8IUG+jli9GPq3n2lEij27ih7lBZrCm3efVssZAv0CGoOkzlj5FtROQyNZ38UGjHkwZL6XRHVpZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994907; 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=vDvHDxz9hAL4AO2gd4dbSYpFgNTjSG2GxTAeEZIJRq0=; b=EQTYnV/BLGL2jGguqEV4I5tDaCqltHJurML0/9RyNPZ+I1Q2hmI8GGgYW4TaVp8IqRbkti6in6exU14afi2QU4gqSc+oGYsz+Ia8cT8/TuJ30126fPmZV8M0DVP+4ffQv61XsjQ0Y5ELgrXFZw14WNZb8zWISwToe/fj7MEVSIY= 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 1578994907768251.14123884333776; Tue, 14 Jan 2020 01:41:47 -0800 (PST) Received: from localhost ([::1]:35376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIhm-0007pD-4j for importer@patchew.org; Tue, 14 Jan 2020 04:41:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57882) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIUz-0007V9-Vl for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIUy-0006kE-NK for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:56544 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 1irIUy-0006js-KF for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28: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-371-kGEM5DgNNVuxl78Qq2SNEw-1; Tue, 14 Jan 2020 04:28:25 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0586B1951260; Tue, 14 Jan 2020 09:28: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 D1BC726182; Tue, 14 Jan 2020 09:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994112; 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=vDvHDxz9hAL4AO2gd4dbSYpFgNTjSG2GxTAeEZIJRq0=; b=Dc1HxBcDij8ZBt1KPHARIyfX4jjS46I9CS60gKbF6+nBVh+6/QBoZpqn3BqopmkNRvPd6K LsrVuVhYF/f+wrHDU48vlz5W1Ka/Jguu0tQQ+2G5bjP1ZLidSAKrr26E/uA/Ay23Mk2ITB ba1KPOEVNw+xEIUbCMZ55mI4pxiCc1s= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 17/29] migration/postcopy: count target page number to decide the place_needed Date: Tue, 14 Jan 2020 10:25:54 +0100 Message-Id: <20200114092606.1761-18-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: kGEM5DgNNVuxl78Qq2SNEw-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 c13b44b4d9..8ebaea255e 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 Sat Apr 20 13:08:20 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=1578995092; cv=none; d=zohomail.com; s=zohoarc; b=MMwkVaQrdcndnT2C44ntyrZBt+ZiAtDrMFdvXz9ZSdWP52Dja0uYBKJKO3DteFNzASI1++EgesZdpcXMN9TOHL4+zLd6szK3HsqatAwquP3UWtRuyfKCZXr0KYaTOIQ7KvhDYv7qGjOVdDBtY64q8rqgkwZFBa8fTa1l0+7NYDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995092; 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=3VZqz3zUF2Y1jQsm5V0KLQ63Ic05gunHzewXnrdXRG4=; b=cqwU6cj6S5OzEUZXo7WLBcZ+uu213v87XezGW0kfcKY1XucslSrSqQ0YXg7XHcz1QuH53CpgV/M1xVdhv4YQ/2usSXt03WD7K6KhNAOZ9iRkm09DzsooFNWqxkVEHAv5auxC5do7zyuJQpHuqAZMi1UO82lfxRvAolDHwrrUf9s= 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 1578995092182910.409695163287; Tue, 14 Jan 2020 01:44:52 -0800 (PST) Received: from localhost ([::1]:35414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIkk-0003AW-My for importer@patchew.org; Tue, 14 Jan 2020 04:44:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57889) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIV0-0007W9-Ka for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIUz-0006kM-1g for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:34 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:42788 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 1irIUy-0006k1-UC for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28: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-237-xZY-SYq6MEeu_rXygy7ngw-1; Tue, 14 Jan 2020 04:28:30 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4F2910054E3; Tue, 14 Jan 2020 09:28:28 +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 59E13384; Tue, 14 Jan 2020 09:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994112; 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=3VZqz3zUF2Y1jQsm5V0KLQ63Ic05gunHzewXnrdXRG4=; b=Hr0NR95df6VJHVktnLEFJtRPghEkVeT7oFaJmf2owuJjk8VjDJVvDRakEYbse9u6olR4Ki l6xtPa9G5qGoYuU8p3ggxOLOPe6LMRUTIgQbrrVZKNd4+126NOs+KBzGOO7Je9ivFexMEC rb1aPv1+6stv1A5dFf9whWhgNRocP1E= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 18/29] migration/postcopy: set all_zero to true on the first target page Date: Tue, 14 Jan 2020 10:25:55 +0100 Message-Id: <20200114092606.1761-19-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: xZY-SYq6MEeu_rXygy7ngw-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 8ebaea255e..460abfa2c3 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 Sat Apr 20 13:08:20 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=1578995465; cv=none; d=zohomail.com; s=zohoarc; b=DWPU/ggrk/T8t9Z0pcCGG054o1fqlRaKEDQr4FUxfxFZNVP8z8rgfda0A++luPdLeOFGpPgVW00E3Ynb2eg0gCUj8IHdOwcp9O3fG8ihK/X3xoT9Zgz09WAV+NePhX6Rv7PlybHlE/QRj6StjFVW8gTYdI4SjyPEywr7P2cbudE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995465; 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=PK1DLQmnnjOb69h2hvvX3jewUj0gHU0HSmNfuQkfjl0=; b=XTw/VO1dFHZUXN4fschYifgT53Xd1NhzgyxTk5IxATMR2yvG3JpmaM9Pom6SXuHmZxaFdBNKqDcW8AUzdSV6zutso2gMW1e9p2S0YCKPmXFzsAudAqsDuZoDzK7TV0zdJAGwgv8RGBJDA3xwu2hwfowFcNFS6aqI2te+FubYJzQ= 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 1578995465996276.3252728011994; Tue, 14 Jan 2020 01:51:05 -0800 (PST) Received: from localhost ([::1]:35542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIqm-0003FF-HA for importer@patchew.org; Tue, 14 Jan 2020 04:51:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57937) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIV5-0007eU-D2 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIV4-0006ld-5D for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:39 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:35053 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 1irIV4-0006lV-1D for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28: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-269-xrh5nKnYO8GKSsBp1lb5HA-1; Tue, 14 Jan 2020 04:28:36 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7882107ACC4; Tue, 14 Jan 2020 09:28:33 +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 363AD384; Tue, 14 Jan 2020 09:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994117; 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=PK1DLQmnnjOb69h2hvvX3jewUj0gHU0HSmNfuQkfjl0=; b=EedFrXmARYzP7LUXaXIeqRcS6HMzokkb6vPtwEZgg/pKLurPQLdX2H545otWsopjD8D6na Nxomun1lp32FFWrdV1ebAj43MCgBw6w3b+H27qyEURjkBbalYcXocN+sS+k0MD7+JOVNaH xcQe5rGKQ/0HLlpdkYbhewEXAkYs2JQ= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 19/29] migration/postcopy: enable random order target page arrival Date: Tue, 14 Jan 2020 10:25:56 +0100 Message-Id: <20200114092606.1761-20-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: xrh5nKnYO8GKSsBp1lb5HA-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 460abfa2c3..a7414170e5 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 Sat Apr 20 13:08:20 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=1578995314; cv=none; d=zohomail.com; s=zohoarc; b=M/U1PRoaETgbo+lk/Vg83pnEKAOxY0jLJl+BSJ5+dTF5hKNSvbmsS879Jq+pYI4XYEgriV9/iHsK1dLG1qm/Rl28Wea17a+mMNTKLRGyXMDs11IN3Cgiqz6LDg0O5cbQSGyB/4I+ieKAEwX5fU0yu+H/QC75GHL2XvdrRIWORBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995314; 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=Yr1WVaAouDj40R39IdfVYwIhtLx/Le0jqD+NYulh5As=; b=ilZ+jvc3FsDg0s5Pj3KHfEth/wfL1PlOfokjxm5yxHIcqzCEo8OKjBOGuwvUDE1TSkr6fRvLkEu7M8vboTkZLfx41oq1cj9cqMRqtQ33VzaUAXaCKPC4clfE0T0YpIufBobemc7o6h2GRuRi8x2vgVj7TD+QKMZmke5/b1F+R5Y= 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 1578995314003160.24012160929; Tue, 14 Jan 2020 01:48:34 -0800 (PST) Received: from localhost ([::1]:35484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIoK-0007rx-Di for importer@patchew.org; Tue, 14 Jan 2020 04:48:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57982) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIVD-0007tk-VB for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIVC-0006n3-H7 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:47 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:20293 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 1irIVC-0006mt-D9 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28: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-338-gA0wU_LwNNO-KwQOCc4NcA-1; Tue, 14 Jan 2020 04:28:44 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0CB9D1951261; Tue, 14 Jan 2020 09:28: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 074C526181; Tue, 14 Jan 2020 09:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994125; 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=Yr1WVaAouDj40R39IdfVYwIhtLx/Le0jqD+NYulh5As=; b=acLiwNPr4mowui7Ws12jTQJhfY4Ksrq7O+mbpXdGpF9TtS6dgygVa0x50SgPqH4gUJ4GzL GPsqFBDUDqswuTsqlJn3VJ/qpsx9GXVIRgUyCMLy2AufBsGDah24KQaKXktR9xB/xLYtjc cbZGT3tAlHjJRzhkOIJYF892Qfb5YTE= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 20/29] migration/postcopy: enable compress during postcopy Date: Tue, 14 Jan 2020 10:25:57 +0100 Message-Id: <20200114092606.1761-21-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: gA0wU_LwNNO-KwQOCc4NcA-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 a7414170e5..5f20c3d15d 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 Sat Apr 20 13:08:20 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=1578995605; cv=none; d=zohomail.com; s=zohoarc; b=nDcWTjnR/ZxqzIBO/jof6oRjNIG7nDgGOZkCSF9GfFIgSzWhO6tHsidj+LTi1jf0RLVY57GCK9ZzZjQmIT5J6yun1yO8mzLpY8vKttG+Uyn4vOqHFVRG11NmwYIAjFgvZmXE/VxO0EssKpmqWaFGyZRJZr4H6a9QKQtxmdGO5mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995605; 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=Um/ZPRrwSgEty2GoCR0h//BX2713mBeYZe2pvS7jfVI=; b=bks3ZLKGKxFRFUEI/ti2V+zB2W6wj+wxRMVTpftPPlCXCGfq6LLXNrjBm0o98OGKjT970gOuF1YunTzWCSGYdM0rG4p9m8E3TNEBi0o3/9LI5/qDrHb+bwKOAt7DQh7sKlau5WHTKCml2uVa+1FKiZwujuzopp/uwohRmwvERkU= 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 157899560550911.174087072327325; Tue, 14 Jan 2020 01:53:25 -0800 (PST) Received: from localhost ([::1]:35590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIt2-0006xD-47 for importer@patchew.org; Tue, 14 Jan 2020 04:53:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58018) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIVI-000820-Ut for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIVH-0006oQ-OR for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:52 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47152 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 1irIVH-0006o7-Kx for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28: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-267-LHF_uLpOP86BrHrZ4b1_BQ-1; Tue, 14 Jan 2020 04:28:50 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2FFB10054E3; Tue, 14 Jan 2020 09:28:47 +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 63FBF384; Tue, 14 Jan 2020 09:28:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994131; 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=Um/ZPRrwSgEty2GoCR0h//BX2713mBeYZe2pvS7jfVI=; b=TlJpu9cIABZ4gMkFo11H7WmwvA9lghbxEH0vYrEA/Tf10SlqhtUnPmnzXWELlaDQrCFiCV W5DIK3re/glLpGtdug7BJDx6IDwF64QbG1iEUvsZx0pcFGAtgRPfGILl5hFrGH+n6XMzSH L14dCiPzvW3X4HZsMUuEqbK73VEzGdM= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 21/29] migration/multifd: clean pages after filling packet Date: Tue, 14 Jan 2020 10:25:58 +0100 Message-Id: <20200114092606.1761-22-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: LHF_uLpOP86BrHrZ4b1_BQ-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 5f20c3d15d..a05448c0c9 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 Sat Apr 20 13:08:20 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=1578995321; cv=none; d=zohomail.com; s=zohoarc; b=EkzjMA8H0HvJO2oppDPJOkyHgZaV1pnuKX8Q2Kwud0J8kP4DRV5SUmWKGpZRsYsOiNvwqfc1XoLSmZXX6pPO1wU9BbgiqkS5LzwyDBrjzpaGbqVHqKR+1jSAlykSaGgkY6KMp1tKotaNxYCs+Ehtg/2iulTgGgMSY9J3/jZDMK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995321; 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=iprvAOa2cyTKcfIq8nOi5Ry3fqn5kNfZVkcEZq0n1vM=; b=d200gOXY+hXd0Zx1MVHF/0fV9m99ezFyNjwDG/7ReF54zyvpYSxRWh3wqBnLaejdQFjeZqs6y+fykcZyuEjdFtzK+44RhavTCluhXhqP5RZno4HQER4kqdIe87St5YxaPAO8glBesg3OYOS6WRHJiNmXuSdk/qNYVchtWodgNI4= 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 1578995321513643.5031007019021; Tue, 14 Jan 2020 01:48:41 -0800 (PST) Received: from localhost ([::1]:35486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIoR-00083K-SI for importer@patchew.org; Tue, 14 Jan 2020 04:48:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58060) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIVN-00089m-HU for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIVM-0006pY-Ce for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:57 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:52821 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 1irIVM-0006p9-89 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:28:56 -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-96-I8sLKwc7PRq2V-ig7jqMFw-1; Tue, 14 Jan 2020 04:28:54 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BDFE6800D41; Tue, 14 Jan 2020 09:28:52 +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 3EE2D384; Tue, 14 Jan 2020 09:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994135; 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=iprvAOa2cyTKcfIq8nOi5Ry3fqn5kNfZVkcEZq0n1vM=; b=X0KYsakZwchULPZue3jPz0elNa+HVVR68FOIcrOHRqMHx8xdIUVsrix/GvcPWBsMp6DHal H4ylBlAC8/2BIUezWr6bsiFIELtiGA5F+M2geJRZ4Ee3dx8+yWjVG/lH1aabIbvi4WtB7n 215x7oqgzGfjd79IHRBLUvnr4c0Vw48= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 22/29] migration/multifd: not use multifd during postcopy Date: Tue, 14 Jan 2020 10:25:59 +0100 Message-Id: <20200114092606.1761-23-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: I8sLKwc7PRq2V-ig7jqMFw-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Wei Yang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 a05448c0c9..d4f33a4f2f 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 Sat Apr 20 13:08:20 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=1578995516; cv=none; d=zohomail.com; s=zohoarc; b=MOgLLJTiFn2Q9xhEHxHB5PxKdP0a2w6RfpMZOnLPA4ml0psh5kG4BjsO4CS0WUDmJRlpqUep/vMXBTxEiELfgMQnaMWMxT4kWYMTEbX3+TOd6G1ZEymFgWIWmQxYKvqzc/XXkDLKx72uqbDrPUiPJAoMBM9Sp3ZaLpZpX21uOzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995516; 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=WBzhg+5JJy6m9TZjuc8ccJtIryAwYcan58WTVlhEz18=; b=HmS/iQiyaRlAEuyxNkZj508JM1z/SrvlRI6EIiUwX7lB9GFlnLIGnEjxRdAXWPc6TbP9+YBHYRz6fiG0rtCGY2Bshx8zCx/Q8vnr9kXoM90Y6QuYDHmTlPrs3LhqdOuD4mXOesuw/Hqx1vjEJ5+UUCtoLC7792qZfoINU+gQPlw= 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 1578995516901178.89264907355573; Tue, 14 Jan 2020 01:51:56 -0800 (PST) Received: from localhost ([::1]:35550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIrb-0004Sv-C2 for importer@patchew.org; Tue, 14 Jan 2020 04:51:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58136) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIVZ-0008ME-A7 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIVX-0006sz-QI for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:09 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33548 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 1irIVX-0006sk-9y for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29: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-86-M2gQWJhqOQqF533B9s1gmg-1; Tue, 14 Jan 2020 04:29:05 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B4883107ACC4; Tue, 14 Jan 2020 09:29: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 1BA0327184; Tue, 14 Jan 2020 09:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994146; 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=WBzhg+5JJy6m9TZjuc8ccJtIryAwYcan58WTVlhEz18=; b=CAbRw077YgtEauHItreN5vCmbATN+pRoiDesqctiYNhMdTbJ/akc9eS+tECkZ1/EV+b6f3 uFyWmZwu5TU24imS9FwP4Qj0ucnCkUWQwJw14qDBLN2aQEUfu5WeI2UMaf7aNeremSpBTd 16FJO9g8MwtBVjv//XNYpdMSyqxfwnA= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 23/29] migration/multifd: fix nullptr access in terminating multifd threads Date: Tue, 14 Jan 2020 10:26:00 +0100 Message-Id: <20200114092606.1761-24-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: M2gQWJhqOQqF533B9s1gmg-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: Corey Minyard , "Michael S. Tsirkin" , Jason Wang , Jiahui Cen , Juan Quintela , Peter Maydell , Ying Fang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, David Gibson , =?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 d4f33a4f2f..278b2ff87a 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 Sat Apr 20 13:08:20 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=1578995619; cv=none; d=zohomail.com; s=zohoarc; b=DsP3HmFIglqadb0dJL6snhMajg/2Yy4Nf31IRZyiTAO0aehwYaGvmCvnRspvNr1h+hEMx3gnX7zjAzW44ljG2wbdiBoN/BxnQoUN6VbiKDbiLe1CGwoFxwg/+u29koc7RyrhVc+X3kBRNn0tnPEBgg3Dc5XJdc/kPZgIUivnFcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995619; 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=sF9PT3VudShxE0wmWXTxFC1tzz8+9eCtUOBba9umQls=; b=D2uEHMBES+J0jSzHUlS7iwOgf2RWjhV3gtoMwvmNAgF7SkT8s9rpiMONdZHC7MZzyjHaUHXzpbJpeiApwiWPqHo5FA2f1+ag3I8fYGf/+P8Md+zt895nRv0eg9IBd04PbecISnSmKjd4eBx6kbaRLkFgVONEHsSkeFwjuPphxgs= 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 1578995619676437.50970169362427; Tue, 14 Jan 2020 01:53:39 -0800 (PST) Received: from localhost ([::1]:35594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irItG-0007H5-Aq for importer@patchew.org; Tue, 14 Jan 2020 04:53:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58183) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIVk-00007B-W5 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIVj-0006v8-Qf for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:20 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56708 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 1irIVj-0006uv-Mg for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:19 -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-230-cd6qPQNGOOKXLbzmPYfuhA-1; Tue, 14 Jan 2020 04:29:17 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D9FC2107ACC5; Tue, 14 Jan 2020 09:29: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 1197E19757; Tue, 14 Jan 2020 09:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994159; 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=sF9PT3VudShxE0wmWXTxFC1tzz8+9eCtUOBba9umQls=; b=Tyk1EvnjmL1vDrQKdNGCq92JiCiA6o4TpDM91N0kJmN6Gu+bDm0a4bF3LcMbpaRa4zlPSd AOCVsdm6UfRdVSLY7Ya4+fgee26+7RkUWJhcYeXSOyaVNQQSwpHiqc73sFWChM3OP0K4ue g/YcAaxC5mpqSNgLDls/LIta+qN2XZo= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 24/29] migration/multifd: fix destroyed mutex access in terminating multifd threads Date: Tue, 14 Jan 2020 10:26:01 +0100 Message-Id: <20200114092606.1761-25-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: cd6qPQNGOOKXLbzmPYfuhA-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: Corey Minyard , "Michael S. Tsirkin" , Jason Wang , Jiahui Cen , Juan Quintela , Peter Maydell , Ying Fang , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, David Gibson , =?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 278b2ff87a..7221f54139 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 Sat Apr 20 13:08:20 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=1578994652; cv=none; d=zohomail.com; s=zohoarc; b=WUWf8LjsWpgTXVn0iwbF1O5sSg0VPwkxiGmcTVSA5gObY43GER2U5C1d8qlTIsIWu/8xDnlDZUxXkkWwmctCQronEq4XAEyIIXuEZ6T+GOvywh33FhFmVZiFz0wGHX1C9k03Tez8YALk80kG7YDdkoLSH+EIcDp0GgqrSdgG7dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994652; 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=8bUpSs16sfRN2CEtPjACS0gftqpvp1N70X+Vg3Et2BU=; b=c+YLBnmGdirec+RXaLVAwQ3tP0RK699oPWa0CzLp6SQqDQLFaFnejBMtrGhS1uq1FOjE+fB7VBxeBLB0jojY1ZXWyPd9MVDkgHngCRtn591udLquU9fLDBhPedSwkFwH50HlODu+dRZtJmxdykE9T0Jb7z68f3y76hqoNsc2I54= 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 1578994652061113.06528041867477; Tue, 14 Jan 2020 01:37:32 -0800 (PST) Received: from localhost ([::1]:35314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIde-0001K3-Bp for importer@patchew.org; Tue, 14 Jan 2020 04:37:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58267) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIVw-0000ON-2a for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIVt-0006xb-FY for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:30 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23810 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 1irIVt-0006xN-Az for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29: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-314-3OgSkqZ7NdGiHhzMK9ANcg-1; Tue, 14 Jan 2020 04:29:27 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D31C801E72; Tue, 14 Jan 2020 09:29:25 +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 3595B19757; Tue, 14 Jan 2020 09:29:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994168; 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=8bUpSs16sfRN2CEtPjACS0gftqpvp1N70X+Vg3Et2BU=; b=jM0tTnfOeBSOtNhDZusUGEFkKF7vXVDYR8tMI3d+x42I9b0GVN66ht/i1HsvCoablOsNZl h8zMBCLkT2S4GxCyIfx3pAp2ch4O7UIW+OtMRJMtjSUILEQ27k/QO+XChY+EHvtvzVBQtr YAcpsv0XaHBHY8HO3QvlpqshCDRGRIc= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 25/29] Bug #1829242 correction. Date: Tue, 14 Jan 2020 10:26:02 +0100 Message-Id: <20200114092606.1761-26-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 3OgSkqZ7NdGiHhzMK9ANcg-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , Alexey Romko , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 7221f54139..d0940387d1 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 Sat Apr 20 13:08:20 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=1578995906; cv=none; d=zohomail.com; s=zohoarc; b=SB9IaHGPBJz6M5bMyBi3VUiVyPV9Aagsjl8eCXu7Vk1hXvt/Lmi+tkvPBsrtuapMeymX+jR7Zb0vwpzoRbsEup/xOXtP1oStWuuCCuNK7t0sdNYXJujOMJCxdWNkdDMeSr2fTPFsMWChiGVP9wARhr90OaBjJ+8s+5PY13bW7hM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995906; 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=CtOIjCo7An4Aaw3lq8ZKO9mFpkv3eOJ0PtgTI/uHn1t1nz7yjhvFs4SwPP9d0qzRHcNlAGW09y7EhB+2GQkCTCslg2uH0KB8sbdBuswQ6SLLAH8W2XUDr9fQ8PBOzOUdIkSG11c7KV2IE8Bdkj70UOpDysUoZo5S8JdMvOzSO5A= 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 1578995906740316.8412193211208; Tue, 14 Jan 2020 01:58:26 -0800 (PST) Received: from localhost ([::1]:35684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIxt-00059D-55 for importer@patchew.org; Tue, 14 Jan 2020 04:58:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58326) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIW1-0000ZV-Te for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIW0-0006zV-7o for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:37 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:24577 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 1irIW0-0006zJ-3e for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:36 -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-147-I979s3uUN12raRUt7cKIgg-1; Tue, 14 Jan 2020 04:29:34 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B874F800D48; Tue, 14 Jan 2020 09:29:32 +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 CFA4019757; Tue, 14 Jan 2020 09:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994175; 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=jISU42aZ5wQpZrUO4CXsCfIGotZxYG4YhuYwi9KBciLk88Pr1mqd6L9udv0i+BLhOeiUS+ 6siA8xMvuZ5N1o3SIx34jTNHN1qbNe9DVSZYsRAMg0724sY9NsKTunjRsAmPNMYCF1eR9e LLd8Lbnf/KRjWi/Wws7pDO+U4Su2ano= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 26/29] migration: Define VMSTATE_INSTANCE_ID_ANY Date: Tue, 14 Jan 2020 10:26:03 +0100 Message-Id: <20200114092606.1761-27-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: I979s3uUN12raRUt7cKIgg-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , Peter Xu , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 Sat Apr 20 13:08:20 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=1578995521; cv=none; d=zohomail.com; s=zohoarc; b=flFZcLKh2OIMRkmIdyzp4vIQ/tmTepAZiC+8wau0vRo5kUTsHs5mNCsd6/JfwX3/KoKlYbNynn9kZVwR22WbpiKb+re6wce6a4ge58i3GoVwjbzAZhBMqaazo+kMFqV2sFwEv9DSvTh7ujwlbxyh1VfVM07Q5ttWaPDQCmkamJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995521; 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=TZQCYZ/tQxsU5X5vuBcNR5ZeamX1PNDLPQp6uXwGWrrvDK4G9m4S51RPov1RlydYHjiAfJy9Yt5Z5rmsHQKXNr/nVvjJIrwAbUFpdiBBVbJ03zM5cdE4M5s3VvxnYQ9/rOzWJAZY/mKrzTIBSUjq3W1dE0LYUnrehIbQg/F9HOM= 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 1578995521813285.9027506896721; Tue, 14 Jan 2020 01:52:01 -0800 (PST) Received: from localhost ([::1]:35564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIrg-0004cz-F6 for importer@patchew.org; Tue, 14 Jan 2020 04:52:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58379) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIW8-0000kc-ON for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIW7-00071R-AU for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:44 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36847 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 1irIW7-000719-65 for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:43 -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-20-BZcDqtpSNWOEE4XkuKEjFw-1; Tue, 14 Jan 2020 04:29:39 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 951118024DD; Tue, 14 Jan 2020 09:29:37 +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 1A0F0381; Tue, 14 Jan 2020 09:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994182; 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=E60boLO2ndaSOR1XLjNzp90hWgY+uxwaXg+2IDek/yO0LKb83uMqr3SyeFuXzUWvGZqY5b aUUd4MXa2/JgGIFXxi2HJf0mR1+rJYuxow+Qoy0pO/HS4dkyiXKwMOgAMBXzIeWe0WgnFZ cY39M0FwPlQH366nhVC9OzXniLqNlvg= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 27/29] migration: Change SaveStateEntry.instance_id into uint32_t Date: Tue, 14 Jan 2020 10:26:04 +0100 Message-Id: <20200114092606.1761-28-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: BZcDqtpSNWOEE4XkuKEjFw-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , Peter Xu , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 Sat Apr 20 13:08:20 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=1578994820; cv=none; d=zohomail.com; s=zohoarc; b=WPFYvg+f+LCh2traeDM0H95KOihSAO3ssjMw91BI+DEzqgdE0FHhL5Bs1agO2iRr0DNuAnFoz36zqINVu8eE7wPg3Ucj21kMZeSvJ+/MidOAopo0nQpp087UFnP3EQPx1DgyPhgqcA33B+lhpY319pYqHCnm4cfTC3pvhTf+1Hw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578994820; 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=hmZ1Fu8I337FRyQah9lbXlZEJ2Oa7a17IIGMN688qFw7Cds6HIti0Q13UJJkW//t3qIOaE2ubuUBIC6XYEC78d8lX5tFk2xWK/dlHg/fs3fSennTWM7hX8gH2k05Wx0Lhz3lg3VoQbINaSf157qKQEd7qyObYjYx0VUXUKCZu00= 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 1578994820292184.86050718270656; Tue, 14 Jan 2020 01:40:20 -0800 (PST) Received: from localhost ([::1]:35350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIgM-0005k0-Lg for importer@patchew.org; Tue, 14 Jan 2020 04:40:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58434) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIWI-00012X-QO for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIWH-00073C-Kq for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29:54 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:26582 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 1irIWH-00072u-Fb for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:29: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-256-zJGkoKT3P_CcxqHYqR9lpg-1; Tue, 14 Jan 2020 04:29:48 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0025D800D41; Tue, 14 Jan 2020 09:29:47 +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 E7B73381; Tue, 14 Jan 2020 09:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994191; 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=ThuxC087IEMfHJy3ls1gx47jT6vOV9YDEH8F4+tjRsIUGnazepaVEssfeKs2KgmIDsfln9 dGu3kVmyRNHrpprgMBmqnaICl7gMzm11U++OZY60Nkgn/ecTLwy0OHFOYunLNdBr48scFJ ECwYSnde8itfMGj8moIucCB2NA+PZ9s= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 28/29] apic: Use 32bit APIC ID for migration instance ID Date: Tue, 14 Jan 2020 10:26:05 +0100 Message-Id: <20200114092606.1761-29-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: zJGkoKT3P_CcxqHYqR9lpg-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 , Corey Minyard , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Peter Maydell , Stefan Weil , Jason Wang , Juan Quintela , "Dr. David Alan Gilbert" , Peter Xu , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , David Gibson , Richard Henderson , 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: 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 Sat Apr 20 13:08:20 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=1578995647; cv=none; d=zohomail.com; s=zohoarc; b=IfMkT75cm8oHdN1mhbYlri6QajgE2eXsPvGNXrT1Bxjgfmny8omw6cTNM9zU3O1NO1DgBXrUD12hu+HxcQ/9eI94rgqUwtxGu5IefPqc0b2Lq3ditj/2etZAL9VeRv76ZNyDoeLfoHRGc5YhZswr0TYZ298ElngXr0w7t6glwac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578995647; 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=FD1IzczHPUYBtsjo4vWBgWjEsJFPC7hHYxjM1W6lWVhWCNcbc9uTdRyliGNqSWNfWR15AdiplRU7Dif5h0FeEW0tDdRQ3stWwBak8I+hDWCaGKeP9XtH6//7bx2QM2IW/0Gj/uKphpPGWVkZKCPhsQuT3ejVefcV6mdUNZAJixY= 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 157899564742350.020177736043706; Tue, 14 Jan 2020 01:54:07 -0800 (PST) Received: from localhost ([::1]:35597 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIth-0007rM-Tt for importer@patchew.org; Tue, 14 Jan 2020 04:54:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58481) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irIWR-0001JT-4U for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:30:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1irIWO-00074v-Nb for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:30:02 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:58727 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 1irIWO-00074b-Ig for qemu-devel@nongnu.org; Tue, 14 Jan 2020 04:30:00 -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-424--L9aIUc-N-yOTTIR-XXDQw-1; Tue, 14 Jan 2020 04:29:58 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 83085800D50; Tue, 14 Jan 2020 09:29:56 +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 53CA619757; Tue, 14 Jan 2020 09:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578994200; 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=COsEJJXrVl0glcwJwwnZm0Ii4vlbMBPNvkZ/WWA5GYweCOvnCoovqp+ms6HnNMpsbeeKUO zWvf6ba7an1nI807VYAVkTcqt3bMergNdLXhvHzpG7BsJM2XnSzefnOb0DxJLxzE/kc2NH ke/xePtS5ZZsu/6sJP51PTOBDiTgolg= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 29/29] migration: Support QLIST migration Date: Tue, 14 Jan 2020 10:26:06 +0100 Message-Id: <20200114092606.1761-30-quintela@redhat.com> In-Reply-To: <20200114092606.1761-1-quintela@redhat.com> References: <20200114092606.1761-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: -L9aIUc-N-yOTTIR-XXDQw-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: Corey Minyard , "Michael S. Tsirkin" , Jason Wang , Peter Xu , Juan Quintela , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Richard Henderson , Laurent Vivier , Thomas Huth , Eduardo Habkost , Stefan Weil , "Dr. David Alan Gilbert" , Eric Auger , qemu-arm@nongnu.org, David Gibson , =?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