[PATCH 03/24] qemu: Don't generate migration URI in qemuBuildCommandLine

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

 



Make callers of qemuBuildCommandLine responsible for providing the URI
which should be passed as a parameter for -incoming.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_command.c  | 32 ++++++++------------------------
 src/qemu/qemu_command.h  |  9 +++++++--
 src/qemu/qemu_driver.c   |  2 +-
 src/qemu/qemu_process.c  | 14 +++++++++++++-
 tests/qemuxml2argvtest.c | 15 ++++++++++-----
 5 files changed, 39 insertions(+), 33 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 723609d..41a212f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9136,7 +9136,7 @@ qemuBuildTPMCommandLine(virDomainDefPtr def,
     return 0;
 }
 
-static int
+int
 qemuBuildIncomingCheckProtocol(virQEMUCapsPtr qemuCaps,
                                const char *migrateFrom)
 {
@@ -9161,7 +9161,7 @@ qemuBuildIncomingCheckProtocol(virQEMUCapsPtr qemuCaps,
 }
 
 
-static char *
+char *
 qemuBuildIncomingURI(const char *migrateFrom,
                      int migrateFd)
 {
@@ -9194,8 +9194,7 @@ qemuBuildCommandLine(virConnectPtr conn,
                      virDomainChrSourceDefPtr monitor_chr,
                      bool monitor_json,
                      virQEMUCapsPtr qemuCaps,
-                     const char *migrateFrom,
-                     int migrateFd,
+                     const char *migrateURI,
                      virDomainSnapshotObjPtr snapshot,
                      virNetDevVPortProfileOp vmop,
                      qemuBuildCommandLineCallbacksPtr callbacks,
@@ -9256,10 +9255,9 @@ qemuBuildCommandLine(virConnectPtr conn,
     int bootCD = 0, bootFloppy = 0, bootDisk = 0;
 
     VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d "
-              "qemuCaps=%p migrateFrom=%s migrateFD=%d "
-              "snapshot=%p vmop=%d",
+              "qemuCaps=%p migrateURI=%s snapshot=%p vmop=%d",
               conn, driver, def, monitor_chr, monitor_json,
-              qemuCaps, migrateFrom, migrateFd, snapshot, vmop);
+              qemuCaps, migrateURI, snapshot, vmop);
 
     virUUIDFormat(def->uuid, uuid);
 
@@ -9338,7 +9336,7 @@ qemuBuildCommandLine(virConnectPtr conn,
         goto error;
 
     if (qemuBuildCpuArgStr(driver, def, emulator, qemuCaps,
-                           hostarch, &cpu, &hasHwVirt, !!migrateFrom) < 0)
+                           hostarch, &cpu, &hasHwVirt, !!migrateURI) < 0)
         goto error;
 
     if (cpu) {
@@ -9353,7 +9351,7 @@ qemuBuildCommandLine(virConnectPtr conn,
     if (qemuBuildDomainLoaderCommandLine(cmd, def, qemuCaps) < 0)
         goto error;
 
-    if (!migrateFrom && !snapshot &&
+    if (!migrateURI && !snapshot &&
         qemuDomainAlignMemorySizes(def) < 0)
         goto error;
 
@@ -11044,22 +11042,8 @@ qemuBuildCommandLine(virConnectPtr conn,
         }
     }
 
-    if (migrateFrom) {
-        char *migrateURI;
-
-        if (qemuBuildIncomingCheckProtocol(qemuCaps, migrateFrom) < 0)
-            goto error;
-
-        if (STREQ(migrateFrom, "stdio") &&
-            STRPREFIX(migrateFrom, "fd"))
-            virCommandPassFD(cmd, migrateFd, 0);
-
-        migrateURI = qemuBuildIncomingURI(migrateFrom, migrateFd);
-        if (!migrateURI)
-            goto error;
+    if (migrateURI)
         virCommandAddArgList(cmd, "-incoming", migrateURI, NULL);
-        VIR_FREE(migrateURI);
-    }
 
     /* QEMU changed its default behavior to not include the virtio balloon
      * device.  Explicitly request it to ensure it will be present.
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index d1af3b7..5c65008 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -78,8 +78,7 @@ virCommandPtr qemuBuildCommandLine(virConnectPtr conn,
                                    virDomainChrSourceDefPtr monitor_chr,
                                    bool monitor_json,
                                    virQEMUCapsPtr qemuCaps,
-                                   const char *migrateFrom,
-                                   int migrateFd,
+                                   const char *migrateURI,
                                    virDomainSnapshotObjPtr current_snapshot,
                                    virNetDevVPortProfileOp vmop,
                                    qemuBuildCommandLineCallbacksPtr callbacks,
@@ -322,4 +321,10 @@ 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_driver.c b/src/qemu/qemu_driver.c
index 92a9961..42f76fa 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7268,7 +7268,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
 
     if (!(cmd = qemuBuildCommandLine(conn, driver, def,
                                      &monConfig, monitor_json, qemuCaps,
-                                     NULL, -1, NULL,
+                                     NULL, NULL,
                                      VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
                                      &buildCommandLineCallbacks,
                                      true,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4545f77..0bafef9 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4185,6 +4185,7 @@ int qemuProcessStart(virConnectPtr conn,
     size_t nnicindexes = 0;
     int *nicindexes = NULL;
     char *tmppath = NULL;
+    char *migrateURI = NULL;
 
     VIR_DEBUG("vm=%p name=%s id=%d asyncJob=%d migrateFrom=%s stdin_fd=%d "
               "stdin_path=%s snapshot=%p vmop=%d flags=0x%x",
@@ -4512,16 +4513,26 @@ int qemuProcessStart(virConnectPtr conn,
             goto error;
     }
 
+    if (migrateFrom) {
+        if (qemuBuildIncomingCheckProtocol(priv->qemuCaps, migrateFrom) < 0)
+            goto error;
+
+        if (!(migrateURI = qemuBuildIncomingURI(migrateFrom, stdin_fd)))
+            goto error;
+    }
+
     VIR_DEBUG("Building emulator command line");
     if (!(cmd = qemuBuildCommandLine(conn, driver, vm->def, priv->monConfig,
                                      priv->monJSON, priv->qemuCaps,
-                                     migrateFrom, stdin_fd, snapshot, vmop,
+                                     migrateURI, snapshot, vmop,
                                      &buildCommandLineCallbacks, false,
                                      qemuCheckFips(),
                                      priv->autoNodeset,
                                      &nnicindexes, &nicindexes)))
         goto error;
 
+    if (migrateFrom && stdin_fd != -1)
+        virCommandPassFD(cmd, stdin_fd, 0);
 
     /*
      * Create all per-domain directories in order to make sure domain
@@ -4907,6 +4918,7 @@ int qemuProcessStart(virConnectPtr conn,
     VIR_FREE(nicindexes);
     VIR_FREE(nodeset);
     VIR_FREE(tmppath);
+    VIR_FREE(migrateURI);
     return ret;
 
  error:
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 1c52828..50a7dff 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -249,8 +249,7 @@ typedef enum {
 static int testCompareXMLToArgvFiles(const char *xml,
                                      const char *cmdline,
                                      virQEMUCapsPtr extraFlags,
-                                     const char *migrateFrom,
-                                     int migrateFd,
+                                     const char *migrateURI,
                                      virQemuXML2ArgvTestFlags flags)
 {
     char *actualargv = NULL;
@@ -341,7 +340,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 
     if (!(cmd = qemuBuildCommandLine(conn, &driver, vmdef, &monitor_chr,
                                      (flags & FLAG_JSON), extraFlags,
-                                     migrateFrom, migrateFd, NULL,
+                                     migrateURI, NULL,
                                      VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
                                      &testCallbacks, false,
                                      (flags & FLAG_FIPS),
@@ -408,6 +407,12 @@ testCompareXMLToArgvHelper(const void *data)
     char *xml = NULL;
     char *args = NULL;
     unsigned int flags = info->flags;
+    char *migrateURI = NULL;
+
+    if (info->migrateFrom &&
+        !(migrateURI = qemuBuildIncomingURI(info->migrateFrom,
+                                            info->migrateFd)))
+        goto cleanup;
 
     if (virAsprintf(&xml, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
                     abs_srcdir, info->name) < 0 ||
@@ -427,10 +432,10 @@ testCompareXMLToArgvHelper(const void *data)
         goto cleanup;
 
     result = testCompareXMLToArgvFiles(xml, args, info->extraFlags,
-                                       info->migrateFrom, info->migrateFd,
-                                       flags);
+                                       migrateURI, flags);
 
  cleanup:
+    VIR_FREE(migrateURI);
     VIR_FREE(xml);
     VIR_FREE(args);
     return result;
-- 
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]