[libvirt PATCH v2 41/81] qemu: Check flags incompatible with offline migration earlier

Jiri Denemark jdenemar at redhat.com
Wed Jun 1 12:49:41 UTC 2022


Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
Reviewed-by: Peter Krempa <pkrempa at redhat.com>
Reviewed-by: Pavel Hrdina <phrdina at redhat.com>
---

Notes:
    Version 2:
    - dropped line breaks from error messages

 src/qemu/qemu_migration.c | 41 ++++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 5765647ad7..4e3d823806 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2512,6 +2512,25 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver,
         return NULL;
     }
 
+    if (flags & VIR_MIGRATE_OFFLINE) {
+        if (flags & (VIR_MIGRATE_NON_SHARED_DISK |
+                     VIR_MIGRATE_NON_SHARED_INC)) {
+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                           _("offline migration cannot handle non-shared storage"));
+            return NULL;
+        }
+        if (!(flags & VIR_MIGRATE_PERSIST_DEST)) {
+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                           _("offline migration must be specified with the persistent flag set"));
+            return NULL;
+        }
+        if (flags & VIR_MIGRATE_TUNNELLED) {
+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                           _("tunnelled offline migration does not make sense"));
+            return NULL;
+        }
+    }
+
     if (flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)) {
         if (flags & VIR_MIGRATE_NON_SHARED_SYNCHRONOUS_WRITES &&
             !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
@@ -2591,28 +2610,6 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver,
                                   cookieFlags) < 0)
         return NULL;
 
-    if (flags & VIR_MIGRATE_OFFLINE) {
-        if (flags & (VIR_MIGRATE_NON_SHARED_DISK |
-                     VIR_MIGRATE_NON_SHARED_INC)) {
-            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                           _("offline migration cannot handle "
-                             "non-shared storage"));
-            return NULL;
-        }
-        if (!(flags & VIR_MIGRATE_PERSIST_DEST)) {
-            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                           _("offline migration must be specified with "
-                             "the persistent flag set"));
-            return NULL;
-        }
-        if (flags & VIR_MIGRATE_TUNNELLED) {
-            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-                           _("tunnelled offline migration does not "
-                             "make sense"));
-            return NULL;
-        }
-    }
-
     if (xmlin) {
         if (!(def = virDomainDefParseString(xmlin, driver->xmlopt, priv->qemuCaps,
                                             VIR_DOMAIN_DEF_PARSE_INACTIVE |
-- 
2.35.1



More information about the libvir-list mailing list