From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15003927439011018.3858512559716; Tue, 18 Jul 2017 08:45:43 -0700 (PDT) Received: from localhost ([::1]:57272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUgv-0003Nr-L1 for importer@patchew.org; Tue, 18 Jul 2017 11:45:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUd2-0008CW-BO for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUcy-0005p3-Ep for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34704) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUcy-0005nW-8l for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C29372F86C0 for ; Tue, 18 Jul 2017 15:41:31 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D3C97F467; Tue, 18 Jul 2017 15:41:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C29372F86C0 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C29372F86C0 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:12 +0200 Message-Id: <20170718154127.6459-2-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 18 Jul 2017 15:41:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/16] migration/rdma: Fix race on source X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Fix a race where the destination might try and send the source a WRID_READY before the source has done a post-recv for it. rdma_post_recv has to happen after the qp exists, and we're OK since we've already called qemu_rdma_source_init that calls qemu_alloc_qp. This corresponds to: https://bugzilla.redhat.com/show_bug.cgi?id=3D1285044 The race can be triggered by adding a few ms wait before this post_recv_control (which was originally due to me turning on loads of debug). Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Message-Id: <20170717110936.23314-2-dgilbert@redhat.com> Signed-off-by: Juan Quintela --- migration/rdma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index c6bc607..6111e10 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2365,6 +2365,12 @@ static int qemu_rdma_connect(RDMAContext *rdma, Erro= r **errp) =20 caps_to_network(&cap); =20 + ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); + if (ret) { + ERROR(errp, "posting second control recv"); + goto err_rdma_source_connect; + } + ret =3D rdma_connect(rdma->cm_id, &conn_param); if (ret) { perror("rdma_connect"); @@ -2405,12 +2411,6 @@ static int qemu_rdma_connect(RDMAContext *rdma, Erro= r **errp) =20 rdma_ack_cm_event(cm_event); =20 - ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); - if (ret) { - ERROR(errp, "posting second control recv!"); - goto err_rdma_source_connect; - } - rdma->control_ready_expected =3D 1; rdma->nb_sent =3D 0; return 0; --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500392597269583.0775284858098; Tue, 18 Jul 2017 08:43:17 -0700 (PDT) Received: from localhost ([::1]:57256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUeY-0000pH-W3 for importer@patchew.org; Tue, 18 Jul 2017 11:43:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUd2-0008CV-BN for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUd0-0005pi-1B for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39440) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUcz-0005pW-R7 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:37 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C614DD6481 for ; Tue, 18 Jul 2017 15:41:36 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DCD67F467; Tue, 18 Jul 2017 15:41:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C614DD6481 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C614DD6481 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:13 +0200 Message-Id: <20170718154127.6459-3-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 18 Jul 2017 15:41:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/16] migration: Close file on failed migration load X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Closing the file before exit on a failure allows the source to cleanup better, especially with RDMA. Partial fix for https://bugs.launchpad.net/qemu/+bug/1545052 Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Message-Id: <20170717110936.23314-3-dgilbert@redhat.com> 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 a0db40d..8552f54 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -348,6 +348,7 @@ static void process_incoming_migration_co(void *opaque) migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_FAILED); error_report("load of migration failed: %s", strerror(-ret)); + qemu_fclose(mis->from_src_file); exit(EXIT_FAILURE); } mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500392743607531.4518329521725; Tue, 18 Jul 2017 08:45:43 -0700 (PDT) Received: from localhost ([::1]:57271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUgv-0003M9-7N for importer@patchew.org; Tue, 18 Jul 2017 11:45:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUd3-0008D7-8l for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUd2-0005rE-Ii for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37056) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUd2-0005qJ-D0 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 58332C058EA2 for ; Tue, 18 Jul 2017 15:41:39 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25A0B7F464; Tue, 18 Jul 2017 15:41:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 58332C058EA2 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 58332C058EA2 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:14 +0200 Message-Id: <20170718154127.6459-4-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 18 Jul 2017 15:41:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/16] migration/rdma: fix qemu_rdma_block_for_wrid error paths X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" The two places that 'goto err_block_for_wrid' weren't setting ret and so would end up returning 0 even though we've failed. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Message-Id: <20170717110936.23314-4-dgilbert@redhat.com> Signed-off-by: Juan Quintela --- migration/rdma.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 6111e10..59810ae 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1521,14 +1521,16 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rd= ma, int wrid_requested, yield_until_fd_readable(rdma->comp_channel->fd); } =20 - if (ibv_get_cq_event(rdma->comp_channel, &cq, &cq_ctx)) { + ret =3D ibv_get_cq_event(rdma->comp_channel, &cq, &cq_ctx); + if (ret) { perror("ibv_get_cq_event"); goto err_block_for_wrid; } =20 num_cq_events++; =20 - if (ibv_req_notify_cq(cq, 0)) { + ret =3D -ibv_req_notify_cq(cq, 0); + if (ret) { goto err_block_for_wrid; } =20 @@ -1564,6 +1566,8 @@ err_block_for_wrid: if (num_cq_events) { ibv_ack_cq_events(cq, num_cq_events); } + + rdma->error_state =3D ret; return ret; } =20 --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500392628087312.6862180313748; Tue, 18 Jul 2017 08:43:48 -0700 (PDT) Received: from localhost ([::1]:57258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUf2-0001G3-Cz for importer@patchew.org; Tue, 18 Jul 2017 11:43:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUd5-0008Ex-BE for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUd4-0005sC-Bw for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37420) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUd4-0005rs-2f for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:42 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A0982F86D6 for ; Tue, 18 Jul 2017 15:41:41 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id A99417F760; Tue, 18 Jul 2017 15:41:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0A0982F86D6 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0A0982F86D6 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:15 +0200 Message-Id: <20170718154127.6459-5-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 18 Jul 2017 15:41:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/16] migration/rdma: Allow cancelling while waiting for wrid X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" When waiting for a WRID, if the other side dies we end up waiting for ever with no way to cancel the migration. Cure this by poll()ing the fd first with a timeout and checking error flags and migration state. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Message-Id: <20170717110936.23314-5-dgilbert@redhat.com> Signed-off-by: Juan Quintela --- migration/rdma.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++--= ---- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 59810ae..0cf55a6 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1466,6 +1466,56 @@ static uint64_t qemu_rdma_poll(RDMAContext *rdma, ui= nt64_t *wr_id_out, return 0; } =20 +/* Wait for activity on the completion channel. + * Returns 0 on success, none-0 on error. + */ +static int qemu_rdma_wait_comp_channel(RDMAContext *rdma) +{ + /* + * Coroutine doesn't start until migration_fd_process_incoming() + * so don't yield unless we know we're running inside of a coroutine. + */ + if (rdma->migration_started_on_destination) { + yield_until_fd_readable(rdma->comp_channel->fd); + } else { + /* This is the source side, we're in a separate thread + * or destination prior to migration_fd_process_incoming() + * we can't yield; so we have to poll the fd. + * But we need to be able to handle 'cancel' or an error + * without hanging forever. + */ + while (!rdma->error_state && !rdma->received_error) { + GPollFD pfds[1]; + pfds[0].fd =3D rdma->comp_channel->fd; + pfds[0].events =3D G_IO_IN | G_IO_HUP | G_IO_ERR; + /* 0.1s timeout, should be fine for a 'cancel' */ + switch (qemu_poll_ns(pfds, 1, 100 * 1000 * 1000)) { + case 1: /* fd active */ + return 0; + + case 0: /* Timeout, go around again */ + break; + + default: /* Error of some type - + * I don't trust errno from qemu_poll_ns + */ + error_report("%s: poll failed", __func__); + return -EPIPE; + } + + if (migrate_get_current()->state =3D=3D MIGRATION_STATUS_CANCE= LLING) { + /* Bail out and let the cancellation happen */ + return -EPIPE; + } + } + } + + if (rdma->received_error) { + return -EPIPE; + } + return rdma->error_state; +} + /* * Block until the next work request has completed. * @@ -1513,12 +1563,9 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdm= a, int wrid_requested, } =20 while (1) { - /* - * Coroutine doesn't start until migration_fd_process_incoming() - * so don't yield unless we know we're running inside of a corouti= ne. - */ - if (rdma->migration_started_on_destination) { - yield_until_fd_readable(rdma->comp_channel->fd); + ret =3D qemu_rdma_wait_comp_channel(rdma); + if (ret) { + goto err_block_for_wrid; } =20 ret =3D ibv_get_cq_event(rdma->comp_channel, &cq, &cq_ctx); --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500392772725709.557818964966; Tue, 18 Jul 2017 08:46:12 -0700 (PDT) Received: from localhost ([::1]:57273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUhP-0003np-B2 for importer@patchew.org; Tue, 18 Jul 2017 11:46:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUd7-0008Gi-4i for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUd6-0005t6-16 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45764) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUd5-0005sb-O3 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD2DA7CE1B for ; Tue, 18 Jul 2017 15:41:42 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C7A07F467; Tue, 18 Jul 2017 15:41:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AD2DA7CE1B Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AD2DA7CE1B From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:16 +0200 Message-Id: <20170718154127.6459-6-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 18 Jul 2017 15:41:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/16] migration/rdma: Safely convert control types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" control_desc[] is an array of strings that correspond to a series of message types; they're used only for error messages, but if the message type is seriously broken then we could go off the end of the array. Convert the array to a function control_desc() that bound checks. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Message-Id: <20170717110936.23314-6-dgilbert@redhat.com> Signed-off-by: Juan Quintela --- migration/rdma.c | 54 ++++++++++++++++++++++++++++++++--------------------= -- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 0cf55a6..972167d 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -165,20 +165,6 @@ enum { RDMA_CONTROL_UNREGISTER_FINISHED, /* unpinning finished */ }; =20 -static const char *control_desc[] =3D { - [RDMA_CONTROL_NONE] =3D "NONE", - [RDMA_CONTROL_ERROR] =3D "ERROR", - [RDMA_CONTROL_READY] =3D "READY", - [RDMA_CONTROL_QEMU_FILE] =3D "QEMU FILE", - [RDMA_CONTROL_RAM_BLOCKS_REQUEST] =3D "RAM BLOCKS REQUEST", - [RDMA_CONTROL_RAM_BLOCKS_RESULT] =3D "RAM BLOCKS RESULT", - [RDMA_CONTROL_COMPRESS] =3D "COMPRESS", - [RDMA_CONTROL_REGISTER_REQUEST] =3D "REGISTER REQUEST", - [RDMA_CONTROL_REGISTER_RESULT] =3D "REGISTER RESULT", - [RDMA_CONTROL_REGISTER_FINISHED] =3D "REGISTER FINISHED", - [RDMA_CONTROL_UNREGISTER_REQUEST] =3D "UNREGISTER REQUEST", - [RDMA_CONTROL_UNREGISTER_FINISHED] =3D "UNREGISTER FINISHED", -}; =20 /* * Memory and MR structures used to represent an IB Send/Recv work request. @@ -251,6 +237,30 @@ typedef struct QEMU_PACKED RDMADestBlock { uint32_t padding; } RDMADestBlock; =20 +static const char *control_desc(unsigned int rdma_control) +{ + static const char *strs[] =3D { + [RDMA_CONTROL_NONE] =3D "NONE", + [RDMA_CONTROL_ERROR] =3D "ERROR", + [RDMA_CONTROL_READY] =3D "READY", + [RDMA_CONTROL_QEMU_FILE] =3D "QEMU FILE", + [RDMA_CONTROL_RAM_BLOCKS_REQUEST] =3D "RAM BLOCKS REQUEST", + [RDMA_CONTROL_RAM_BLOCKS_RESULT] =3D "RAM BLOCKS RESULT", + [RDMA_CONTROL_COMPRESS] =3D "COMPRESS", + [RDMA_CONTROL_REGISTER_REQUEST] =3D "REGISTER REQUEST", + [RDMA_CONTROL_REGISTER_RESULT] =3D "REGISTER RESULT", + [RDMA_CONTROL_REGISTER_FINISHED] =3D "REGISTER FINISHED", + [RDMA_CONTROL_UNREGISTER_REQUEST] =3D "UNREGISTER REQUEST", + [RDMA_CONTROL_UNREGISTER_FINISHED] =3D "UNREGISTER FINISHED", + }; + + if (rdma_control > RDMA_CONTROL_UNREGISTER_FINISHED) { + return "??BAD CONTROL VALUE??"; + } + + return strs[rdma_control]; +} + static uint64_t htonll(uint64_t v) { union { uint32_t lv[2]; uint64_t llv; } u; @@ -1641,7 +1651,7 @@ static int qemu_rdma_post_send_control(RDMAContext *r= dma, uint8_t *buf, .num_sge =3D 1, }; =20 - trace_qemu_rdma_post_send_control(control_desc[head->type]); + trace_qemu_rdma_post_send_control(control_desc(head->type)); =20 /* * We don't actually need to do a memcpy() in here if we used @@ -1720,16 +1730,16 @@ static int qemu_rdma_exchange_get_response(RDMACont= ext *rdma, network_to_control((void *) rdma->wr_data[idx].control); memcpy(head, rdma->wr_data[idx].control, sizeof(RDMAControlHeader)); =20 - trace_qemu_rdma_exchange_get_response_start(control_desc[expecting]); + trace_qemu_rdma_exchange_get_response_start(control_desc(expecting)); =20 if (expecting =3D=3D RDMA_CONTROL_NONE) { - trace_qemu_rdma_exchange_get_response_none(control_desc[head->type= ], + trace_qemu_rdma_exchange_get_response_none(control_desc(head->type= ), head->type); } else if (head->type !=3D expecting || head->type =3D=3D RDMA_CONTROL= _ERROR) { error_report("Was expecting a %s (%d) control message" ", but got: %s (%d), length: %d", - control_desc[expecting], expecting, - control_desc[head->type], head->type, head->len); + control_desc(expecting), expecting, + control_desc(head->type), head->type, head->len); if (head->type =3D=3D RDMA_CONTROL_ERROR) { rdma->received_error =3D true; } @@ -1839,7 +1849,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, } } =20 - trace_qemu_rdma_exchange_send_waiting(control_desc[resp->type]); + trace_qemu_rdma_exchange_send_waiting(control_desc(resp->type)); ret =3D qemu_rdma_exchange_get_response(rdma, resp, resp->type, RDMA_WRID_DATA); =20 @@ -1851,7 +1861,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, if (resp_idx) { *resp_idx =3D RDMA_WRID_DATA; } - trace_qemu_rdma_exchange_send_received(control_desc[resp->type]); + trace_qemu_rdma_exchange_send_received(control_desc(resp->type)); } =20 rdma->control_ready_expected =3D 1; @@ -3401,7 +3411,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f,= void *opaque) ret =3D -EIO; goto out; default: - error_report("Unknown control message %s", control_desc[head.t= ype]); + error_report("Unknown control message %s", control_desc(head.t= ype)); ret =3D -EIO; goto out; } --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500392904056786.8952860089776; Tue, 18 Jul 2017 08:48:24 -0700 (PDT) Received: from localhost ([::1]:57281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUjT-0006Y9-On for importer@patchew.org; Tue, 18 Jul 2017 11:48:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUd8-0008Hs-9b for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUd7-0005ts-Id for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39856) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUd7-0005tV-CU for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BAB5D6482 for ; Tue, 18 Jul 2017 15:41:44 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C6BC7F465; Tue, 18 Jul 2017 15:41:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5BAB5D6482 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5BAB5D6482 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:17 +0200 Message-Id: <20170718154127.6459-7-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 18 Jul 2017 15:41:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/16] migration/rdma: Send error during cancelling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" When we issue a cancel and clean up the RDMA channel send a CONTROL_ERROR to get the destination to quit. The rdma_cleanup code waits for the event to come back from the rdma_disconnect; but that wont happen until the destination quits and there's currently nothing to force it. Note this makes the case of a cancel work while the destination is alive, and it already works if the destination is truly dead. Note it doesn't fix the case where the destination is hung (we get stuck waiting for the rdma_disconnect event). Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu Message-Id: <20170717110936.23314-7-dgilbert@redhat.com> Signed-off-by: Juan Quintela --- migration/rdma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 972167d..ca56594 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2269,7 +2269,9 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) int ret, idx; =20 if (rdma->cm_id && rdma->connected) { - if (rdma->error_state && !rdma->received_error) { + if ((rdma->error_state || + migrate_get_current()->state =3D=3D MIGRATION_STATUS_CANCELLI= NG) && + !rdma->received_error) { RDMAControlHeader head =3D { .len =3D 0, .type =3D RDMA_CONTROL_ERROR, .repeat =3D 1, --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150039294200850.8255311417596; Tue, 18 Jul 2017 08:49:02 -0700 (PDT) Received: from localhost ([::1]:57285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUk4-0007RD-7H for importer@patchew.org; Tue, 18 Jul 2017 11:48:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUdF-0008Nh-9U for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUdE-0005yF-9Q for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58788) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUdE-0005xZ-0Y for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 031FFC04D2EF for ; Tue, 18 Jul 2017 15:41:51 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1C377EF67; Tue, 18 Jul 2017 15:41:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 031FFC04D2EF Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 031FFC04D2EF From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:18 +0200 Message-Id: <20170718154127.6459-8-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 18 Jul 2017 15:41:51 +0000 (UTC) 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: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/16] qdev: provide DEFINE_PROP_INT64() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Eduardo Habkost , dgilbert@redhat.com, peterx@redhat.com, Markus Armbruster , Marcel Apfelbaum , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Peter Xu We have nearly all the stuff, but this one is missing. Add it in. Am going to use this new helper for MigrationParameters fields, since most of them are int64_t. CC: Markus Armbruster CC: Eduardo Habkost CC: Marc-Andr=C3=A9 Lureau CC: Peter Xu CC: Juan Quintela CC: Marcel Apfelbaum CC: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Marcel Apfelbaum Reviewed-by: Juan Quintela Reviewed-by: Eduardo Habkost Signed-off-by: Peter Xu Message-Id: <1500349150-13240-2-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- hw/core/qdev-properties.c | 32 ++++++++++++++++++++++++++++++++ include/hw/qdev-properties.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index dcecdf0..c1d4e54 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -404,6 +404,31 @@ static void set_uint64(Object *obj, Visitor *v, const = char *name, visit_type_uint64(v, name, ptr, errp); } =20 +static void get_int64(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + DeviceState *dev =3D DEVICE(obj); + Property *prop =3D opaque; + int64_t *ptr =3D qdev_get_prop_ptr(dev, prop); + + visit_type_int64(v, name, ptr, errp); +} + +static void set_int64(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + DeviceState *dev =3D DEVICE(obj); + Property *prop =3D opaque; + int64_t *ptr =3D qdev_get_prop_ptr(dev, prop); + + if (dev->realized) { + qdev_prop_set_after_realize(dev, name, errp); + return; + } + + visit_type_int64(v, name, ptr, errp); +} + const PropertyInfo qdev_prop_uint64 =3D { .name =3D "uint64", .get =3D get_uint64, @@ -411,6 +436,13 @@ const PropertyInfo qdev_prop_uint64 =3D { .set_default_value =3D set_default_value_uint, }; =20 +const PropertyInfo qdev_prop_int64 =3D { + .name =3D "int64", + .get =3D get_int64, + .set =3D set_int64, + .set_default_value =3D set_default_value_int, +}; + /* --- string --- */ =20 static void release_string(Object *obj, const char *name, void *opaque) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 3929796..e2321f1 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -13,6 +13,7 @@ extern const PropertyInfo qdev_prop_uint16; extern const PropertyInfo qdev_prop_uint32; extern const PropertyInfo qdev_prop_int32; extern const PropertyInfo qdev_prop_uint64; +extern const PropertyInfo qdev_prop_int64; extern const PropertyInfo qdev_prop_size; extern const PropertyInfo qdev_prop_string; extern const PropertyInfo qdev_prop_chr; @@ -157,6 +158,8 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t) #define DEFINE_PROP_UINT64(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t) +#define DEFINE_PROP_INT64(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int64, int64_t) #define DEFINE_PROP_SIZE(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t) #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500392903234789.1698567739896; Tue, 18 Jul 2017 08:48:23 -0700 (PDT) Received: from localhost ([::1]:57282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUjU-0006ZO-Lp for importer@patchew.org; Tue, 18 Jul 2017 11:48:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUdM-0008US-7n for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUdI-00061B-AH for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUdI-00060b-0P for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0149F7F408 for ; Tue, 18 Jul 2017 15:41:55 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56FE87EF67; Tue, 18 Jul 2017 15:41:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0149F7F408 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0149F7F408 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:19 +0200 Message-Id: <20170718154127.6459-9-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 18 Jul 2017 15:41:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/16] migration: export parameters to props X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Export migration parameters to qdev properties. Then we can use, for example: -global migration.x-cpu-throttle-initial=3Dxxx To specify migration parameters during init. Prefix "x-" is appended for each parameter exported to show that this is not a stable interface, and only for debugging/testing purpose. Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1500349150-13240-3-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- migration/migration.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 8552f54..f5ed333 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2010,6 +2010,31 @@ static Property migration_properties[] =3D { send_configuration, true), DEFINE_PROP_BOOL("send-section-footer", MigrationState, send_section_footer, true), + + /* Migration parameters */ + DEFINE_PROP_INT64("x-compress-level", MigrationState, + parameters.compress_level, + DEFAULT_MIGRATE_COMPRESS_LEVEL), + DEFINE_PROP_INT64("x-compress-threads", MigrationState, + parameters.compress_threads, + DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT), + DEFINE_PROP_INT64("x-decompress-threads", MigrationState, + parameters.decompress_threads, + DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT), + DEFINE_PROP_INT64("x-cpu-throttle-initial", MigrationState, + parameters.cpu_throttle_initial, + DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL), + DEFINE_PROP_INT64("x-cpu-throttle-increment", MigrationState, + parameters.cpu_throttle_increment, + DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT), + DEFINE_PROP_INT64("x-max-bandwidth", MigrationState, + parameters.max_bandwidth, MAX_THROTTLE), + DEFINE_PROP_INT64("x-downtime-limit", MigrationState, + parameters.downtime_limit, + DEFAULT_MIGRATE_SET_DOWNTIME), + DEFINE_PROP_INT64("x-checkpoint-delay", MigrationState, + parameters.x_checkpoint_delay, + DEFAULT_MIGRATE_X_CHECKPOINT_DELAY), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -2028,16 +2053,6 @@ static void migration_instance_init(Object *obj) ms->state =3D MIGRATION_STATUS_NONE; ms->xbzrle_cache_size =3D DEFAULT_MIGRATE_CACHE_SIZE; ms->mbps =3D -1; - ms->parameters =3D (MigrationParameters) { - .compress_level =3D DEFAULT_MIGRATE_COMPRESS_LEVEL, - .compress_threads =3D DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT, - .decompress_threads =3D DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, - .cpu_throttle_initial =3D DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, - .cpu_throttle_increment =3D DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, - .max_bandwidth =3D MAX_THROTTLE, - .downtime_limit =3D DEFAULT_MIGRATE_SET_DOWNTIME, - .x_checkpoint_delay =3D DEFAULT_MIGRATE_X_CHECKPOINT_DELAY, - }; ms->parameters.tls_creds =3D g_strdup(""); ms->parameters.tls_hostname =3D g_strdup(""); } --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500393068742379.2002850610837; Tue, 18 Jul 2017 08:51:08 -0700 (PDT) Received: from localhost ([::1]:57295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUm8-0001fS-Gu for importer@patchew.org; Tue, 18 Jul 2017 11:51:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUdM-0008UO-6w for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUdK-00063m-7F for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUdK-00063C-12 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:58 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE00E61D38 for ; Tue, 18 Jul 2017 15:41:56 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56B087F464; Tue, 18 Jul 2017 15:41:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EE00E61D38 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EE00E61D38 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:20 +0200 Message-Id: <20170718154127.6459-10-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 18 Jul 2017 15:41:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/16] migration: export capabilities to props X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Do the same thing to migration capabilities, just like what we did in previous patch for migration parameters. Reviewed-by: Juan Quintela Reviewed-by: Eduardo Habkost Signed-off-by: Peter Xu Message-Id: <1500349150-13240-4-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- migration/migration.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index f5ed333..16f5d9a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2002,6 +2002,9 @@ void migration_global_dump(Monitor *mon) ms->send_configuration, ms->send_section_footer); } =20 +#define DEFINE_PROP_MIG_CAP(name, x) \ + DEFINE_PROP_BOOL(name, MigrationState, enabled_capabilities[x], false) + static Property migration_properties[] =3D { DEFINE_PROP_BOOL("store-global-state", MigrationState, store_global_state, true), @@ -2035,6 +2038,20 @@ static Property migration_properties[] =3D { DEFINE_PROP_INT64("x-checkpoint-delay", MigrationState, parameters.x_checkpoint_delay, DEFAULT_MIGRATE_X_CHECKPOINT_DELAY), + + /* Migration capabilities */ + DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), + DEFINE_PROP_MIG_CAP("x-rdma-pin-all", MIGRATION_CAPABILITY_RDMA_PIN_AL= L), + DEFINE_PROP_MIG_CAP("x-auto-converge", MIGRATION_CAPABILITY_AUTO_CONVE= RGE), + DEFINE_PROP_MIG_CAP("x-zero-blocks", MIGRATION_CAPABILITY_ZERO_BLOCKS), + DEFINE_PROP_MIG_CAP("x-compress", MIGRATION_CAPABILITY_COMPRESS), + DEFINE_PROP_MIG_CAP("x-events", MIGRATION_CAPABILITY_EVENTS), + DEFINE_PROP_MIG_CAP("x-postcopy-ram", MIGRATION_CAPABILITY_POSTCOPY_RA= M), + DEFINE_PROP_MIG_CAP("x-colo", MIGRATION_CAPABILITY_X_COLO), + DEFINE_PROP_MIG_CAP("x-release-ram", MIGRATION_CAPABILITY_RELEASE_RAM), + DEFINE_PROP_MIG_CAP("x-block", MIGRATION_CAPABILITY_BLOCK), + DEFINE_PROP_MIG_CAP("x-return-path", MIGRATION_CAPABILITY_RETURN_PATH), + DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500393202252199.4417963397119; Tue, 18 Jul 2017 08:53:22 -0700 (PDT) Received: from localhost ([::1]:57306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUoI-0003OZ-U0 for importer@patchew.org; Tue, 18 Jul 2017 11:53:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUdM-0008Uz-Tr for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUdL-00064u-V9 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUdL-00064N-LV for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:41:59 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E15DD6480 for ; Tue, 18 Jul 2017 15:41:58 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F3F07EF70; Tue, 18 Jul 2017 15:41:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9E15DD6480 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9E15DD6480 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:21 +0200 Message-Id: <20170718154127.6459-11-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 18 Jul 2017 15:41:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/16] migration: introduce migrate_params_check() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Helper to check the parameters. Abstracted from qmp_migrate_set_parameters(). Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1500349150-13240-5-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- migration/migration.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 16f5d9a..02d6987 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -644,64 +644,86 @@ void qmp_migrate_set_capabilities(MigrationCapability= StatusList *params, } } =20 -void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) +/* + * Check whether the parameters are valid. Error will be put into errp + * (if provided). Return true if valid, otherwise false. + */ +static bool migrate_params_check(MigrationParameters *params, Error **errp) { - MigrationState *s =3D migrate_get_current(); - if (params->has_compress_level && (params->compress_level < 0 || params->compress_level > 9)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level", "is invalid, it should be in the range of 0 to 9"); - return; + return false; } + if (params->has_compress_threads && (params->compress_threads < 1 || params->compress_threads > 255)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_threads", "is invalid, it should be in the range of 1 to 255"); - return; + return false; } + if (params->has_decompress_threads && (params->decompress_threads < 1 || params->decompress_threads > 25= 5)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "decompress_threads", "is invalid, it should be in the range of 1 to 255"); - return; + return false; } + if (params->has_cpu_throttle_initial && (params->cpu_throttle_initial < 1 || params->cpu_throttle_initial > 99)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu_throttle_initial", "an integer in the range of 1 to 99"); - return; + return false; } + if (params->has_cpu_throttle_increment && (params->cpu_throttle_increment < 1 || params->cpu_throttle_increment > 99)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu_throttle_increment", "an integer in the range of 1 to 99"); - return; + return false; } + if (params->has_max_bandwidth && (params->max_bandwidth < 0 || params->max_bandwidth > SIZE_MAX)) { error_setg(errp, "Parameter 'max_bandwidth' expects an integer in = the" " range of 0 to %zu bytes/second", SIZE_MAX); - return; + return false; } + if (params->has_downtime_limit && (params->downtime_limit < 0 || params->downtime_limit > MAX_MIGRATE_DOWNTIME)) { error_setg(errp, "Parameter 'downtime_limit' expects an integer in= " "the range of 0 to %d milliseconds", MAX_MIGRATE_DOWNTIME); - return; + return false; } + if (params->has_x_checkpoint_delay && (params->x_checkpoint_delay < 0)= ) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "x_checkpoint_delay", "is invalid, it should be positive"); + return false; + } + + return true; +} + +void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) +{ + MigrationState *s =3D migrate_get_current(); + + if (!migrate_params_check(params, errp)) { + /* Invalid parameter */ + return; } =20 if (params->has_compress_level) { --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500393096611189.50509708393815; Tue, 18 Jul 2017 08:51:36 -0700 (PDT) Received: from localhost ([::1]:57299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUmd-00027d-Ao for importer@patchew.org; Tue, 18 Jul 2017 11:51:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUdR-00007P-3j for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUdQ-00067y-7L for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9158) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUdP-00067M-Uf for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D958A2E97CC for ; Tue, 18 Jul 2017 15:42:02 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id F18D87EF6A; Tue, 18 Jul 2017 15:41:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D958A2E97CC Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D958A2E97CC From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:22 +0200 Message-Id: <20170718154127.6459-12-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 18 Jul 2017 15:42:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/16] migration: provide migrate_params_apply() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Abstracted from qmp_migrate_set_parameters(). Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1500349150-13240-6-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- migration/migration.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 02d6987..13d9f00 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -717,38 +717,40 @@ static bool migrate_params_check(MigrationParameters = *params, Error **errp) return true; } =20 -void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) +static void migrate_params_apply(MigrationParameters *params) { MigrationState *s =3D migrate_get_current(); =20 - if (!migrate_params_check(params, errp)) { - /* Invalid parameter */ - return; - } - if (params->has_compress_level) { s->parameters.compress_level =3D params->compress_level; } + if (params->has_compress_threads) { s->parameters.compress_threads =3D params->compress_threads; } + if (params->has_decompress_threads) { s->parameters.decompress_threads =3D params->decompress_threads; } + if (params->has_cpu_throttle_initial) { s->parameters.cpu_throttle_initial =3D params->cpu_throttle_initia= l; } + if (params->has_cpu_throttle_increment) { s->parameters.cpu_throttle_increment =3D params->cpu_throttle_incr= ement; } + if (params->has_tls_creds) { g_free(s->parameters.tls_creds); s->parameters.tls_creds =3D g_strdup(params->tls_creds); } + if (params->has_tls_hostname) { g_free(s->parameters.tls_hostname); s->parameters.tls_hostname =3D g_strdup(params->tls_hostname); } + if (params->has_max_bandwidth) { s->parameters.max_bandwidth =3D params->max_bandwidth; if (s->to_dst_file) { @@ -756,6 +758,7 @@ void qmp_migrate_set_parameters(MigrationParameters *pa= rams, Error **errp) s->parameters.max_bandwidth / XFER_LIMIT_R= ATIO); } } + if (params->has_downtime_limit) { s->parameters.downtime_limit =3D params->downtime_limit; } @@ -766,11 +769,22 @@ void qmp_migrate_set_parameters(MigrationParameters *= params, Error **errp) colo_checkpoint_notify(s); } } + if (params->has_block_incremental) { s->parameters.block_incremental =3D params->block_incremental; } } =20 +void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp) +{ + if (!migrate_params_check(params, errp)) { + /* Invalid parameter */ + return; + } + + migrate_params_apply(params); +} + =20 void qmp_migrate_start_postcopy(Error **errp) { --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500393067590874.5022902483943; Tue, 18 Jul 2017 08:51:07 -0700 (PDT) Received: from localhost ([::1]:57296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUm8-0001fz-Nc for importer@patchew.org; Tue, 18 Jul 2017 11:51:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUdW-0000CY-HD for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUdS-0006AG-Kz for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34582) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUdS-00069J-Bd for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B1E5C0587E9 for ; Tue, 18 Jul 2017 15:42:05 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 371C47F471; Tue, 18 Jul 2017 15:42:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4B1E5C0587E9 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4B1E5C0587E9 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:23 +0200 Message-Id: <20170718154127.6459-13-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 18 Jul 2017 15:42:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/16] migration: check global params for validity X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Adding validity check for the migration parameters passed in via global properties. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Message-Id: <1500349150-13240-7-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- migration/migration.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 13d9f00..c59dad9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -102,14 +102,22 @@ enum mig_rp_message_type { =20 static MigrationState *current_migration; =20 +static bool migration_object_check(MigrationState *ms, Error **errp); + void migration_object_init(void) { MachineState *ms =3D MACHINE(qdev_get_machine()); + Error *err =3D NULL; =20 /* This can only be called once. */ assert(!current_migration); current_migration =3D MIGRATION_OBJ(object_new(TYPE_MIGRATION)); =20 + if (!migration_object_check(current_migration, &err)) { + error_report_err(err); + exit(1); + } + /* * We cannot really do this in migration_instance_init() since at * that time global properties are not yet applied, then this @@ -2102,12 +2110,38 @@ static void migration_class_init(ObjectClass *klass= , void *data) static void migration_instance_init(Object *obj) { MigrationState *ms =3D MIGRATION_OBJ(obj); + MigrationParameters *params =3D &ms->parameters; =20 ms->state =3D MIGRATION_STATUS_NONE; ms->xbzrle_cache_size =3D DEFAULT_MIGRATE_CACHE_SIZE; ms->mbps =3D -1; - ms->parameters.tls_creds =3D g_strdup(""); - ms->parameters.tls_hostname =3D g_strdup(""); + + params->tls_hostname =3D g_strdup(""); + params->tls_creds =3D g_strdup(""); + + /* Set has_* up only for parameter checks */ + params->has_compress_level =3D true; + params->has_compress_threads =3D true; + params->has_decompress_threads =3D true; + params->has_cpu_throttle_initial =3D true; + params->has_cpu_throttle_increment =3D true; + params->has_max_bandwidth =3D true; + params->has_downtime_limit =3D true; + params->has_x_checkpoint_delay =3D true; + params->has_block_incremental =3D true; +} + +/* + * Return true if check pass, false otherwise. Error will be put + * inside errp if provided. + */ +static bool migration_object_check(MigrationState *ms, Error **errp) +{ + if (!migrate_params_check(&ms->parameters, errp)) { + return false; + } + + return true; } =20 static const TypeInfo migration_type =3D { --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500393200076831.6676203826111; Tue, 18 Jul 2017 08:53:20 -0700 (PDT) Received: from localhost ([::1]:57307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUoI-0003Oe-R8 for importer@patchew.org; Tue, 18 Jul 2017 11:53:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUdW-0000Cc-Iq for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUdV-0006Ci-Bt for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36296) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUdV-0006C0-2h for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08BC94A70F; Tue, 18 Jul 2017 15:42:08 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CFCE7EF67; Tue, 18 Jul 2017 15:42:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 08BC94A70F Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 08BC94A70F From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:24 +0200 Message-Id: <20170718154127.6459-14-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 18 Jul 2017 15:42:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/16] migration: remove check against colo support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Paolo Bonzini , dgilbert@redhat.com, peterx@redhat.com, Hailiang Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Since commit a15215f3 ("build: remove --enable-colo/--disable-colo"), colo is always supported. We don't need any colo_supported() now since it is always true. Removing any extra code that depends on it. CC: Paolo Bonzini CC: Hailiang Zhang Reviewed-by: Juan Quintela Reviewed-by: Zhang Chen Signed-off-by: Peter Xu Message-Id: <1500349150-13240-8-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- include/migration/colo.h | 1 - migration/colo.c | 5 ----- migration/migration.c | 11 ----------- 3 files changed, 17 deletions(-) diff --git a/include/migration/colo.h b/include/migration/colo.h index be6beba..ff9874e 100644 --- a/include/migration/colo.h +++ b/include/migration/colo.h @@ -15,7 +15,6 @@ =20 #include "qemu-common.h" =20 -bool colo_supported(void); void colo_info_init(void); =20 void migrate_start_colo_process(MigrationState *s); diff --git a/migration/colo.c b/migration/colo.c index ef35f00..a425543 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -29,11 +29,6 @@ static bool vmstate_loading; =20 #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) =20 -bool colo_supported(void) -{ - return true; -} - bool migration_in_colo_state(void) { MigrationState *s =3D migrate_get_current(); diff --git a/migration/migration.c b/migration/migration.c index c59dad9..915c8cc 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -412,9 +412,6 @@ MigrationCapabilityStatusList *qmp_query_migrate_capabi= lities(Error **errp) continue; } #endif - if (i =3D=3D MIGRATION_CAPABILITY_X_COLO && !colo_supported()) { - continue; - } if (head =3D=3D NULL) { head =3D g_malloc0(sizeof(*caps)); caps =3D head; @@ -613,14 +610,6 @@ void qmp_migrate_set_capabilities(MigrationCapabilityS= tatusList *params, continue; } #endif - if (cap->value->capability =3D=3D MIGRATION_CAPABILITY_X_COLO) { - if (!colo_supported()) { - error_setg(errp, "COLO is not currently supported, please" - " configure with --enable-colo option in orde= r to" - " support COLO feature"); - continue; - } - } s->enabled_capabilities[cap->value->capability] =3D cap->value->st= ate; } =20 --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500393336269260.3438560727766; Tue, 18 Jul 2017 08:55:36 -0700 (PDT) Received: from localhost ([::1]:57329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUqT-0005FY-R8 for importer@patchew.org; Tue, 18 Jul 2017 11:55:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUdY-0000Ea-LQ for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUdX-0006Eq-BX for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57880) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUdX-0006Dn-2N for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B1B97C849 for ; Tue, 18 Jul 2017 15:42:10 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58ADD7EF6A; Tue, 18 Jul 2017 15:42:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0B1B97C849 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0B1B97C849 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:25 +0200 Message-Id: <20170718154127.6459-15-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 18 Jul 2017 15:42:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/16] migration: provide migrate_caps_check() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Abstract helper function to check migration capabilities (from the old qmp_migrate_set_capabilities). Prepare to be used somewhere else. There is side effect on the change: when applying the capabilities, we were skipping the invalid ones, but still applying the valid ones (if they are provided in the same QMP request). After this refactoring, we'll ignore all the capabilities if we detected invalid setup along the way. However, I don't think it is a problem since general users should not provide anything invalid after all. Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1500349150-13240-9-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- migration/migration.c | 79 ++++++++++++++++++++++++++++++++++-------------= ---- 1 file changed, 53 insertions(+), 26 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 915c8cc..74099b3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -588,43 +588,49 @@ MigrationInfo *qmp_query_migrate(Error **errp) return info; } =20 -void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, - Error **errp) +/** + * @migration_caps_check - check capability validity + * + * @cap_list: old capability list, array of bool + * @params: new capabilities to be applied soon + * @errp: set *errp if the check failed, with reason + * + * Returns true if check passed, otherwise false. + */ +static bool migrate_caps_check(bool *cap_list, + MigrationCapabilityStatusList *params, + Error **errp) { - MigrationState *s =3D migrate_get_current(); MigrationCapabilityStatusList *cap; - bool old_postcopy_cap =3D migrate_postcopy_ram(); + bool old_postcopy_cap; =20 - if (migration_is_setup_or_active(s->state)) { - error_setg(errp, QERR_MIGRATION_ACTIVE); - return; - } + old_postcopy_cap =3D cap_list[MIGRATION_CAPABILITY_POSTCOPY_RAM]; =20 for (cap =3D params; cap; cap =3D cap->next) { + cap_list[cap->value->capability] =3D cap->value->state; + } + #ifndef CONFIG_LIVE_BLOCK_MIGRATION - if (cap->value->capability =3D=3D MIGRATION_CAPABILITY_BLOCK - && cap->value->state) { - error_setg(errp, "QEMU compiled without old-style (blk/-b, inc= /-i) " - "block migration"); - error_append_hint(errp, "Use drive_mirror+NBD instead.\n"); - continue; - } + if (cap_list[MIGRATION_CAPABILITY_BLOCK]) { + error_setg(errp, "QEMU compiled without old-style (blk/-b, inc/-i)= " + "block migration"); + error_append_hint(errp, "Use drive_mirror+NBD instead.\n"); + return false; + } #endif - s->enabled_capabilities[cap->value->capability] =3D cap->value->st= ate; - } =20 - if (migrate_postcopy_ram()) { - if (migrate_use_compression()) { + 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_report("Postcopy is not currently compatible with " - "compression"); - s->enabled_capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM] =3D - false; + 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. @@ -634,11 +640,32 @@ void qmp_migrate_set_capabilities(MigrationCapability= StatusList *params, /* postcopy_ram_supported_by_host will have emitted a more * detailed message */ - error_report("Postcopy is not supported"); - s->enabled_capabilities[MIGRATION_CAPABILITY_POSTCOPY_RAM] =3D - false; + error_setg(errp, "Postcopy is not supported"); + return false; } } + + return true; +} + +void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, + Error **errp) +{ + MigrationState *s =3D migrate_get_current(); + MigrationCapabilityStatusList *cap; + + if (migration_is_setup_or_active(s->state)) { + error_setg(errp, QERR_MIGRATION_ACTIVE); + return; + } + + if (!migrate_caps_check(s->enabled_capabilities, params, errp)) { + return; + } + + for (cap =3D params; cap; cap =3D cap->next) { + s->enabled_capabilities[cap->value->capability] =3D cap->value->st= ate; + } } =20 /* --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500392648339153.06866151537395; Tue, 18 Jul 2017 08:44:08 -0700 (PDT) Received: from localhost ([::1]:57260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUfN-0001Zb-2V for importer@patchew.org; Tue, 18 Jul 2017 11:44:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUdh-0000NA-QX for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUdd-0006Mg-VM for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUdd-0006L0-O0 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:17 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86A902F86EE for ; Tue, 18 Jul 2017 15:42:16 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DB007F465; Tue, 18 Jul 2017 15:42:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 86A902F86EE Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 86A902F86EE From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:26 +0200 Message-Id: <20170718154127.6459-16-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 18 Jul 2017 15:42:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 15/16] migration: provide migrate_cap_add() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Abstracted from migrate_set_block_enabled() to allocate MigrationCapabilityStatusList properly. Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Message-Id: <1500349150-13240-10-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- migration/migration.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 74099b3..0ebdde1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -842,14 +842,27 @@ void migrate_set_state(int *state, int old_state, int= new_state) } } =20 -void migrate_set_block_enabled(bool value, Error **errp) +static MigrationCapabilityStatusList *migrate_cap_add( + MigrationCapabilityStatusList *list, + MigrationCapability index, + bool state) { MigrationCapabilityStatusList *cap; =20 cap =3D g_new0(MigrationCapabilityStatusList, 1); cap->value =3D g_new0(MigrationCapabilityStatus, 1); - cap->value->capability =3D MIGRATION_CAPABILITY_BLOCK; - cap->value->state =3D value; + cap->value->capability =3D index; + cap->value->state =3D state; + cap->next =3D list; + + return cap; +} + +void migrate_set_block_enabled(bool value, Error **errp) +{ + MigrationCapabilityStatusList *cap; + + cap =3D migrate_cap_add(NULL, MIGRATION_CAPABILITY_BLOCK, value); qmp_migrate_set_capabilities(cap, errp); qapi_free_MigrationCapabilityStatusList(cap); } --=20 2.9.4 From nobody Wed May 1 22:13:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500392796351337.6555201152788; Tue, 18 Jul 2017 08:46:36 -0700 (PDT) Received: from localhost ([::1]:57274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUhn-0004KV-3H for importer@patchew.org; Tue, 18 Jul 2017 11:46:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXUdh-0000NC-Rd for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXUdg-0006Rz-T0 for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47458) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXUdg-0006Qm-Mz for qemu-devel@nongnu.org; Tue, 18 Jul 2017 11:42:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C7BB7CE1A for ; Tue, 18 Jul 2017 15:42:19 +0000 (UTC) Received: from secure.mitica (ovpn-117-165.ams2.redhat.com [10.36.117.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB3D87EF6A; Tue, 18 Jul 2017 15:42:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9C7BB7CE1A Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9C7BB7CE1A From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 17:41:27 +0200 Message-Id: <20170718154127.6459-17-quintela@redhat.com> In-Reply-To: <20170718154127.6459-1-quintela@redhat.com> References: <20170718154127.6459-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 18 Jul 2017 15:42:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 16/16] migration: check global caps for validity X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu Checks validity for all the capabilities that we enabled with command line. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Message-Id: <1500349150-13240-11-git-send-email-peterx@redhat.com> Signed-off-by: Juan Quintela --- migration/migration.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 0ebdde1..7615391 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2166,11 +2166,27 @@ static void migration_instance_init(Object *obj) */ static bool migration_object_check(MigrationState *ms, Error **errp) { + MigrationCapabilityStatusList *head =3D NULL; + /* Assuming all off */ + bool cap_list[MIGRATION_CAPABILITY__MAX] =3D { 0 }, ret; + int i; + if (!migrate_params_check(&ms->parameters, errp)) { return false; } =20 - return true; + for (i =3D 0; i < MIGRATION_CAPABILITY__MAX; i++) { + if (ms->enabled_capabilities[i]) { + head =3D migrate_cap_add(head, i, true); + } + } + + ret =3D migrate_caps_check(cap_list, head, errp); + + /* It works with head =3D=3D NULL */ + qapi_free_MigrationCapabilityStatusList(head); + + return ret; } =20 static const TypeInfo migration_type =3D { --=20 2.9.4