From nobody Sun Feb 8 12:18:54 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=1658320736; cv=none; d=zohomail.com; s=zohoarc; b=lr+L+6w/4hcHahjn+XHwqjnKRCYOgir7SIttHExwF75Lbiopi+hihTf59A7S9H23qUsmc1JCDq71YD8DbXpU4MCYXER3IpSCIMXCEk1LDsuzhC3jh3DhPaUwS47wMKmy/yBpxz+nTPdXxNz9FAhjR1ejNcUlPUllg1XFCgwJZb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658320736; 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=0ci2EZA55ysEWdocMnDtvx2lOPOEukpH1ag48bHdIuw=; b=J9O3qukzDluqi8I1iR2jk5kgOKR9rpo5zC7QHlQ7GYXQ/xyNyeMziBb0G8IQE9T9jr57SZzustLTbw8TRoO+DuuL3SQZrPtHKrvR9yl+81tfpmxZAjDBnHVEWp+QKDrdnB06JjhIx7OJhG4FzEss+LZaAGmQoi6gHx2oyZA6PxY= 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 1658320736878114.1894021744829; Wed, 20 Jul 2022 05:38:56 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-110-m2LXWVvyP0GX21SWPnsaYw-1; Wed, 20 Jul 2022 08:38:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD9E03817A7C; Wed, 20 Jul 2022 12:38:51 +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 732EF2166B26; Wed, 20 Jul 2022 12:38:51 +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 0CE411935016; Wed, 20 Jul 2022 12:38:46 +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 E308C1947066 for ; Wed, 20 Jul 2022 12:16:05 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D57631121315; Wed, 20 Jul 2022 12:16:05 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7A1C1121314; Wed, 20 Jul 2022 12:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658320735; 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=0ci2EZA55ysEWdocMnDtvx2lOPOEukpH1ag48bHdIuw=; b=EmKdBS/ZXA5mtDsWmLcqxE3Nb+G62hK0NLtOdjm1RNyZR4W6/Uo5i4K94R3LJlcBCpp3aC wUDdjV6PzVRnSa7B+VpwsQy5owDfENhWpwMvl7RLlwf4SklUzmPwSwcF6R8NNnWRQMHcl6 VhQrVLrp60AHQKn3rzlCyD+Fd0GZNZI= X-MC-Unique: m2LXWVvyP0GX21SWPnsaYw-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 v3 3/4] qemu_migration: get migration blockers before hardcoded checks Date: Wed, 20 Jul 2022 14:15:57 +0200 Message-Id: <20220720121558.3150209-4-eperezma@redhat.com> In-Reply-To: <20220720121558.3150209-1-eperezma@redhat.com> References: <20220720121558.3150209-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 , Laine Stump , Jiri Denemark , Jaroslav Suchanek Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: 1658320737421100001 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 --- v3: * Report message with a colon. * Report all blockers instead of only the first. --- src/qemu/qemu_migration.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index b12cb518ee..6ac4ef150b 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,26 @@ 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) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("cannot migrate domain: %s"), + _("error getting blockers")); + 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