From nobody Wed May 14 17:21:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523457785179295.11095497451765; Wed, 11 Apr 2018 07:43:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 546D07D4FE; Wed, 11 Apr 2018 14:43:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36631832D7; Wed, 11 Apr 2018 14:43:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id ED56C181A72D; Wed, 11 Apr 2018 14:42:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3BEgGwa008828 for ; Wed, 11 Apr 2018 10:42:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 194BCAB3E5; Wed, 11 Apr 2018 14:42:16 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B41E3AB3E4 for ; Wed, 11 Apr 2018 14:42:15 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B5AC2100B80; Wed, 11 Apr 2018 16:42:10 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:41:34 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 44/73] qemu: Move qemuMigrationAnyCompression* X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 11 Apr 2018 14:43:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The code really belongs to qemu_migration_params.c. Signed-off-by: Jiri Denemark Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_migration.c | 140 ----------------------------- src/qemu/qemu_migration.h | 19 ---- src/qemu/qemu_migration_params.c | 147 +++++++++++++++++++++++++++++++ src/qemu/qemu_migration_params.h | 11 +++ 4 files changed, 158 insertions(+), 159 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index d4c5994f25..d0d0d97be4 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -77,11 +77,6 @@ VIR_ENUM_IMPL(qemuMigrationJobPhase, QEMU_MIGRATION_PHAS= E_LAST, "finish3", ); =20 -VIR_ENUM_IMPL(qemuMigrationCompressMethod, QEMU_MIGRATION_COMPRESS_LAST, - "xbzrle", - "mt", -); - static int qemuMigrationJobStart(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -5439,141 +5434,6 @@ qemuMigrationDstErrorReport(virQEMUDriverPtr driver, } =20 =20 -/* don't ever pass NULL params with non zero nparams */ -qemuMigrationCompressionPtr -qemuMigrationAnyCompressionParse(virTypedParameterPtr params, - int nparams, - unsigned long flags) -{ - size_t i; - qemuMigrationCompressionPtr compression =3D NULL; - - if (VIR_ALLOC(compression) < 0) - return NULL; - - for (i =3D 0; i < nparams; i++) { - int method; - - if (STRNEQ(params[i].field, VIR_MIGRATE_PARAM_COMPRESSION)) - continue; - - method =3D qemuMigrationCompressMethodTypeFromString(params[i].val= ue.s); - if (method < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Unsupported compression method '%s'"), - params[i].value.s); - goto error; - } - - if (compression->methods & (1ULL << method)) { - virReportError(VIR_ERR_INVALID_ARG, - _("Compression method '%s' is specified twice"), - params[i].value.s); - goto error; - } - - compression->methods |=3D 1ULL << method; - } - -#define GET_PARAM(PARAM, TYPE, VALUE) \ - do { \ - int rc; \ - const char *par =3D VIR_MIGRATE_PARAM_COMPRESSION_ ## PARAM; \ - \ - if ((rc =3D virTypedParamsGet ## TYPE(params, nparams, \ - par, &compression->VALUE)) < 0= ) \ - goto error; \ - \ - if (rc =3D=3D 1) \ - compression->VALUE ## _set =3D true; \ - } while (0) - - if (params) { - GET_PARAM(MT_LEVEL, Int, level); - GET_PARAM(MT_THREADS, Int, threads); - GET_PARAM(MT_DTHREADS, Int, dthreads); - GET_PARAM(XBZRLE_CACHE, ULLong, xbzrle_cache); - } - -#undef GET_PARAM - - if ((compression->level_set || - compression->threads_set || - compression->dthreads_set) && - !(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_MT))) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("Turn multithread compression on to tune it")); - goto error; - } - - if (compression->xbzrle_cache_set && - !(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE))= ) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("Turn xbzrle compression on to tune it")); - goto error; - } - - if (!compression->methods && (flags & VIR_MIGRATE_COMPRESSED)) - compression->methods =3D 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE; - - return compression; - - error: - VIR_FREE(compression); - return NULL; -} - -int -qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression, - virTypedParameterPtr *params, - int *nparams, - int *maxparams, - unsigned long *flags) -{ - size_t i; - - if (compression->methods =3D=3D 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE= && - !compression->xbzrle_cache_set) { - *flags |=3D VIR_MIGRATE_COMPRESSED; - return 0; - } - - for (i =3D 0; i < QEMU_MIGRATION_COMPRESS_LAST; ++i) { - if ((compression->methods & (1ULL << i)) && - virTypedParamsAddString(params, nparams, maxparams, - VIR_MIGRATE_PARAM_COMPRESSION, - qemuMigrationCompressMethodTypeToStrin= g(i)) < 0) - return -1; - } - - if (compression->level_set && - virTypedParamsAddInt(params, nparams, maxparams, - VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, - compression->level) < 0) - return -1; - - if (compression->threads_set && - virTypedParamsAddInt(params, nparams, maxparams, - VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, - compression->threads) < 0) - return -1; - - if (compression->dthreads_set && - virTypedParamsAddInt(params, nparams, maxparams, - VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, - compression->dthreads) < 0) - return -1; - - if (compression->xbzrle_cache_set && - virTypedParamsAddULLong(params, nparams, maxparams, - VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, - compression->xbzrle_cache) < 0) - return -1; - - return 0; -} - - int qemuMigrationSrcFetchMirrorStats(virQEMUDriverPtr driver, virDomainObjPtr vm, diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 3cd456568a..53d8c529fc 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -98,25 +98,6 @@ typedef enum { } qemuMigrationJobPhase; VIR_ENUM_DECL(qemuMigrationJobPhase) =20 -typedef enum { - QEMU_MIGRATION_COMPRESS_XBZRLE =3D 0, - QEMU_MIGRATION_COMPRESS_MT, - - QEMU_MIGRATION_COMPRESS_LAST -} qemuMigrationCompressMethod; -VIR_ENUM_DECL(qemuMigrationCompressMethod) - -qemuMigrationCompressionPtr -qemuMigrationAnyCompressionParse(virTypedParameterPtr params, - int nparams, - unsigned long flags); -int -qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression, - virTypedParameterPtr *params, - int *nparams, - int *maxparams, - unsigned long *flags); - int qemuMigrationSrcSetOffline(virQEMUDriverPtr driver, virDomainObjPtr vm); diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index b532299a5f..94eb08a6bb 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -43,6 +43,19 @@ struct _qemuMigrationParams { qemuMonitorMigrationParams params; }; =20 +typedef enum { + QEMU_MIGRATION_COMPRESS_XBZRLE =3D 0, + QEMU_MIGRATION_COMPRESS_MT, + + QEMU_MIGRATION_COMPRESS_LAST +} qemuMigrationCompressMethod; +VIR_ENUM_DECL(qemuMigrationCompressMethod) +VIR_ENUM_IMPL(qemuMigrationCompressMethod, QEMU_MIGRATION_COMPRESS_LAST, + "xbzrle", + "mt", +); + + typedef struct _qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysO= nItem; struct _qemuMigrationParamsAlwaysOnItem { qemuMonitorMigrationCaps cap; @@ -201,6 +214,140 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr par= ams, #undef GET =20 =20 +qemuMigrationCompressionPtr +qemuMigrationAnyCompressionParse(virTypedParameterPtr params, + int nparams, + unsigned long flags) +{ + size_t i; + qemuMigrationCompressionPtr compression =3D NULL; + + if (VIR_ALLOC(compression) < 0) + return NULL; + + for (i =3D 0; i < nparams; i++) { + int method; + + if (STRNEQ(params[i].field, VIR_MIGRATE_PARAM_COMPRESSION)) + continue; + + method =3D qemuMigrationCompressMethodTypeFromString(params[i].val= ue.s); + if (method < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Unsupported compression method '%s'"), + params[i].value.s); + goto error; + } + + if (compression->methods & (1ULL << method)) { + virReportError(VIR_ERR_INVALID_ARG, + _("Compression method '%s' is specified twice"), + params[i].value.s); + goto error; + } + + compression->methods |=3D 1ULL << method; + } + +#define GET_PARAM(PARAM, TYPE, VALUE) \ + do { \ + int rc; \ + const char *par =3D VIR_MIGRATE_PARAM_COMPRESSION_ ## PARAM; \ + \ + if ((rc =3D virTypedParamsGet ## TYPE(params, nparams, \ + par, &compression->VALUE)) < 0= ) \ + goto error; \ + \ + if (rc =3D=3D 1) \ + compression->VALUE ## _set =3D true; \ + } while (0) + + if (params) { + GET_PARAM(MT_LEVEL, Int, level); + GET_PARAM(MT_THREADS, Int, threads); + GET_PARAM(MT_DTHREADS, Int, dthreads); + GET_PARAM(XBZRLE_CACHE, ULLong, xbzrle_cache); + } + +#undef GET_PARAM + + if ((compression->level_set || + compression->threads_set || + compression->dthreads_set) && + !(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_MT))) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Turn multithread compression on to tune it")); + goto error; + } + + if (compression->xbzrle_cache_set && + !(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE))= ) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Turn xbzrle compression on to tune it")); + goto error; + } + + if (!compression->methods && (flags & VIR_MIGRATE_COMPRESSED)) + compression->methods =3D 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE; + + return compression; + + error: + VIR_FREE(compression); + return NULL; +} + +int +qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression, + virTypedParameterPtr *params, + int *nparams, + int *maxparams, + unsigned long *flags) +{ + size_t i; + + if (compression->methods =3D=3D 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE= && + !compression->xbzrle_cache_set) { + *flags |=3D VIR_MIGRATE_COMPRESSED; + return 0; + } + + for (i =3D 0; i < QEMU_MIGRATION_COMPRESS_LAST; ++i) { + if ((compression->methods & (1ULL << i)) && + virTypedParamsAddString(params, nparams, maxparams, + VIR_MIGRATE_PARAM_COMPRESSION, + qemuMigrationCompressMethodTypeToStrin= g(i)) < 0) + return -1; + } + + if (compression->level_set && + virTypedParamsAddInt(params, nparams, maxparams, + VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, + compression->level) < 0) + return -1; + + if (compression->threads_set && + virTypedParamsAddInt(params, nparams, maxparams, + VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, + compression->threads) < 0) + return -1; + + if (compression->dthreads_set && + virTypedParamsAddInt(params, nparams, maxparams, + VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, + compression->dthreads) < 0) + return -1; + + if (compression->xbzrle_cache_set && + virTypedParamsAddULLong(params, nparams, maxparams, + VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, + compression->xbzrle_cache) < 0) + return -1; + + return 0; +} + + /** * qemuMigrationParamsApply * @driver: qemu driver diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 494ac104ad..165e1267ab 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -62,6 +62,17 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, unsigned long flags, qemuMigrationParty party); =20 +qemuMigrationCompressionPtr +qemuMigrationAnyCompressionParse(virTypedParameterPtr params, + int nparams, + unsigned long flags); +int +qemuMigrationAnyCompressionDump(qemuMigrationCompressionPtr compression, + virTypedParameterPtr *params, + int *nparams, + int *maxparams, + unsigned long *flags); + void qemuMigrationParamsFree(qemuMigrationParamsPtr migParams); =20 --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list