From nobody Sun Feb 8 23:03:44 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=1658334318; cv=none; d=zohomail.com; s=zohoarc; b=NXN4W+7vc5CruYk4Qvi/O8xqn/QbnT9lZJdu/pShAP+3nAVVWdUdFwuIW3b+Dz7mNRIc1SMt+w/7iJfWkc5XsfrWpcxXRk0eVoCVHMyHeX8K5zeXkBpSs9aOpp1MUaSx8Qjs8uYXxuSwQbU7muleYIVNgOEzFcwyJxIneTawTb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658334318; h=Content-Type:Content-Transfer-Encoding:Cc: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=qmIE7U09PjvsEOijXVI+omi3UzTi7YFv2XxW/XEvxO8=; b=eOBG7x3DKkO0t+C+eC2FGLSucXUpMF9reFpgADQG55C7BCcwZ4AS+hKOGUZQPcysqwlwPLWoBNKpcwACNI6dpzbgpcNXcRuOr1WgPq1c5Ch1K7QYIy3t7o3mbU/M6lye3aN5YvHDksSSpNL3s3KTXAvIOMuBzqhp7er2peh0zGU= 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 1658334318309682.9434281364365; Wed, 20 Jul 2022 09:25:18 -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-348-X1It0CvINnagQcDQd6T66A-1; Wed, 20 Jul 2022 12:25:07 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F81A18E5355; Wed, 20 Jul 2022 16:24:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 580C1492C3B; Wed, 20 Jul 2022 16:23:20 +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 19B451935048; Wed, 20 Jul 2022 16:23:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B00361947066 for ; Wed, 20 Jul 2022 16:05:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 94555112131B; Wed, 20 Jul 2022 16:05:57 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id D435B1121314; Wed, 20 Jul 2022 16:05:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658334317; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=qmIE7U09PjvsEOijXVI+omi3UzTi7YFv2XxW/XEvxO8=; b=DniHqjQPVxCWQqC8LMt8ic5iz/TuLOgRWytgTvjVWqD3I+colaWRCA4fnqhO8O9nmsTE8W Qy3mTxaKlybLM8mbpzeqFV9Lax9X/M+/lGVBM+9BuVFPvak9DbCoqZGV966m9olWfNBpfy ThgO72DlsMAP+KF+Eytsg34EP7QMHuA= X-MC-Unique: X1It0CvINnagQcDQd6T66A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: libvir-list@redhat.com Subject: [libvirt PATCH v4 3/4] qemu_migration: get migration blockers before hardcoded checks Date: Wed, 20 Jul 2022 18:05:48 +0200 Message-Id: <20220720160549.3168021-4-eperezma@redhat.com> In-Reply-To: <20220720160549.3168021-1-eperezma@redhat.com> References: <20220720160549.3168021-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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: , Cc: Laurent Vivier , Jason Wang , Jaroslav Suchanek , Jiri Denemark , Laine Stump Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1658334320042100001 since qemu 6.0, if migration is blocked for some reason, 'query-migrate' will return an array of error strings describing the migration blockers. This can be used to check whether there are any devices blocking migration, etc. Enable qemuMigrationSrcIsAllowed to query it. Signed-off-by: Eugenio P=C3=A9rez Reviewed-by: Jiri Denemark --- v4: * Do not override qemuDomainGetMigrationBlockers error calling again virReportError. * Replace ", " with "; " in blockers separators. v3: * Report message with a colon. * Report all blockers instead of only the first. --- src/qemu/qemu_migration.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index b12cb518ee..2e3044289a 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1414,6 +1414,20 @@ qemuMigrationSrcIsAllowedHostdev(const virDomainDef = *def) return true; } =20 +static int +qemuDomainGetMigrationBlockers(virQEMUDriver *driver, + virDomainObj *vm, + char ***blockers) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + int rc; + + qemuDomainObjEnterMonitor(driver, vm); + rc =3D qemuMonitorGetMigrationBlockers(priv->mon, blockers); + qemuDomainObjExitMonitor(vm); + + return rc; +} =20 /** * qemuMigrationSrcIsAllowed: @@ -1439,6 +1453,22 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver, int nsnapshots; int pauseReason; size_t i; + int r; + + /* Ask qemu if it have a migration blocker */ + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_BLOCKED_REASONS= )) { + g_auto(GStrv) blockers =3D NULL; + r =3D qemuDomainGetMigrationBlockers(driver, vm, &blockers); + if (r !=3D 0) + return false; + + if (blockers && blockers[0]) { + g_autofree char *reasons =3D g_strjoinv("; ", blockers); + virReportError(VIR_ERR_OPERATION_INVALID, + _("cannot migrate domain: %s"), reasons); + return false; + } + } =20 /* perform these checks only when migrating to remote hosts */ if (remote) { --=20 2.31.1