From patchwork Wed Apr 8 06:20:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Liang Z" X-Patchwork-Id: 459099 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E125E140157 for ; Wed, 8 Apr 2015 16:31:44 +1000 (AEST) Received: from localhost ([::1]:50805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YfjWY-0005a6-RL for incoming@patchwork.ozlabs.org; Wed, 08 Apr 2015 02:31:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YfjVR-0003hq-Am for qemu-devel@nongnu.org; Wed, 08 Apr 2015 02:30:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YfjVM-0002zv-A8 for qemu-devel@nongnu.org; Wed, 08 Apr 2015 02:30:33 -0400 Received: from mga09.intel.com ([134.134.136.24]:7131) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YfjVM-0002zn-0B for qemu-devel@nongnu.org; Wed, 08 Apr 2015 02:30:28 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 07 Apr 2015 23:30:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,543,1422950400"; d="scan'208";a="676871880" Received: from lil.sh.intel.com (HELO localhost) ([10.239.159.126]) by orsmga001.jf.intel.com with ESMTP; 07 Apr 2015 23:30:26 -0700 From: Liang Li To: qemu-devel@nongnu.org Date: Wed, 8 Apr 2015 14:20:09 +0800 Message-Id: <1428474011-30797-13-git-send-email-liang.z.li@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428474011-30797-1-git-send-email-liang.z.li@intel.com> References: <1428474011-30797-1-git-send-email-liang.z.li@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.24 Cc: quintela@redhat.com, Liang Li , armbru@redhat.com, lcapitulino@redhat.com, Yang Zhang , amit.shah@redhat.com, dgilbert@redhat.com Subject: [Qemu-devel] [v7 12/14] migration: Use an array instead of 3 parameters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Put the three parameters related to multiple thread (de)compression into an int array, and use an enum type to index the parameter. Signed-off-by: Liang Li Signed-off-by: Yang Zhang Reviewed-by: Juan Quintela --- include/migration/migration.h | 4 +--- migration/migration.c | 31 +++++++++++++++++++------------ qapi-schema.json | 23 +++++++++++++++++++++++ 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index d4a1062..a6e025a 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -50,9 +50,7 @@ struct MigrationState QemuThread thread; QEMUBH *cleanup_bh; QEMUFile *file; - int compress_thread_count; - int decompress_thread_count; - int compress_level; + int parameters[MIGRATION_PARAMETER_MAX]; int state; MigrationParams params; diff --git a/migration/migration.c b/migration/migration.c index dc7db87..533717c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -60,9 +60,12 @@ MigrationState *migrate_get_current(void) .bandwidth_limit = MAX_THROTTLE, .xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE, .mbps = -1, - .compress_thread_count = DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT, - .decompress_thread_count = DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, - .compress_level = DEFAULT_MIGRATE_COMPRESS_LEVEL, + .parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = + DEFAULT_MIGRATE_COMPRESS_LEVEL, + .parameters[MIGRATION_PARAMETER_COMPRESS_THREADS] = + DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT, + .parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] = + DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, }; return ¤t_migration; @@ -406,9 +409,11 @@ static MigrationState *migrate_init(const MigrationParams *params) int64_t bandwidth_limit = s->bandwidth_limit; bool enabled_capabilities[MIGRATION_CAPABILITY_MAX]; int64_t xbzrle_cache_size = s->xbzrle_cache_size; - int compress_level = s->compress_level; - int compress_thread_count = s->compress_thread_count; - int decompress_thread_count = s->decompress_thread_count; + int compress_level = s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL]; + int compress_thread_count = + s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS]; + int decompress_thread_count = + s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS]; memcpy(enabled_capabilities, s->enabled_capabilities, sizeof(enabled_capabilities)); @@ -419,9 +424,11 @@ static MigrationState *migrate_init(const MigrationParams *params) sizeof(enabled_capabilities)); s->xbzrle_cache_size = xbzrle_cache_size; - s->compress_level = compress_level; - s->compress_thread_count = compress_thread_count; - s->decompress_thread_count = decompress_thread_count; + s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL] = compress_level; + s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS] = + compress_thread_count; + s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS] = + decompress_thread_count; s->bandwidth_limit = bandwidth_limit; s->state = MIGRATION_STATUS_SETUP; trace_migrate_set_state(MIGRATION_STATUS_SETUP); @@ -624,7 +631,7 @@ int migrate_compress_level(void) s = migrate_get_current(); - return s->compress_level; + return s->parameters[MIGRATION_PARAMETER_COMPRESS_LEVEL]; } int migrate_compress_threads(void) @@ -633,7 +640,7 @@ int migrate_compress_threads(void) s = migrate_get_current(); - return s->compress_thread_count; + return s->parameters[MIGRATION_PARAMETER_COMPRESS_THREADS]; } int migrate_decompress_threads(void) @@ -642,7 +649,7 @@ int migrate_decompress_threads(void) s = migrate_get_current(); - return s->decompress_thread_count; + return s->parameters[MIGRATION_PARAMETER_DECOMPRESS_THREADS]; } int migrate_use_xbzrle(void) diff --git a/qapi-schema.json b/qapi-schema.json index b117008..e7e2343 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -569,6 +569,29 @@ ## { 'command': 'query-migrate-capabilities', 'returns': ['MigrationCapabilityStatus']} +# @MigrationParameter +# +# Migration parameters enumeration +# +# @compress-level: Set the compression level to be used in live migration, +# the compression level is an integer between 0 and 9, where 0 means +# no compression, 1 means the best compression speed, and 9 means best +# compression ratio which will consume more CPU. +# +# @compress-threads: Set compression thread count to be used in live migration, +# the compression thread count is an integer between 1 and 255. +# +# @decompress-threads: Set decompression thread count to be used in live +# migration, the decompression thread count is an integer between 1 +# and 255. Usually, decompression is at least 4 times as fast as +# compression, so set the decompress-threads to the number about 1/4 +# of compress-threads is adequate. +# +# Since: 2.3 +## +{ 'enum': 'MigrationParameter', + 'data': ['compress-level', 'compress-threads', 'decompress-threads'] } + ## # @MouseInfo: #