[PATCH 3/4] qemu: migration: Use migration flags in qemuMigrationIsAllowed

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

 



Use the migration @flags for checking various migration aspects rather
than picking them out as booleans. Document the new semantics in the
function header.
---
 src/qemu/qemu_driver.c    |  8 ++++----
 src/qemu/qemu_migration.c | 24 ++++++++++++++++++------
 src/qemu/qemu_migration.h |  2 +-
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d3017d2..f133b45 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3182,7 +3182,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;

-    if (!qemuMigrationIsAllowed(driver, vm, false, false))
+    if (!qemuMigrationIsAllowed(driver, vm, false, 0))
         goto cleanup;

     if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SAVE) < 0)
@@ -3614,7 +3614,7 @@ doCoreDump(virQEMUDriverPtr driver,
             goto cleanup;
         }

-        if (!qemuMigrationIsAllowed(driver, vm, false, false))
+        if (!qemuMigrationIsAllowed(driver, vm, false, 0))
             goto cleanup;

         ret = qemuMigrationToFile(driver, vm, fd, 0, path,
@@ -13688,7 +13688,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
     bool resume = false;
     int ret = -1;

-    if (!qemuMigrationIsAllowed(driver, vm, false, false))
+    if (!qemuMigrationIsAllowed(driver, vm, false, 0))
         goto cleanup;

     if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
@@ -14503,7 +14503,7 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
     /* do the memory snapshot if necessary */
     if (memory) {
         /* check if migration is possible */
-        if (!qemuMigrationIsAllowed(driver, vm, false, false))
+        if (!qemuMigrationIsAllowed(driver, vm, false, 0))
             goto cleanup;

         /* allow the migration job to be cancelled or the domain to be paused */
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 3279ab2..851c9d0 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2184,11 +2184,25 @@ qemuMigrationIsAllowedHostdev(const virDomainDef *def)
 }


+/**
+ * qemuMigrationIsAllowed:
+ * @driver: qemu driver struct
+ * @vm: domain object
+ * @remote: migration is remote
+ * @flags: migration flags (see struct virDomainMigrateFlags)
+ *
+ * Validates that the configuration of @vm can be migrated in various
+ * situations. If @remote is true, the migration happens to remote host. @flags
+ * is used to check various special migration types according to the request.
+ *
+ * Returns true if migration is supported. Reports libvirt error and returns
+ * false otherwise.
+ */
 bool
 qemuMigrationIsAllowed(virQEMUDriverPtr driver,
                        virDomainObjPtr vm,
                        bool remote,
-                       bool abort_on_error)
+                       unsigned int flags)
 {
     int nsnapshots;
     int pauseReason;
@@ -2214,7 +2228,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver,
         }

         /* cancel migration if disk I/O error is emitted while migrating */
-        if (abort_on_error &&
+        if (flags & VIR_MIGRATE_ABORT_ON_ERROR &&
             virDomainObjGetState(vm, &pauseReason) == VIR_DOMAIN_PAUSED &&
             pauseReason == VIR_DOMAIN_PAUSED_IOERROR) {
             virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -2950,7 +2964,6 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virCapsPtr caps = NULL;
     unsigned int cookieFlags = QEMU_MIGRATION_COOKIE_LOCKSTATE;
-    bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);

     VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, dname=%s,"
               " cookieout=%p, cookieoutlen=%p,"
@@ -2969,7 +2982,7 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
     if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT)
         qemuMigrationJobSetPhase(driver, vm, QEMU_MIGRATION_PHASE_BEGIN3);

-    if (!qemuMigrationIsAllowed(driver, vm, true, abort_on_error))
+    if (!qemuMigrationIsAllowed(driver, vm, true, flags))
         goto cleanup;

     if (!(flags & VIR_MIGRATE_UNSAFE) &&
@@ -5319,7 +5332,6 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
     int ret = -1;
     virErrorPtr orig_err = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);

     if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
         goto cleanup;
@@ -5330,7 +5342,7 @@ qemuMigrationPerformJob(virQEMUDriverPtr driver,
         goto endjob;
     }

-    if (!qemuMigrationIsAllowed(driver, vm, true, abort_on_error))
+    if (!qemuMigrationIsAllowed(driver, vm, true, flags))
         goto endjob;

     if (!(flags & VIR_MIGRATE_UNSAFE) &&
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 54676df..8175f4b 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -174,7 +174,7 @@ int qemuMigrationConfirm(virConnectPtr conn,
                          int cancelled);

 bool qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
-                            bool remote, bool abort_on_error);
+                            bool remote, unsigned int flags);

 int qemuMigrationToFile(virQEMUDriverPtr driver, virDomainObjPtr vm,
                         int fd, off_t offset, const char *path,
-- 
2.4.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]