[PATCH v3 3/7] qemu: Introduce qemuProcessFinishStartup

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

Notes:
    Version 3:
    - propagate asyncJob into qemuProcessFinishStartup to avoid effectively
      reverting 668a0fe fix from Jan
    
    Version 2:
    - save status before running VIR_HOOK_QEMU_OP_STARTED hook
    - rename qemuProcessFinish as qemuProcessFinishStartup
    - remove unused cfg from qemuProcessStart

 src/qemu/qemu_process.c | 79 ++++++++++++++++++++++++++++++++-----------------
 src/qemu/qemu_process.h |  7 +++++
 2 files changed, 59 insertions(+), 27 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1b3cbc0..1fe551b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5065,6 +5065,53 @@ qemuProcessLaunch(virConnectPtr conn,
 }
 
 
+/**
+ * qemuProcessFinishStartup:
+ *
+ * Finish starting a new domain.
+ */
+int
+qemuProcessFinishStartup(virConnectPtr conn,
+                         virQEMUDriverPtr driver,
+                         virDomainObjPtr vm,
+                         qemuDomainAsyncJob asyncJob,
+                         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,
+                                 asyncJob) < 0) {
+            if (!virGetLastError())
+                virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                               _("resume operation failed"));
+            goto cleanup;
+        }
+    } else {
+        virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, pausedReason);
+    }
+
+    VIR_DEBUG("Writing domain status to disk");
+    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
+        goto cleanup;
+
+    if (qemuProcessStartHook(driver, vm,
+                             VIR_HOOK_QEMU_OP_STARTED,
+                             VIR_HOOK_SUBOP_BEGIN) < 0)
+        goto cleanup;
+
+    ret = 0;
+
+ cleanup:
+    virObjectUnref(cfg);
+    return ret;
+}
+
+
 int
 qemuProcessStart(virConnectPtr conn,
                  virQEMUDriverPtr driver,
@@ -5077,7 +5124,6 @@ qemuProcessStart(virConnectPtr conn,
                  virNetDevVPortProfileOp vmop,
                  unsigned int flags)
 {
-    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     qemuDomainObjPrivatePtr priv = vm->privateData;
     qemuProcessIncomingDefPtr incoming = NULL;
     unsigned int stopFlags;
@@ -5120,31 +5166,11 @@ qemuProcessStart(virConnectPtr conn,
         qemuMigrationRunIncoming(driver, vm, incoming->deferredURI, asyncJob) < 0)
         goto stop;
 
-    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,
-                                 asyncJob) < 0) {
-            if (virGetLastError() == NULL)
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               "%s", _("resume operation failed"));
-            goto stop;
-        }
-    } else {
-        virDomainObjSetState(vm, VIR_DOMAIN_PAUSED,
-                             incoming ?
-                             VIR_DOMAIN_PAUSED_MIGRATION :
-                             VIR_DOMAIN_PAUSED_USER);
-    }
-
-    VIR_DEBUG("Writing domain status to disk");
-    if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
-        goto stop;
-
-    if (qemuProcessStartHook(driver, vm,
-                             VIR_HOOK_QEMU_OP_STARTED,
-                             VIR_HOOK_SUBOP_BEGIN) < 0)
+    if (qemuProcessFinishStartup(conn, driver, vm, asyncJob,
+                                 !(flags & VIR_QEMU_PROCESS_START_PAUSED),
+                                 incoming ?
+                                 VIR_DOMAIN_PAUSED_MIGRATION :
+                                 VIR_DOMAIN_PAUSED_USER) < 0)
         goto stop;
 
     /* Keep watching qemu log for errors during incoming migration, otherwise
@@ -5155,7 +5181,6 @@ qemuProcessStart(virConnectPtr conn,
     ret = 0;
 
  cleanup:
-    virObjectUnref(cfg);
     qemuProcessIncomingDefFree(incoming);
     return ret;
 
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 54009c5..978aa3a 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -94,6 +94,13 @@ int qemuProcessLaunch(virConnectPtr conn,
                       virNetDevVPortProfileOp vmop,
                       unsigned int flags);
 
+int qemuProcessFinishStartup(virConnectPtr conn,
+                             virQEMUDriverPtr driver,
+                             virDomainObjPtr vm,
+                             qemuDomainAsyncJob asyncJob,
+                             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]