qemu: don't try to query QEMU about migration blockers during offline migration

The new code that queries QEMU about migration blockers was put at the
top of qemuMigrationSrcIsAllowed(), but that function can also be
called in the case of offline migration (ie when the domain is
inactive / QEMU isn't running). This check should have been put inside
the "if (!(flags & VIR_MIGRATE_OFFLINE))" conditional, so let's move
it there.

Fixes: 156e99f686
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Laine Stump 2022-07-21 01:56:11 -04:00
parent 6262752460
commit 2dd5587f1d

View File

@ -1458,24 +1458,6 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver,
int nsnapshots;
int pauseReason;
size_t i;
bool blockedReasonsCap = virQEMUCapsGet(priv->qemuCaps,
QEMU_CAPS_MIGRATION_BLOCKED_REASONS);
/* Ask qemu if it has a migration blocker */
if (blockedReasonsCap) {
g_auto(GStrv) blockers = NULL;
if (qemuDomainGetMigrationBlockers(driver, vm,
VIR_ASYNC_JOB_MIGRATION_OUT,
&blockers) < 0)
return false;
if (blockers && blockers[0]) {
g_autofree char *reasons = g_strjoinv("; ", blockers);
virReportError(VIR_ERR_OPERATION_INVALID,
_("cannot migrate domain: %s"), reasons);
return false;
}
}
/* perform these checks only when migrating to remote hosts */
if (remote) {
@ -1493,6 +1475,27 @@ qemuMigrationSrcIsAllowed(virQEMUDriver *driver,
/* following checks don't make sense for offline migration */
if (!(flags & VIR_MIGRATE_OFFLINE)) {
bool blockedReasonsCap = virQEMUCapsGet(priv->qemuCaps,
QEMU_CAPS_MIGRATION_BLOCKED_REASONS);
/* Ask qemu if it has a migration blocker */
if (blockedReasonsCap) {
g_auto(GStrv) blockers = NULL;
if (qemuDomainGetMigrationBlockers(driver, vm,
VIR_ASYNC_JOB_MIGRATION_OUT,
&blockers) < 0) {
return false;
}
if (blockers && blockers[0]) {
g_autofree char *reasons = g_strjoinv("; ", blockers);
virReportError(VIR_ERR_OPERATION_INVALID,
_("cannot migrate domain: %s"), reasons);
return false;
}
}
if (remote) {
/* cancel migration if disk I/O error is emitted while migrating */
if (flags & VIR_MIGRATE_ABORT_ON_ERROR &&