From nobody Sun Feb 8 13:10:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652345825; cv=none; d=zohomail.com; s=zohoarc; b=H+Lh2nZyyluYrNITfxgH6O1hD3gcEioKHMS53TajvmnxhknbnJR09MXYVSM4hkFAgh6QmHnvMgPwqWY39uWb61oKFOWLKa3If9JLbVLwDxOVYJhMgY5wS9VIa1oaEminecCck1+Agh85qW1BIRu2F25BcYcF41v+yW6NMyNWIaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652345825; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u1es/W1l1ejjiFimLVngbBJJquN9wECl0tRhUGfrJqI=; b=ZVT0V3/wRkgdng6zRNUm3nU65k3r6i4n8tyV1hkJFDf4kAElK1FZuFOgmddSmbuvaztr+9KqWI4WlnX0sbcVij41EJHOE7M3+Rd1+FMmDiASLIIiemh0vItQEwQtWLyrJ5CXYuIJmAB7oi1qR39BFkobI1o8bP0x7F+RevevRjQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 165234582581224.137184378041184; Thu, 12 May 2022 01:57:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-397--yxR6XTbMDCNSdx_gAnp3A-1; Thu, 12 May 2022 04:55:59 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5CE1B1801387; Thu, 12 May 2022 08:55:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47B8241617B; Thu, 12 May 2022 08:55:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3607A193220C; Thu, 12 May 2022 08:55:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 280EC1932207 for ; Thu, 12 May 2022 08:55:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D32F65690DC; Thu, 12 May 2022 08:55:49 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9785C56BEED for ; Thu, 12 May 2022 08:55:49 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8C58D2445EF; Thu, 12 May 2022 10:55:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652345824; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=u1es/W1l1ejjiFimLVngbBJJquN9wECl0tRhUGfrJqI=; b=H4igfTY8wMyziwM9rNwlCdK3hwFw2MqHjTPkayZx8Lp6SmggeHhPgMAEAXtxKDc+3tUV1b F3YZJaq3wzL4ax6l0ZUMcgKF0uLvXIu1vWhd+lESHr9b8Ps9jmnKkGJJLLYR3G1JHBhH3e 8ef9iFBZMpZ8b+0vbvLKiAOlcZo3ryY= X-MC-Unique: -yxR6XTbMDCNSdx_gAnp3A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] qemu: Enable migration events only for fresh QEMU process Date: Thu, 12 May 2022 10:55:47 +0200 Message-Id: <4ad843c02f2930f6185bb2d7ea590bd2a103a96e.1652345711.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652345826383100001 Content-Type: text/plain; charset="utf-8" Every running QEMU process we are willing to reconnect (i.e., at least 3.1.0) supports migration events and we can assume the capability is already enabled since last time libvirt daemon connected to its monitor. Well, it's not guaranteed though. If libvirt 1.2.17 or older was used to start QEMU 3.1.0 or newer, migration events would not be enabled. And if the user decides to upgrade libvirt from 1.2.17 to 8.4.0 while the QEMU process is still running, they would not be able to migrate the domain because of disabled migration events. I think we do not really need to worry about this scenario as libvirt 1.2.17 is 7 years old while QEMU 3.1.0 was released only 3.5 years ago. Thus a chance someone would be running such configuration should be fairly small and a combination with upgrading 1.2.17 to 8.4.0 (or newer) with running domains should get it pretty much to zero. The issue would disappear ff the ancient libvirt is first upgraded to something older than 8.4.0 and then to the current libvirt. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: I was hoping we could do this without any downside, but it appeared this was not possible. In case someone still thinks this would be an issue, I can take an alternative solution and check whether migration events are enabled when reconnecting to QEMU monitor. src/qemu/qemu_migration_params.c | 26 ++++++++++++++------------ src/qemu/qemu_migration_params.h | 3 ++- src/qemu/qemu_process.c | 14 +++++++++----- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 26754f03f8..95fd773645 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1385,10 +1385,10 @@ qemuMigrationParamsParse(xmlXPathContextPtr ctxt, int qemuMigrationCapsCheck(virQEMUDriver *driver, virDomainObj *vm, - int asyncJob) + int asyncJob, + bool reconnect) { qemuDomainObjPrivate *priv =3D vm->privateData; - g_autoptr(virBitmap) migEvent =3D NULL; g_autoptr(virJSONValue) json =3D NULL; g_auto(GStrv) caps =3D NULL; char **capStr; @@ -1419,22 +1419,24 @@ qemuMigrationCapsCheck(virQEMUDriver *driver, } } =20 - migEvent =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); + if (!reconnect) { + g_autoptr(virBitmap) migEvent =3D virBitmapNew(QEMU_MIGRATION_CAP_= LAST); =20 - ignore_value(virBitmapSetBit(migEvent, QEMU_MIGRATION_CAP_EVENTS)); + ignore_value(virBitmapSetBit(migEvent, QEMU_MIGRATION_CAP_EVENTS)); =20 - if (!(json =3D qemuMigrationCapsToJSON(migEvent, migEvent))) - return -1; + if (!(json =3D qemuMigrationCapsToJSON(migEvent, migEvent))) + return -1; =20 - if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return -1; + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; =20 - rc =3D qemuMonitorSetMigrationCapabilities(priv->mon, &json); + rc =3D qemuMonitorSetMigrationCapabilities(priv->mon, &json); =20 - qemuDomainObjExitMonitor(vm); + qemuDomainObjExitMonitor(vm); =20 - if (rc < 0) - return -1; + if (rc < 0) + return -1; + } =20 /* Migration events capability must always be enabled, clearing it from * migration capabilities bitmap makes sure it won't be touched anywhe= re diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index 4a8815e776..a0909b9f3d 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -162,7 +162,8 @@ qemuMigrationParamsParse(xmlXPathContextPtr ctxt, int qemuMigrationCapsCheck(virQEMUDriver *driver, virDomainObj *vm, - int asyncJob); + int asyncJob, + bool reconnect); =20 bool qemuMigrationCapsGet(virDomainObj *vm, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2b16298942..fd4db43a42 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1914,8 +1914,12 @@ qemuProcessInitMonitor(virQEMUDriver *driver, =20 =20 static int -qemuConnectMonitor(virQEMUDriver *driver, virDomainObj *vm, int asyncJob, - bool retry, qemuDomainLogContext *logCtxt) +qemuConnectMonitor(virQEMUDriver *driver, + virDomainObj *vm, + int asyncJob, + bool retry, + qemuDomainLogContext *logCtxt, + bool reconnect) { qemuDomainObjPrivate *priv =3D vm->privateData; qemuMonitor *mon =3D NULL; @@ -1968,7 +1972,7 @@ qemuConnectMonitor(virQEMUDriver *driver, virDomainOb= j *vm, int asyncJob, if (qemuProcessInitMonitor(driver, vm, asyncJob) < 0) return -1; =20 - if (qemuMigrationCapsCheck(driver, vm, asyncJob) < 0) + if (qemuMigrationCapsCheck(driver, vm, asyncJob, reconnect) < 0) return -1; =20 return 0; @@ -2353,7 +2357,7 @@ qemuProcessWaitForMonitor(virQEMUDriver *driver, VIR_DEBUG("Connect monitor to vm=3D%p name=3D'%s' retry=3D%d", vm, vm->def->name, retry); =20 - if (qemuConnectMonitor(driver, vm, asyncJob, retry, logCtxt) < 0) + if (qemuConnectMonitor(driver, vm, asyncJob, retry, logCtxt, false) < = 0) goto cleanup; =20 /* Try to get the pty path mappings again via the monitor. This is muc= h more @@ -8773,7 +8777,7 @@ qemuProcessReconnect(void *opaque) tryMonReconn =3D true; =20 /* XXX check PID liveliness & EXE path */ - if (qemuConnectMonitor(driver, obj, VIR_ASYNC_JOB_NONE, retry, NULL) <= 0) + if (qemuConnectMonitor(driver, obj, VIR_ASYNC_JOB_NONE, retry, NULL, t= rue) < 0) goto error; =20 priv->machineName =3D qemuDomainGetMachineName(obj); --=20 2.35.1