From nobody Mon Dec 30 17:43:00 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1704735259183498.12353567254047; Mon, 8 Jan 2024 09:34:19 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 23F121B91; Mon, 8 Jan 2024 12:34:18 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 05F6C1B82; Mon, 8 Jan 2024 12:09:00 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B20E61B7B; Mon, 8 Jan 2024 12:08:47 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B15E318D8 for ; Mon, 8 Jan 2024 12:06:51 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-jE_wA2XKPNW0tzq9CIUWRg-1; Mon, 08 Jan 2024 12:06:49 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A09388D12C for ; Mon, 8 Jan 2024 17:06:49 +0000 (UTC) Received: from orkuz (unknown [10.45.226.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37FE8492BE6 for ; Mon, 8 Jan 2024 17:06:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: jE_wA2XKPNW0tzq9CIUWRg-1 From: Jiri Denemark To: devel@lists.libvirt.org Subject: [libvirt PATCH 4/6] qemu: Add support for optional migration capabilities Date: Mon, 8 Jan 2024 18:06:40 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: WA32YXJWR2AUFO6TJLDZNXE7WO6ADMYL X-Message-ID-Hash: WA32YXJWR2AUFO6TJLDZNXE7WO6ADMYL X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1704735260414100001 We enable various migration capabilities according to the flags passed to a migration API. Missing support for such capabilities results in an error because they are required by the corresponding flag. This patch adds support for additional optional capability we may want to enable for a given API flag in case it is supported. This is useful for capabilities which are not critical for the flags to be supported, but they can make things work better in some way. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/qemu/qemu_migration.c | 8 ++--- src/qemu/qemu_migration_params.c | 57 +++++++++++++++++++++++++++++--- src/qemu/qemu_migration_params.h | 1 + 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3ba0aa502b..5504119079 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3172,8 +3172,8 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, if (qemuMigrationDstPrepareAnyBlockDirtyBitmaps(vm, mig, migParams, fl= ags) < 0) goto error; =20 - if (qemuMigrationParamsCheck(vm, VIR_ASYNC_JOB_MIGRATION_IN, - migParams, mig->caps->automatic) < 0) + if (qemuMigrationParamsCheck(vm, VIR_ASYNC_JOB_MIGRATION_IN, migParams, + mig->caps->supported, mig->caps->automati= c) < 0) goto error; =20 /* Save original migration parameters */ @@ -4831,8 +4831,8 @@ qemuMigrationSrcRun(virQEMUDriver *driver, qemuMigrationSrcRunPrepareBlockDirtyBitmaps(vm, mig, migParams, fl= ags) < 0) goto error; =20 - if (qemuMigrationParamsCheck(vm, VIR_ASYNC_JOB_MIGRATION_OUT, - migParams, mig->caps->automatic) < 0) + if (qemuMigrationParamsCheck(vm, VIR_ASYNC_JOB_MIGRATION_OUT, migParam= s, + mig->caps->supported, mig->caps->automati= c) < 0) goto error; =20 /* Save original migration parameters */ diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index f441c59d67..133f1f762d 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -64,6 +64,11 @@ struct _qemuMigrationParamValue { struct _qemuMigrationParams { unsigned long long compMethods; /* bit-wise OR of qemuMigrationCompres= sMethod */ virBitmap *caps; + /* Optional capabilities are enabled only if supported by QEMU */ + virBitmap *optional; + /* A capability present on both optional and remoteOptional bitmaps are + * enabled only if they are supported by both sides of migration. */ + virBitmap *remoteOptional; qemuMigrationParamValue params[QEMU_MIGRATION_PARAM_LAST]; virJSONValue *blockDirtyBitmapMapping; }; @@ -141,6 +146,10 @@ struct _qemuMigrationParamsFlagMapItem { virDomainMigrateFlags flag; /* Migration capability to be enabled or disabled based on the flag. */ qemuMigrationCapability cap; + /* An optional capability to set in addition to @cap in case it is + * supported. Depending on @part either one or both sides of migration + * has to support the optional capability to be enabled. */ + qemuMigrationCapability optional; /* Bit-wise OR of qemuMigrationParty. Determines whether the capabilit= y has * to be enabled on the source, on the destination, or on both sides of * migration. */ @@ -334,6 +343,8 @@ qemuMigrationParamsNew(void) params =3D g_new0(qemuMigrationParams, 1); =20 params->caps =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); + params->optional =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); + params->remoteOptional =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); =20 return g_steal_pointer(¶ms); } @@ -353,6 +364,8 @@ qemuMigrationParamsFree(qemuMigrationParams *migParams) } =20 virBitmapFree(migParams->caps); + virBitmapFree(migParams->optional); + virBitmapFree(migParams->remoteOptional); virJSONValueFree(migParams->blockDirtyBitmapMapping); g_free(migParams); } @@ -698,6 +711,13 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr para= ms, VIR_DEBUG("Enabling migration capability '%s'", qemuMigrationCapabilityTypeToString(item->cap)); ignore_value(virBitmapSetBit(migParams->caps, item->cap)); + + if (item->optional) { + qemuMigrationCapability opt =3D item->optional; + ignore_value(virBitmapSetBit(migParams->optional, opt)); + if (item->party !=3D party) + ignore_value(virBitmapSetBit(migParams->remoteOptional= , opt)); + } } } =20 @@ -1290,6 +1310,7 @@ int qemuMigrationParamsCheck(virDomainObj *vm, int asyncJob, qemuMigrationParams *migParams, + virBitmap *remoteSupported, virBitmap *remoteAuto) { qemuDomainJobPrivate *jobPriv =3D vm->job->privateData; @@ -1303,16 +1324,42 @@ qemuMigrationParamsCheck(virDomainObj *vm, party =3D QEMU_MIGRATION_DESTINATION; =20 for (cap =3D 0; cap < QEMU_MIGRATION_CAP_LAST; cap++) { - bool state =3D false; - - ignore_value(virBitmapGetBit(migParams->caps, cap, &state)); - - if (state && !qemuMigrationCapsGet(vm, cap)) { + bool enable =3D false; + bool optional =3D false; + bool remoteOpt =3D false; + bool remote =3D false; + bool qemu =3D qemuMigrationCapsGet(vm, cap); + + ignore_value(virBitmapGetBit(migParams->caps, cap, &enable)); + ignore_value(virBitmapGetBit(migParams->optional, cap, &optional)); + ignore_value(virBitmapGetBit(migParams->remoteOptional, cap, &remo= teOpt)); + ignore_value(virBitmapGetBit(remoteSupported, cap, &remote)); + + if (enable && !qemu) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, _("Migration option '%1$s' is not supported by = QEMU binary"), qemuMigrationCapabilityTypeToString(cap)); return -1; } + + if (optional) { + if (!qemu) { + VIR_DEBUG("Optional migration capability '%s' not supporte= d by QEMU", + qemuMigrationCapabilityTypeToString(cap)); + optional =3D false; + } else if (remoteOpt && ! remote) { + VIR_DEBUG("Optional migration capability '%s' not supporte= d " + "by the other side of migration", + qemuMigrationCapabilityTypeToString(cap)); + optional =3D false; + } + + if (optional) { + VIR_DEBUG("Enabling optional migration capability '%s'", + qemuMigrationCapabilityTypeToString(cap)); + ignore_value(virBitmapSetBit(migParams->caps, cap)); + } + } } =20 for (i =3D 0; i < G_N_ELEMENTS(qemuMigrationParamsAlwaysOn); i++) { diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 44f5c2a882..115d7bc597 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -142,6 +142,7 @@ int qemuMigrationParamsCheck(virDomainObj *vm, int asyncJob, qemuMigrationParams *migParams, + virBitmap *remoteSupported, virBitmap *remoteAuto); =20 void --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org