[PATCH 20/24] qemu: Introduce qemuProcessFinish

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

 



Finishes starting a new domain launched by qemuProcessLaunch.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_process.c | 76 +++++++++++++++++++++++++++++++++----------------
 src/qemu/qemu_process.h |  6 ++++
 2 files changed, 57 insertions(+), 25 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 0314c4a..38c4eeb 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5053,6 +5053,52 @@ qemuProcessLaunch(virConnectPtr conn,
 }
 
 
+/**
+ * qemuProcessFinish:
+ *
+ * Finish starting a new domain.
+ */
+int
+qemuProcessFinish(virConnectPtr conn,
+                  virQEMUDriverPtr driver,
+                  virDomainObjPtr vm,
+                  bool startCPUs,
+                  virDomainPausedReason pausedReason)
+{
+    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+    int ret = -1;
+
+    if (startCPUs) {
+        VIR_DEBUG("Starting domain CPUs");
+        if (qemuProcessStartCPUs(driver, vm, conn,
+                                 VIR_DOMAIN_RUNNING_BOOTED,
+                                 QEMU_ASYNC_JOB_NONE) < 0) {
+            if (!virGetLastError())
+                virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                               _("resume operation failed"));
+            goto cleanup;
+        }
+    } else {
+        virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, pausedReason);
+    }
+
+    if (qemuProcessStartHook(driver, vm,
+                             VIR_HOOK_QEMU_OP_STARTED,
+                             VIR_HOOK_SUBOP_BEGIN) < 0)
+        goto cleanup;
+
+    VIR_DEBUG("Writing domain status to disk");
+    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
+        goto cleanup;
+
+    ret = 0;
+
+ cleanup:
+    virObjectUnref(cfg);
+    return ret;
+}
+
+
 int
 qemuProcessStart(virConnectPtr conn,
                  virQEMUDriverPtr driver,
@@ -5101,31 +5147,11 @@ qemuProcessStart(virConnectPtr conn,
         qemuMigrationRunIncoming(driver, vm, incoming->deferredURI, asyncJob) < 0)
         goto error;
 
-    if (!(flags & VIR_QEMU_PROCESS_START_PAUSED)) {
-        VIR_DEBUG("Starting domain CPUs");
-        /* Allow the CPUS to start executing */
-        if (qemuProcessStartCPUs(driver, vm, conn,
-                                 VIR_DOMAIN_RUNNING_BOOTED,
-                                 QEMU_ASYNC_JOB_NONE) < 0) {
-            if (virGetLastError() == NULL)
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               "%s", _("resume operation failed"));
-            goto error;
-        }
-    } else {
-        virDomainObjSetState(vm, VIR_DOMAIN_PAUSED,
-                             incoming ?
-                             VIR_DOMAIN_PAUSED_MIGRATION :
-                             VIR_DOMAIN_PAUSED_USER);
-    }
-
-    if (qemuProcessStartHook(driver, vm,
-                             VIR_HOOK_QEMU_OP_STARTED,
-                             VIR_HOOK_SUBOP_BEGIN) < 0)
-        goto error;
-
-    VIR_DEBUG("Writing domain status to disk");
-    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
+    if (qemuProcessFinish(conn, driver, vm,
+                          !(flags & VIR_QEMU_PROCESS_START_PAUSED),
+                          incoming ?
+                          VIR_DOMAIN_PAUSED_MIGRATION :
+                          VIR_DOMAIN_PAUSED_USER) < 0)
         goto error;
 
     /* Keep watching qemu log for errors during incoming migration, otherwise
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 54009c5..6af36ee 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -94,6 +94,12 @@ int qemuProcessLaunch(virConnectPtr conn,
                       virNetDevVPortProfileOp vmop,
                       unsigned int flags);
 
+int qemuProcessFinish(virConnectPtr conn,
+                      virQEMUDriverPtr driver,
+                      virDomainObjPtr vm,
+                      bool startCPUs,
+                      virDomainPausedReason pausedReason);
+
 typedef enum {
     VIR_QEMU_PROCESS_STOP_MIGRATED      = 1 << 0,
     VIR_QEMU_PROCESS_STOP_NO_RELABEL    = 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]