From nobody Thu May 15 13:43:48 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508326183248210.83826780305014; Wed, 18 Oct 2017 04:29:43 -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 3AC9C5F7B9; Wed, 18 Oct 2017 11:29:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BDFC6D80B; Wed, 18 Oct 2017 11:29:42 +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 DC9013FC71; Wed, 18 Oct 2017 11:29:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9IBTWR1018786 for ; Wed, 18 Oct 2017 07:29:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id D10E380E07; Wed, 18 Oct 2017 11:29:32 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F73680956 for ; Wed, 18 Oct 2017 11:29:29 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A639E1020BB; Wed, 18 Oct 2017 13:29:28 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3AC9C5F7B9 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 18 Oct 2017 13:29:23 +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.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] qemu: Store supported migration capabilities in a bitmap 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.39]); Wed, 18 Oct 2017 11:29:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Each time we need to check whether a given migration capability is supported by QEMU, we call query-migrate-capabilities QMP command and lookup the capability in the returned list. Asking for the list of supported capabilities once when we connect to QEMU and storing the result in a bitmap is much better and we don't need to enter a monitor just to check whether a migration capability is supported. Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 68 +++++++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_domain.h | 9 +++++++ src/qemu/qemu_process.c | 13 +--------- 3 files changed, 78 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 05e8b96aa4..a8cabc5727 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1767,6 +1767,9 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr= priv) priv->namespaces =3D NULL; =20 priv->reconnectBlockjobs =3D VIR_TRISTATE_BOOL_ABSENT; + + virBitmapFree(priv->migrationCaps); + priv->migrationCaps =3D NULL; } =20 =20 @@ -10122,3 +10125,68 @@ qemuDomainGetMachineName(virDomainObjPtr vm) =20 return ret; } + + +int +qemuDomainCheckMigrationCapabilities(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + char **caps =3D NULL; + char **capStr; + int ret =3D -1; + int rc; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + rc =3D qemuMonitorGetMigrationCapabilities(priv->mon, &caps); + + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + goto cleanup; + + if (!caps) { + ret =3D 0; + goto cleanup; + } + + priv->migrationCaps =3D virBitmapNew(QEMU_MONITOR_MIGRATION_CAPS_LAST); + if (!priv->migrationCaps) + goto cleanup; + + for (capStr =3D caps; *capStr; capStr++) { + int cap =3D qemuMonitorMigrationCapsTypeFromString(*capStr); + + if (cap < 0) { + VIR_DEBUG("Unknown migration capability: '%s'", *capStr); + } else { + ignore_value(virBitmapSetBit(priv->migrationCaps, cap)); + VIR_DEBUG("Found migration capability: '%s'", *capStr); + } + } + + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT)) { + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + goto cleanup; + + rc =3D qemuMonitorSetMigrationCapability(priv->mon, + QEMU_MONITOR_MIGRATION_CAPS= _EVENTS, + true); + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + goto cleanup; + + if (rc < 0) { + virResetLastError(); + VIR_DEBUG("Cannot enable migration events; clearing capability= "); + virQEMUCapsClear(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT); + } + } + + ret =3D 0; + + cleanup: + virStringListFree(caps); + return ret; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 5201c6a0ac..fb20d8ea63 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -323,6 +323,10 @@ struct _qemuDomainObjPrivate { =20 /* Tracks blockjob state for vm. Valid only while reconnecting to qemu= . */ virTristateBool reconnectBlockjobs; + + /* Migration capabilities. Rechecked on reconnect, not to be saved in + * private XML. */ + virBitmapPtr migrationCaps; }; =20 # define QEMU_DOMAIN_PRIVATE(vm) \ @@ -978,4 +982,9 @@ qemuDomainFixupCPUs(virDomainObjPtr vm, char * qemuDomainGetMachineName(virDomainObjPtr vm); =20 +int +qemuDomainCheckMigrationCapabilities(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 24675498a2..cea2f90ce1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1816,18 +1816,7 @@ qemuConnectMonitor(virQEMUDriverPtr driver, virDomai= nObjPtr vm, int asyncJob, if (qemuProcessInitMonitor(driver, vm, asyncJob) < 0) return -1; =20 - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; - - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT) && - qemuMonitorSetMigrationCapability(priv->mon, - QEMU_MONITOR_MIGRATION_CAPS_EVEN= TS, - true) < 0) { - VIR_DEBUG("Cannot enable migration events; clearing capability"); - virQEMUCapsClear(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT); - } - - if (qemuDomainObjExitMonitor(driver, vm) < 0) + if (qemuDomainCheckMigrationCapabilities(driver, vm, asyncJob) < 0) return -1; =20 return 0; --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list