From nobody Thu May 2 01:49:49 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=1578677704; cv=none; d=zohomail.com; s=zohoarc; b=hgPjjVLhk8I5bS2X6WcV1PTpyl/onBqMuPiybYE6M9hoiyHxYVapAkzkhaqd+w3tV9SydD9DiFnpOp9Yq+rA7EubaK9FlA1qZUfOqR2eijg4ChKoq3AyVa4N8tdgNypK5VqtHlKYL5Io9l7QxPY0Ts62yJZVzDB3uoB2KDhA5HE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578677704; 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=6q+bFL2mRnnlYQePE3rwAd8P4c5ap15wWC2cumpM8d8=; b=J+q1zrvxLkL3wvDPGG6bv+gZpMNu3sL0cXqlebbtbGpg2Uim//qyVQDP/5QDojV25rf+jOCCs1nF6kpYLtflcboSuUxBNAREwRkhnKteRN7TkSjbSjX7PADnvH9QX6GbI5r6rlcWWqufHGPTMWCZwcHy9sUtgg+FK1leFCO87sM= 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 1578677704455430.89689203267767; Fri, 10 Jan 2020 09:35:04 -0800 (PST) Received: from localhost ([::1]:49700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyBZ-00052s-GT for importer@patchew.org; Fri, 10 Jan 2020 12:35:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43839) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipy9G-0002xl-O6 for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:32:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipy9E-0007oN-53 for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:32:38 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:32729 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 1ipy9E-0007lX-1M for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:32: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-271-s7pzEnzFPdC-Z0BPIVmDtQ-1; Fri, 10 Jan 2020 12:32: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 44640477; Fri, 10 Jan 2020 17:32:32 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D30419C58; Fri, 10 Jan 2020 17:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677555; 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=6q+bFL2mRnnlYQePE3rwAd8P4c5ap15wWC2cumpM8d8=; b=EEcEigcMRQ9S3icDG8KnmehL49wKqCmWYQvq3mPDzWAFFxYGXzEoNL63sFGyoa4n3Wgg0g ah4g/4r0UgEux/R3QO3RJ1DSm4e4h+JztYbQIkbsJbHzEdM4i/9HsIUv9Tc6VaJV+wgCQ8 +x/i3bPcVhE3HXGELIZVuL3wraysXZI= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 01/28] migration-test: Add migration multifd test Date: Fri, 10 Jan 2020 18:31:48 +0100 Message-Id: <20200110173215.3865-2-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: s7pzEnzFPdC-Z0BPIVmDtQ-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Wei Yang , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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/migration-test.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/migration-test.c b/tests/migration-test.c index 53afec4395..fb70214f44 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -1202,6 +1202,61 @@ static void test_migrate_auto_converge(void) test_migrate_end(from, to, true); } =20 +static void test_multifd_tcp(void) +{ + MigrateStart *args =3D migrate_start_new(); + QTestState *from, *to; + QDict *rsp; + char *uri; + + if (test_migrate_start(&from, &to, "defer", args)) { + return; + } + + /* + * We want to pick a speed slow enough that the test completes + * quickly, but that it doesn't complete precopy even on a slow + * machine, so also set the downtime. + */ + /* 1 ms should make it not converge*/ + migrate_set_parameter_int(from, "downtime-limit", 1); + /* 1GB/s */ + migrate_set_parameter_int(from, "max-bandwidth", 1000000000); + + migrate_set_parameter_int(from, "multifd-channels", 16); + migrate_set_parameter_int(to, "multifd-channels", 16); + + migrate_set_capability(from, "multifd", "true"); + migrate_set_capability(to, "multifd", "true"); + + /* Start incoming migration from the 1st socket */ + rsp =3D wait_command(to, "{ 'execute': 'migrate-incoming'," + " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}"); + qobject_unref(rsp); + + /* Wait for the first serial output from the source */ + wait_for_serial("src_serial"); + + uri =3D migrate_get_socket_address(to, "socket-address"); + + migrate_qmp(from, uri, "{}"); + + wait_for_migration_pass(from); + + /* 300ms it should converge */ + migrate_set_parameter_int(from, "downtime-limit", 300); + + if (!got_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + qtest_qmp_eventwait(to, "RESUME"); + + wait_for_serial("dest_serial"); + wait_for_migration_complete(from); + test_migrate_end(from, to, true); + free(uri); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -1266,6 +1321,7 @@ int main(int argc, char **argv) test_validate_uuid_dst_not_set); =20 qtest_add_func("/migration/auto_converge", test_migrate_auto_converge); + qtest_add_func("/migration/multifd/tcp", test_multifd_tcp); =20 ret =3D g_test_run(); =20 --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578677910; cv=none; d=zohomail.com; s=zohoarc; b=ZN8kSC37Uhivj8uYlML8v3qplQXWJQa2tk4SGuDbFUfCwtR/jIloi8PcL62L+UmBeN6ZU/kAMenv/g4kPCGC698isBhP0pKSd9Y2Nse+j3f+u2/p/ZQ7HIxl2T/EmMMklJC/blev2BPZ1dZ2VRNF/7K6xVZ21Z3tv8tfqClwAA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578677910; 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=5EL+5+x+Vj2DalU+m/ovKS7r5Wc7mPC5/7p6MkBt67I=; b=i6qQd6q+u2fMKYxqqLM5597SYyB8DZfTrJ49s307hoY8YCp24/LLWZO3cnyz8kRvARocM8gTHV3pJVBf/ryTFjptZYOgafPMp9E8LOzLFvv1iwDkpaxg0AcoevNz99o8z6rq0J2GiJqPeKx2/D0GJxuMTb8XP8CEjcvsjreax0U= 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 1578677910481867.4618975584156; Fri, 10 Jan 2020 09:38:30 -0800 (PST) Received: from localhost ([::1]:49842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyEv-0001Zi-0a for importer@patchew.org; Fri, 10 Jan 2020 12:38:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44075) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipy9K-000331-9v for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:32:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipy9J-00089n-3k for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:32:42 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:23158 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 1ipy9I-00087X-UG for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:32:41 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-taq-H4FaOo6isdBCQvLrbg-1; Fri, 10 Jan 2020 12:32:38 -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 E1E8B1B18BC0; Fri, 10 Jan 2020 17:32:36 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99EEF19C4F; Fri, 10 Jan 2020 17:32:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677560; 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=5EL+5+x+Vj2DalU+m/ovKS7r5Wc7mPC5/7p6MkBt67I=; b=QkmLDBeIuXcBPN3/6S4OjvWTGlXaOuPUC5CyDzmy33QL3ByWuMJXSqXIQU/3Lec4RsrWB6 wl0E31aUmdtivgpcW+8kFzp2tWtuPes1tQovpJjRxv3fxDn/DkZHtdvyTKK2ZN8yII0bi8 TRo5YejH29xtWttlrPU0oEmw3wShHZ0= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 02/28] migration: Make sure that we don't call write() in case of error Date: Fri, 10 Jan 2020 18:31:49 +0100 Message-Id: <20200110173215.3865-3-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: taq-H4FaOo6isdBCQvLrbg-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 96feb4062c..6e678dbd2e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -900,6 +900,12 @@ struct { uint64_t packet_num; /* send channels ready */ QemuSemaphore channels_ready; + /* + * Have we already run terminate threads. There is a race when it + * happens that we got one error while we are exiting. + * We will use atomic operations. Only valid values are 0 and 1. + */ + int exiting; } *multifd_send_state; =20 /* @@ -928,6 +934,10 @@ static int multifd_send_pages(RAMState *rs) MultiFDPages_t *pages =3D multifd_send_state->pages; uint64_t transferred; =20 + if (atomic_read(&multifd_send_state->exiting)) { + return -1; + } + qemu_sem_wait(&multifd_send_state->channels_ready); for (i =3D next_channel;; i =3D (i + 1) % migrate_multifd_channels()) { p =3D &multifd_send_state->params[i]; @@ -1009,6 +1019,16 @@ static void multifd_send_terminate_threads(Error *er= r) } } =20 + /* + * We don't want to exit each threads twice. Depending on where + * we get the error, or if there are two independent errors in two + * threads at the same time, we can end calling this function + * twice. + */ + if (atomic_xchg(&multifd_send_state->exiting, 1)) { + return; + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; =20 @@ -1118,6 +1138,10 @@ static void *multifd_send_thread(void *opaque) =20 while (true) { qemu_sem_wait(&p->sem); + + if (atomic_read(&multifd_send_state->exiting)) { + break; + } qemu_mutex_lock(&p->mutex); =20 if (p->pending_job) { @@ -1224,6 +1248,7 @@ int multifd_save_setup(void) multifd_send_state->params =3D g_new0(MultiFDSendParams, thread_count); multifd_send_state->pages =3D multifd_pages_init(page_count); qemu_sem_init(&multifd_send_state->channels_ready, 0); + atomic_set(&multifd_send_state->exiting, 0); =20 for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578677893; cv=none; d=zohomail.com; s=zohoarc; b=bMP3sVYYtfyUxjv2KTwk1rMEOtlz9IhqACy0ZgrVkmLe3ffhtKJ6h42tp9H1uoBSfNqh0EYrUSFz9+Lr1tYGpv9RvSLSL9t0388fFkmAhVxWlniXfOaThuM0TMQXlNcRr3YhtedCLrGGe1UIqD2vB2shRspE9ShdpPTQeHgdpZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578677893; 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=L2koovzYghX0UyrQOjfFsAZEcpEKHd3wFRPhyQQOv6M=; b=DjC0NEZcYPIwZf9vlBOQFifIy9FGnKlMjfVo4gswM4BOF870d0I13bhpwB5S5BzHVJcu6P68aX73v/7vaV5RUHLBhA9ridHdmfdyhZnXNCD48sZf6o+DRpb425DOiqahiH5cEGB0h/17T7RYu8fOh4eaSUYtgyGbBvS+yZGPA2U= 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 1578677893064583.112483570204; Fri, 10 Jan 2020 09:38:13 -0800 (PST) Received: from localhost ([::1]:49834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyEc-00013t-Mh for importer@patchew.org; Fri, 10 Jan 2020 12:38:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44736) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipy9V-0003JL-RO for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:32:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipy9U-0000c8-Ny for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:32:53 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:49639 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 1ipy9U-0000Zf-IY for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:32: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-423-NKkCgfInOpC3dxeMr6oCQw-1; Fri, 10 Jan 2020 12:32: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 D98F5800EBF; Fri, 10 Jan 2020 17:32:48 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4147F19C4F; Fri, 10 Jan 2020 17:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677572; 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=L2koovzYghX0UyrQOjfFsAZEcpEKHd3wFRPhyQQOv6M=; b=gO2Qg8LWWBqN0nMo8zzrHHdYR9sAzd6A1HNoLDjhCwBFsxd1Dw2dmPInzbH1vZdc/LCeyY Ne+zo1vG5s8uPdcRwmydxk9+9H+SCGZIN6GM/q4t/7vzYD08nTZuBZDlGFwfUlW8+sJA7B AkrEh+uvHkgPzztxD2WAC45B7wJlCyw= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 03/28] migration-test: introduce functions to handle string parameters Date: Fri, 10 Jan 2020 18:31:50 +0100 Message-Id: <20200110173215.3865-4-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: NKkCgfInOpC3dxeMr6oCQw-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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/migration-test.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/migration-test.c b/tests/migration-test.c index fb70214f44..b0580dd541 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -356,6 +356,43 @@ static void migrate_set_parameter_int(QTestState *who,= const char *parameter, migrate_check_parameter_int(who, parameter, value); } =20 +static char *migrate_get_parameter_str(QTestState *who, + const char *parameter) +{ + QDict *rsp; + char *result; + + rsp =3D wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + result =3D g_strdup(qdict_get_str(rsp, parameter)); + qobject_unref(rsp); + return result; +} + +static void migrate_check_parameter_str(QTestState *who, const char *param= eter, + const char *value) +{ + char *result; + + result =3D migrate_get_parameter_str(who, parameter); + g_assert_cmpstr(result, =3D=3D, value); + g_free(result); +} + +__attribute__((unused)) +static void migrate_set_parameter_str(QTestState *who, const char *paramet= er, + const char *value) +{ + QDict *rsp; + + rsp =3D qtest_qmp(who, + "{ 'execute': 'migrate-set-parameters'," + "'arguments': { %s: %s } }", + parameter, value); + g_assert(qdict_haskey(rsp, "return")); + qobject_unref(rsp); + migrate_check_parameter_str(who, parameter, value); +} + static void migrate_pause(QTestState *who) { QDict *rsp; --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578677745; cv=none; d=zohomail.com; s=zohoarc; b=lKIo5nU4fOxH7Lha0ZhAEtGySVEgCJEzTWWY2cSod/O72CjytmmLfTCn+Yp7AFuZ4lBNYIb3MEUVLw5ECSijMHYQrdqKJCpmck98eq2u7x9LhsETEH6hZkWqQPitqrsIaKb3lF3umr22lhSAQ1BpT/Ja6MgUPl6ZntWQoQtOPYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578677745; 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=n9smWOLQyZ4hJe62Tvqeac2SxHMaaD3q8ynMCnIZ38A=; b=ZHltI0u4AnDj+NWGpqSLdi25UGkmnfAHwsvgtzMQDNszbMlBmEB4kQXqPbjLSk0GW5U5/UBr1lDGHMpYp59/lUfq9OblUSluprIV6cj8xdOUNmuwachqdR9EFf0T1HStBWL1U1an1BOCP+DcdZ0+GMcBXJh8AWSKOoFWn19VyH8= 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 1578677745169936.9900055049735; Fri, 10 Jan 2020 09:35:45 -0800 (PST) Received: from localhost ([::1]:49708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyCE-0006Bc-Ea for importer@patchew.org; Fri, 10 Jan 2020 12:35:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45177) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipy9d-0003U7-EN for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipy9c-00014d-A3 for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:01 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:28451 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 1ipy9c-00011q-6g for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33: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-222-3zNnShorMHGmOG3z16Krzg-1; Fri, 10 Jan 2020 12:32: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 3DDA48024DB; Fri, 10 Jan 2020 17:32:56 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39B5A19C4F; Fri, 10 Jan 2020 17:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677579; 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=n9smWOLQyZ4hJe62Tvqeac2SxHMaaD3q8ynMCnIZ38A=; b=Kor0kKJaXnW+kN+zQdyrIr6Eu2NJ5yGcNs43GzVq4oxOW2X0OnZl2ojreOrJco5B0fX1AU Zn++rxWVctyikZu7+0dNXXCm0I5tHIARxa8MebBbvNr0stk/CYGiXKN0R1j1+hOua4yvSc dgTp2x/dWTMp+nvKD0yL4q3bih3NeTU= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 04/28] migration-test: ppc64: fix FORTH test program Date: Fri, 10 Jan 2020 18:31:51 +0100 Message-Id: <20200110173215.3865-5-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 3zNnShorMHGmOG3z16Krzg-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 , wei@redhat.com, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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/migration-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index b0580dd541..26e2e77289 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -517,14 +517,14 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, } else if (strcmp(arch, "ppc64") =3D=3D 0) { machine_opts =3D "vsmt=3D8"; memory_size =3D "256M"; + start_address =3D PPC_TEST_MEM_START; + end_address =3D PPC_TEST_MEM_END; arch_source =3D g_strdup_printf("-nodefaults " "-prom-env 'use-nvramrc?=3Dtrue' -pr= om-env " "'nvramrc=3Dhex .\" _\" begin %x %x " "do i c@ 1 + i c! 1000 +loop .\" B\"= 0 " "until'", end_address, start_address= ); arch_target =3D g_strdup(""); - start_address =3D PPC_TEST_MEM_START; - end_address =3D PPC_TEST_MEM_END; } else if (strcmp(arch, "aarch64") =3D=3D 0) { init_bootfile(bootpath, aarch64_kernel, sizeof(aarch64_kernel)); machine_opts =3D "virt,gic-version=3Dmax"; --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578677808; cv=none; d=zohomail.com; s=zohoarc; b=MqKMMK3tzHpfu7jvp3WVHiKI4ROTaxFiTIYD8Giq4QB0nlD4ky6oS68MFt/MKphWMRzXJ7wadHyNV8HnYVIf40HvHWJKiiSGX68fPjXnW/oBOnFJUGpTTlSVgjI26LCjSP8RYIe9WxgAnohOAgJfowTDOX/ba+qppgVtqZh+VQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578677808; 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=zvTDQne+jYYuSTiUHa/PS8PRm8MB0e0ph2uScK4uXBU=; b=Z2ygqbLV3RgyW8eH8zb2BTOQp9m9wZ055DGvVp5jNBw+o07VZvFJAiXKSq0eMoL66m58mzbspLvmDwRCgotZYFr99OXStufTlKqMs/m7EJ8E5mpLIXvyAlzAv9H73zFvEs9jSwueK4tskZHdtQm+Zw7OHr5embJKOc6zCChQwJE= 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 1578677808167240.17372178815936; Fri, 10 Jan 2020 09:36:48 -0800 (PST) Received: from localhost ([::1]:49788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyDG-0007ZF-HG for importer@patchew.org; Fri, 10 Jan 2020 12:36:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45565) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipy9k-0003dw-9c for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipy9j-0001RP-7P for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:08 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:42225 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 1ipy9j-0001QF-2k for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33: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-131-SEE2xhYCPBO3O-bWFWjcXg-1; Fri, 10 Jan 2020 12:33: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 4E329800D41; Fri, 10 Jan 2020 17:33:03 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92BFB19C4F; Fri, 10 Jan 2020 17:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677586; 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=zvTDQne+jYYuSTiUHa/PS8PRm8MB0e0ph2uScK4uXBU=; b=WRiBpFaLKzMdAIcMzwT6Okw5fhdZLAnFoLGRH0lUImQ8i8/Nq2RLcL1qUsWSA/8ioJKLeD /THF1EVE1pwntEL/ne/xeJLSzsVZ537V2Pf7ny6bN2g/mWHmtHDw2fJ3HcwiIuQuvGEdF8 aCbD9Hc1/8uKxXQ5B69nDfFjhBEI7t4= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 05/28] runstate: ignore finishmigrate -> prelaunch transition Date: Fri, 10 Jan 2020 18:31:52 +0100 Message-Id: <20200110173215.3865-6-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: SEE2xhYCPBO3O-bWFWjcXg-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 b211921258..5401d6e440 100644 --- a/vl.c +++ b/vl.c @@ -1604,9 +1604,6 @@ static bool main_loop_should_exit(void) RunState r; ShutdownCause request; =20 - if (runstate_check(RUN_STATE_FINISH_MIGRATE)) { - return false; - } if (preconfig_exit_requested) { if (runstate_check(RUN_STATE_PRECONFIG)) { runstate_set(RUN_STATE_PRELAUNCH); @@ -1635,8 +1632,13 @@ static bool main_loop_should_exit(void) pause_all_vcpus(); qemu_system_reset(request); resume_all_vcpus(); + /* + * runstate can change in pause_all_vcpus() + * as iothread mutex is unlocked + */ if (!runstate_check(RUN_STATE_RUNNING) && - !runstate_check(RUN_STATE_INMIGRATE)) { + !runstate_check(RUN_STATE_INMIGRATE) && + !runstate_check(RUN_STATE_FINISH_MIGRATE)) { runstate_set(RUN_STATE_PRELAUNCH); } } --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678103; cv=none; d=zohomail.com; s=zohoarc; b=mv1zdyERGKxsGcrR4YlwidwnGF+YEVlAyueB19Kqq+epV7FuGVlLPF24ETitJ2Fo2trDfKqUa6KI2p+T1JDIYCuhfZrVxqCZ/kwPo0wSnSUAtsmsLX+GR9hNPAKFSlhZKsGSEZX42A7Lxv1lRj3gZpZihBT2QxuNVO1vzFdhxNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678103; 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=mnI/sbCMOcA0SZwWKL8BtRU3qflUGbMDQizc7NKUMq8=; b=gtDuh8aN3xsS4gvajbPAJyl0dtqQbDVdMXcxGx5NaQVYwlFxuY6gyfSHp4mJ7BIb3dzJZLBWA42YR12VoidNxQ9XW7JfOWBgEvsxo5CkhfEWNKYV4rAGInIb0uz+yRUaW+HIcsksR1CgdOmlAd2sAy6jy60sN8MpUwh4YlzqdIs= 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 1578678103013300.84468209874035; Fri, 10 Jan 2020 09:41:43 -0800 (PST) Received: from localhost ([::1]:49896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyI1-0005fw-Gz for importer@patchew.org; Fri, 10 Jan 2020 12:41:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45827) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipy9s-0003lj-3g for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipy9q-0001fa-QY for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:15 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:56817 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 1ipy9q-0001eb-Lb for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:14 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-365-rC9xlEHPMdCqfN11ClQ1tg-1; Fri, 10 Jan 2020 12:33:12 -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 A0BC21800D71; Fri, 10 Jan 2020 17:33:10 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id A298B19C4F; Fri, 10 Jan 2020 17:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677594; 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=mnI/sbCMOcA0SZwWKL8BtRU3qflUGbMDQizc7NKUMq8=; b=PGPPSsw2/NmKNnfd78LyyvOnl3G8WjXGYYRFEzCOKNGqAFml4ENTXedDsglz01Q49B8Zz5 1z5gOggUMpOsu2H5KUn2zaoo7hLmRPxNmp82naV2IbvITNN9/0C5PnhKdgAFPD5UZo1Jxr loAlh1FxE92gQlHhfqYjYKcmmp7rBOk= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 06/28] ram.c: remove unneeded labels Date: Fri, 10 Jan 2020 18:31:53 +0100 Message-Id: <20200110173215.3865-7-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: rC9xlEHPMdCqfN11ClQ1tg-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 , Daniel Henrique Barboza , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 6e678dbd2e..733aee61e3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2459,7 +2459,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr= _t start, ram_addr_t len) * it's the 1st request. */ error_report("ram_save_queue_pages no previous block"); - goto err; + return -1; } } else { ramblock =3D qemu_ram_block_by_name(rbname); @@ -2467,7 +2467,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr= _t start, ram_addr_t len) if (!ramblock) { /* We shouldn't be asked for a non-existent RAMBlock */ error_report("ram_save_queue_pages no block '%s'", rbname); - goto err; + return -1; } rs->last_req_rb =3D ramblock; } @@ -2476,7 +2476,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr= _t start, ram_addr_t len) error_report("%s request overrun start=3D" RAM_ADDR_FMT " len=3D" RAM_ADDR_FMT " blocklen=3D" RAM_ADDR_FMT, __func__, start, len, ramblock->used_length); - goto err; + return -1; } =20 struct RAMSrcPageRequest *new_entry =3D @@ -2492,9 +2492,6 @@ int ram_save_queue_pages(const char *rbname, ram_addr= _t start, ram_addr_t len) qemu_mutex_unlock(&rs->src_page_req_mutex); =20 return 0; - -err: - return -1; } =20 static bool save_page_use_compression(RAMState *rs) @@ -3097,8 +3094,6 @@ int ram_postcopy_send_discard_bitmap(MigrationState *= ms) */ int ram_discard_range(const char *rbname, uint64_t start, size_t length) { - int ret =3D -1; - trace_ram_discard_range(rbname, start, length); =20 RCU_READ_LOCK_GUARD(); @@ -3106,7 +3101,7 @@ int ram_discard_range(const char *rbname, uint64_t st= art, size_t length) =20 if (!rb) { error_report("ram_discard_range: Failed to find block '%s'", rbnam= e); - goto err; + return -1; } =20 /* @@ -3118,10 +3113,7 @@ int ram_discard_range(const char *rbname, uint64_t s= tart, size_t length) length >> qemu_target_page_bits()); } =20 - ret =3D ram_block_discard_range(rb, start, length); - -err: - return ret; + return ram_block_discard_range(rb, start, length); } =20 /* --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578677949; cv=none; d=zohomail.com; s=zohoarc; b=gQZNWRllnUqraewzZJoHfzanfQfbnap0GW2BHCG9ZyySox+tIP1BmJz4FdH0abuziHUYXS1l06Jy1CtXf5PAR3TXwI7lG0PxkjuWy/dD47Z2O/9MpJyjncopvvwyPcNyRDYjHaSMAfqwTn9Pq/zehXnTAne0r20OFq6FY4WWn9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578677949; 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=eEHRcnwANxr423cwLkkLHDuGP/Ef0JMPZnyINFPFaGo=; b=F432IuU1ifXvtkZMFzam8b04fKSATjr87UURmsJD8UC5yL++V275aJNI+U1YL1KC2gm//jJEpt1J6LKXhgzhVy/feXa7rDEIjusBH6MN4aRCgxAbU+1H3g91Vyb0EzhtzBbzoMmjFtuMkxreBAQhGGzUfZrvlg93izgzQ8R3g8g= 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 1578677949151823.7437400577157; Fri, 10 Jan 2020 09:39:09 -0800 (PST) Received: from localhost ([::1]:49848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyFX-0002df-Mb for importer@patchew.org; Fri, 10 Jan 2020 12:39:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46215) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyA0-0003vk-PQ for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipy9y-00021A-3t for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:24 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60362 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 1ipy9x-000202-UZ for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:22 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-234-5cgGwGj_NValYyU-6de_Vg-1; Fri, 10 Jan 2020 12:33:19 -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 089E1801E70; Fri, 10 Jan 2020 17:33:18 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 002C219C4F; Fri, 10 Jan 2020 17:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677601; 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=eEHRcnwANxr423cwLkkLHDuGP/Ef0JMPZnyINFPFaGo=; b=DERXxMKSy/W6sa8yVGBkX/SAjpkvrxKuMum7AF6m8dhY0ie1487bd5lDWB1goGH4XWki5Q HaBW5SVTze7pG3oRXuFQ+RoTRtNqmCnKXfV+Z5vX8n7KWB+Mq9mkY5FdlT8P7oJUy4VBeQ v+6y/8k/od9BNJLdv/56H/CIDp3NSv4= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 07/28] migration: Rate limit inside host pages Date: Fri, 10 Jan 2020 18:31:54 +0100 Message-Id: <20200110173215.3865-8-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 5cgGwGj_NValYyU-6de_Vg-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 , Peter Maydell , Jason Wang , Peter Xu , Juan Quintela , "Michael S. Tsirkin" , =?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 733aee61e3..718a02a974 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2639,6 +2639,8 @@ static int ram_save_host_page(RAMState *rs, PageSearc= hStatus *pss, =20 pages +=3D tmppages; pss->page++; + /* Allow rate limiting to happen in the middle of huge pages */ + migration_rate_limit(); } while ((pss->page & (pagesize_bits - 1)) && offset_in_ramblock(pss->block, pss->page << TARGET_PAGE_BITS)= ); =20 diff --git a/migration/trace-events b/migration/trace-events index 6dee7b5389..2f9129e213 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -138,12 +138,12 @@ migrate_send_rp_recv_bitmap(char *name, int64_t size)= "block '%s' size 0x%"PRIi6 migration_completion_file_err(void) "" migration_completion_postcopy_end(void) "" migration_completion_postcopy_end_after_complete(void) "" +migration_rate_limit_pre(int ms) "%d ms" +migration_rate_limit_post(int urgent) "urgent: %d" migration_return_path_end_before(void) "" migration_return_path_end_after(int rp_error) "%d" migration_thread_after_loop(void) "" migration_thread_file_err(void) "" -migration_thread_ratelimit_pre(int ms) "%d ms" -migration_thread_ratelimit_post(int urgent) "urgent: %d" migration_thread_setup_complete(void) "" open_return_path_on_source(void) "" open_return_path_on_source_continue(void) "" --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678288; cv=none; d=zohomail.com; s=zohoarc; b=YVMIW22wnOhRT0AhB1zXBvRmsBWmkxoTNsPemJIi2EP1cvaLmO4T14hDqgO9LWQjgI/z/3hQCtYdpM7/heih0xTUutnzhfCcEdCg3ShycFTe9UUjraCMNsfpON8l+aD0+U65ChohiryFxbty3CZBCH243SKxJVjU6DuqWgWyc/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678288; 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=E4Uw1VV0CdF0tG79RkNLvkI0PfagpvJFL0tjASsB1KI=; b=GzZ5ow7Wgy+QCJ93kFy7R11iuNJjZLuuQeEGRC0luSRDVkNNbbgUkhDNleivtyYGZ/oaXPW8JhSbLyayGw8yOYHOs51zEi51Um6o29IzOWBi+odwfTduf48BBOVd7Ao4ztZQtDyrVU5OgCJRlHK7TsMbqufreewMTQzf3Q9L178= 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 1578678288532499.9464758669061; Fri, 10 Jan 2020 09:44:48 -0800 (PST) Received: from localhost ([::1]:49944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyKx-0002kR-9m for importer@patchew.org; Fri, 10 Jan 2020 12:44:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46605) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyAC-00044C-6O for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyA8-0002Il-6d for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:36 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:38922 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 1ipyA8-0002HP-0t for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33: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-25-Y_v9ObPWPBWvB-hAC018TQ-1; Fri, 10 Jan 2020 12:33: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 DD65C800D48; Fri, 10 Jan 2020 17:33:27 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E1B119C4F; Fri, 10 Jan 2020 17:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677611; 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=E4Uw1VV0CdF0tG79RkNLvkI0PfagpvJFL0tjASsB1KI=; b=HicEyk3iGAAo46BM8UxslnYKMCwoR+n7SppDujwJQWvfYu3Vc8Uud6ZGtdoZ5njPYQurfL FCaAOt9WjS67xBVaShpPc1XF1u3FvNiHMTQOXo59WcbjaiAhSy7QiNJj9G1nKAXinjvnOe iccpcR/xskgzRnZ8iZ0YuIRER0Ns6FU= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 08/28] migration: Support QLIST migration Date: Fri, 10 Jan 2020 18:31:55 +0100 Message-Id: <20200110173215.3865-9-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: Y_v9ObPWPBWvB-hAC018TQ-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: Corey Minyard , Peter Maydell , Jason Wang , Peter Xu , Juan Quintela , "Michael S. Tsirkin" , =?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 4aef72c426..0dc04fc48e 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..49e8a3ef46 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, *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 From nobody Thu May 2 01:49:49 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=1578678498; cv=none; d=zohomail.com; s=zohoarc; b=b15oEjoFZri09c2KDUxk3ndv9Q34CEQMxWZg3F/3ISNkIqQ8p7voevx1FxbZPdD+wfLqhUGDcUESGN2uZiJhOtx66p+xCbdxje+6tTu1MPmM00Rulz3NY3kT9tm/JLFTzM3JDMFjGjjEgax75MToD3RzWB4H27RyVXxZoOao2hw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678498; 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=Pz+s9M+tNyF3FhX6uxxaz9RHqgmTiwdtpS4d7TxB4vIn/J50PvOE9yME3C2/SlnCWFxPOMgCjhnBJdxg3hdjXyFIUWCuDBXkaZW+DRb1VvyWmb5N3/TSGM3qWqseVtmoilvOTQNItb5vuSVcXES2FCgCdDrqgQJx9oweAtBDjsI= 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 1578678498009472.5632115382741; Fri, 10 Jan 2020 09:48:18 -0800 (PST) Received: from localhost ([::1]:49996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyOO-0006Ua-BE for importer@patchew.org; Fri, 10 Jan 2020 12:48:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46860) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyAJ-0004FH-Ta for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyAI-0002bg-GP for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:43 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:24874 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 1ipyAI-0002aG-Bl for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:42 -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-330-Fm2T6eCWPFaTofxLe91aaQ-1; Fri, 10 Jan 2020 12:33:40 -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 65FC6800D48; Fri, 10 Jan 2020 17:33:38 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DB9619C4F; Fri, 10 Jan 2020 17:33:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677621; 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=YBnaC2CXPjlVuwkZ48aAbA2rqk+QNlyrs5sqxzdliQ5DZO0ev1R+jSjlDqqJt2N2oKUQm0 ec0uoDHU9/Canf0kBQsYjGsRlqRTWjJ72zCQCoygVA0l11kGQ3+itTudtV8NGDE2hEixqX RUKtcHg3C1JgEpjJvT+ARK+oxMy5qtg= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 09/28] migration: Fix incorrect integer->float conversion caught by clang Date: Fri, 10 Jan 2020 18:31:56 +0100 Message-Id: <20200110173215.3865-10-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: Fm2T6eCWPFaTofxLe91aaQ-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 , Peter Maydell , Jason Wang , Juan Quintela , "Michael S. Tsirkin" , 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 Thu May 2 01:49:49 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=1578678348; cv=none; d=zohomail.com; s=zohoarc; b=bn1czyiEFtwCWTM18qyxiy3/RxHwqLDmZtL9SXFxSzzt6nFW3IjsOAv9kVmnMcD3LLULVzXztJ2uLsTi6G+/sRuqUCUCM4zdaLHWD2bPOd3s07kmPkq5WId5y0PVPRqJnd5CROF2qFU0NgJEgS4ssfgEwDw3T7hSuzzYtKDRClE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678348; 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=JJC6KwOgLVw/RZoXD/aXOb0rj9wFTB0eahmqACbTGlUV5zmotRQl30m6q6oG7rjoJ9IYXTMoMj7YrxX1LaVST8pGFTVvtNSJoNtUwQJx0JOO75QeEb7c7468hT/HRwrRxSdPcXSoGD9XyFW7cH1G2Cekq2thl5LfGaUUchDrDvM= 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 1578678348070241.26855118277388; Fri, 10 Jan 2020 09:45:48 -0800 (PST) Received: from localhost ([::1]:49950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyLx-0003Zk-R9 for importer@patchew.org; Fri, 10 Jan 2020 12:45:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48088) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyAh-0004qI-Oh for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyAg-0003j6-LP for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:07 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22487 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 1ipyAg-0003hK-GM for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:06 -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-343-N9qKbkM6P3-YkKeEKJdSYg-1; Fri, 10 Jan 2020 12:34: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 2D8731800D6B; Fri, 10 Jan 2020 17:33:46 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id B55A419C4F; Fri, 10 Jan 2020 17:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677646; 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=XpvbLD8oCwHGgAWNRe+4aOkn+Ndz6uBb5cTfHTFg0xH2FY7S9gEKYYyYa/gjeJxDBt+m+m MkXtfAhtTcSOrAoGpWhzp/JFfEu6Gafjj6wzCOiHKlkRDkFCdox2GFZ1d58vidPOmBawz9 fL2IHiISLIS791lXhaldmI8VqsiccNE= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 10/28] migration: Fix the re-run check of the migrate-incoming command Date: Fri, 10 Jan 2020 18:31:57 +0100 Message-Id: <20200110173215.3865-11-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: N9qKbkM6P3-YkKeEKJdSYg-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: Corey Minyard , Peter Maydell , Jason Wang , Juan Quintela , "Michael S. Tsirkin" , =?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 Thu May 2 01:49:49 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=1578678135; cv=none; d=zohomail.com; s=zohoarc; b=EmZM2o3hkk9NyK7LHYY8/C/emLMXWccL1SvTSgambrI517B1o9doa2qeZtIcitdFA+f3VKtnt6vkWtN+YqRtlLpc4IUxtYGXZHwwyCsQnCe0S1W0myYNCAggf+AWe/YHa0YDr7jL61rd1y45c/obc/p3PqocPeyEWqIUd2RtBNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678135; 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=g86U4vqSGIR0dmz+kdmgnvzIH70mrjX7GCmXf0kQEdhdWLerXFMVODw82o14Onm/IIcVatCbqIj5ZJddyPqEcHHiTuCChYPmgNv+ZO+82nRqahgdcsy6SwAEMRPXK/sxesfnHc0zUqvRbQJ9gJkdlgaFBeIAe58OAmztlx2S8+o= 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 1578678135665556.7994808757704; Fri, 10 Jan 2020 09:42:15 -0800 (PST) Received: from localhost ([::1]:49904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyIY-0006bM-7p for importer@patchew.org; Fri, 10 Jan 2020 12:42:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47569) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyAY-0004ar-UL for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyAX-0003Gd-M2 for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49403 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 1ipyAX-0003EM-Gj for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:33:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-24-nGu7bzSpOF-94JielOxiyg-1; Fri, 10 Jan 2020 12:33:55 -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 8C04C1005513; Fri, 10 Jan 2020 17:33:53 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F4FD19C4F; Fri, 10 Jan 2020 17:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677637; 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=hg5JRXqdMh6qHgYiRfAXEKPdvAT3/+1GOeX3rRaG7THxanYb0nBQ6sKajaAG6rvfqRocee 7Omve2CbWL7K8i7BgruqCcW664O6LA/IlklGz2kvy3U8Adk4vCrbyjO16EWUAkartx2+gN NHwzBhIDftLGgYJbIEUsgvIbHmnJ9uQ= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 11/28] misc: use QEMU_IS_ALIGNED Date: Fri, 10 Jan 2020 18:31:58 +0100 Message-Id: <20200110173215.3865-12-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: nGu7bzSpOF-94JielOxiyg-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Juan Quintela Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Berger Reviewed-by: Paolo Bonzini Signed-off-by: Juan Quintela --- exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index d4b769d0d4..1feda49ca1 100644 --- a/exec.c +++ b/exec.c @@ -3895,7 +3895,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t st= art, size_t length) =20 uint8_t *host_startaddr =3D rb->host + start; =20 - if ((uintptr_t)host_startaddr & (rb->page_size - 1)) { + if (!QEMU_PTR_IS_ALIGNED(host_startaddr, rb->page_size)) { error_report("ram_block_discard_range: Unaligned start address: %p= ", host_startaddr); goto err; @@ -3903,7 +3903,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t st= art, size_t length) =20 if ((start + length) <=3D rb->used_length) { bool need_madvise, need_fallocate; - if (length & (rb->page_size - 1)) { + if (!QEMU_IS_ALIGNED(length, rb->page_size)) { error_report("ram_block_discard_range: Unaligned length: %zx", length); goto err; --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678163; cv=none; d=zohomail.com; s=zohoarc; b=bnYoDPKE8bHipCYEPqh2FA5Aou0DLtDpDdHfSBt15EHz+rfMw3i/oG0ZnqFKbBkPBhww1qF7Ma+V1wVyRWCSHZXj9H5/Sk+jVonRQG6reYjmaoBq/KBusqSMvATB76zb4BKTfboRc4ieNFTf12+T9p3t/Lrj63oogA7qNSK5ejE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678163; 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=SA4BlBZWRx5uWUsauiLpGHTRcwHWzILd1H/rvqQjb8718050xo3gdP/2+5fedYgy4zdT5Tg5skcvPuuuW/ejmyEf0pc058LkyNsGj4NALxzxmJi+Hj30bGvszaOmLf6MUSOr0RRXb5QHe809MPUTBRXH8H13RDDeSITbARgRIjY= 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 1578678163242625.0652305905166; Fri, 10 Jan 2020 09:42:43 -0800 (PST) Received: from localhost ([::1]:49906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyIz-0007Xc-Jr for importer@patchew.org; Fri, 10 Jan 2020 12:42:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47969) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyAg-0004nI-3N for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyAe-0003d8-Rv for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:05 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26045 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 1ipyAe-0003bh-Oh for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:04 -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-384-syCVE1FMMziir2jLA5ncog-1; Fri, 10 Jan 2020 12:34:00 -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 5EB91593AF; Fri, 10 Jan 2020 17:33:58 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE0DC19C4F; Fri, 10 Jan 2020 17:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677644; 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=PClEyZhZ0qp0ZP2N+7x6mak1K16T5UWcx8P8EgwYyZwEU1cXSeQ3prbSxTIOht1cpqn30P cclAfdzb7o+ZhbGo6e0tQRNWR/9H3Opky9CR54rpeVzWxxv4L9o/TjSYDR8f5lWsifNCrB 3+HoPlunIuHPs2KFcV2wNpRrnFex4zo= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 12/28] migration: add savevm_state_handler_remove() Date: Fri, 10 Jan 2020 18:31:59 +0100 Message-Id: <20200110173215.3865-13-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: syCVE1FMMziir2jLA5ncog-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Scott Cheloha , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Scott Cheloha Create a function to abstract common logic needed when removing a SaveStateEntry element from the savevm_state.handlers queue. For now we just remove the element. Soon it will involve additional cleanup. Signed-off-by: Scott Cheloha Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/savevm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 59efc1981d..30d980caa2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -725,6 +725,11 @@ static void savevm_state_handler_insert(SaveStateEntry= *nse) } } =20 +static void savevm_state_handler_remove(SaveStateEntry *se) +{ + QTAILQ_REMOVE(&savevm_state.handlers, se, entry); +} + /* TODO: Individual devices generally have very little idea about the rest of the system, so instance_id should be removed/replaced. Meanwhile pass -1 as instance_id if you do not already have a clearly @@ -777,7 +782,7 @@ void unregister_savevm(VMStateIf *obj, const char *idst= r, void *opaque) =20 QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) { if (strcmp(se->idstr, id) =3D=3D 0 && se->opaque =3D=3D opaque) { - QTAILQ_REMOVE(&savevm_state.handlers, se, entry); + savevm_state_handler_remove(se); g_free(se->compat); g_free(se); } @@ -841,7 +846,7 @@ void vmstate_unregister(VMStateIf *obj, const VMStateDe= scription *vmsd, =20 QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) { if (se->vmsd =3D=3D vmsd && se->opaque =3D=3D opaque) { - QTAILQ_REMOVE(&savevm_state.handlers, se, entry); + savevm_state_handler_remove(se); g_free(se->compat); g_free(se); } --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678039; cv=none; d=zohomail.com; s=zohoarc; b=eAFw+6uTn2I3QK3qqhku60+fFD0xx5aROsQDB5Go0sb1Wk0mwMiSbLOAvv9DL7g1tEnybkXxg+FKOWfBbN2drChhRBVHKhwQTX52+PucD6ABe9GyahsIf8dLZkf6JUmKmsDvA/+zfbqIiGC1Lg9W/oRp6R9e+AJD2We5qKC1A4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678039; 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=lrEZrWCJBIGbVq8UCTyPKNwCJs6DYDc7sGBrFVoehXIe3Vxs1im0RIDLiJNHBBzv+JDF7U1znt30K5A4w/mNlC0FdxN7taTRMtHCNS9DUuGUaBNEyaFSKMHmrj3OVLhSdZj2XCWGEQg/3Kcy/2OOENBHK2dBgMHY8I/7xQMiwDc= 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 1578678039333747.3533689391272; Fri, 10 Jan 2020 09:40:39 -0800 (PST) Received: from localhost ([::1]:49866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyGz-000407-4J for importer@patchew.org; Fri, 10 Jan 2020 12:40:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48304) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyAl-0004wU-IB for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyAk-0003vH-9A for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:11 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:42793 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 1ipyAk-0003tt-4U for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:10 -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-310-koAjN4TwOPO0fmewik4BYg-1; Fri, 10 Jan 2020 12:34:07 -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 D45DD800D48; Fri, 10 Jan 2020 17:34:05 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1F1F272CB; Fri, 10 Jan 2020 17:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677649; 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=hFPBwPobaspc4CJk6SBGwDTU45MHqMvzFfjW1EG+omWz2WIul7fHO2u5irBs67dypm9T6+ Vnru4TXuYWEE5nZ8FtP+XnIkfDQ4AN6zX7svpZD77WriO2l3oRSFAgKRT2G3wCS6dX9PqJ ifPSBnI9HFDlYzzkf1tYTl1YLtbOJoE= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 13/28] migration: savevm_state_handler_insert: constant-time element insertion Date: Fri, 10 Jan 2020 18:32:00 +0100 Message-Id: <20200110173215.3865-14-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: koAjN4TwOPO0fmewik4BYg-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Scott Cheloha , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Scott Cheloha savevm_state's SaveStateEntry TAILQ is a priority queue. Priority sorting is maintained by searching from head to tail for a suitable insertion spot. Insertion is thus an O(n) operation. If we instead keep track of the head of each priority's subqueue within that larger queue we can reduce this operation to O(1) time. savevm_state_handler_remove() becomes slightly more complex to accomodate these gains: we need to replace the head of a priority's subqueue when removing it. With O(1) insertion, booting VMs with many SaveStateEntry objects is more plausible. For example, a ppc64 VM with maxmem=3D8T has 40000 such objects to insert. Signed-off-by: Scott Cheloha Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/savevm.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 30d980caa2..e57686bca7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -250,6 +250,7 @@ typedef struct SaveStateEntry { =20 typedef struct SaveState { QTAILQ_HEAD(, SaveStateEntry) handlers; + SaveStateEntry *handler_pri_head[MIG_PRI_MAX + 1]; int global_section_id; uint32_t len; const char *name; @@ -261,6 +262,7 @@ typedef struct SaveState { =20 static SaveState savevm_state =3D { .handlers =3D QTAILQ_HEAD_INITIALIZER(savevm_state.handlers), + .handler_pri_head =3D { [MIG_PRI_DEFAULT ... MIG_PRI_MAX] =3D NULL }, .global_section_id =3D 0, }; =20 @@ -709,24 +711,42 @@ static void savevm_state_handler_insert(SaveStateEntr= y *nse) { MigrationPriority priority =3D save_state_priority(nse); SaveStateEntry *se; + int i; =20 assert(priority <=3D MIG_PRI_MAX); =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (save_state_priority(se) < priority) { + for (i =3D priority - 1; i >=3D 0; i--) { + se =3D savevm_state.handler_pri_head[i]; + if (se !=3D NULL) { + assert(save_state_priority(se) < priority); break; } } =20 - if (se) { + if (i >=3D 0) { QTAILQ_INSERT_BEFORE(se, nse, entry); } else { QTAILQ_INSERT_TAIL(&savevm_state.handlers, nse, entry); } + + if (savevm_state.handler_pri_head[priority] =3D=3D NULL) { + savevm_state.handler_pri_head[priority] =3D nse; + } } =20 static void savevm_state_handler_remove(SaveStateEntry *se) { + SaveStateEntry *next; + MigrationPriority priority =3D save_state_priority(se); + + if (se =3D=3D savevm_state.handler_pri_head[priority]) { + next =3D QTAILQ_NEXT(se, entry); + if (next !=3D NULL && save_state_priority(next) =3D=3D priority) { + savevm_state.handler_pri_head[priority] =3D next; + } else { + savevm_state.handler_pri_head[priority] =3D NULL; + } + } QTAILQ_REMOVE(&savevm_state.handlers, se, entry); } =20 --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678200; cv=none; d=zohomail.com; s=zohoarc; b=JlccBWLYFkLFW1XcE3CFWbIFn6qO4g79HuZIHs6H9TFh4g757eIFJ/KZIEm1iZ6KuYCBINWTBrIj2npu37gCHcw6vAsBS3VEHE3DG/pmSMU2fxCtySmVTiI17iW69shTmh4JduGzTKNsR/nWOGfrxHrVlp1t1tIzJ0dazBhUEbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678200; 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=JxCbwD9ESrOvIVropC3VeESx3dDGEoVExeMI/hEinrQ=; b=ThN0NzHjo46QVKLopZx4SVsS7gIrOR5gqZwSXbeHdMLHt55SEI7RHw2dUIN1I8ioEZhTdbrxckVlioXPArrxVOvKliOgq2fg+0FXRfSewY7Ka0V4Z2i8Wif5fNfqmIkrqOZ3Q+yW7XYLDjQUMEAjnO0fnwWHSTMKZQN84rWlyDo= 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 157867820069086.34244667269093; Fri, 10 Jan 2020 09:43:20 -0800 (PST) Received: from localhost ([::1]:49914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyJa-0000I8-Ro for importer@patchew.org; Fri, 10 Jan 2020 12:43:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48816) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyAu-0005DI-N6 for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyAt-0004P7-Ga for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34:20 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:32779 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 1ipyAt-0004Mt-8j for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:34: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-168-NtDE5FqrPm-z3j2whetV2A-1; Fri, 10 Jan 2020 12:34: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 B5F2D107ACC4; Fri, 10 Jan 2020 17:34:14 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32072272CB; Fri, 10 Jan 2020 17:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677658; 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=JxCbwD9ESrOvIVropC3VeESx3dDGEoVExeMI/hEinrQ=; b=Jm/jMyqigt0K43/UqSrY88ZcM4M6kKQRGk4t9stSPdUa+xzdB2IcXrmYDnzwMxC65bk4y4 8jYUrzJAUC2ShPNsjjRGhvlhg/hFaiVQJckVLxEIg99ixRpoYAp77rO9H8pU6gYEyUz0C2 4b9xIh/3Nyi7iG6eUWBlA3b220dZjLg= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 14/28] migration/ram: Yield periodically to the main loop Date: Fri, 10 Jan 2020 18:32:01 +0100 Message-Id: <20200110173215.3865-15-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: NtDE5FqrPm-z3j2whetV2A-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Yury Kotov , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 718a02a974..31d21b7f6b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4246,7 +4246,7 @@ static void colo_flush_ram_cache(void) */ static int ram_load_precopy(QEMUFile *f) { - int flags =3D 0, ret =3D 0, invalid_flags =3D 0, len =3D 0; + int flags =3D 0, ret =3D 0, invalid_flags =3D 0, len =3D 0, i =3D 0; /* ADVISE is earlier, it shows the source has the postcopy capability = on */ bool postcopy_advised =3D postcopy_is_advised(); if (!migrate_use_compression()) { @@ -4258,6 +4258,17 @@ static int ram_load_precopy(QEMUFile *f) void *host =3D NULL; uint8_t ch; =20 + /* + * Yield periodically to let main loop run, but an iteration of + * the main loop is expensive, so do it each some iterations + */ + if ((i & 32767) =3D=3D 0 && qemu_in_coroutine()) { + aio_co_schedule(qemu_get_current_aio_context(), + qemu_coroutine_self()); + qemu_coroutine_yield(); + } + i++; + addr =3D qemu_get_be64(f); flags =3D addr & ~TARGET_PAGE_MASK; addr &=3D TARGET_PAGE_MASK; --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678793; cv=none; d=zohomail.com; s=zohoarc; b=GhSL+iB+GvuWCt5JZfsjHIqBgJOZcc6+eh2/vWvROAELrN7UIE2lx+SEzxUoDqWnYyHvwnEGpFZPZty3HPivHV0OWVteDchmZl38UazUArWthzIEj1Gg8PQaxHVAP1z2QEMSXUTiXBNI8jB3wYYqPT/FyUwLAlDZLHPmLkyy0Ys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678793; 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=OisJlcbsKKct9fJ9vFighsrr4pIY6/pz8QAKoFLGOWk=; b=jGvcZO/XwpX+i+goEo+Y+NNvVBtIJjkTE/IJS8DZhWrVGHonc/BMLwkoUTukWujazjXUgxEEncKvhS/sPc6EVvjUGeMRVdDRffWc6lP6hIa6jpHIOWKaMck1HNvDTaFySDTHD8zGkpYznocn46BlvshlHvBlgHHC94uLa8YuKrM= 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 1578678793742691.4462661448395; Fri, 10 Jan 2020 09:53:13 -0800 (PST) Received: from localhost ([::1]:50076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyTA-00053Z-7Z for importer@patchew.org; Fri, 10 Jan 2020 12:53:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50448) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyBc-0006R8-Rb for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyBb-0005pV-MB for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:04 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53891 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 1ipyBb-0005ng-FB for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:03 -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-15-f4aR5GAHPNm5748OnqYHmw-1; Fri, 10 Jan 2020 12:34:59 -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 9C66A800D48; Fri, 10 Jan 2020 17:34:57 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1224119C4F; Fri, 10 Jan 2020 17:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677703; 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=OisJlcbsKKct9fJ9vFighsrr4pIY6/pz8QAKoFLGOWk=; b=NYHDnDMJvIVp0+g9MFCPk3tNxe1Hx60Dfeb7Adu53IlwJIaEedkgoYKz9bQVta/N8KM2ac pVoMz4zirjgCbMBBO4Dgr30OLk88ZtH8q9rTfWvFTqWAcmFvv0m94SW3Gtm6zvKGTy1Vbc giPuhlpATFVQINn0aToBJTTwz+pFyZ8= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 15/28] migration/postcopy: reduce memset when it is zero page and matches_target_page_size Date: Fri, 10 Jan 2020 18:32:02 +0100 Message-Id: <20200110173215.3865-16-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: f4aR5GAHPNm5748OnqYHmw-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Wei Yang , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 31d21b7f6b..6702a3203e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4126,7 +4126,13 @@ static int ram_load_postcopy(QEMUFile *f) switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { case RAM_SAVE_FLAG_ZERO: ch =3D qemu_get_byte(f); - memset(page_buffer, ch, TARGET_PAGE_SIZE); + /* + * Can skip to set page_buffer when + * this is a zero page and (block->page_size =3D=3D TARGET_PAG= E_SIZE). + */ + if (ch || !matches_target_page_size) { + memset(page_buffer, ch, TARGET_PAGE_SIZE); + } if (ch) { all_zero =3D false; } --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678379; cv=none; d=zohomail.com; s=zohoarc; b=MZTsWquRSsErYJBYRBsfQB4hlgI4KE3rBBFpoiKpsnmzJ1PHe8ssejAfG6XObbM5+6igy/m+jfLppeiLkqwdQ0LvrRzCszTP8J6GrNRXGVMnS/duqVevQ498v8aPfloNwEOZxaTMJ4rgv36xOqkM1v/ecMhkDs+FXuKygjYeG7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678379; 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=1crBoDA7dZjLh/vd5aacO45W4I+MDUclKl+K7u5CGQY=; b=nJAi5L+KZAYJXneO6J5lQv2QOPWycnm34aa88DMVjozn0WIoS1Wh0rPCTzMg8nGrdATarrHvz+pE5s5iIiyrB9RmI9OOmzmgU7WYV3SsXHlOyOrA2rIz9hCkq5yOx+p94TyFznt7rnStawAbRviXykpvNZf3v8715e3uk1qvqDU= 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 1578678379478904.6063585493064; Fri, 10 Jan 2020 09:46:19 -0800 (PST) Received: from localhost ([::1]:49958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyMU-00040o-3V for importer@patchew.org; Fri, 10 Jan 2020 12:46:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50652) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyBl-0006XF-6T for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyBk-00065p-1p for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:13 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:36388 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 1ipyBi-000605-6u for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:10 -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-44-C_aiEUGINXaif_n-gJJJwQ-1; Fri, 10 Jan 2020 12:35:06 -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 DD9501800D6B; Fri, 10 Jan 2020 17:35:04 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1CFB19C4F; Fri, 10 Jan 2020 17:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677708; 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=1crBoDA7dZjLh/vd5aacO45W4I+MDUclKl+K7u5CGQY=; b=git4lddNDcHUi3D9b6mVFglhhhOXx3H2HAvzoZhkmPicLgPRn+IRPv81fQnbzsxu+TVc0s GQc9iPu9u0ioptCLjehdhep51UfTg6+P9Jy7Mo/D96ITIJ3pFjB5NUyx40EybeqwFKte/F 86d5HL6Q1MAVLmMJIEHJoklxLYITnhw= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 16/28] migration/postcopy: wait for decompress thread in precopy Date: Fri, 10 Jan 2020 18:32:03 +0100 Message-Id: <20200110173215.3865-17-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: C_aiEUGINXaif_n-gJJJwQ-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Wei Yang , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 6702a3203e..f9e6f20024 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4421,6 +4421,7 @@ static int ram_load_precopy(QEMUFile *f) } } =20 + ret |=3D wait_for_decompress_done(); return ret; } =20 @@ -4452,8 +4453,6 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) } else { ret =3D ram_load_precopy(f); } - - ret |=3D wait_for_decompress_done(); } trace_ram_load_complete(ret, seq_iter); =20 --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678425; cv=none; d=zohomail.com; s=zohoarc; b=ch3y5jPze4Ps3+3s+xm2n8bDmZKC8qvqEbHrHxZfqcCVOs5VVNFC7/eUjei3kU0yVsUl3K58GK5pKHxlJNLfW7ert1yRMLf1tntw7rPmeieNHIgmuM0QtluV4qo2WUfBwPF9AIDP+UoMzofWuD55G+sNszInOSeK5yiWsjc9DaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678425; 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=EQALvcPXzFFV1dUEGEEm7mAMYA5rBk0OVau7kpARh/c=; b=G5hL1fFFpSy5wpT5IqSGjVLuSHArEOxGzM96xenypzrQF4ROfoqRMXWTmejF9CXf7nJHoONeI8zN2JNpXFll1XUEV9/P6NBGsRwgYEa6DRwqWxIRNlhw2NWLWyV4bJl7DZlM4+hGlzixDT5nNKnSLQHypz/RCV7lI8fLaHn0/Nw= 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 1578678425785218.56875839757947; Fri, 10 Jan 2020 09:47:05 -0800 (PST) Received: from localhost ([::1]:49976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyND-00050C-FO for importer@patchew.org; Fri, 10 Jan 2020 12:47:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50838) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyBq-0006bM-8E for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyBo-0006IJ-FO for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:18 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32701 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 1ipyBo-0006Gt-7M for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:16 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-399-YjNmZRo7NbOgheaYLYTEXQ-1; Fri, 10 Jan 2020 12:35:14 -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 344A4100550E; Fri, 10 Jan 2020 17:35:12 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A18519C4F; Fri, 10 Jan 2020 17:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677715; 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=EQALvcPXzFFV1dUEGEEm7mAMYA5rBk0OVau7kpARh/c=; b=XMiaae0s9M70Zm9M1h3YMyXOkPPqwQpGTwKBTJamtgA/FISSBwFok39JMi5MHJYDq+Puym VEDhegoI3bx6S9eF1k83m+7bKKOcooJMjvITvqny9+zKkP/OPEBT3mlYCJctlayYT0tkzK jsy5HqDHGiRDUB6WuHbpNLD9CaFR33I= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 17/28] migration/postcopy: count target page number to decide the place_needed Date: Fri, 10 Jan 2020 18:32:04 +0100 Message-Id: <20200110173215.3865-18-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: YjNmZRo7NbOgheaYLYTEXQ-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Wei Yang , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 f9e6f20024..f20dfc3b68 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4052,6 +4052,7 @@ static int ram_load_postcopy(QEMUFile *f) void *postcopy_host_page =3D mis->postcopy_tmp_page; void *last_host =3D NULL; bool all_zero =3D false; + int target_pages =3D 0; =20 while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) { ram_addr_t addr; @@ -4086,6 +4087,7 @@ static int ram_load_postcopy(QEMUFile *f) ret =3D -EINVAL; break; } + target_pages++; matches_target_page_size =3D block->page_size =3D=3D TARGET_PA= GE_SIZE; /* * Postcopy requires that we place whole host pages atomically; @@ -4117,8 +4119,10 @@ static int ram_load_postcopy(QEMUFile *f) * If it's the last part of a host page then we place the host * page */ - place_needed =3D (((uintptr_t)host + TARGET_PAGE_SIZE) & - (block->page_size - 1)) =3D=3D 0; + if (target_pages =3D=3D (block->page_size / TARGET_PAGE_SIZE))= { + place_needed =3D true; + target_pages =3D 0; + } place_source =3D postcopy_host_page; } last_host =3D host; --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678953; cv=none; d=zohomail.com; s=zohoarc; b=KyoBIM75kuIHiLcio+UYikyqZkfbxI3PfDJl4g17wA5s2Xz5PGCVNqctMfAYDpgNDt96Efc6XUlV/zj4Iqslsrq9jIEstlyA+hkFdKMyZGKohV5seYKNyguJfHgy49sztqGJYjhihfPvrMDw+gT0XzsP+58COujFtprP5RDd0+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678953; 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=Oxe1AWGfIOdagHVu8yxuMNHyn0Md0ln06wq1254wDAI=; b=jxNKFnqsYLBEg8h8Gw3EuMVPf0tyUk5NlElQIZmogerq+lpfZ5At0J/C8AiKJNMyyTvNQ1qyZwtnhdDvXiFDtYoaY41vZuAArt1Gcylzmtv+I6vZMsLJ9gOG9TXMA/yKfmZgfxF+QkHzzymDgNxt1zRdDWaQSoHSoKzBq1zKPwc= 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 1578678953851226.37816212147004; Fri, 10 Jan 2020 09:55:53 -0800 (PST) Received: from localhost ([::1]:50116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyVk-0000rk-Df for importer@patchew.org; Fri, 10 Jan 2020 12:55:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51258) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyBy-0006ji-Ds for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyBx-0006fg-8B for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:26 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:39073 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 1ipyBx-0006eb-46 for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:25 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-359-r1SJUby4MkiHT6NGyB29TQ-1; Fri, 10 Jan 2020 12:35:19 -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 03505800D41; Fri, 10 Jan 2020 17:35:17 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 894DF19C4F; Fri, 10 Jan 2020 17:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677724; 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=Oxe1AWGfIOdagHVu8yxuMNHyn0Md0ln06wq1254wDAI=; b=QiUbWSYkuE/P1/e2LEgwCNrgobrpC6Y5+0CGhDMIUkIqA/XeNLuxr9WFroTmoDIpTcGgN3 hBCuqep3ydKXwLH2QxFvQpG3tvU4gZwEkMUUdX2Ne62X3rBPaaIYUS7xEphylkaMZKm/R8 rTwNcvzsyE7JUJ4EGgvwB3AwZ+nWCnc= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 18/28] migration/postcopy: set all_zero to true on the first target page Date: Fri, 10 Jan 2020 18:32:05 +0100 Message-Id: <20200110173215.3865-19-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: r1SJUby4MkiHT6NGyB29TQ-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Wei Yang , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 f20dfc3b68..f3889904b2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4102,7 +4102,7 @@ static int ram_load_postcopy(QEMUFile *f) page_buffer =3D postcopy_host_page + ((uintptr_t)host & (block->page_size - 1)); /* If all TP are zero then we can optimise the place */ - if (!((uintptr_t)host & (block->page_size - 1))) { + if (target_pages =3D=3D 1) { all_zero =3D true; } else { /* not the 1st TP within the HP */ --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678636; cv=none; d=zohomail.com; s=zohoarc; b=TglI3Ttj2gE39v0Q+M4cV3UIGjW+cZazHTy37l3AWUdEKJXlD0qdf9YrPa9ZJEpuaDqlU4HKGueh8PIfG3vhsluA39b38NZqkwg/xSQ/iVJFbS6Qjt9Y67hsguXucykPgLMRC2Ex57TSVbI/XiCFlmKNiOCu6roCTKIAUX5+2cQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678636; 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=D+xCqjP1u5jxgqE8Hjw6g0qhR9m0fEpUPTGLQdEIbQ4=; b=bN7CNgjsSbxcLw+IaFTj/jdv1VAKqfeY319weesVerVCYSMjUOR36jC1AvNxGBIvffRQRZBuxdCez5aPjNir8x+izIALvptRg0J2Zp5fQ4WScG9Zu0LRqtYiQj/S/VcWJl3WTqGqohNPoc4kJIGj1sVKPNPSbXjxtVSOOaT9WFA= 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 1578678636603877.7795912395768; Fri, 10 Jan 2020 09:50:36 -0800 (PST) Received: from localhost ([::1]:50022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyQd-0000hY-17 for importer@patchew.org; Fri, 10 Jan 2020 12:50:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51445) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyC4-0006pg-QV for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyC3-0006pc-Cm for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:32 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35566 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 1ipyC2-0006nA-Sd for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35: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-12-CrM10n1aP3m-hUuKvCWDow-1; Fri, 10 Jan 2020 12:35: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 48C6B107ACC4; Fri, 10 Jan 2020 17:35:24 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 580EF19C4F; Fri, 10 Jan 2020 17:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677728; 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=D+xCqjP1u5jxgqE8Hjw6g0qhR9m0fEpUPTGLQdEIbQ4=; b=Fp9FLc108Eo9nxIIaalvKchJCSbK+gCq2czpSHsAWksX5ytgCkA8i2ZiAPWDokab8bpjBG Ac9hQC2pRaBsgi8hMaSRg2ddMVdLuQS3VnzhCSHgAZ7Qbdp1xzFyAWIRw5g+go43xugH/c vf6GOgAJFMJyP+5B26qs+cphoYj5WVM= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 19/28] migration/postcopy: enable random order target page arrival Date: Fri, 10 Jan 2020 18:32:06 +0100 Message-Id: <20200110173215.3865-20-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: CrM10n1aP3m-hUuKvCWDow-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Wei Yang , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 f3889904b2..b5546940f9 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4050,7 +4050,7 @@ static int ram_load_postcopy(QEMUFile *f) MigrationIncomingState *mis =3D migration_incoming_get_current(); /* Temporary page that is later 'placed' */ void *postcopy_host_page =3D mis->postcopy_tmp_page; - void *last_host =3D NULL; + void *this_host =3D NULL; bool all_zero =3D false; int target_pages =3D 0; =20 @@ -4097,24 +4097,26 @@ static int ram_load_postcopy(QEMUFile *f) * that's moved into place later. * The migration protocol uses, possibly smaller, target-pages * however the source ensures it always sends all the componen= ts - * of a host page in order. + * of a host page in one chunk. */ page_buffer =3D postcopy_host_page + ((uintptr_t)host & (block->page_size - 1)); /* If all TP are zero then we can optimise the place */ if (target_pages =3D=3D 1) { all_zero =3D true; + this_host =3D (void *)QEMU_ALIGN_DOWN((uintptr_t)host, + block->page_size); } else { /* not the 1st TP within the HP */ - if (host !=3D (last_host + TARGET_PAGE_SIZE)) { - error_report("Non-sequential target page %p/%p", - host, last_host); + if (QEMU_ALIGN_DOWN((uintptr_t)host, block->page_size) != =3D + (uintptr_t)this_host) { + error_report("Non-same host page %p/%p", + host, this_host); ret =3D -EINVAL; break; } } =20 - /* * If it's the last part of a host page then we place the host * page @@ -4125,7 +4127,6 @@ static int ram_load_postcopy(QEMUFile *f) } place_source =3D postcopy_host_page; } - last_host =3D host; =20 switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { case RAM_SAVE_FLAG_ZERO: @@ -4178,7 +4179,8 @@ static int ram_load_postcopy(QEMUFile *f) =20 if (!ret && place_needed) { /* This gets called at the last target page in the host page */ - void *place_dest =3D host + TARGET_PAGE_SIZE - block->page_siz= e; + void *place_dest =3D (void *)QEMU_ALIGN_DOWN((uintptr_t)host, + block->page_size); =20 if (all_zero) { ret =3D postcopy_place_page_zero(mis, place_dest, --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678591; cv=none; d=zohomail.com; s=zohoarc; b=IVXBOQp65kaHgE9tPWSeivtZgGKUSnI9KsdJxGcfP7Jt/M3qAZRG3ofySif7gZ4WvOb3MLUNHqlsflWyR7qtY6Y0VgXZc7G6HacTn596uCTjKkTWHUlVzYi4GWxunRlxob7eNX1HMSzALGXckmeeD6l5qonOHiAh75rBgpc22C4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678591; 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=SSqpK7OYRTRdYmsOlX0kj3gAK31HzZmc08e82895ib0=; b=Jf74FNWqN2ohWDq0WRj0YXciHW3UBDcUhuV4fUiJkqmT5PRuNfgo7WM5+FVnxFASeVHvyoaCmDeDGXxxNyAQR/DXW7LkqGtLyzEcG0w+gMMfNOLOslvLk4Y2gIrd5BfkcVEOSh4Za83AYZeLDNJosAxtEao7cbuvJiSgUhHWwJ4= 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 1578678591957223.0855399462023; Fri, 10 Jan 2020 09:49:51 -0800 (PST) Received: from localhost ([::1]:50018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyPu-00009Y-8g for importer@patchew.org; Fri, 10 Jan 2020 12:49:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51785) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyCB-00070i-Lg for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyCA-00076H-4N for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:39 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:58722 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 1ipyC9-00074o-UG for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35: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-125-wTIjINQJPFeIejiK3BSxzA-1; Fri, 10 Jan 2020 12:35: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 7D70E107ACC5; Fri, 10 Jan 2020 17:35:31 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E12419C4F; Fri, 10 Jan 2020 17:35:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677737; 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=SSqpK7OYRTRdYmsOlX0kj3gAK31HzZmc08e82895ib0=; b=bIgqLB3/2s6DnlggCUPPPTAjIwAcTUGRGeZ3ARvSCO0x1MZJuTeQaNgpk3BcmyEt2S1eAb I4lNSqFnSJt4IPQO5uclc2OEI/n31zLGCIopyUDetTNtxQtDJ+BlmBSi3RF+zxHIrVJsb1 1RH5O28aCyhZvNmzkeyCQXorB2N8G2k= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 20/28] migration/postcopy: enable compress during postcopy Date: Fri, 10 Jan 2020 18:32:07 +0100 Message-Id: <20200110173215.3865-21-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: wTIjINQJPFeIejiK3BSxzA-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Wei Yang , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 b5546940f9..b9eb08f549 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3469,6 +3469,14 @@ static int ram_save_iterate(QEMUFile *f, void *opaqu= e) =20 rs->target_page_count +=3D pages; =20 + /* + * During postcopy, it is necessary to make sure one whole host + * page is sent in one chunk. + */ + if (migrate_postcopy_ram()) { + flush_compressed_data(rs); + } + /* * we want to check in the 1st loop, just in case it was the 1= st * time and we had to sync the dirty bitmap. @@ -4061,6 +4069,7 @@ static int ram_load_postcopy(QEMUFile *f) void *place_source =3D NULL; RAMBlock *block =3D NULL; uint8_t ch; + int len; =20 addr =3D qemu_get_be64(f); =20 @@ -4078,7 +4087,8 @@ static int ram_load_postcopy(QEMUFile *f) =20 trace_ram_load_postcopy_loop((uint64_t)addr, flags); place_needed =3D false; - if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE)) { + if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE | + RAM_SAVE_FLAG_COMPRESS_PAGE)) { block =3D ram_block_from_stream(f, flags); =20 host =3D host_from_ram_block_offset(block, addr); @@ -4161,6 +4171,17 @@ static int ram_load_postcopy(QEMUFile *f) TARGET_PAGE_SIZE); } break; + case RAM_SAVE_FLAG_COMPRESS_PAGE: + all_zero =3D false; + len =3D qemu_get_be32(f); + if (len < 0 || len > compressBound(TARGET_PAGE_SIZE)) { + error_report("Invalid compressed data length: %d", len); + ret =3D -EINVAL; + break; + } + decompress_data_with_multi_threads(f, page_buffer, len); + break; + case RAM_SAVE_FLAG_EOS: /* normal exit */ multifd_recv_sync_main(); @@ -4172,6 +4193,11 @@ static int ram_load_postcopy(QEMUFile *f) break; } =20 + /* Got the whole host page, wait for decompress before placing. */ + if (place_needed) { + ret |=3D wait_for_decompress_done(); + } + /* Detect for any possible file errors */ if (!ret && qemu_file_get_error(f)) { ret =3D qemu_file_get_error(f); --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678619; cv=none; d=zohomail.com; s=zohoarc; b=Wa6ynotBoDNhc0/By6atp2kQVPprtukPkBi9owpMePfgPPr9fRrYXdiw0MeRlECYod91HN4IMGW/FaG2rcIFtty12nCAu6zRRSKq7MtlgvyWVg4/xpEwpYkaEVuCVG8g+vt5Js2ENM+vJjOxWJCpIXsUWVKIMKbBIt2MoLVauxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678619; 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=3NgGhtimpsgHYnBlOteURcPsztJP5JapGSQKNnFjsvE=; b=UhLymYifJGU7PgO/ELcOofJmlmuTYRkvfsd4zn0u/tARs5EZHAuEtAmpHvxh+9j3RF714zJ0t+vTQdFwxInuCpA0GIjWBj3xp7CR4u+fUeFNuMMOmqxW8B8MsmQ60i/D8utdDjBN1OX8EP1WvNOX3/Cdd6TPAddb/pnILpqg2dU= 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 1578678618996511.42607754611583; Fri, 10 Jan 2020 09:50:18 -0800 (PST) Received: from localhost ([::1]:50020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyQJ-0000UZ-VG for importer@patchew.org; Fri, 10 Jan 2020 12:50:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51927) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyCD-00073B-Ns for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyCC-0007EX-Ai for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:41 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:56182 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 1ipyCC-0007CU-4t for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:40 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-155-zPECZwk5O_-Xo_UpTyyf0Q-1; Fri, 10 Jan 2020 12:35:38 -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 48D08477; Fri, 10 Jan 2020 17:35:36 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id D105419C4F; Fri, 10 Jan 2020 17:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677739; 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=3NgGhtimpsgHYnBlOteURcPsztJP5JapGSQKNnFjsvE=; b=ifxR05jjsxL5JlyJOZBB33M5haYKGyfZv6KgDcCajGZ9ns66GivdptbkfiKZteKbbvqits lHE6XJZ1Xpqfzn+w/AgrVe4bXsTh2bLPoe9VP3qMu06DU11GESeVvWc/wOc7qRopulTcQY +fjPHQfeaO4jsnxHqY+BgyjLtoC4MZs= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 21/28] migration/multifd: clean pages after filling packet Date: Fri, 10 Jan 2020 18:32:08 +0100 Message-Id: <20200110173215.3865-22-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: zPECZwk5O_-Xo_UpTyyf0Q-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Wei Yang , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 b9eb08f549..57e22cac4c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -955,10 +955,10 @@ static int multifd_send_pages(RAMState *rs) } qemu_mutex_unlock(&p->mutex); } - p->pages->used =3D 0; + assert(!p->pages->used); + assert(!p->pages->block); =20 p->packet_num =3D multifd_send_state->packet_num++; - p->pages->block =3D NULL; multifd_send_state->pages =3D p->pages; p->pages =3D pages; transferred =3D ((uint64_t) pages->used) * TARGET_PAGE_SIZE + p->packe= t_len; @@ -1154,6 +1154,8 @@ static void *multifd_send_thread(void *opaque) p->flags =3D 0; p->num_packets++; p->num_pages +=3D used; + p->pages->used =3D 0; + p->pages->block =3D NULL; qemu_mutex_unlock(&p->mutex); =20 trace_multifd_send(p->id, packet_num, used, flags, --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578679071; cv=none; d=zohomail.com; s=zohoarc; b=de6aajcAw7VQdAGAcypG5ba1MY9pwk6e+GstUiweq7XqBeE5JMgIv2aL+k/xXuRflMFziHR1yftEpBeoEcV9c95MUdpuIjTuq22yxzgwv7dS8UZPr4CO60aRO/skkQ1z/RzVtAjJxpPuJkoIWdyv7jb0djyauY9R1jBAB8GM/Wc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578679071; 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=ipUbyqSi2LbvtRe4A/gxQ9gfFY5LWhrpHClvIgUmIV4=; b=hbIMwp54xELusVHxJnDEyDbHSSIBsd/pIImPB6Yi4BTh+lFo5olQpFV3hi+d8nXd44nVTzrgHUXPQYLT8GJo4NUxdFDXmYGSLygC3ZjoY+zxx5YX3wRVegWpP+dOy22cz97TvMqtEJiwzIfbtBMXDi1hjBIfyFz8BK17+DdxKqk= 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 1578679071956819.1039110073342; Fri, 10 Jan 2020 09:57:51 -0800 (PST) Received: from localhost ([::1]:50154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyXe-0002yb-Oc for importer@patchew.org; Fri, 10 Jan 2020 12:57:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52284) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyCL-0007BR-OB for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyCK-0007ag-EQ for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:49 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:33567 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 1ipyCK-0007Yc-1H for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:48 -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-190-AGQADt99M-Kf04wakqCoTA-1; Fri, 10 Jan 2020 12:35: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 8684F1005502; Fri, 10 Jan 2020 17:35:43 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D5AA19C4F; Fri, 10 Jan 2020 17:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677747; 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=ipUbyqSi2LbvtRe4A/gxQ9gfFY5LWhrpHClvIgUmIV4=; b=h5BGUg7Jw/HL6BSw7dfsowZkEmsk8C+ZGXdi0j+j/hGFhKkdcD6jtawAyK4D2vSncNViay vPqv1Af/EsF984bzYZjBB3Np99JSyHtkxcyVmFCDV4v57D7rZv6ER3bD/dxm7q6Ih7WTo1 pNJSDOx1Sg+x1JBmuV24hG/ZsP2T0fM= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 22/28] migration/multifd: not use multifd during postcopy Date: Fri, 10 Jan 2020 18:32:09 +0100 Message-Id: <20200110173215.3865-23-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: AGQADt99M-Kf04wakqCoTA-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Wei Yang , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 57e22cac4c..4ba9037e78 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2587,10 +2587,13 @@ static int ram_save_target_page(RAMState *rs, PageS= earchStatus *pss, } =20 /* - * do not use multifd for compression as the first page in the new - * block should be posted out before sending the compressed page + * Do not use multifd for: + * 1. Compression as the first page in the new block should be posted = out + * before sending the compressed page + * 2. In postcopy as one whole host page should be placed */ - if (!save_page_use_compression(rs) && migrate_use_multifd()) { + if (!save_page_use_compression(rs) && migrate_use_multifd() + && !migration_in_postcopy()) { return ram_save_multifd_page(rs, block, offset); } =20 --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678762; cv=none; d=zohomail.com; s=zohoarc; b=aJ7O5t2munbquyi2ILBOtjm+WERjdz2esIE54r1YjMk1BNHhv8aTklL66jYxke0npNSxoa7YqWV688xRO+1MC6H266iu2TB2TFdCANUxWDLZKHNX/YykTTI2c2rR48gQUYJRSRNxcbHslz7bpmQfu9nW+jteUft5F4g1Uf5amxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678762; 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=dbZzHITBVOqnVDLD4TmM+9ycTwCTtYfRJUwroSled+g=; b=biT+7VHlWlG1U4OPzjmqlM0A+fMUv5keIX2T8Q2y9gcqOjj7oej1oTSPHwo0Z7urGaP2ALOpD4650812QE16u6PvaZIIELt9Cl8l6VdZrBomrx9qUUX/YzlydtzJl6jPSNd1FQKkyuVBTbulAGGMyAIiCwDy2zkUvWZ3GpM5NsQ= 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 1578678762761786.5680903899604; Fri, 10 Jan 2020 09:52:42 -0800 (PST) Received: from localhost ([::1]:50072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipySf-0004M2-5o for importer@patchew.org; Fri, 10 Jan 2020 12:52:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52786) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyCT-0007MP-Iq for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyCS-0007xG-7m for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35:57 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:43584 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 1ipyCS-0007vm-2L for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:35: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-380-kJCXF1M2NOeo3MGVOwTh-w-1; Fri, 10 Jan 2020 12:35:53 -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 B7714800EBF; Fri, 10 Jan 2020 17:35:51 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA2FC272D3; Fri, 10 Jan 2020 17:35:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677755; 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=dbZzHITBVOqnVDLD4TmM+9ycTwCTtYfRJUwroSled+g=; b=J9Mdwn4nqwakSGd2VKh8KzPlutxRdqsVM7fal+JxsD1Bs+fFr+7qWwqpPDP2nIuuEOiVIz /GHTxaEOmf0Tx2DO/5n/rcPQhqr9i+cfcJIyUvcUd0jVCy5LwhrQ4xSs/ZZZanMLSNlC5T eZLarmXDSpCf1ulc9r9T4XetEmIhBus= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 23/28] migration/multifd: fix nullptr access in terminating multifd threads Date: Fri, 10 Jan 2020 18:32:10 +0100 Message-Id: <20200110173215.3865-24-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: kJCXF1M2NOeo3MGVOwTh-w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Peter Maydell , Jason Wang , Jiahui Cen , Juan Quintela , "Michael S. Tsirkin" , 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 4ba9037e78..5da3a47ffc 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1308,7 +1308,9 @@ static void multifd_recv_terminate_threads(Error *err) - normal quit, i.e. everything went fine, just finished - error quit: We close the channels so the channel threads finish the qio_channel_read_all_eof() */ - qio_channel_shutdown(p->c, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); + if (p->c) { + qio_channel_shutdown(p->c, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); + } qemu_mutex_unlock(&p->mutex); } } --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578679155; cv=none; d=zohomail.com; s=zohoarc; b=CNNKlXEFe9CeoFQdpb/xpy79PLUccu6GhPAM6uy2xk2PTfZ09j5CPfN81F6p/kWNiGRvaXRkO+QjYOayBTGfsfEvWsd4afhh4Vf4jJIGU/9KtAdwpa+7CmYrBnh5ruXmWboWtZrFxyHxgvkb6iD4ZVUoOQq+P9VlgOosO/tpfYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578679155; 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=x3qXLxq3XDCTQEo1U+67oBjmEQimTcl8aT0X6zM6L84=; b=FcjbZXYZY2EaYw3qzjJKyWy4qltDOGSKGYvK968o6k6tWcJTwMf/yszRumPFZAds0pzKTapzKdzrwM/KfanfO1zHpg0P+T+fA4ZIudcudnHWoOheEIho+85mjjmE236b/RD0AcpGUZIhX26WZXfd9LakDhJQ9DV6GJz0yezCk6k= 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 1578679155917775.4937546052274; Fri, 10 Jan 2020 09:59:15 -0800 (PST) Received: from localhost ([::1]:50176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyZ0-0004aq-I5 for importer@patchew.org; Fri, 10 Jan 2020 12:59:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53099) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyCY-0007Tx-7s for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyCX-0008Aj-0K for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:02 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:37781 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 1ipyCW-00089h-Qo for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36: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-13-AUzJFFS3MFGMYq7TlHBN7w-1; Fri, 10 Jan 2020 12:35:59 -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 D0EDF107ACC4; Fri, 10 Jan 2020 17:35:56 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18D9519C4F; Fri, 10 Jan 2020 17:35:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677760; 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=x3qXLxq3XDCTQEo1U+67oBjmEQimTcl8aT0X6zM6L84=; b=XAv4ybVdgRaeZRWAVWueUTnL7oS4PtxeDgQImBU9KYDAyNJunt951QFuB0cpzvMpYqao2L tw6TXVeqg6ywp10aSn4LInUI0fd6IjkJXtFCElNuo4EXlFsQGpccjQ0qc/3vEkXFQC4cQN KhEB71HJB0w394q7g+adbH42JaD/iZE= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 24/28] migration/multifd: fix destroyed mutex access in terminating multifd threads Date: Fri, 10 Jan 2020 18:32:11 +0100 Message-Id: <20200110173215.3865-25-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: AUzJFFS3MFGMYq7TlHBN7w-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 , Peter Maydell , Jason Wang , Jiahui Cen , Juan Quintela , "Michael S. Tsirkin" , 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 5da3a47ffc..67a24bf217 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1053,6 +1053,10 @@ void multifd_save_cleanup(void) if (p->running) { qemu_thread_join(&p->thread); } + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { + MultiFDSendParams *p =3D &multifd_send_state->params[i]; + socket_send_channel_destroy(p->c); p->c =3D NULL; qemu_mutex_destroy(&p->mutex); @@ -1336,6 +1340,10 @@ int multifd_load_cleanup(Error **errp) qemu_sem_post(&p->sem_sync); qemu_thread_join(&p->thread); } + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { + MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + object_unref(OBJECT(p->c)); p->c =3D NULL; qemu_mutex_destroy(&p->mutex); --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678762; cv=none; d=zohomail.com; s=zohoarc; b=h2iLNSUvXw/OsgJ1OkCwMuwW/Rkh3hP2I3Leq65WX+/xheXP1B8J8+0EClY2FS43BvKk+YcGEu70Yy1GQ5Nccjxw4bN1BdBv/+c+Id+ZvkOrxBRMPLrvtH2Xr+5zveNLj/mOt7gcNruPGjbVqOJMQ9Rec+tX8lwHZEdePohmgsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678762; 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=PXB++T9ALYs5r1QNRbd/pIVxGJNn5bO7prB3hJ/SS6U=; b=Q5cqXYiu8Kuw4mJwaQXuqSglKYA9GT2t4CfNfoqzkVpfNm5nwyy70e9pezEfG5w5l6w8zQRkXNK2yFUgEsqSiQ4mY1qQ8/iKu7w8r2aztxs+fDIprHJPO/2fFZzobeqMJKTzm4k8Gc36m6ReYxcX+om6uc9PXNah4S1GLn5REJE= 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 1578678762886195.72454956434126; Fri, 10 Jan 2020 09:52:42 -0800 (PST) Received: from localhost ([::1]:50074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipySf-0004MD-K7 for importer@patchew.org; Fri, 10 Jan 2020 12:52:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53520) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyCf-0007eH-5p for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyCd-0008Ux-Ru for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:09 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:26981 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 1ipyCd-0008Th-MW for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36: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-255-slps1OqRNFm3Awf5pRu_eA-1; Fri, 10 Jan 2020 12:36:06 -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 F189910054E3; Fri, 10 Jan 2020 17:36:03 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FA5619C58; Fri, 10 Jan 2020 17:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677767; 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=PXB++T9ALYs5r1QNRbd/pIVxGJNn5bO7prB3hJ/SS6U=; b=W0WR2aWpGUQ1CShweSExjhcR4mdnHcHdgK1DDzZjwuuI753TmRGQFnppdBAWcxCUC28NXL M/wR3vIxdHGBhQLS/vAzx9KmtDRY7MtKaExAU8Cbyh1VayBTL4Oakt5M7GOUDtnjFuXngT 4/ZerBW3pfjMCoo5ANRBLyx0e/13BSw= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 25/28] Bug #1829242 correction. Date: Fri, 10 Jan 2020 18:32:12 +0100 Message-Id: <20200110173215.3865-26-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: slps1OqRNFm3Awf5pRu_eA-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , Alexey Romko , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 67a24bf217..e711f9003b 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1768,7 +1768,7 @@ static inline bool migration_bitmap_clear_dirty(RAMSt= ate *rs, if (rb->clear_bmap && clear_bmap_test_and_clear(rb, page)) { uint8_t shift =3D rb->clear_bmap_shift; hwaddr size =3D 1ULL << (TARGET_PAGE_BITS + shift); - hwaddr start =3D (page << TARGET_PAGE_BITS) & (-size); + hwaddr start =3D (((ram_addr_t)page) << TARGET_PAGE_BITS) & (-size= ); =20 /* * CLEAR_BITMAP_SHIFT_MIN should always guarantee this... this @@ -2005,7 +2005,7 @@ static void ram_release_pages(const char *rbname, uin= t64_t offset, int pages) return; } =20 - ram_discard_range(rbname, offset, pages << TARGET_PAGE_BITS); + ram_discard_range(rbname, offset, ((ram_addr_t)pages) << TARGET_PAGE_B= ITS); } =20 /* @@ -2093,7 +2093,7 @@ static int ram_save_page(RAMState *rs, PageSearchStat= us *pss, bool last_stage) uint8_t *p; bool send_async =3D true; RAMBlock *block =3D pss->block; - ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; + ram_addr_t offset =3D ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; ram_addr_t current_addr =3D block->offset + offset; =20 p =3D block->host + offset; @@ -2280,7 +2280,8 @@ static bool find_dirty_block(RAMState *rs, PageSearch= Status *pss, bool *again) *again =3D false; return false; } - if ((pss->page << TARGET_PAGE_BITS) >=3D pss->block->used_length) { + if ((((ram_addr_t)pss->page) << TARGET_PAGE_BITS) + >=3D pss->block->used_length) { /* Didn't find anything in this RAM Block */ pss->page =3D 0; pss->block =3D QLIST_NEXT_RCU(pss->block, next); @@ -2571,7 +2572,7 @@ static int ram_save_target_page(RAMState *rs, PageSea= rchStatus *pss, bool last_stage) { RAMBlock *block =3D pss->block; - ram_addr_t offset =3D pss->page << TARGET_PAGE_BITS; + ram_addr_t offset =3D ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; int res; =20 if (control_save_page(rs, block, offset, &res)) { @@ -2657,7 +2658,8 @@ static int ram_save_host_page(RAMState *rs, PageSearc= hStatus *pss, /* Allow rate limiting to happen in the middle of huge pages */ migration_rate_limit(); } while ((pss->page & (pagesize_bits - 1)) && - offset_in_ramblock(pss->block, pss->page << TARGET_PAGE_BITS)= ); + offset_in_ramblock(pss->block, + ((ram_addr_t)pss->page) << TARGET_PAGE_BIT= S)); =20 /* The offset we leave with is the last one we looked at */ pss->page--; @@ -2874,8 +2876,10 @@ void ram_postcopy_migrated_memory_release(MigrationS= tate *ms) =20 while (run_start < range) { unsigned long run_end =3D find_next_bit(bitmap, range, run_sta= rt + 1); - ram_discard_range(block->idstr, run_start << TARGET_PAGE_BITS, - (run_end - run_start) << TARGET_PAGE_BITS); + ram_discard_range(block->idstr, + ((ram_addr_t)run_start) << TARGET_PAGE_BITS, + ((ram_addr_t)(run_end - run_start)) + << TARGET_PAGE_BITS); run_start =3D find_next_zero_bit(bitmap, range, run_end + 1); } } @@ -4273,13 +4277,16 @@ static void colo_flush_ram_cache(void) while (block) { offset =3D migration_bitmap_find_dirty(ram_state, block, offse= t); =20 - if (offset << TARGET_PAGE_BITS >=3D block->used_length) { + if (((ram_addr_t)offset) << TARGET_PAGE_BITS + >=3D block->used_length) { offset =3D 0; block =3D QLIST_NEXT_RCU(block, next); } else { migration_bitmap_clear_dirty(ram_state, block, offset); - dst_host =3D block->host + (offset << TARGET_PAGE_BITS); - src_host =3D block->colo_cache + (offset << TARGET_PAGE_BI= TS); + dst_host =3D block->host + + (((ram_addr_t)offset) << TARGET_PAGE_BITS); + src_host =3D block->colo_cache + + (((ram_addr_t)offset) << TARGET_PAGE_BITS); memcpy(dst_host, src_host, TARGET_PAGE_SIZE); } } --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678931; cv=none; d=zohomail.com; s=zohoarc; b=hTMkBWhc7PLPm9ovaVVdv+QH5trQVoJc+2zQArmo+2TYxnCRmilfhtG2+1vibny2RHrlTL7Ah/F6Pog1pZht2F/NEkRiBUlOd+fL2QipKN+RzGr+tI6vo0MbsP5t1Bk7y4cNV4UQkSCMqDs7gjas7jt60gmLOUP9C5OJfBKzKpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678931; 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=/Drh7UpvTII31N4druR4ljQRvEuykagecCXzdoYcf1Y=; b=KcNYA8cwENQ/faYLXRhxDS5O5uKZWkqfT19K8qQ8N/Dd1razOcQKx5J8OdoGkrjjyGXqUc1udK75TPX/YlzCY0lVL27vdan8EEY2bN9tsT9+Yo5AlIzUctvo2QSH6cUzESE9zFAyTPZ+0jdFhgbRXSB7ytgQHv6aXIe4zyef1mA= 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 1578678931475531.5057697353903; Fri, 10 Jan 2020 09:55:31 -0800 (PST) Received: from localhost ([::1]:50108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyVO-0008Us-6s for importer@patchew.org; Fri, 10 Jan 2020 12:55:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54250) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyCq-0007wY-KF for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyCo-0000i9-OT for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:20 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:21781 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 1ipyCo-0000g6-Ik for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36: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-278-1ozPHdVgOeiD7NNsMGfTeQ-1; Fri, 10 Jan 2020 12:36: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 E8F20107ACC4; Fri, 10 Jan 2020 17:36:14 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51CE519C58; Fri, 10 Jan 2020 17:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677778; 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=/Drh7UpvTII31N4druR4ljQRvEuykagecCXzdoYcf1Y=; b=CW5c6pgNneEVbSL4gYfCy+KpV3fr7p++tgK7VMT1oPGGSN6nAA35v0tnGpSePERp1fwFdx exrTjxB9/L+8v7Izp6h+4kChBVJ/FZSvNiJS2jqEcM8Mhm6ZR7xmK7aRzL+0BZSYwK9cjq ml6lcNLtDND+6KF3FsYVh5gWmTqaaLk= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 26/28] migration: Define VMSTATE_INSTANCE_ID_ANY Date: Fri, 10 Jan 2020 18:32:13 +0100 Message-Id: <20200110173215.3865-27-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 1ozPHdVgOeiD7NNsMGfTeQ-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Peter Xu , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 f11422fc41..07b389a18f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2950,7 +2950,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 0dc04fc48e..a33861e1d4 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1178,6 +1178,8 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDe= scription *vmsd, =20 bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque); =20 +#define VMSTATE_INSTANCE_ID_ANY -1 + /* Returns: 0 on success, -1 on failure */ int vmstate_register_with_alias_id(VMStateIf *obj, int instance_id, const VMStateDescription *vmsd, diff --git a/migration/savevm.c b/migration/savevm.c index e57686bca7..8dab99efc4 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -775,7 +775,7 @@ int register_savevm_live(const char *idstr, =20 pstrcat(se->idstr, sizeof(se->idstr), idstr); =20 - if (instance_id =3D=3D -1) { + if (instance_id =3D=3D VMSTATE_INSTANCE_ID_ANY) { se->instance_id =3D calculate_new_instance_id(se->idstr); } else { se->instance_id =3D instance_id; @@ -842,14 +842,14 @@ int vmstate_register_with_alias_id(VMStateIf *obj, in= t instance_id, =20 se->compat =3D g_new0(CompatEntry, 1); pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->na= me); - se->compat->instance_id =3D instance_id =3D=3D -1 ? + se->compat->instance_id =3D instance_id =3D=3D VMSTATE_INSTANC= E_ID_ANY ? calculate_compat_instance_id(vmsd->name) : instan= ce_id; - instance_id =3D -1; + instance_id =3D VMSTATE_INSTANCE_ID_ANY; } } pstrcat(se->idstr, sizeof(se->idstr), vmsd->name); =20 - if (instance_id =3D=3D -1) { + if (instance_id =3D=3D VMSTATE_INSTANCE_ID_ANY) { se->instance_id =3D calculate_new_instance_id(se->idstr); } else { se->instance_id =3D instance_id; --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578678941; cv=none; d=zohomail.com; s=zohoarc; b=jRDk3tm320hyyliipo4ByxC6gKMId8RAKosYO6bHVWEQjRLbO4UuyB3ngyRfXvfRi90eUC11+1iECJ0+ctYVcgTA3q6fnhgGpuCn40q1P4Ambyaws6md5l6/PSil1inTfeJdghHLr61ZBllaFql/lV8UsNoYtX5M7nh65FtqxTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578678941; 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=iIrj8LM+9IgudScxc6wwuzUYeG5oA8toxySeqRyiy8U=; b=IXdjZHB+BmTbGB0Q3S3A1PtQwhR3Vu7mQqJBIcPPHL9RLP7MbHf+Tw29BhW/DbXuigpxnU0Byoh8ht6ZncV/J/ALwIochgdnU2NJnHZBn5c5wyh+j1daKfjA61AGM4/9eSzFFqShRJAAOx2LRk4ToLUBFH2JYEdygLCO9CHwHgU= 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 1578678941817660.5834692707524; Fri, 10 Jan 2020 09:55:41 -0800 (PST) Received: from localhost ([::1]:50110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyVY-0000QL-8S for importer@patchew.org; Fri, 10 Jan 2020 12:55:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54547) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyD4-00084b-Ln for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyCz-00013O-7c for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:34 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:58625 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 1ipyCx-00011k-W1 for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36: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-370-8pM9M99oNwuonlDl_8HZgg-1; Fri, 10 Jan 2020 12:36:24 -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 3A00A10054E3; Fri, 10 Jan 2020 17:36:22 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4861619C4F; Fri, 10 Jan 2020 17:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677787; 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=iIrj8LM+9IgudScxc6wwuzUYeG5oA8toxySeqRyiy8U=; b=jQdvWmB7VXtkNqNfn36NSHG8ohrAEfcT2WyJuj6IhyKwLjRDJD/lUOIJ3sL8mwmDrOUoZl QA8KNUsZpGl1GkR3j+XmeIkv6BvROzWNFU/Hw+AJOEsVfV5arr8nCWO/4XeaNcz9Pxl0Ch zbAl0GRF+QphdHUFLkKXM4tH/KQ9ulg= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 27/28] migration: Change SaveStateEntry.instance_id into uint32_t Date: Fri, 10 Jan 2020 18:32:14 +0100 Message-Id: <20200110173215.3865-28-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: 8pM9M99oNwuonlDl_8HZgg-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Peter Xu , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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 a33861e1d4..30667631bc 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1181,7 +1181,7 @@ bool vmstate_save_needed(const VMStateDescription *vm= sd, void *opaque); #define VMSTATE_INSTANCE_ID_ANY -1 =20 /* Returns: 0 on success, -1 on failure */ -int vmstate_register_with_alias_id(VMStateIf *obj, int instance_id, +int vmstate_register_with_alias_id(VMStateIf *obj, uint32_t instance_id, const VMStateDescription *vmsd, void *base, int alias_id, int required_for_version, diff --git a/migration/savevm.c b/migration/savevm.c index 8dab99efc4..adfdca26ac 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -233,7 +233,7 @@ typedef struct CompatEntry { typedef struct SaveStateEntry { QTAILQ_ENTRY(SaveStateEntry) entry; char idstr[256]; - int instance_id; + uint32_t instance_id; int alias_id; int version_id; /* version id read from the stream */ @@ -667,10 +667,10 @@ void dump_vmstate_json_to_file(FILE *out_file) fclose(out_file); } =20 -static int calculate_new_instance_id(const char *idstr) +static uint32_t calculate_new_instance_id(const char *idstr) { SaveStateEntry *se; - int instance_id =3D 0; + uint32_t instance_id =3D 0; =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (strcmp(idstr, se->idstr) =3D=3D 0 @@ -678,6 +678,8 @@ static int calculate_new_instance_id(const char *idstr) instance_id =3D se->instance_id + 1; } } + /* Make sure we never loop over without being noticed */ + assert(instance_id !=3D VMSTATE_INSTANCE_ID_ANY); return instance_id; } =20 @@ -755,7 +757,7 @@ static void savevm_state_handler_remove(SaveStateEntry = *se) Meanwhile pass -1 as instance_id if you do not already have a clearly distinguishing id for all instances of your device class. */ int register_savevm_live(const char *idstr, - int instance_id, + uint32_t instance_id, int version_id, const SaveVMHandlers *ops, void *opaque) @@ -809,7 +811,7 @@ void unregister_savevm(VMStateIf *obj, const char *idst= r, void *opaque) } } =20 -int vmstate_register_with_alias_id(VMStateIf *obj, int instance_id, +int vmstate_register_with_alias_id(VMStateIf *obj, uint32_t instance_id, const VMStateDescription *vmsd, void *opaque, int alias_id, int required_for_version, @@ -1625,7 +1627,7 @@ int qemu_save_device_state(QEMUFile *f) return qemu_file_get_error(f); } =20 -static SaveStateEntry *find_se(const char *idstr, int instance_id) +static SaveStateEntry *find_se(const char *idstr, uint32_t instance_id) { SaveStateEntry *se; =20 @@ -2292,7 +2294,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migration= IncomingState *mis) /* Find savevm section */ se =3D find_se(idstr, instance_id); if (se =3D=3D NULL) { - error_report("Unknown savevm section or instance '%s' %d. " + error_report("Unknown savevm section or instance '%s' %"PRIu32". " "Make sure that your current VM setup matches your " "saved VM setup, including any hotplugged devices", idstr, instance_id); @@ -2316,7 +2318,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migration= IncomingState *mis) =20 ret =3D vmstate_load(f, se); if (ret < 0) { - error_report("error while loading state for instance 0x%x of" + error_report("error while loading state for instance 0x%"PRIx32" o= f" " device '%s'", instance_id, idstr); return ret; } diff --git a/stubs/vmstate.c b/stubs/vmstate.c index 6951d9fdc5..cc4fe41dfc 100644 --- a/stubs/vmstate.c +++ b/stubs/vmstate.c @@ -4,7 +4,7 @@ const VMStateDescription vmstate_dummy =3D {}; =20 int vmstate_register_with_alias_id(VMStateIf *obj, - int instance_id, + uint32_t instance_id, const VMStateDescription *vmsd, void *base, int alias_id, int required_for_version, --=20 2.24.1 From nobody Thu May 2 01:49:49 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=1578679235; cv=none; d=zohomail.com; s=zohoarc; b=KvGTBgzXqTAcG11/UBVw0TAQBDQeTnTRCB75UhjV7l9bZJUrmAhSSQYyFjKTMIJP5OWnTZxWhY5fFVO/yDdXA72hD3a0RUBwVEb5qdp4uPsF/jLY1yWlXjXCTMAsAFGgFwzmbFTDl7XJRtnQO3dK2xXJmhvXu6r5vlJmBIFmAWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578679235; 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=e2K4U4ZlHX+FlZFL9ln+mX4sWhcMEsG6cHypHZxt0IDHYCGBFGY53hPrhKkXRk8MtuhKvs/7KCEa47Fej4roFYK7r8oHuCqT1NSqw7H80xD590Z3fey18G02tolkhEKT141So0GRyYal4jWe9+pKcuh3Md+/lcVU9B1Ko00c+w8= 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 1578679235530697.4452411836646; Fri, 10 Jan 2020 10:00:35 -0800 (PST) Received: from localhost ([::1]:50194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyaI-0005gC-FI for importer@patchew.org; Fri, 10 Jan 2020 13:00:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54667) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipyD6-00086i-1D for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipyD4-00018R-LS for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:35 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:26394 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 1ipyD4-00014Q-Hn for qemu-devel@nongnu.org; Fri, 10 Jan 2020 12:36:34 -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-45-nm_WpXYhM7-VA3mzNGbqJA-1; Fri, 10 Jan 2020 12:36: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 0EB25593A1; Fri, 10 Jan 2020 17:36:27 +0000 (UTC) Received: from secure.mitica (ovpn-116-240.ams2.redhat.com [10.36.116.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DAA919C4F; Fri, 10 Jan 2020 17:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578677791; 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=cwYWD5nygWlETyxS7QdZiKBeZ/G0XiAj73KLzN5RyxzAdL2arPnR33f/nq31rKoDpmvSl0 RkbN2wD3qsW1Fzv37Xci/8VRwb9ulNY4iCPSyiHR904MXjH12WpmG6y7EDO2Rz3hgzpU+Y +x6dGF7ilKmcrJOO2HOuZv0chXwcZqE= From: Juan Quintela To: qemu-devel@nongnu.org Subject: [PULL 28/28] apic: Use 32bit APIC ID for migration instance ID Date: Fri, 10 Jan 2020 18:32:15 +0100 Message-Id: <20200110173215.3865-29-quintela@redhat.com> In-Reply-To: <20200110173215.3865-1-quintela@redhat.com> References: <20200110173215.3865-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: nm_WpXYhM7-VA3mzNGbqJA-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 , Juan Quintela , Peter Maydell , Stefan Weil , Jason Wang , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Peter Xu , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Stefan Berger , Richard Henderson 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