[PATCH 04/24] qemu: Move incoming URI code to qemu_migration

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

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_command.c   | 39 ---------------------------------------
 src/qemu/qemu_command.h   |  5 -----
 src/qemu/qemu_migration.c | 40 ++++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_migration.h |  6 ++++++
 src/qemu/qemu_process.c   |  4 ++--
 tests/qemuxml2argvtest.c  |  5 +++--
 6 files changed, 51 insertions(+), 48 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 41a212f..d196417 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9136,45 +9136,6 @@ qemuBuildTPMCommandLine(virDomainDefPtr def,
     return 0;
 }
 
-int
-qemuBuildIncomingCheckProtocol(virQEMUCapsPtr qemuCaps,
-                               const char *migrateFrom)
-{
-    if (STRPREFIX(migrateFrom, "rdma")) {
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_RDMA)) {
-            virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
-                           _("incoming RDMA migration is not supported "
-                             "with this QEMU binary"));
-            return -1;
-        }
-    } else if (!STRPREFIX(migrateFrom, "tcp") &&
-               !STRPREFIX(migrateFrom, "exec") &&
-               !STRPREFIX(migrateFrom, "fd") &&
-               !STRPREFIX(migrateFrom, "unix") &&
-               STRNEQ(migrateFrom, "stdio")) {
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
-                       _("unknown migration protocol"));
-        return -1;
-    }
-
-    return 0;
-}
-
-
-char *
-qemuBuildIncomingURI(const char *migrateFrom,
-                     int migrateFd)
-{
-    char *uri = NULL;
-
-    if (STREQ(migrateFrom, "stdio"))
-        ignore_value(virAsprintf(&uri, "fd:%d", migrateFd));
-    else
-        ignore_value(VIR_STRDUP(uri, migrateFrom));
-
-    return uri;
-}
-
 
 qemuBuildCommandLineCallbacks buildCommandLineCallbacks = {
     .qemuGetSCSIDeviceSgName = virSCSIDeviceGetSgName,
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 5c65008..7027402 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -321,10 +321,5 @@ bool qemuCheckCCWS390AddressSupport(virDomainDefPtr def,
                                     virDomainDeviceInfo info,
                                     virQEMUCapsPtr qemuCaps,
                                     const char *devicename);
-int qemuBuildIncomingCheckProtocol(virQEMUCapsPtr qemuCaps,
-                                   const char *migrateFrom);
-
-char *qemuBuildIncomingURI(const char *migrateFrom,
-                           int migrateFd);
 
 #endif /* __QEMU_COMMAND_H__*/
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index e6b3484..4d5b966 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2911,6 +2911,46 @@ qemuDomainMigrateOPDRelocate(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
 }
 
 
+int
+qemuMigrationCheckIncoming(virQEMUCapsPtr qemuCaps,
+                           const char *migrateFrom)
+{
+    if (STRPREFIX(migrateFrom, "rdma")) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MIGRATE_RDMA)) {
+            virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                           _("incoming RDMA migration is not supported "
+                             "with this QEMU binary"));
+            return -1;
+        }
+    } else if (!STRPREFIX(migrateFrom, "tcp") &&
+               !STRPREFIX(migrateFrom, "exec") &&
+               !STRPREFIX(migrateFrom, "fd") &&
+               !STRPREFIX(migrateFrom, "unix") &&
+               STRNEQ(migrateFrom, "stdio")) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                       _("unknown migration protocol"));
+        return -1;
+    }
+
+    return 0;
+}
+
+
+char *
+qemuMigrationIncomingURI(const char *migrateFrom,
+                         int migrateFd)
+{
+    char *uri = NULL;
+
+    if (STREQ(migrateFrom, "stdio"))
+        ignore_value(virAsprintf(&uri, "fd:%d", migrateFd));
+    else
+        ignore_value(VIR_STRDUP(uri, migrateFrom));
+
+    return uri;
+}
+
+
 /* This is called for outgoing non-p2p migrations when a connection to the
  * client which initiated the migration was closed but we were waiting for it
  * to follow up with the next phase, that is, in between
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 8175f4b..ff4fe30 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -199,4 +199,10 @@ void qemuMigrationErrorSave(virQEMUDriverPtr driver,
 void qemuMigrationErrorReport(virQEMUDriverPtr driver,
                               const char *name);
 
+int qemuMigrationCheckIncoming(virQEMUCapsPtr qemuCaps,
+                               const char *migrateFrom);
+
+char *qemuMigrationIncomingURI(const char *migrateFrom,
+                               int migrateFd);
+
 #endif /* __QEMU_MIGRATION_H__ */
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 0bafef9..fdd640d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4514,10 +4514,10 @@ int qemuProcessStart(virConnectPtr conn,
     }
 
     if (migrateFrom) {
-        if (qemuBuildIncomingCheckProtocol(priv->qemuCaps, migrateFrom) < 0)
+        if (qemuMigrationCheckIncoming(priv->qemuCaps, migrateFrom) < 0)
             goto error;
 
-        if (!(migrateURI = qemuBuildIncomingURI(migrateFrom, stdin_fd)))
+        if (!(migrateURI = qemuMigrationIncomingURI(migrateFrom, stdin_fd)))
             goto error;
     }
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 50a7dff..e5c1c4f 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -17,6 +17,7 @@
 # include "qemu/qemu_capabilities.h"
 # include "qemu/qemu_command.h"
 # include "qemu/qemu_domain.h"
+# include "qemu/qemu_migration.h"
 # include "datatypes.h"
 # include "conf/storage_conf.h"
 # include "cpu/cpu_map.h"
@@ -410,8 +411,8 @@ testCompareXMLToArgvHelper(const void *data)
     char *migrateURI = NULL;
 
     if (info->migrateFrom &&
-        !(migrateURI = qemuBuildIncomingURI(info->migrateFrom,
-                                            info->migrateFd)))
+        !(migrateURI = qemuMigrationIncomingURI(info->migrateFrom,
+                                                info->migrateFd)))
         goto cleanup;
 
     if (virAsprintf(&xml, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
-- 
2.6.3

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