[libvirt PATCH v2 17/81] qemu: Don't wait for migration job when migration is running

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Migration is a job which takes some time and if it succeeds, there's
nothing to call another migration on. If a migration fails, it might
make sense to rerun it with different arguments, but this would only be
done once the first migration fails rather than while it is still
running.

If this was not enough, the migration job now stays active even if
post-copy migration fails and anyone possibly retrying the migration
would be waiting for the job timeout just to get a suboptimal error
message.

So let's special case getting a migration job when another one is
already active.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
Reviewed-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---

Notes:
    Version 2:
    - no change

 src/qemu/qemu_migration.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index b9a8326fbb..f81d1e65ff 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -82,6 +82,23 @@ VIR_ENUM_IMPL(qemuMigrationJobPhase,
 );
 
 
+static bool ATTRIBUTE_NONNULL(1)
+qemuMigrationJobIsAllowed(virDomainObj *vm)
+{
+    qemuDomainObjPrivate *priv = vm->privateData;
+
+    if (priv->job.asyncJob == VIR_ASYNC_JOB_MIGRATION_IN ||
+        priv->job.asyncJob == VIR_ASYNC_JOB_MIGRATION_OUT) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       _("another migration job is already running for domain '%s'"),
+                       vm->def->name);
+        return false;
+    }
+
+    return true;
+}
+
+
 static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT
 qemuMigrationJobStart(virQEMUDriver *driver,
                       virDomainObj *vm,
@@ -92,6 +109,9 @@ qemuMigrationJobStart(virQEMUDriver *driver,
     virDomainJobOperation op;
     unsigned long long mask;
 
+    if (!qemuMigrationJobIsAllowed(vm))
+        return -1;
+
     if (job == VIR_ASYNC_JOB_MIGRATION_IN) {
         op = VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN;
         mask = VIR_JOB_NONE;
@@ -2602,6 +2622,9 @@ qemuMigrationSrcBegin(virConnectPtr conn,
             goto cleanup;
         asyncJob = VIR_ASYNC_JOB_MIGRATION_OUT;
     } else {
+        if (!qemuMigrationJobIsAllowed(vm))
+            goto cleanup;
+
         if (qemuDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) < 0)
             goto cleanup;
         asyncJob = VIR_ASYNC_JOB_NONE;
-- 
2.35.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux