[PATCH 05/24] qemu: Introduce qemuProcessIncomingDef

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

 



Incoming migration may require quite a few parameters (URI, fd, path) to
be considered while starting QEMU and we will soon add another one.
Let's group all of them in a single struct.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_process.c | 67 +++++++++++++++++++++++++++++++++++++++----------
 src/qemu/qemu_process.h | 14 +++++++++++
 2 files changed, 68 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index fdd640d..638ad02 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4156,6 +4156,47 @@ qemuLogOperation(virDomainObjPtr vm,
     goto cleanup;
 }
 
+
+void
+qemuProcessIncomingDefFree(qemuProcessIncomingDefPtr inc)
+{
+    if (!inc)
+        return;
+
+    VIR_FREE(inc->launchURI);
+    VIR_FREE(inc);
+}
+
+
+qemuProcessIncomingDefPtr
+qemuProcessIncomingDefNew(virQEMUCapsPtr qemuCaps,
+                          const char *migrateFrom,
+                          int fd,
+                          const char *path)
+{
+    qemuProcessIncomingDefPtr inc = NULL;
+
+    if (qemuMigrationCheckIncoming(qemuCaps, migrateFrom) < 0)
+        return NULL;
+
+    if (VIR_ALLOC(inc) < 0)
+        return NULL;
+
+    inc->launchURI = qemuMigrationIncomingURI(migrateFrom, fd);
+    if (!inc->launchURI)
+        goto error;
+
+    inc->fd = fd;
+    inc->path = path;
+
+    return inc;
+
+ error:
+    qemuProcessIncomingDefFree(inc);
+    return NULL;
+}
+
+
 int qemuProcessStart(virConnectPtr conn,
                      virQEMUDriverPtr driver,
                      virDomainObjPtr vm,
@@ -4185,7 +4226,7 @@ int qemuProcessStart(virConnectPtr conn,
     size_t nnicindexes = 0;
     int *nicindexes = NULL;
     char *tmppath = NULL;
-    char *migrateURI = NULL;
+    qemuProcessIncomingDefPtr incoming = 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",
@@ -4514,25 +4555,25 @@ int qemuProcessStart(virConnectPtr conn,
     }
 
     if (migrateFrom) {
-        if (qemuMigrationCheckIncoming(priv->qemuCaps, migrateFrom) < 0)
-            goto error;
-
-        if (!(migrateURI = qemuMigrationIncomingURI(migrateFrom, stdin_fd)))
+        incoming = qemuProcessIncomingDefNew(priv->qemuCaps, migrateFrom,
+                                             stdin_fd, stdin_path);
+        if (!incoming)
             goto error;
     }
 
     VIR_DEBUG("Building emulator command line");
     if (!(cmd = qemuBuildCommandLine(conn, driver, vm->def, priv->monConfig,
                                      priv->monJSON, priv->qemuCaps,
-                                     migrateURI, snapshot, vmop,
+                                     incoming ? incoming->launchURI : NULL,
+                                     snapshot, vmop,
                                      &buildCommandLineCallbacks, false,
                                      qemuCheckFips(),
                                      priv->autoNodeset,
                                      &nnicindexes, &nicindexes)))
         goto error;
 
-    if (migrateFrom && stdin_fd != -1)
-        virCommandPassFD(cmd, stdin_fd, 0);
+    if (incoming && incoming->fd != -1)
+        virCommandPassFD(cmd, incoming->fd, 0);
 
     /*
      * Create all per-domain directories in order to make sure domain
@@ -4731,7 +4772,7 @@ int qemuProcessStart(virConnectPtr conn,
         goto error;
     VIR_DEBUG("Handshake complete, child running");
 
-    if (migrateFrom)
+    if (incoming)
         flags |= VIR_QEMU_PROCESS_START_PAUSED;
 
     if (rv == -1) /* The VM failed to start; tear filters before taps */
@@ -4852,7 +4893,7 @@ int qemuProcessStart(virConnectPtr conn,
     /* Since CPUs were not started yet, the balloon could not return the memory
      * to the host and thus cur_balloon needs to be updated so that GetXMLdesc
      * and friends return the correct size in case they can't grab the job */
-    if (!migrateFrom && !snapshot &&
+    if (!incoming && !snapshot &&
         qemuProcessRefreshBalloonState(driver, vm, asyncJob) < 0)
         goto error;
 
@@ -4873,7 +4914,7 @@ int qemuProcessStart(virConnectPtr conn,
         }
     } else {
         virDomainObjSetState(vm, VIR_DOMAIN_PAUSED,
-                             migrateFrom ?
+                             incoming ?
                              VIR_DOMAIN_PAUSED_MIGRATION :
                              VIR_DOMAIN_PAUSED_USER);
     }
@@ -4905,7 +4946,7 @@ int qemuProcessStart(virConnectPtr conn,
 
     /* Keep watching qemu log for errors during incoming migration, otherwise
      * unset reporting errors from qemu log. */
-    if (!migrateFrom)
+    if (!incoming)
         qemuMonitorSetDomainLog(priv->mon, -1);
 
     ret = 0;
@@ -4918,7 +4959,7 @@ int qemuProcessStart(virConnectPtr conn,
     VIR_FREE(nicindexes);
     VIR_FREE(nodeset);
     VIR_FREE(tmppath);
-    VIR_FREE(migrateURI);
+    qemuProcessIncomingDefFree(incoming);
     return ret;
 
  error:
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index d40f68d..7eee2b2 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -44,6 +44,20 @@ void qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver);
 
 int qemuProcessAssignPCIAddresses(virDomainDefPtr def);
 
+typedef struct _qemuProcessIncomingDef qemuProcessIncomingDef;
+typedef qemuProcessIncomingDef *qemuProcessIncomingDefPtr;
+struct _qemuProcessIncomingDef {
+    char *launchURI; /* used as a parameter for -incoming command line option */
+    int fd; /* for fd:N URI */
+    const char *path; /* path associated with fd */
+};
+
+qemuProcessIncomingDefPtr qemuProcessIncomingDefNew(virQEMUCapsPtr qemuCaps,
+                                                    const char *migrateFrom,
+                                                    int fd,
+                                                    const char *path);
+void qemuProcessIncomingDefFree(qemuProcessIncomingDefPtr inc);
+
 typedef enum {
     VIR_QEMU_PROCESS_START_COLD         = 1 << 0,
     VIR_QEMU_PROCESS_START_PAUSED       = 1 << 1,
-- 
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]