From nobody Mon Dec 15 23:29:10 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 1523457816369128.13030682481417; Wed, 11 Apr 2018 07:43:36 -0700 (PDT) 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 BE0EB21BB7; Wed, 11 Apr 2018 14:43:34 +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 91BAC88445; Wed, 11 Apr 2018 14:43:34 +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 448AB181BA1B; Wed, 11 Apr 2018 14:43:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3BEgH2j008896 for ; Wed, 11 Apr 2018 10:42:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0B2F2215CDAF; Wed, 11 Apr 2018 14:42:17 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2941215CDCB for ; Wed, 11 Apr 2018 14:42:16 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 17516100B94; Wed, 11 Apr 2018 16:42:11 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 11 Apr 2018 16:41:50 +0200 Message-Id: <3747d958700b801781d0350bdbcf3f33f28a7285.1523456480.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 60/73] qemu: Check remote caps when enabling always-on capabilities 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 11 Apr 2018 14:43:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When an always-on migration capability is supposed to be enabled on both sides of migration, each side can only enable the feature if it is enabled by the other side. Thus the source host sends a list of supported migration capabilities in the migration cookie generated in the Begin phase. The destination host consumes the list in the Prepare phase and decides what capabilities can be enabled when starting a QEMU process for incoming migration. Once done the destination sends the list of supported capabilities back to the source where it is used during the Perform phase to determine what capabilities can be automatically enabled. Signed-off-by: Jiri Denemark Reviewed-by: J=EF=BF=BDn Tomko --- src/qemu/qemu_migration.c | 17 ++++++++++++----- src/qemu/qemu_migration_params.c | 22 ++++++++++++++++++++-- src/qemu/qemu_migration_params.h | 3 ++- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f573bd3eba..42194c0ea8 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1913,6 +1913,9 @@ qemuMigrationSrcBeginPhase(virQEMUDriverPtr driver, =20 cookieFlags |=3D QEMU_MIGRATION_COOKIE_ALLOW_REBOOT; =20 + if (!(flags & VIR_MIGRATE_OFFLINE)) + cookieFlags |=3D QEMU_MIGRATION_COOKIE_CAPS; + if (!(mig =3D qemuMigrationEatCookie(driver, vm, NULL, 0, 0))) goto cleanup; =20 @@ -2205,7 +2208,8 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, } cookieFlags =3D 0; } else { - cookieFlags =3D QEMU_MIGRATION_COOKIE_GRAPHICS; + cookieFlags =3D QEMU_MIGRATION_COOKIE_GRAPHICS | + QEMU_MIGRATION_COOKIE_CAPS; } =20 if (flags & VIR_MIGRATE_POSTCOPY && @@ -2299,7 +2303,8 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, QEMU_MIGRATION_COOKIE_MEMORY_HOTPLU= G | QEMU_MIGRATION_COOKIE_CPU_HOTPLUG | QEMU_MIGRATION_COOKIE_CPU | - QEMU_MIGRATION_COOKIE_ALLOW_REBOOT)= )) + QEMU_MIGRATION_COOKIE_ALLOW_REBOOT | + QEMU_MIGRATION_COOKIE_CAPS))) goto cleanup; =20 if (STREQ_NULLABLE(protocol, "rdma") && @@ -2378,7 +2383,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, } =20 if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, - migParams) < 0) + migParams, mig->caps->automatic) < 0) goto stopjob; =20 /* Migrations using TLS need to add the "tls-creds-x509" object and @@ -3302,7 +3307,9 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, } =20 mig =3D qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, - cookieFlags | QEMU_MIGRATION_COOKIE_GRAPH= ICS); + cookieFlags | + QEMU_MIGRATION_COOKIE_GRAPHICS | + QEMU_MIGRATION_COOKIE_CAPS); if (!mig) goto error; =20 @@ -3310,7 +3317,7 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, VIR_WARN("unable to provide data for graphics client relocation"); =20 if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, - migParams) < 0) + migParams, mig->caps->automatic) < 0) goto error; =20 if (flags & VIR_MIGRATE_TLS) { diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 1b1e5829e8..979610c3a8 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -116,7 +116,9 @@ struct _qemuMigrationParamsFlagMapItem { }; =20 /* Migration capabilities which should always be enabled as long as they - * are supported by QEMU. */ + * are supported by QEMU. If the capability is supposed to be enabled on b= oth + * sides of migration, it won't be enabled unless both sides support it. + */ static const qemuMigrationParamsAlwaysOnItem qemuMigrationParamsAlwaysOn[]= =3D { {QEMU_MIGRATION_CAP_PAUSE_BEFORE_SWITCHOVER, QEMU_MIGRATION_SOURCE}, @@ -975,7 +977,8 @@ int qemuMigrationParamsCheck(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob, - qemuMigrationParamsPtr migParams) + qemuMigrationParamsPtr migParams, + virBitmapPtr remoteCaps) { qemuDomainObjPrivatePtr priv =3D vm->privateData; qemuMigrationCapability cap; @@ -1005,6 +1008,21 @@ qemuMigrationParamsCheck(virQEMUDriverPtr driver, =20 if (qemuMigrationParamsAlwaysOn[i].party & party && qemuMigrationCapsGet(vm, cap)) { + if (qemuMigrationParamsAlwaysOn[i].party !=3D party) { + bool remote =3D false; + + if (remoteCaps) + ignore_value(virBitmapGetBit(remoteCaps, cap, &remote)= ); + + if (!remote) { + VIR_DEBUG("Not enabling migration capability '%s'; it = is " + "not supported or automatically enabled by t= he " + "other side of migration", + qemuMigrationCapabilityTypeToString(cap)); + continue; + } + } + VIR_DEBUG("Enabling migration capability '%s'", qemuMigrationCapabilityTypeToString(cap)); ignore_value(virBitmapSetBit(migParams->caps, cap)); diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 75a441e1e1..eb4016806d 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -123,7 +123,8 @@ int qemuMigrationParamsCheck(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob, - qemuMigrationParamsPtr migParams); + qemuMigrationParamsPtr migParams, + virBitmapPtr remoteCaps); =20 void qemuMigrationParamsReset(virQEMUDriverPtr driver, --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list