[PATCH 12/20] qemu: Move creation of qemuProcessIncomingDef struct

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

 



qemuProcessStartWithMemoryState() is the only caller of qemuProcessStart()
that uses the qemuProcessIncomingDef struct. Move creation of the struct
to qemuProcessStartWithMemoryState().

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 src/qemu/qemu_process.c | 44 ++++++++++++++++++++---------------------
 src/qemu/qemu_process.h |  2 +-
 2 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index cec739c984..7eeb85062c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8191,7 +8191,7 @@ qemuProcessStart(virConnectPtr conn,
                  virDomainObj *vm,
                  virCPUDef *updatedCPU,
                  virDomainAsyncJob asyncJob,
-                 const char *migrateFrom,
+                 qemuProcessIncomingDef *incoming,
                  int migrateFd,
                  const char *migratePath,
                  virDomainMomentObj *snapshot,
@@ -8199,7 +8199,6 @@ qemuProcessStart(virConnectPtr conn,
                  unsigned int flags)
 {
     qemuDomainObjPrivate *priv = vm->privateData;
-    qemuProcessIncomingDef *incoming = NULL;
     unsigned int stopFlags;
     bool relabel = false;
     bool relabelSavedState = false;
@@ -8207,11 +8206,11 @@ qemuProcessStart(virConnectPtr conn,
     int rv;
 
     VIR_DEBUG("conn=%p driver=%p vm=%p name=%s id=%d asyncJob=%s "
-              "migrateFrom=%s migrateFd=%d migratePath=%s "
+              "incoming=%p migrateFd=%d migratePath=%s "
               "snapshot=%p vmop=%d flags=0x%x",
               conn, driver, vm, vm->def->name, vm->def->id,
               virDomainAsyncJobTypeToString(asyncJob),
-              NULLSTR(migrateFrom), migrateFd, NULLSTR(migratePath),
+              incoming, migrateFd, NULLSTR(migratePath),
               snapshot, vmop, flags);
 
     virCheckFlagsGoto(VIR_QEMU_PROCESS_START_COLD |
@@ -8220,20 +8219,13 @@ qemuProcessStart(virConnectPtr conn,
                       VIR_QEMU_PROCESS_START_GEN_VMID |
                       VIR_QEMU_PROCESS_START_RESET_NVRAM, cleanup);
 
-    if (!migrateFrom && !snapshot)
+    if (!incoming && !snapshot)
         flags |= VIR_QEMU_PROCESS_START_NEW;
 
     if (qemuProcessInit(driver, vm, updatedCPU,
-                        asyncJob, !!migrateFrom, flags) < 0)
+                        asyncJob, !!incoming, flags) < 0)
         goto cleanup;
 
-    if (migrateFrom) {
-        incoming = qemuProcessIncomingDefNew(priv->qemuCaps, NULL, migrateFrom,
-                                             migrateFd, migratePath);
-        if (!incoming)
-            goto stop;
-    }
-
     if (qemuProcessPrepareDomain(driver, vm, flags) < 0)
         goto stop;
 
@@ -8286,14 +8278,13 @@ qemuProcessStart(virConnectPtr conn,
         qemuSecurityRestoreSavedStateLabel(driver->securityManager,
                                            vm->def, migratePath) < 0)
         VIR_WARN("failed to restore save state label on %s", migratePath);
-    qemuProcessIncomingDefFree(incoming);
     return ret;
 
  stop:
     stopFlags = 0;
     if (!relabel)
         stopFlags |= VIR_QEMU_PROCESS_STOP_NO_RELABEL;
-    if (migrateFrom)
+    if (incoming)
         stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
     if (priv->mon)
         qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL);
@@ -8347,20 +8338,24 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
     VIR_AUTOCLOSE intermediatefd = -1;
     g_autoptr(virCommand) cmd = NULL;
     g_autofree char *errbuf = NULL;
-    const char *migrateFrom = NULL;
+    qemuProcessIncomingDef *incoming = NULL;
     int rc = 0;
+    int ret = -1;
+
+    incoming = qemuProcessIncomingDefNew(priv->qemuCaps, NULL, "stdio",
+                                         *fd, path);
+    if (!incoming)
+        return -1;
 
     if (data) {
         if (virSaveCookieParseString(data->cookie, (virObject **)&cookie,
                                      virDomainXMLOptionGetSaveCookie(driver->xmlopt)) < 0)
-            return -1;
+            goto cleanup;
 
         if (qemuSaveImageDecompressionStart(data, fd, &intermediatefd,
                                             &errbuf, &cmd) < 0) {
-            return -1;
+            goto cleanup;
         }
-
-        migrateFrom = "stdio";
     }
 
     /* No cookie means libvirt which saved the domain was too old to mess up
@@ -8373,7 +8368,7 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
         priv->disableSlirp = true;
 
     if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL,
-                         asyncJob, migrateFrom, *fd, path, snapshot,
+                         asyncJob, incoming, *fd, path, snapshot,
                          VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
                          start_flags) == 0)
         *started = true;
@@ -8385,14 +8380,17 @@ qemuProcessStartWithMemoryState(virConnectPtr conn,
 
     virDomainAuditStart(vm, reason, *started);
     if (!*started || rc < 0)
-        return -1;
+        goto cleanup;
 
     /* qemuProcessStart doesn't unset the qemu error reporting infrastructure
      * in case of migration (which is used in this case) so we need to reset it
      * so that the handle to virtlogd is not held open unnecessarily */
     qemuMonitorSetDomainLog(qemuDomainGetMonitor(vm), NULL, NULL, NULL);
+    ret = 0;
 
-    return 0;
+ cleanup:
+    qemuProcessIncomingDefFree(incoming);
+    return ret;
 }
 
 
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 2324aeb7bd..e48d53dc46 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -84,7 +84,7 @@ int qemuProcessStart(virConnectPtr conn,
                      virDomainObj *vm,
                      virCPUDef *updatedCPU,
                      virDomainAsyncJob asyncJob,
-                     const char *migrateFrom,
+                     qemuProcessIncomingDef *incoming,
                      int stdin_fd,
                      const char *stdin_path,
                      virDomainMomentObj *snapshot,
-- 
2.35.3



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

  Powered by Linux