From patchwork Thu Apr 26 09:15:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10365093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2DEB460542 for ; Thu, 26 Apr 2018 09:15:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C2AD28FFD for ; Thu, 26 Apr 2018 09:15:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 108932905D; Thu, 26 Apr 2018 09:15:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 341C928FFD for ; Thu, 26 Apr 2018 09:15:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754638AbeDZJPa (ORCPT ); Thu, 26 Apr 2018 05:15:30 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:37511 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753487AbeDZJP1 (ORCPT ); Thu, 26 Apr 2018 05:15:27 -0400 Received: by mail-pg0-f65.google.com with SMTP id a13so10996359pgu.4 for ; Thu, 26 Apr 2018 02:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=k/nhQIAx9eymtO5OqQaimr2mgl6OUvFmqBlkvA5gAHU=; b=KHorZxijoLaAIdKUFc54VGMiEN9HcX5OFhWaphUaTO3qjic29uRrZJ/l/Qo0mm/mie aMoPThsntpqtk+p/+LmIzGd65GlhLSwX43H0NMSdiYbproj5PPZ90aBUldB03y9i3fEC nKJJhRRIRSEF1eP5xjgHwWKBpQ3md9qV/jqoyPTpUcevXykvnuGU540J092pwyYSnNTm JZ3QGarS1wAh2FsogJXv4nDUowlrL3ih7SJIMeHPCYokZqkjvKdr6TPT6wBadeaWmqN2 GSBMIZqfHjsQpZGORSAeAGUOOBoIPQ8Lx4bAZdYUEOHpynFHSiTGHgTlSNkWTOxA6FHq 3L1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k/nhQIAx9eymtO5OqQaimr2mgl6OUvFmqBlkvA5gAHU=; b=cN67V+U/cCJvryQJxPe5QoV0RezHihvVqD8NnSywU2IHNu2dqL+5OlQdrDZBZog7rv hT3vz4y8Q2ZPqDgiepzpS0Lxq7B+a5yBUzeKCnX4YGOhBhCYl0yPiRRtiHeVmrDziYY7 d7LYP9qQZKuJ6ursSd6KMp56728oSpTDmWFKWUTikn7OLTIz9USF9NINBVSKIaInwNA6 SWXjVoYMW23qPiEKKNMEm1z//yfSkv9lpZrGQ/a9JccA4l/W6HUXzX/olBJaT3CXPQAe UMV8ZNswtFtvIizVP20Gvw4gAPIUs2yEUKJ3K/oD/p13jq+VEJLXlGI+UhuOhMnk5R6f w8cA== X-Gm-Message-State: ALQs6tDXfqxMQ7SzYeZg51GWXYm96nOiCTwdBuGNZm71p4MloJ/s3JD7 OlzgOAhcRFjjvy8VhmuYANs= X-Google-Smtp-Source: AIpwx4+iEb1a7lWnYoL2S09buFX3mLBAVzpySSGxSth7CPdS36WQ9pNo+BYJkWrH9xVjZ4/He0USug== X-Received: by 10.98.98.65 with SMTP id w62mr31509905pfb.256.1524734127179; Thu, 26 Apr 2018 02:15:27 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.35]) by smtp.gmail.com with ESMTPSA id s17sm1849843pfi.165.2018.04.26.02.15.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Apr 2018 02:15:26 -0700 (PDT) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, dgilbert@redhat.com, peterx@redhat.com, jiang.biao2@zte.com.cn, wei.w.wang@intel.com, Xiao Guangrong Subject: [PATCH] migration: introduce decompress-error-check Date: Thu, 26 Apr 2018 17:15:19 +0800 Message-Id: <20180426091519.26934-1-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Xiao Guangrong QEMU 2.13 enables strict check for compression & decompression to make the migration more robuster, that depends on the source to fix the internal design which triggers the unexpected error conditions To make it work for migrating old version QEMU to 2.13 QEMU, we introduce this parameter to disable the error check on the destination Signed-off-by: Xiao Guangrong --- hmp.c | 8 ++++++++ migration/migration.c | 19 +++++++++++++++++++ migration/migration.h | 1 + migration/ram.c | 2 +- qapi/migration.json | 43 +++++++++++++++++++++++++++++++++++++++---- 5 files changed, 68 insertions(+), 5 deletions(-) diff --git a/hmp.c b/hmp.c index 898e25f3e1..f0b934368b 100644 --- a/hmp.c +++ b/hmp.c @@ -329,6 +329,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS), params->decompress_threads); + assert(params->has_decompress_error_check); + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_ERROR_CHECK), + params->decompress_error_check ? "on" : "off"); assert(params->has_cpu_throttle_initial); monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL), @@ -1593,6 +1597,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) p->has_decompress_threads = true; visit_type_int(v, param, &p->decompress_threads, &err); break; + case MIGRATION_PARAMETER_DECOMPRESS_ERROR_CHECK: + p->has_decompress_error_check = true; + visit_type_bool(v, param, &p->decompress_error_check, &err); + break; case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL: p->has_cpu_throttle_initial = true; visit_type_int(v, param, &p->cpu_throttle_initial, &err); diff --git a/migration/migration.c b/migration/migration.c index 0bdb28e144..1eef084763 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -534,6 +534,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->compress_threads = s->parameters.compress_threads; params->has_decompress_threads = true; params->decompress_threads = s->parameters.decompress_threads; + params->has_decompress_error_check = true; + params->decompress_error_check = s->parameters.decompress_error_check; params->has_cpu_throttle_initial = true; params->cpu_throttle_initial = s->parameters.cpu_throttle_initial; params->has_cpu_throttle_increment = true; @@ -917,6 +919,10 @@ static void migrate_params_test_apply(MigrateSetParameters *params, dest->decompress_threads = params->decompress_threads; } + if (params->has_decompress_error_check) { + dest->decompress_error_check = params->decompress_error_check; + } + if (params->has_cpu_throttle_initial) { dest->cpu_throttle_initial = params->cpu_throttle_initial; } @@ -979,6 +985,10 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) s->parameters.decompress_threads = params->decompress_threads; } + if (params->has_decompress_error_check) { + s->parameters.decompress_error_check = params->decompress_error_check; + } + if (params->has_cpu_throttle_initial) { s->parameters.cpu_throttle_initial = params->cpu_throttle_initial; } @@ -1620,6 +1630,15 @@ int migrate_decompress_threads(void) return s->parameters.decompress_threads; } +bool migrate_decompress_error_check(void) +{ + MigrationState *s; + + s = migrate_get_current(); + + return s->parameters.decompress_error_check; +} + bool migrate_dirty_bitmaps(void) { MigrationState *s; diff --git a/migration/migration.h b/migration/migration.h index 7c69598c54..5efbbaf9d8 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -241,6 +241,7 @@ bool migrate_use_compression(void); int migrate_compress_level(void); int migrate_compress_threads(void); int migrate_decompress_threads(void); +bool migrate_decompress_error_check(void); bool migrate_use_events(void); bool migrate_postcopy_blocktime(void); diff --git a/migration/ram.c b/migration/ram.c index 912810c18e..01cc815410 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2581,7 +2581,7 @@ static void *do_data_decompress(void *opaque) ret = qemu_uncompress_data(¶m->stream, des, pagesize, param->compbuf, len); - if (ret < 0) { + if (ret < 0 && migrate_decompress_error_check()) { error_report("decompress data failed"); qemu_file_set_error(decomp_file, ret); } diff --git a/qapi/migration.json b/qapi/migration.json index f3974c6807..68222358e1 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -455,6 +455,17 @@ # compression, so set the decompress-threads to the number about 1/4 # of compress-threads is adequate. # +# @decompress-error-check: check decompression errors. When false, the errors +# triggered by memory decompression are ignored. +# When true, migration is aborted if the errors are +# detected. For the old QEMU versions (< 2.13) the +# internal design will cause decompression to fail +# so the destination should completely ignore the +# error conditions, i.e, make it be false if these +# QEMUs are going to be migrated. Since 2.13, this +# design is fixed, make it be true to avoid corrupting +# the VM silently (Since 2.13) +# # @cpu-throttle-initial: Initial percentage of time guest cpus are throttled # when migration auto-converge is activated. The # default value is 20. (Since 2.7) @@ -511,10 +522,10 @@ ## { 'enum': 'MigrationParameter', 'data': ['compress-level', 'compress-threads', 'decompress-threads', - 'cpu-throttle-initial', 'cpu-throttle-increment', - 'tls-creds', 'tls-hostname', 'max-bandwidth', - 'downtime-limit', 'x-checkpoint-delay', 'block-incremental', - 'x-multifd-channels', 'x-multifd-page-count', + 'decompress-error-check', 'cpu-throttle-initial', + 'cpu-throttle-increment', 'tls-creds', 'tls-hostname', + 'max-bandwidth', 'downtime-limit', 'x-checkpoint-delay', + 'block-incremental', 'x-multifd-channels', 'x-multifd-page-count', 'xbzrle-cache-size' ] } ## @@ -526,6 +537,17 @@ # # @decompress-threads: decompression thread count # +# @decompress-error-check: check decompression errors. When false, the errors +# triggered by memory decompression are ignored. +# When true, migration is aborted if the errors are +# detected. For the old QEMU versions (< 2.13) the +# internal design will cause decompression to fail +# so the destination should completely ignore the +# error conditions, i.e, make it be false if these +# QEMUs are going to be migrated. Since 2.13, this +# design is fixed, make it be true to avoid corrupting +# the VM silently (Since 2.13) +# # @cpu-throttle-initial: Initial percentage of time guest cpus are # throttled when migration auto-converge is activated. # The default value is 20. (Since 2.7) @@ -591,6 +613,7 @@ 'data': { '*compress-level': 'int', '*compress-threads': 'int', '*decompress-threads': 'int', + '*decompress-error-check': 'bool', '*cpu-throttle-initial': 'int', '*cpu-throttle-increment': 'int', '*tls-creds': 'StrOrNull', @@ -630,6 +653,17 @@ # # @decompress-threads: decompression thread count # +# @decompress-error-check: check decompression errors. When false, the errors +# triggered by memory decompression are ignored. +# When true, migration is aborted if the errors are +# detected. For the old QEMU versions (< 2.13) the +# internal design will cause decompression to fail +# so the destination should completely ignore the +# error conditions, i.e, make it be false if these +# QEMUs are going to be migrated. Since 2.13, this +# design is fixed, make it be true to avoid corrupting +# the VM silently (Since 2.13) +# # @cpu-throttle-initial: Initial percentage of time guest cpus are # throttled when migration auto-converge is activated. # (Since 2.7) @@ -690,6 +724,7 @@ 'data': { '*compress-level': 'uint8', '*compress-threads': 'uint8', '*decompress-threads': 'uint8', + '*decompress-error-check': 'bool', '*cpu-throttle-initial': 'uint8', '*cpu-throttle-increment': 'uint8', '*tls-creds': 'str',