[PATCH 09/12] qemu_process: introduce qemuProcessCreateCmd

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

 



This will skip few steps from qemuProcessStart in order to create only
qemu CMD.  Use a VIR_QEMU_PROCESS_START_PRETEND for all the qemuProcess*
functions called by this one to not modify or check host.

This new function will be used later on for XMLToNative API and also for
qemuxml2argvtest to make sure that both API and test uses the same code
as qemuProcessStart.

We need also update qemuProcessInit to wrap few lines of code with check
that VIR_QEMU_PROCESS_START_PRETEND that makes sense only for
qemuProcessStart.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/qemu/qemu_process.c | 73 +++++++++++++++++++++++++++++++++++++++++--------
 src/qemu/qemu_process.h |  7 +++++
 2 files changed, 69 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9894e3c..dd85276 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4477,19 +4477,20 @@ qemuProcessInit(virQEMUDriverPtr driver,
     if (virDomainObjSetDefTransient(caps, driver->xmlopt, vm, true) < 0)
         goto stop;
 
+    if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) {
+        vm->def->id = qemuDriverAllocateID(driver);
+        qemuDomainSetFakeReboot(driver, vm, false);
+        virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_STARTING_UP);
 
-    vm->def->id = qemuDriverAllocateID(driver);
-    qemuDomainSetFakeReboot(driver, vm, false);
-    virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_STARTING_UP);
+        if (virAtomicIntInc(&driver->nactive) == 1 && driver->inhibitCallback)
+            driver->inhibitCallback(true, driver->inhibitOpaque);
 
-    if (virAtomicIntInc(&driver->nactive) == 1 && driver->inhibitCallback)
-        driver->inhibitCallback(true, driver->inhibitOpaque);
-
-    /* Run an early hook to set-up missing devices */
-    if (qemuProcessStartHook(driver, vm,
-                             VIR_HOOK_QEMU_OP_PREPARE,
-                             VIR_HOOK_SUBOP_BEGIN) < 0)
-        goto stop;
+        /* Run an early hook to set-up missing devices */
+        if (qemuProcessStartHook(driver, vm,
+                                 VIR_HOOK_QEMU_OP_PREPARE,
+                                 VIR_HOOK_SUBOP_BEGIN) < 0)
+            goto stop;
+    }
 
     if (qemuDomainSetPrivatePaths(&priv->libDir,
                                   &priv->channelTargetDir,
@@ -5466,6 +5467,56 @@ qemuProcessStart(virConnectPtr conn,
 }
 
 
+virCommandPtr
+qemuProcessCreateCmd(virConnectPtr conn,
+                     virQEMUDriverPtr driver,
+                     virDomainObjPtr vm,
+                     const char *migrateURI,
+                     bool forceFips,
+                     bool standalone,
+                     unsigned int flags)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    virCommandPtr cmd = NULL;
+
+    virCheckFlagsGoto(VIR_QEMU_PROCESS_START_COLD |
+                      VIR_QEMU_PROCESS_START_PAUSED |
+                      VIR_QEMU_PROCESS_START_AUTODESTROY, cleanup);
+
+    flags |= VIR_QEMU_PROCESS_START_PRETEND;
+
+    if (qemuProcessInit(driver, vm, QEMU_ASYNC_JOB_NONE, !!migrateURI,
+                        false, flags) < 0)
+        goto cleanup;
+
+    if (qemuProcessPrepareDomain(conn, driver, vm, flags) < 0)
+        goto cleanup;
+
+    VIR_DEBUG("Building emulator command line");
+    cmd = qemuBuildCommandLine(conn,
+                               driver,
+                               NULL,
+                               vm->def,
+                               priv->monConfig,
+                               priv->monJSON,
+                               priv->qemuCaps,
+                               migrateURI,
+                               NULL,
+                               VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
+                               &buildCommandLineCallbacks,
+                               standalone,
+                               forceFips ? true : qemuCheckFips(),
+                               priv->autoNodeset,
+                               NULL,
+                               NULL,
+                               priv->libDir,
+                               priv->channelTargetDir);
+
+ cleanup:
+    return cmd;
+}
+
+
 int
 qemuProcessKill(virDomainObjPtr vm, unsigned int flags)
 {
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 4820047..9e16aaf 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -81,6 +81,13 @@ int qemuProcessStart(virConnectPtr conn,
                      virNetDevVPortProfileOp vmop,
                      unsigned int flags);
 
+virCommandPtr qemuProcessCreateCmd(virConnectPtr conn,
+                                   virQEMUDriverPtr driver,
+                                   virDomainObjPtr vm,
+                                   const char *migrateURI,
+                                   bool forceFips,
+                                   bool standalone,
+                                   unsigned int flags);
 
 int qemuProcessStartValidate(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
-- 
2.7.2

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