From nobody Fri Apr 26 23:52:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1560337889; cv=none; d=zoho.com; s=zohoarc; b=Q9isI49NGVC/8qdZPXdEtMIRThQTVedRmf3K778ogDd0s1Zc2G+ZW3Y5IWhLRoGWcpQPlkfRNq3LPPxt3WIx9Mdx+GSs4PA8DTVLyt1uf6s3Ythvtq6PkjXLR7lUOQSajeSdyZUeR1sIYxy4mMqDac6H+Di/cs+13yOphFBBrso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560337889; h=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:ARC-Authentication-Results; bh=vSy+FLr51cgh8iwYHQJdYvR665yFFlbK6cDsFE3GA2A=; b=AU9pSu+LQvCp3MqnvdpeZpV8De/AQ7iSckh6AGs3HCf7pPHdzddlQ5Ct36Ytku6d3ZYsVzRdxUkJutJtgvh2Q5Oz6Cj9Z8iqd4S2IguUwxrb7gdRmieqOBvOmHtnCPKAhOMFF63ib5VZuegq2a8/VZygNPBErtD64SCyTn66MpQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560337889491805.9525494325075; Wed, 12 Jun 2019 04:11:29 -0700 (PDT) Received: from localhost ([::1]:58828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb1A3-0001S0-D9 for importer@patchew.org; Wed, 12 Jun 2019 07:11:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60090) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb0sr-0007xL-FD for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb0sp-0004iJ-3G for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46356) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb0sn-0004hM-GE for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4964C81F18 for ; Wed, 12 Jun 2019 10:53:32 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-241.ams2.redhat.com [10.36.116.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 622FB53786; Wed, 12 Jun 2019 10:53:30 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 12:53:18 +0200 Message-Id: <20190612105323.7051-2-quintela@redhat.com> In-Reply-To: <20190612105323.7051-1-quintela@redhat.com> References: <20190612105323.7051-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 12 Jun 2019 10:53:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 1/6] migration-test: introduce functions to handle string parameters 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 , Thomas Huth , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- tests/migration-test.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/migration-test.c b/tests/migration-test.c index 36d4910192..c7c311e02c 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -442,6 +442,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.21.0 From nobody Fri Apr 26 23:52:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1560337431; cv=none; d=zoho.com; s=zohoarc; b=djUor0xpBGgPXuh12I/Bl/MclPOL6sejoqtT2jGHp4BEX7FSbL7MQuZWzPDcJkIjzBhvTlVe/BGQr/LzMasjX/jLca0OiOsNrD+XKsIvWGe8FavIknE72qRZ3CgN71EKZErcVsLGKAHHfbHdNPrA6Q0TA214p1Dr6En5vvhUaPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560337431; h=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:ARC-Authentication-Results; bh=jrAU7QFx6jzzm4CJYFb0xsRVacnzmKl3qvFxLaxk3Hk=; b=cevVbdxG2+07sAcn+/wjz0DQV+CZ6YRpuKdh2Y5+qTO46mTfQrmEPIr4LaIm3CmdEIJmtskjQJoNMv6bCvCFDoKBaEpIJSsMkaNhza+XhVnXNod/56wK5TPUPTUBktfgOnNqakHB1q80TGom7/Bybq8JbnBE5CtqGSXop5xOVfc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560337431557499.0547457822537; Wed, 12 Jun 2019 04:03:51 -0700 (PDT) Received: from localhost ([::1]:58796 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb12e-00051x-Fi for importer@patchew.org; Wed, 12 Jun 2019 07:03:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60094) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb0sr-0007yD-KI for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb0sp-0004ie-Gx for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48064) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb0sp-0004i7-AT for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 82E663083392 for ; Wed, 12 Jun 2019 10:53:34 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-241.ams2.redhat.com [10.36.116.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D8D453786; Wed, 12 Jun 2019 10:53:32 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 12:53:19 +0200 Message-Id: <20190612105323.7051-3-quintela@redhat.com> In-Reply-To: <20190612105323.7051-1-quintela@redhat.com> References: <20190612105323.7051-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 12 Jun 2019 10:53:34 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 2/6] migration: Make multifd_save_setup() get an Error parameter 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 , Thomas Huth , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- migration/migration.c | 2 +- migration/ram.c | 2 +- migration/ram.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 2865ae3fa9..0ac504be3c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3336,7 +3336,7 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) return; } =20 - if (multifd_save_setup() !=3D 0) { + if (multifd_save_setup(&error_in) !=3D 0) { migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_FAILED); migrate_fd_cleanup(s); diff --git a/migration/ram.c b/migration/ram.c index 89eec7ee9d..4b65d22cb1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1172,7 +1172,7 @@ static void multifd_new_send_channel_async(QIOTask *t= ask, gpointer opaque) } } =20 -int multifd_save_setup(void) +int multifd_save_setup(Error **errp) { int thread_count; uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); diff --git a/migration/ram.h b/migration/ram.h index 936177b3e9..09feaad55b 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -42,7 +42,7 @@ int xbzrle_cache_resize(int64_t new_size, Error **errp); uint64_t ram_bytes_remaining(void); uint64_t ram_bytes_total(void); =20 -int multifd_save_setup(void); +int multifd_save_setup(Error **errp); void multifd_save_cleanup(void); int multifd_load_setup(void); int multifd_load_cleanup(Error **errp); --=20 2.21.0 From nobody Fri Apr 26 23:52:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1560336991; cv=none; d=zoho.com; s=zohoarc; b=RFn3mq0WOGd1Y6b5TFqWOzpkhqWCrH5waGV/W3uR75I48NRitdseJx0RXKrWcuJK5/w5EZsnnByVMB+0Dn8IlLupo0pkiRJ97W+TRbgKX58csWl9Mmauiu7uzi2b3R9cZ6GFfMohtoTpaXl2NIVRzu1mEBEjzKLONuMsNrVrsbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560336991; h=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:ARC-Authentication-Results; bh=Vj7zMxP1qtJhTtT+glHWex15h+B9CXvJjHFX8yU3D50=; b=F4lAYGRwDVA1v8TJyXy+PZNGYs/noSrOtdO5V3v2HRDTSlAMzICloVeuk7QfL6lQ9RfPdfDdVfS7+7ONULN6+mTNi9w9LSRBs6S59f33RV9kKpFhf8JQe6YudszsBRti+YK+uErzhmeVDuHtRanR2eAmr3bNF/EkS3sIvkFsoyg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560336991608440.6416542498989; Wed, 12 Jun 2019 03:56:31 -0700 (PDT) Received: from localhost ([::1]:58745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb0vc-0001do-Pg for importer@patchew.org; Wed, 12 Jun 2019 06:56:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60137) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb0t5-0008JO-8n for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb0t3-0004mo-W1 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40454) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb0t0-0004jy-U3 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 42DEE37E8E for ; Wed, 12 Jun 2019 10:53:40 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-241.ams2.redhat.com [10.36.116.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id D795153786; Wed, 12 Jun 2019 10:53:34 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 12:53:20 +0200 Message-Id: <20190612105323.7051-4-quintela@redhat.com> In-Reply-To: <20190612105323.7051-1-quintela@redhat.com> References: <20190612105323.7051-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 12 Jun 2019 10:53:40 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 3/6] migration: Make multifd_load_setup() get an Error parameter 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 , Thomas Huth , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We need to change the full chain to pass the Error parameter. Signed-off-by: Juan Quintela --- migration/migration.c | 10 +++++----- migration/migration.h | 2 +- migration/ram.c | 2 +- migration/ram.h | 2 +- migration/rdma.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0ac504be3c..4246bdd661 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -513,11 +513,11 @@ fail: exit(EXIT_FAILURE); } =20 -static void migration_incoming_setup(QEMUFile *f) +static void migration_incoming_setup(QEMUFile *f, Error **errp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 - if (multifd_load_setup() !=3D 0) { + if (multifd_load_setup(errp) !=3D 0) { /* We haven't been able to create multifd threads nothing better to do */ exit(EXIT_FAILURE); @@ -567,13 +567,13 @@ static bool postcopy_try_recover(QEMUFile *f) return false; } =20 -void migration_fd_process_incoming(QEMUFile *f) +void migration_fd_process_incoming(QEMUFile *f, Error **errp) { if (postcopy_try_recover(f)) { return; } =20 - migration_incoming_setup(f); + migration_incoming_setup(f, errp); migration_incoming_process(); } =20 @@ -591,7 +591,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Er= ror **errp) return; } =20 - migration_incoming_setup(f); + migration_incoming_setup(f, errp); =20 /* * Common migration only needs one channel, so we can start diff --git a/migration/migration.h b/migration/migration.h index 780a096857..71c03353c3 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -237,7 +237,7 @@ struct MigrationState =20 void migrate_set_state(int *state, int old_state, int new_state); =20 -void migration_fd_process_incoming(QEMUFile *f); +void migration_fd_process_incoming(QEMUFile *f, Error **errp); void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp); void migration_incoming_process(void); =20 diff --git a/migration/ram.c b/migration/ram.c index 4b65d22cb1..b0ca989160 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1370,7 +1370,7 @@ static void *multifd_recv_thread(void *opaque) return NULL; } =20 -int multifd_load_setup(void) +int multifd_load_setup(Error **errp) { int thread_count; uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); diff --git a/migration/ram.h b/migration/ram.h index 09feaad55b..dd1a736417 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -44,7 +44,7 @@ uint64_t ram_bytes_total(void); =20 int multifd_save_setup(Error **errp); void multifd_save_cleanup(void); -int multifd_load_setup(void); +int multifd_load_setup(Error **errp); int multifd_load_cleanup(Error **errp); bool multifd_recv_all_channels_created(void); bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp); diff --git a/migration/rdma.c b/migration/rdma.c index c1bcece53b..69389a8662 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -4019,7 +4019,7 @@ static void rdma_accept_incoming_migration(void *opaq= ue) } =20 rdma->migration_started_on_destination =3D 1; - migration_fd_process_incoming(f); + migration_fd_process_incoming(f, errp); } =20 void rdma_start_incoming_migration(const char *host_port, Error **errp) --=20 2.21.0 From nobody Fri Apr 26 23:52:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1560338077; cv=none; d=zoho.com; s=zohoarc; b=WCsmzSVGlIaOVOiVAnylUABVbTpSKGXIZ/73kJVN6yn8LTqX8XpXBlrsJMZfr2o3QsrQ180sbUn0vSvQCP8XO74Acx8eVpJ5HA74o3PXN33By3Vnc9N5vVZlbdzP2lJjd0eVM9UJA46aj7DPKhIWIMBgbfw12EVeus/k/ElghaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560338077; h=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:ARC-Authentication-Results; bh=NA9MPOmvnHpGuEjd4Afh3oWDQ+NMedkQuH2YIlQBKTk=; b=mBlKAnsQOXkvtHnjIBhSQLrwvup3b5Zy7PkHGi9XQWFAk5IIXpWaBWf8xx+cR45k0NADmPKi32K+52RWsYj7PsusxcHU1DLepENPr7ZLNGDCYs81qoARpWHKuOIuhVg7Ch5FssNQ7FRhEfxOOO3YeYu5d4pEw/J/r8B5IBawfiI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560338077198973.7143385712776; Wed, 12 Jun 2019 04:14:37 -0700 (PDT) Received: from localhost ([::1]:58870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb1DA-0004zg-2T for importer@patchew.org; Wed, 12 Jun 2019 07:14:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60193) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb0t9-0008M5-Qr for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb0t6-0004o2-95 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51388) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb0t5-0004kZ-68 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DC0B882EA for ; Wed, 12 Jun 2019 10:53:42 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-241.ams2.redhat.com [10.36.116.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98CFB17C46; Wed, 12 Jun 2019 10:53:40 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 12:53:21 +0200 Message-Id: <20190612105323.7051-5-quintela@redhat.com> In-Reply-To: <20190612105323.7051-1-quintela@redhat.com> References: <20190612105323.7051-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 12 Jun 2019 10:53:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 4/6] migration: Add multifd-compress parameter 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 , Thomas Huth , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- Rename it to NONE Fix typos (dave) We don't need to chek values returned by visit_type_MultifdCompress (markus) Fix yet more typos (wei) --- hmp.c | 13 +++++++++++++ hw/core/qdev-properties.c | 13 +++++++++++++ include/hw/qdev-properties.h | 3 +++ migration/migration.c | 13 +++++++++++++ qapi/migration.json | 30 +++++++++++++++++++++++++++--- tests/migration-test.c | 13 ++++++++++--- 6 files changed, 79 insertions(+), 6 deletions(-) diff --git a/hmp.c b/hmp.c index be5e345c6f..b011f139ca 100644 --- a/hmp.c +++ b/hmp.c @@ -38,6 +38,7 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/string-input-visitor.h" @@ -435,6 +436,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_CHANNELS), params->multifd_channels); + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESS), + MultifdCompress_str(params->multifd_compress)); monitor_printf(mon, "%s: %" PRIu64 "\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); @@ -1736,6 +1740,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QD= ict *qdict) MigrateSetParameters *p =3D g_new0(MigrateSetParameters, 1); uint64_t valuebw =3D 0; uint64_t cache_size; + MultifdCompress compress_type; Error *err =3D NULL; int val, ret; =20 @@ -1821,6 +1826,14 @@ void hmp_migrate_set_parameter(Monitor *mon, const Q= Dict *qdict) p->has_multifd_channels =3D true; visit_type_int(v, param, &p->multifd_channels, &err); break; + case MIGRATION_PARAMETER_MULTIFD_COMPRESS: + p->has_multifd_compress =3D true; + visit_type_MultifdCompress(v, param, &compress_type, &err); + if (err) { + break; + } + p->multifd_compress =3D compress_type; + break; case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: p->has_xbzrle_cache_size =3D true; visit_type_size(v, param, &cache_size, &err); diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 5da1439a8b..ebeeb5c88d 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -5,6 +5,7 @@ #include "hw/pci/pci.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" +#include "qapi/qapi-types-migration.h" #include "hw/block/block.h" #include "net/hub.h" #include "qapi/visitor.h" @@ -645,6 +646,18 @@ const PropertyInfo qdev_prop_fdc_drive_type =3D { .set_default_value =3D set_default_value_enum, }; =20 +/* --- MultifdCompress --- */ + +const PropertyInfo qdev_prop_multifd_compress =3D { + .name =3D "MultifdCompress", + .description =3D "multifd_compress values, " + "none", + .enum_table =3D &MultifdCompress_lookup, + .get =3D get_enum, + .set =3D set_enum, + .set_default_value =3D set_default_value_enum, +}; + /* --- pci address --- */ =20 /* diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 1eae5ab056..34d906593b 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -23,6 +23,7 @@ extern const PropertyInfo qdev_prop_tpm; extern const PropertyInfo qdev_prop_ptr; extern const PropertyInfo qdev_prop_macaddr; extern const PropertyInfo qdev_prop_on_off_auto; +extern const PropertyInfo qdev_prop_multifd_compress; extern const PropertyInfo qdev_prop_losttickpolicy; extern const PropertyInfo qdev_prop_blockdev_on_error; extern const PropertyInfo qdev_prop_bios_chs_trans; @@ -205,6 +206,8 @@ extern const PropertyInfo qdev_prop_pcie_link_width; DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr) #define DEFINE_PROP_ON_OFF_AUTO(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto) +#define DEFINE_PROP_MULTIFD_COMPRESS(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_multifd_compress, Multifd= Compress) #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy) diff --git a/migration/migration.c b/migration/migration.c index 4246bdd661..3f17d8f2f8 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -82,6 +82,7 @@ /* The delay time (in ms) between two COLO checkpoints */ #define DEFAULT_MIGRATE_X_CHECKPOINT_DELAY (200 * 100) #define DEFAULT_MIGRATE_MULTIFD_CHANNELS 2 +#define DEFAULT_MIGRATE_MULTIFD_COMPRESS MULTIFD_COMPRESS_NONE =20 /* Background transfer rate for postcopy, 0 means unlimited, note * that page requests can still exceed this limit. @@ -769,6 +770,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->block_incremental =3D s->parameters.block_incremental; params->has_multifd_channels =3D true; params->multifd_channels =3D s->parameters.multifd_channels; + params->has_multifd_compress =3D true; + params->multifd_compress =3D s->parameters.multifd_compress; params->has_xbzrle_cache_size =3D true; params->xbzrle_cache_size =3D s->parameters.xbzrle_cache_size; params->has_max_postcopy_bandwidth =3D true; @@ -1268,6 +1271,9 @@ static void migrate_params_test_apply(MigrateSetParam= eters *params, if (params->has_multifd_channels) { dest->multifd_channels =3D params->multifd_channels; } + if (params->has_multifd_compress) { + dest->multifd_compress =3D params->multifd_compress; + } if (params->has_xbzrle_cache_size) { dest->xbzrle_cache_size =3D params->xbzrle_cache_size; } @@ -1364,6 +1370,9 @@ static void migrate_params_apply(MigrateSetParameters= *params, Error **errp) if (params->has_multifd_channels) { s->parameters.multifd_channels =3D params->multifd_channels; } + if (params->has_multifd_compress) { + s->parameters.multifd_compress =3D params->multifd_compress; + } if (params->has_xbzrle_cache_size) { s->parameters.xbzrle_cache_size =3D params->xbzrle_cache_size; xbzrle_cache_resize(params->xbzrle_cache_size, errp); @@ -3406,6 +3415,9 @@ static Property migration_properties[] =3D { DEFINE_PROP_UINT8("multifd-channels", MigrationState, parameters.multifd_channels, DEFAULT_MIGRATE_MULTIFD_CHANNELS), + DEFINE_PROP_MULTIFD_COMPRESS("multifd-compress", MigrationState, + parameters.multifd_compress, + DEFAULT_MIGRATE_MULTIFD_COMPRESS), DEFINE_PROP_SIZE("xbzrle-cache-size", MigrationState, parameters.xbzrle_cache_size, DEFAULT_MIGRATE_XBZRLE_CACHE_SIZE), @@ -3495,6 +3507,7 @@ static void migration_instance_init(Object *obj) params->has_x_checkpoint_delay =3D true; params->has_block_incremental =3D true; params->has_multifd_channels =3D true; + params->has_multifd_compress =3D true; params->has_xbzrle_cache_size =3D true; params->has_max_postcopy_bandwidth =3D true; params->has_max_cpu_throttle =3D true; diff --git a/qapi/migration.json b/qapi/migration.json index 9cfbaf8c6c..153527e120 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -482,6 +482,19 @@ ## { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabil= ityStatus']} =20 +## +# @MultifdCompress: +# +# An enumeration of multifd compression. +# +# @none: no compression. +# +# Since: 4.1 +# +## +{ 'enum': 'MultifdCompress', + 'data': [ 'none' ] } + ## # @MigrationParameter: # @@ -580,6 +593,9 @@ # @max-cpu-throttle: maximum cpu throttle percentage. # Defaults to 99. (Since 3.1) # +# @multifd-compress: Which compression method to use. +# Defaults to none. (Since 4.1) +# # Since: 2.4 ## { 'enum': 'MigrationParameter', @@ -592,7 +608,7 @@ 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', 'multifd-channels', 'xbzrle-cache-size', 'max-postcopy-bandwidth', - 'max-cpu-throttle' ] } + 'max-cpu-throttle', 'multifd-compress' ] } =20 ## # @MigrateSetParameters: @@ -682,6 +698,9 @@ # @max-cpu-throttle: maximum cpu throttle percentage. # The default value is 99. (Since 3.1) # +# @multifd-compress: Which compression method to use. +# Defaults to none. (Since 4.1) +# # Since: 2.4 ## # TODO either fuse back into MigrationParameters, or make @@ -707,7 +726,8 @@ '*multifd-channels': 'int', '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', - '*max-cpu-throttle': 'int' } } + '*max-cpu-throttle': 'int', + '*multifd-compress': 'MultifdCompress' } } =20 ## # @migrate-set-parameters: @@ -817,6 +837,9 @@ # Defaults to 99. # (Since 3.1) # +# @multifd-compress: Which compression method to use. +# Defaults to none. (Since 4.1) +# # Since: 2.4 ## { 'struct': 'MigrationParameters', @@ -840,7 +863,8 @@ '*multifd-channels': 'uint8', '*xbzrle-cache-size': 'size', '*max-postcopy-bandwidth': 'size', - '*max-cpu-throttle':'uint8'} } + '*max-cpu-throttle': 'uint8', + '*multifd-compress': 'MultifdCompress' } } =20 ## # @query-migrate-parameters: diff --git a/tests/migration-test.c b/tests/migration-test.c index c7c311e02c..e5b8125e1c 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -464,7 +464,6 @@ static void migrate_check_parameter_str(QTestState *who= , const char *parameter, g_free(result); } =20 -__attribute__((unused)) static void migrate_set_parameter_str(QTestState *who, const char *paramet= er, const char *value) { @@ -1165,7 +1164,7 @@ static void test_migrate_fd_proto(void) test_migrate_end(from, to, true); } =20 -static void test_multifd_tcp(void) +static void test_multifd_tcp(const char *method) { char *uri; QTestState *from, *to; @@ -1187,6 +1186,9 @@ static void test_multifd_tcp(void) migrate_set_parameter_int(from, "multifd-channels", 2); migrate_set_parameter_int(to, "multifd-channels", 2); =20 + migrate_set_parameter_str(from, "multifd-compress", method); + migrate_set_parameter_str(to, "multifd-compress", method); + migrate_set_capability(from, "multifd", "true"); migrate_set_capability(to, "multifd", "true"); /* Wait for the first serial output from the source */ @@ -1212,6 +1214,11 @@ static void test_multifd_tcp(void) free(uri); } =20 +static void test_multifd_tcp_none(void) +{ + test_multifd_tcp("none"); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -1267,7 +1274,7 @@ int main(int argc, char **argv) /* qtest_add_func("/migration/ignore_shared", test_ignore_shared); */ qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix); qtest_add_func("/migration/fd_proto", test_migrate_fd_proto); - qtest_add_func("/migration/multifd/tcp", test_multifd_tcp); + qtest_add_func("/migration/multifd/tcp/none", test_multifd_tcp_none); =20 ret =3D g_test_run(); =20 --=20 2.21.0 From nobody Fri Apr 26 23:52:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1560338296; cv=none; d=zoho.com; s=zohoarc; b=HO1MRZKz4IY/gfa52EdJpr6QjbRJo8rCALVREGtUlgtXbI2e8LbTKcPFt6NNuZwj+Sb+4oiB6ZmyhjXgsS4dDU6vdCTyun/YH4ipnBucgudJpc17mInwZC8moCk4AQPwefOSxXoN+6Se0ysBz2zM8zYW8woeRrhWr46B5RdqXjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560338296; h=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:ARC-Authentication-Results; bh=zXpDecmreH/QPNE7PoWsXnADBQ0n0PwnlLlLiw87c50=; b=CgkJ5UUecIX1tVgQgHwhLgeM3H60MT76s0e4cIdXt/InWpiodZh7yIMlO9j1FvnQ8+EcB8PJExqwWv2ISpzyCJQZXY0MUyHnXi38SdIyGQDP8E76f6dFsUAgZCd02z/qPyJXlYElZr2po27F8P/h+YOkYVNKVmzSX2JVCsXDg8A= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560338296618600.5388896177176; Wed, 12 Jun 2019 04:18:16 -0700 (PDT) Received: from localhost ([::1]:58928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb1GD-0007JN-Dv for importer@patchew.org; Wed, 12 Jun 2019 07:17:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60173) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb0t8-0008Ko-1X for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb0t5-0004nU-94 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37992) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb0t3-0004l3-U2 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B63AC3082EF1 for ; Wed, 12 Jun 2019 10:53:44 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-241.ams2.redhat.com [10.36.116.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id D08BC17C21; Wed, 12 Jun 2019 10:53:42 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 12:53:22 +0200 Message-Id: <20190612105323.7051-6-quintela@redhat.com> In-Reply-To: <20190612105323.7051-1-quintela@redhat.com> References: <20190612105323.7051-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 12 Jun 2019 10:53:44 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 5/6] migration: Make no compression operations into its own structure 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 , Thomas Huth , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" It will be used later. Signed-off-by: Juan Quintela --- Move setup of ->ops helper to proper place (wei) Rename s/none/nocomp/ (dave) --- migration/migration.c | 9 ++ migration/migration.h | 1 + migration/ram.c | 188 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 190 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 3f17d8f2f8..a3526d395b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2174,6 +2174,15 @@ int migrate_multifd_channels(void) return s->parameters.multifd_channels; } =20 +int migrate_multifd_method(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->parameters.multifd_compress; +} + int migrate_use_xbzrle(void) { MigrationState *s; diff --git a/migration/migration.h b/migration/migration.h index 71c03353c3..437abf3405 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -270,6 +270,7 @@ bool migrate_auto_converge(void); bool migrate_use_multifd(void); bool migrate_pause_before_switchover(void); int migrate_multifd_channels(void); +int migrate_multifd_method(void); =20 int migrate_use_xbzrle(void); int64_t migrate_xbzrle_cache_size(void); diff --git a/migration/ram.c b/migration/ram.c index b0ca989160..3b0002ddba 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -45,6 +45,7 @@ #include "page_cache.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "qapi/qapi-types-migration.h" #include "qapi/qapi-events-migration.h" #include "qapi/qmp/qerror.h" #include "trace.h" @@ -661,6 +662,8 @@ typedef struct { uint64_t num_packets; /* pages sent through this channel */ uint64_t num_pages; + /* used for compression methods */ + void *data; } MultiFDSendParams; =20 typedef struct { @@ -696,8 +699,152 @@ typedef struct { uint64_t num_pages; /* syncs main thread and channels */ QemuSemaphore sem_sync; + /* used for de-compression methods */ + void *data; } MultiFDRecvParams; =20 +typedef struct { + /* Setup for sending side */ + int (*send_setup)(MultiFDSendParams *p, Error **errp); + /* Cleanup for sending side */ + void (*send_cleanup)(MultiFDSendParams *p); + /* Prepare the send packet */ + int (*send_prepare)(MultiFDSendParams *p, uint32_t used, Error **errp); + /* Write the send packet */ + int (*send_write)(MultiFDSendParams *p, uint32_t used, Error **errp); + /* Setup for receiving side */ + int (*recv_setup)(MultiFDRecvParams *p, Error **errp); + /* Cleanup for receiving side */ + void (*recv_cleanup)(MultiFDRecvParams *p); + /* Read all pages */ + int (*recv_pages)(MultiFDRecvParams *p, uint32_t used, Error **errp); +} MultiFDMethods; + +/* Multifd without compression */ + +/** + * nocomp_send_setup: setup send side + * + * For no compression this function does nothing. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @errp: pointer to an error + */ +static int nocomp_send_setup(MultiFDSendParams *p, Error **errp) +{ + return 0; +} + +/** + * nocomp_send_cleanup: cleanup send side + * + * For no compression this function does nothing. + * + * @p: Params for the channel that we are using + */ +static void nocomp_send_cleanup(MultiFDSendParams *p) +{ + return; +} + +/** + * nocomp_send_prepare: prepare date to be able to send + * + * For no compression we just have to calculate the size of the + * packet. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int nocomp_send_prepare(MultiFDSendParams *p, uint32_t used, + Error **errp) +{ + p->next_packet_size =3D used * qemu_target_page_size(); + return 0; +} + +/** + * nocomp_send_write: do the actual write of the data + * + * For no compression we just have to write the data. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int nocomp_send_write(MultiFDSendParams *p, uint32_t used, Error **= errp) +{ + return qio_channel_writev_all(p->c, p->pages->iov, used, errp); +} + +/** + * nocomp_recv_setup: setup receive side + * + * For no compression this function does nothing. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @errp: pointer to an error + */ +static int nocomp_recv_setup(MultiFDRecvParams *p, Error **errp) +{ + return 0; +} + +/** + * nocomp_recv_cleanup: setup receive side + * + * For no compression this function does nothing. + * + * @p: Params for the channel that we are using + */ +static void nocomp_recv_cleanup(MultiFDRecvParams *p) +{ +} + +/** + * nocomp_recv_pages: read the data from the channel into actual pages + * + * For no compression we just need to read things into the correct place. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int nocomp_recv_pages(MultiFDRecvParams *p, uint32_t used, Error **= errp) +{ + if (p->flags !=3D 0) { + error_setg(errp, "multifd %d: flags received %x flags expected %x", + p->id, MULTIFD_FLAG_ZLIB, p->flags); + return -1; + } + return qio_channel_readv_all(p->c, p->pages->iov, used, errp); +} + +static MultiFDMethods multifd_nocomp_ops =3D { + .send_setup =3D nocomp_send_setup, + .send_cleanup =3D nocomp_send_cleanup, + .send_prepare =3D nocomp_send_prepare, + .send_write =3D nocomp_send_write, + .recv_setup =3D nocomp_recv_setup, + .recv_cleanup =3D nocomp_recv_cleanup, + .recv_pages =3D nocomp_recv_pages +}; + +static MultiFDMethods *multifd_ops[MULTIFD_COMPRESS__MAX] =3D { + [MULTIFD_COMPRESS_NONE] =3D &multifd_nocomp_ops, +}; + static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp) { MultiFDInit_t msg; @@ -900,6 +1047,8 @@ struct { uint64_t packet_num; /* send channels ready */ QemuSemaphore channels_ready; + /* multifd ops */ + MultiFDMethods *ops; } *multifd_send_state; =20 /* @@ -1030,6 +1179,7 @@ void multifd_save_cleanup(void) p->packet_len =3D 0; g_free(p->packet); p->packet =3D NULL; + multifd_send_state->ops->send_cleanup(p); } qemu_sem_destroy(&multifd_send_state->channels_ready); qemu_sem_destroy(&multifd_send_state->sem_sync); @@ -1097,7 +1247,14 @@ static void *multifd_send_thread(void *opaque) uint64_t packet_num =3D p->packet_num; uint32_t flags =3D p->flags; =20 - p->next_packet_size =3D used * qemu_target_page_size(); + if (used) { + ret =3D multifd_send_state->ops->send_prepare(p, used, + &local_err); + if (ret !=3D 0) { + qemu_mutex_unlock(&p->mutex); + break; + } + } multifd_send_fill_packet(p); p->flags =3D 0; p->num_packets++; @@ -1115,8 +1272,7 @@ static void *multifd_send_thread(void *opaque) } =20 if (used) { - ret =3D qio_channel_writev_all(p->c, p->pages->iov, - used, &local_err); + ret =3D multifd_send_state->ops->send_write(p, used, &loca= l_err); if (ret !=3D 0) { break; } @@ -1176,6 +1332,7 @@ int multifd_save_setup(Error **errp) { int thread_count; uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + int ret =3D 0; uint8_t i; =20 if (!migrate_use_multifd()) { @@ -1187,9 +1344,11 @@ int multifd_save_setup(Error **errp) multifd_send_state->pages =3D multifd_pages_init(page_count); qemu_sem_init(&multifd_send_state->sem_sync, 0); qemu_sem_init(&multifd_send_state->channels_ready, 0); + multifd_send_state->ops =3D multifd_ops[migrate_multifd_method()]; =20 for (i =3D 0; i < thread_count; i++) { MultiFDSendParams *p =3D &multifd_send_state->params[i]; + int res; =20 qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem, 0); @@ -1202,8 +1361,12 @@ int multifd_save_setup(Error **errp) p->packet =3D g_malloc0(p->packet_len); p->name =3D g_strdup_printf("multifdsend_%d", i); socket_send_channel_create(multifd_new_send_channel_async, p); + res =3D multifd_send_state->ops->send_setup(p, errp); + if (ret =3D=3D 0) { + ret =3D res; + } } - return 0; + return ret; } =20 struct { @@ -1214,6 +1377,8 @@ struct { QemuSemaphore sem_sync; /* global number of generated multifd packets */ uint64_t packet_num; + /* multifd ops */ + MultiFDMethods *ops; } *multifd_recv_state; =20 static void multifd_recv_terminate_threads(Error *err) @@ -1246,7 +1411,6 @@ static void multifd_recv_terminate_threads(Error *err) int multifd_load_cleanup(Error **errp) { int i; - int ret =3D 0; =20 if (!migrate_use_multifd()) { return 0; @@ -1269,6 +1433,7 @@ int multifd_load_cleanup(Error **errp) p->packet_len =3D 0; g_free(p->packet); p->packet =3D NULL; + multifd_recv_state->ops->recv_cleanup(p); } qemu_sem_destroy(&multifd_recv_state->sem_sync); g_free(multifd_recv_state->params); @@ -1276,7 +1441,7 @@ int multifd_load_cleanup(Error **errp) g_free(multifd_recv_state); multifd_recv_state =3D NULL; =20 - return ret; + return 0; } =20 static void multifd_recv_sync_main(void) @@ -1337,6 +1502,8 @@ static void *multifd_recv_thread(void *opaque) =20 used =3D p->pages->used; flags =3D p->flags; + /* recv methods don't know how to handle the SYNC flag */ + p->flags &=3D ~MULTIFD_FLAG_SYNC; trace_multifd_recv(p->id, p->packet_num, used, flags, p->next_packet_size); p->num_packets++; @@ -1344,8 +1511,7 @@ static void *multifd_recv_thread(void *opaque) qemu_mutex_unlock(&p->mutex); =20 if (used) { - ret =3D qio_channel_readv_all(p->c, p->pages->iov, - used, &local_err); + ret =3D multifd_recv_state->ops->recv_pages(p, used, &local_er= r); if (ret !=3D 0) { break; } @@ -1384,9 +1550,11 @@ int multifd_load_setup(Error **errp) multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); atomic_set(&multifd_recv_state->count, 0); qemu_sem_init(&multifd_recv_state->sem_sync, 0); + multifd_recv_state->ops =3D multifd_ops[migrate_multifd_method()]; =20 for (i =3D 0; i < thread_count; i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + int ret; =20 qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem_sync, 0); @@ -1396,6 +1564,10 @@ int multifd_load_setup(Error **errp) + sizeof(ram_addr_t) * page_count; p->packet =3D g_malloc0(p->packet_len); p->name =3D g_strdup_printf("multifdrecv_%d", i); + ret =3D multifd_recv_state->ops->recv_setup(p, errp); + if (ret !=3D 0) { + return ret; + } } return 0; } --=20 2.21.0 From nobody Fri Apr 26 23:52:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1560338367; cv=none; d=zoho.com; s=zohoarc; b=kVaRPbPZsJfSS87/VovIeoADA6v4kKSxnpe2mADBcg1OW4sJN/RP0uUDzAw+7vEw7alASa7smRUtZ2RUPyK8I16pK/nT32Ohn58nI4OC8BX27fnpiKIG8hwIc7wvFUcOdlhhiP8qgNSPhsSyn48/akhbMLHvQf0GoyDpUW9IECc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560338367; h=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:ARC-Authentication-Results; bh=x0LC1+otObOd6c1i8Yg4GPRGUtHcEPR0uiJscOPBDH8=; b=UXmNetEi0xBrSUG4BKA1SV1YY9koks469JeqoZfuVQoPLQ8uI+PdTTv6+Ju0oMdGrb1zx8ksdWRSY/CZN2Udb4MxPpaoC6ZGI3DE5Fe2SqWFQ9fM2M51MFrHU3AkGwFlenBtOH3x+foM32Kj6dCotbfapW6LeAFDpCyZzeeWOvc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1560338367905184.9159807986117; Wed, 12 Jun 2019 04:19:27 -0700 (PDT) Received: from localhost ([::1]:59012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb1Hn-0000x1-JQ for importer@patchew.org; Wed, 12 Jun 2019 07:19:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60194) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb0t9-0008M6-Qr for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb0t6-0004o5-97 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47550) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hb0t5-0004lu-8c for qemu-devel@nongnu.org; Wed, 12 Jun 2019 06:53:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF1D9C05D3F9 for ; Wed, 12 Jun 2019 10:53:46 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-241.ams2.redhat.com [10.36.116.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1647353786; Wed, 12 Jun 2019 10:53:44 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2019 12:53:23 +0200 Message-Id: <20190612105323.7051-7-quintela@redhat.com> In-Reply-To: <20190612105323.7051-1-quintela@redhat.com> References: <20190612105323.7051-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 12 Jun 2019 10:53:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 6/6] migration: Add zlib compression multifd support 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 , Thomas Huth , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Juan Quintela --- hw/core/qdev-properties.c | 2 +- migration/ram.c | 262 ++++++++++++++++++++++++++++++++++++++ qapi/migration.json | 2 +- tests/migration-test.c | 6 + 4 files changed, 270 insertions(+), 2 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index ebeeb5c88d..e40aa806e2 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -651,7 +651,7 @@ const PropertyInfo qdev_prop_fdc_drive_type =3D { const PropertyInfo qdev_prop_multifd_compress =3D { .name =3D "MultifdCompress", .description =3D "multifd_compress values, " - "none", + "none/zlib", .enum_table =3D &MultifdCompress_lookup, .get =3D get_enum, .set =3D set_enum, diff --git a/migration/ram.c b/migration/ram.c index 3b0002ddba..691ebd9108 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -583,6 +583,7 @@ exit: #define MULTIFD_VERSION 1 =20 #define MULTIFD_FLAG_SYNC (1 << 0) +#define MULTIFD_FLAG_ZLIB (1 << 1) =20 /* This value needs to be a multiple of qemu_target_page_size() */ #define MULTIFD_PACKET_SIZE (512 * 1024) @@ -625,6 +626,15 @@ typedef struct { RAMBlock *block; } MultiFDPages_t; =20 +struct zlib_data { + /* stream for compression */ + z_stream zs; + /* compressed buffer */ + uint8_t *zbuff; + /* size of compressed buffer */ + uint32_t zbuff_len; +}; + typedef struct { /* this fields are not changed once the thread is created */ /* channel number */ @@ -841,8 +851,260 @@ static MultiFDMethods multifd_nocomp_ops =3D { .recv_pages =3D nocomp_recv_pages }; =20 +/* Multifd zlib compression */ + +/** + * zlib_send_setup: setup send side + * + * Setup each channel with zlib compression. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @errp: pointer to an error + */ +static int zlib_send_setup(MultiFDSendParams *p, Error **errp) +{ + uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + struct zlib_data *z =3D g_malloc0(sizeof(struct zlib_data)); + z_stream *zs =3D &z->zs; + + p->data =3D z; + zs->zalloc =3D Z_NULL; + zs->zfree =3D Z_NULL; + zs->opaque =3D Z_NULL; + if (deflateInit(zs, migrate_compress_level()) !=3D Z_OK) { + error_setg(errp, "multifd %d: deflate init failed", p->id); + return -1; + } + /* We will never have more than page_count pages */ + z->zbuff_len =3D page_count * qemu_target_page_size(); + z->zbuff_len *=3D 2; + z->zbuff =3D g_try_malloc(z->zbuff_len); + if (!z->zbuff) { + error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + return -1; + } + return 0; +} + +/** + * zlib_send_cleanup: cleanup send side + * + * Close the channel and return memory. + * + * @p: Params for the channel that we are using + */ +static void zlib_send_cleanup(MultiFDSendParams *p) +{ + struct zlib_data *z =3D p->data; + + deflateEnd(&z->zs); + g_free(z->zbuff); + z->zbuff =3D NULL; + g_free(p->data); + p->data =3D NULL; +} + +/** + * zlib_send_prepare: prepare date to be able to send + * + * Create a compressed buffer with all the pages that we are going to + * send. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + */ +static int zlib_send_prepare(MultiFDSendParams *p, uint32_t used, Error **= errp) +{ + struct iovec *iov =3D p->pages->iov; + struct zlib_data *z =3D p->data; + z_stream *zs =3D &z->zs; + uint32_t out_size =3D 0; + int ret; + uint32_t i; + + for (i =3D 0; i < used; i++) { + uint32_t available =3D z->zbuff_len - out_size; + int flush =3D Z_NO_FLUSH; + + if (i =3D=3D used - 1) { + flush =3D Z_SYNC_FLUSH; + } + + zs->avail_in =3D iov[i].iov_len; + zs->next_in =3D iov[i].iov_base; + + zs->avail_out =3D available; + zs->next_out =3D z->zbuff + out_size; + + ret =3D deflate(zs, flush); + if (ret !=3D Z_OK) { + error_setg(errp, "multifd %d: deflate returned %d instead of Z= _OK", + p->id, ret); + return -1; + } + out_size +=3D available - zs->avail_out; + } + p->next_packet_size =3D out_size; + p->flags |=3D MULTIFD_FLAG_ZLIB; + + return 0; +} + +/** + * zlib_send_write: do the actual write of the data + * + * Do the actual write of the comprresed buffer. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int zlib_send_write(MultiFDSendParams *p, uint32_t used, Error **er= rp) +{ + struct zlib_data *z =3D p->data; + + return qio_channel_write_all(p->c, (void *)z->zbuff, p->next_packet_si= ze, + errp); +} + +/** + * zlib_recv_setup: setup receive side + * + * Create the compressed channel and buffer. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @errp: pointer to an error + */ +static int zlib_recv_setup(MultiFDRecvParams *p, Error **errp) +{ + uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + struct zlib_data *z =3D g_malloc0(sizeof(struct zlib_data)); + z_stream *zs =3D &z->zs; + + p->data =3D z; + zs->zalloc =3D Z_NULL; + zs->zfree =3D Z_NULL; + zs->opaque =3D Z_NULL; + zs->avail_in =3D 0; + zs->next_in =3D Z_NULL; + if (inflateInit(zs) !=3D Z_OK) { + error_setg(errp, "multifd %d: inflate init failed", p->id); + return -1; + } + /* We will never have more than page_count pages */ + z->zbuff_len =3D page_count * qemu_target_page_size(); + /* We know compression "could" use more space */ + z->zbuff_len *=3D 2; + z->zbuff =3D g_try_malloc(z->zbuff_len); + if (!z->zbuff) { + error_setg(errp, "multifd %d: out of memory for zbuff", p->id); + return -1; + } + return 0; +} + +/** + * zlib_recv_cleanup: setup receive side + * + * For no compression this function does nothing. + * + * @p: Params for the channel that we are using + */ +static void zlib_recv_cleanup(MultiFDRecvParams *p) +{ + struct zlib_data *z =3D p->data; + + inflateEnd(&z->zs); + g_free(z->zbuff); + z->zbuff =3D NULL; + g_free(p->data); + p->data =3D NULL; +} + +/** + * zlib_recv_pages: read the data from the channel into actual pages + * + * Read the compressed buffer, and uncompress it into the actual + * pages. + * + * Returns 0 for success or -1 for error + * + * @p: Params for the channel that we are using + * @used: number of pages used + * @errp: pointer to an error + */ +static int zlib_recv_pages(MultiFDRecvParams *p, uint32_t used, Error **er= rp) +{ + uint32_t in_size =3D p->next_packet_size; + uint32_t out_size =3D 0; + uint32_t expected_size =3D used * qemu_target_page_size(); + struct zlib_data *z =3D p->data; + z_stream *zs =3D &z->zs; + int ret; + int i; + + if (p->flags !=3D MULTIFD_FLAG_ZLIB) { + error_setg(errp, "multifd %d: flags received %x flags expected %x", + p->id, MULTIFD_FLAG_ZLIB, p->flags); + return -1; + } + ret =3D qio_channel_read_all(p->c, (void *)z->zbuff, in_size, errp); + + if (ret !=3D 0) { + return ret; + } + + zs->avail_in =3D in_size; + zs->next_in =3D z->zbuff; + + for (i =3D 0; i < used; i++) { + struct iovec *iov =3D &p->pages->iov[i]; + int flush =3D Z_NO_FLUSH; + + if (i =3D=3D used - 1) { + flush =3D Z_SYNC_FLUSH; + } + + zs->avail_out =3D iov->iov_len; + zs->next_out =3D iov->iov_base; + + ret =3D inflate(zs, flush); + if (ret !=3D Z_OK) { + error_setg(errp, "multifd %d: inflate returned %d instead of Z= _OK", + p->id, ret); + return ret; + } + out_size +=3D iov->iov_len; + } + if (out_size !=3D expected_size) { + error_setg(errp, "multifd %d: packet size received %d size expecte= d %d", + p->id, out_size, expected_size); + return -1; + } + return 0; +} + +static MultiFDMethods multifd_zlib_ops =3D { + .send_setup =3D zlib_send_setup, + .send_cleanup =3D zlib_send_cleanup, + .send_prepare =3D zlib_send_prepare, + .send_write =3D zlib_send_write, + .recv_setup =3D zlib_recv_setup, + .recv_cleanup =3D zlib_recv_cleanup, + .recv_pages =3D zlib_recv_pages +}; + static MultiFDMethods *multifd_ops[MULTIFD_COMPRESS__MAX] =3D { [MULTIFD_COMPRESS_NONE] =3D &multifd_nocomp_ops, + [MULTIFD_COMPRESS_ZLIB] =3D &multifd_zlib_ops, }; =20 static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp) diff --git a/qapi/migration.json b/qapi/migration.json index 153527e120..085eba8f07 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -493,7 +493,7 @@ # ## { 'enum': 'MultifdCompress', - 'data': [ 'none' ] } + 'data': [ 'none', 'zlib' ] } =20 ## # @MigrationParameter: diff --git a/tests/migration-test.c b/tests/migration-test.c index e5b8125e1c..e6995ae4e7 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -1219,6 +1219,11 @@ static void test_multifd_tcp_none(void) test_multifd_tcp("none"); } =20 +static void test_multifd_tcp_zlib(void) +{ + test_multifd_tcp("zlib"); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -1275,6 +1280,7 @@ int main(int argc, char **argv) qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix); qtest_add_func("/migration/fd_proto", test_migrate_fd_proto); qtest_add_func("/migration/multifd/tcp/none", test_multifd_tcp_none); + qtest_add_func("/migration/multifd/tcp/zlib", test_multifd_tcp_zlib); =20 ret =3D g_test_run(); =20 --=20 2.21.0