[PATCH 4/5] qemu: refactor functions with removed driver if possible

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

 



Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c    |  3 +--
 src/qemu/qemu_driver.c    | 52 ++++++++++++++-------------------------
 src/qemu/qemu_hotplug.c   | 12 +++------
 src/qemu/qemu_migration.c | 39 ++++++++++-------------------
 src/qemu/qemu_snapshot.c  |  3 +--
 5 files changed, 37 insertions(+), 72 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b1c17bcd03..93fd11a3c9 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6081,8 +6081,7 @@ qemuDomainObjExitMonitor(virDomainObj *obj)
 
 void qemuDomainObjEnterMonitor(virDomainObj *obj)
 {
-    ignore_value(qemuDomainObjEnterMonitorInternal(obj,
-                                                   VIR_ASYNC_JOB_NONE));
+    ignore_value(qemuDomainObjEnterMonitorInternal(obj, VIR_ASYNC_JOB_NONE));
 }
 
 /*
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0503a79075..4ff1d65c1e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -184,8 +184,8 @@ qemuAutostartDomain(virDomainObj *vm,
     virResetLastError();
     if (vm->autostart &&
         !virDomainObjIsActive(vm)) {
-        if (qemuProcessBeginJob(vm,
-                                VIR_DOMAIN_JOB_OPERATION_START, flags) < 0) {
+        if (qemuProcessBeginJob(vm, VIR_DOMAIN_JOB_OPERATION_START,
+                                flags) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Failed to start job on VM '%s': %s"),
                            vm->def->name, virGetLastErrorMessage());
@@ -1623,8 +1623,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
                                    NULL)))
         goto cleanup;
 
-    if (qemuProcessBeginJob(vm, VIR_DOMAIN_JOB_OPERATION_START,
-                            flags) < 0) {
+    if (qemuProcessBeginJob(vm, VIR_DOMAIN_JOB_OPERATION_START, flags) < 0) {
         qemuDomainRemoveInactive(driver, vm);
         goto cleanup;
     }
@@ -1784,8 +1783,7 @@ qemuDomainShutdownFlagsAgent(virDomainObj *vm,
     int agentFlag = isReboot ?  QEMU_AGENT_SHUTDOWN_REBOOT :
         QEMU_AGENT_SHUTDOWN_POWERDOWN;
 
-    if (qemuDomainObjBeginAgentJob(vm,
-                                   VIR_AGENT_JOB_MODIFY) < 0)
+    if (qemuDomainObjBeginAgentJob(vm, VIR_AGENT_JOB_MODIFY) < 0)
         return -1;
 
     if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
@@ -1913,8 +1911,7 @@ qemuDomainRebootAgent(virDomainObj *vm,
     if (!isReboot)
         agentFlag = QEMU_AGENT_SHUTDOWN_POWERDOWN;
 
-    if (qemuDomainObjBeginAgentJob(vm,
-                                   VIR_AGENT_JOB_MODIFY) < 0)
+    if (qemuDomainObjBeginAgentJob(vm, VIR_AGENT_JOB_MODIFY) < 0)
         return -1;
 
     if (!qemuDomainAgentAvailable(vm, agentForced))
@@ -1941,8 +1938,7 @@ qemuDomainRebootMonitor(virDomainObj *vm,
     qemuDomainObjPrivate *priv = vm->privateData;
     int ret = -1;
 
-    if (qemuDomainObjBeginJob(vm,
-                              VIR_JOB_MODIFY) < 0)
+    if (qemuDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
         return -1;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -3221,8 +3217,7 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom,
     if (virDomainCoreDumpWithFormatEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (qemuDomainObjBeginAsyncJob(vm,
-                                   VIR_ASYNC_JOB_DUMP,
+    if (qemuDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_DUMP,
                                    VIR_DOMAIN_JOB_OPERATION_DUMP,
                                    flags) < 0)
         goto cleanup;
@@ -3460,8 +3455,7 @@ processWatchdogEvent(virQEMUDriver *driver,
 
     switch (action) {
     case VIR_DOMAIN_WATCHDOG_ACTION_DUMP:
-        if (qemuDomainObjBeginAsyncJob(vm,
-                                       VIR_ASYNC_JOB_DUMP,
+        if (qemuDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_DUMP,
                                        VIR_DOMAIN_JOB_OPERATION_DUMP,
                                        flags) < 0) {
             return;
@@ -4268,8 +4262,7 @@ static void qemuProcessEventHandler(void *data, void *opaque)
                                   processEvent->action);
         break;
     case QEMU_PROCESS_EVENT_BLOCK_JOB:
-        processBlockJobEvent(vm,
-                             processEvent->data,
+        processBlockJobEvent(vm, processEvent->data,
                              processEvent->action,
                              processEvent->status);
         break;
@@ -6040,8 +6033,7 @@ qemuDomainRestoreInternal(virConnectPtr conn,
         priv->hookRun = true;
     }
 
-    if (qemuProcessBeginJob(vm, VIR_DOMAIN_JOB_OPERATION_RESTORE,
-                            flags) < 0)
+    if (qemuProcessBeginJob(vm, VIR_DOMAIN_JOB_OPERATION_RESTORE, flags) < 0)
         goto cleanup;
 
     ret = qemuSaveImageStartVM(conn, driver, vm, &fd, data, path,
@@ -6650,8 +6642,7 @@ qemuDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
     if (virDomainCreateWithFlagsEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (qemuProcessBeginJob(vm, VIR_DOMAIN_JOB_OPERATION_START,
-                            flags) < 0)
+    if (qemuProcessBeginJob(vm, VIR_DOMAIN_JOB_OPERATION_START, flags) < 0)
         goto cleanup;
 
     if (virDomainObjIsActive(vm)) {
@@ -7001,8 +6992,7 @@ qemuDomainAttachDeviceLive(virDomainObj *vm,
         break;
 
     case VIR_DOMAIN_DEVICE_SHMEM:
-        ret = qemuDomainAttachShmemDevice(vm,
-                                          dev->data.shmem);
+        ret = qemuDomainAttachShmemDevice(vm, dev->data.shmem);
         if (!ret) {
             alias = dev->data.shmem->info.alias;
             dev->data.shmem = NULL;
@@ -7010,8 +7000,7 @@ qemuDomainAttachDeviceLive(virDomainObj *vm,
         break;
 
     case VIR_DOMAIN_DEVICE_WATCHDOG:
-        ret = qemuDomainAttachWatchdog(vm,
-                                       dev->data.watchdog);
+        ret = qemuDomainAttachWatchdog(vm, dev->data.watchdog);
         if (!ret) {
             alias = dev->data.watchdog->info.alias;
             dev->data.watchdog = NULL;
@@ -7293,8 +7282,7 @@ qemuDomainChangeMemoryLive(virQEMUDriver *driver G_GNUC_UNUSED,
     if (!qemuDomainChangeMemoryLiveValidateChange(oldDef, newDef))
         return -1;
 
-    if (qemuDomainChangeMemoryRequestedSize(vm,
-                                            newDef->info.alias,
+    if (qemuDomainChangeMemoryRequestedSize(vm, newDef->info.alias,
                                             newDef->requestedsize) < 0)
         return -1;
 
@@ -13092,8 +13080,7 @@ qemuDomainMigrateGetMaxDowntime(virDomainPtr dom,
     if (virDomainObjCheckActive(vm) < 0)
         goto endjob;
 
-    if (qemuMigrationParamsFetch(vm, VIR_ASYNC_JOB_NONE,
-                                 &migParams) < 0)
+    if (qemuMigrationParamsFetch(vm, VIR_ASYNC_JOB_NONE, &migParams) < 0)
         goto endjob;
 
     if ((rc = qemuMigrationParamsGetULL(migParams,
@@ -13316,8 +13303,7 @@ qemuDomainMigrationGetPostcopyBandwidth(virDomainObj *vm,
     if (virDomainObjCheckActive(vm) < 0)
         goto cleanup;
 
-    if (qemuMigrationParamsFetch(vm, VIR_ASYNC_JOB_NONE,
-                                 &migParams) < 0)
+    if (qemuMigrationParamsFetch(vm, VIR_ASYNC_JOB_NONE, &migParams) < 0)
         goto cleanup;
 
     if ((rc = qemuMigrationParamsGetULL(migParams,
@@ -19065,8 +19051,7 @@ qemuDomainGetFSInfoAgent(virDomainObj *vm,
     int ret = -1;
     qemuAgent *agent;
 
-    if (qemuDomainObjBeginAgentJob(vm,
-                                   VIR_AGENT_JOB_QUERY) < 0)
+    if (qemuDomainObjBeginAgentJob(vm, VIR_AGENT_JOB_QUERY) < 0)
         return ret;
 
     if (virDomainObjCheckActive(vm) < 0)
@@ -20616,8 +20601,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
     if (virDomainGetGuestInfoEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (qemuDomainObjBeginAgentJob(vm,
-                                   VIR_AGENT_JOB_QUERY) < 0)
+    if (qemuDomainObjBeginAgentJob(vm, VIR_AGENT_JOB_QUERY) < 0)
         goto cleanup;
 
     if (!qemuDomainAgentAvailable(vm, true))
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index f5f7d4bdf1..2a782b6e79 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1904,8 +1904,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriver *driver,
         ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias));
     qemuDomainObjExitMonitor(vm);
     virErrorRestore(&orig_err);
-    qemuDomainDelTLSObjects(vm, VIR_ASYNC_JOB_NONE,
-                            secAlias, tlsAlias);
+    qemuDomainDelTLSObjects(vm, VIR_ASYNC_JOB_NONE, secAlias, tlsAlias);
     goto audit;
 }
 
@@ -2197,8 +2196,7 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver,
     qemuDomainObjExitMonitor(vm);
     virErrorRestore(&orig_err);
 
-    qemuDomainDelTLSObjects(vm, VIR_ASYNC_JOB_NONE,
-                            secAlias, tlsAlias);
+    qemuDomainDelTLSObjects(vm, VIR_ASYNC_JOB_NONE, secAlias, tlsAlias);
     goto audit;
 }
 
@@ -2303,8 +2301,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver,
     qemuDomainObjExitMonitor(vm);
     virErrorRestore(&orig_err);
 
-    qemuDomainDelTLSObjects(vm, VIR_ASYNC_JOB_NONE,
-                            secAlias, tlsAlias);
+    qemuDomainDelTLSObjects(vm, VIR_ASYNC_JOB_NONE, secAlias, tlsAlias);
     goto audit;
 }
 
@@ -2405,8 +2402,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver,
     mem = NULL;
 
     /* this step is best effort, removing the device would be so much trouble */
-    ignore_value(qemuDomainUpdateMemoryDeviceInfo(vm,
-                                                  VIR_ASYNC_JOB_NONE));
+    ignore_value(qemuDomainUpdateMemoryDeviceInfo(vm, VIR_ASYNC_JOB_NONE));
 
     ret = 0;
 
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index f846932857..7d3cfa6212 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -603,8 +603,7 @@ qemuMigrationDstStartNBDServer(virQEMUDriver *driver,
             }
         }
 
-        if (qemuDomainObjEnterMonitorAsync(vm,
-                                           VIR_ASYNC_JOB_MIGRATION_IN) < 0)
+        if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_MIGRATION_IN) < 0)
             goto cleanup;
 
         if (!server_started) {
@@ -643,8 +642,7 @@ qemuMigrationDstStopNBDServer(virDomainObj *vm,
     if (!mig->nbd)
         return 0;
 
-    if (qemuDomainObjEnterMonitorAsync(vm,
-                                       VIR_ASYNC_JOB_MIGRATION_IN) < 0)
+    if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_MIGRATION_IN) < 0)
         return -1;
 
     if (qemuMonitorNBDServerStop(priv->mon) < 0)
@@ -1049,8 +1047,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virDomainObj *vm,
                                                              false)))
         return -1;
 
-    if (qemuDomainObjEnterMonitorAsync(vm,
-                                       VIR_ASYNC_JOB_MIGRATION_OUT) < 0)
+    if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_MIGRATION_OUT) < 0)
         return -1;
 
     mon_ret = qemuBlockStorageSourceAttachApply(qemuDomainGetMonitor(vm), data);
@@ -1097,8 +1094,7 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virDomainObj *vm,
                                    diskAlias);
     }
 
-    if (qemuDomainObjEnterMonitorAsync(vm,
-                                       VIR_ASYNC_JOB_MIGRATION_OUT) < 0)
+    if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_MIGRATION_OUT) < 0)
         return -1;
 
     mon_ret = qemuMonitorDriveMirror(qemuDomainGetMonitor(vm),
@@ -1156,8 +1152,7 @@ qemuMigrationSrcNBDStorageCopyOne(virDomainObj *vm,
 
     if (flags & VIR_MIGRATE_TLS ||
         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
-        rc = qemuMigrationSrcNBDStorageCopyBlockdev(vm,
-                                                    disk, jobname,
+        rc = qemuMigrationSrcNBDStorageCopyBlockdev(vm, disk, jobname,
                                                     sourcename, persistjob,
                                                     host, port, socket,
                                                     mirror_speed,
@@ -2078,8 +2073,7 @@ qemuMigrationSrcWaitForCompletion(virDomainObj *vm,
 
     jobData->status = VIR_DOMAIN_JOB_STATUS_MIGRATING;
 
-    while ((rv = qemuMigrationAnyCompleted(vm, asyncJob,
-                                           dconn, flags)) != 1) {
+    while ((rv = qemuMigrationAnyCompleted(vm, asyncJob, dconn, flags)) != 1) {
         if (rv < 0)
             return rv;
 
@@ -2119,8 +2113,7 @@ qemuMigrationDstWaitForCompletion(virDomainObj *vm,
     if (postcopy)
         flags = QEMU_MIGRATION_COMPLETED_POSTCOPY;
 
-    while ((rv = qemuMigrationAnyCompleted(vm, asyncJob,
-                                           NULL, flags)) != 1) {
+    while ((rv = qemuMigrationAnyCompleted(vm, asyncJob, NULL, flags)) != 1) {
         if (rv < 0 || virDomainObjWait(vm) < 0)
             return -1;
     }
@@ -2208,8 +2201,7 @@ qemuMigrationSrcGraphicsRelocate(virDomainObj *vm,
     if (port <= 0 && tlsPort <= 0)
         return 0;
 
-    if (qemuDomainObjEnterMonitorAsync(vm,
-                                       VIR_ASYNC_JOB_MIGRATION_OUT) == 0) {
+    if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_MIGRATION_OUT) == 0) {
         qemuDomainJobPrivate *jobPriv = priv->job.privateData;
 
         rc = qemuMonitorGraphicsRelocate(priv->mon, type, listenAddress,
@@ -2895,8 +2887,7 @@ qemuMigrationSrcBegin(virConnectPtr conn,
     }
 
     if ((flags & VIR_MIGRATE_CHANGE_PROTECTION)) {
-        if (qemuMigrationJobStart(vm, VIR_ASYNC_JOB_MIGRATION_OUT,
-                                  flags) < 0)
+        if (qemuMigrationJobStart(vm, VIR_ASYNC_JOB_MIGRATION_OUT, flags) < 0)
             goto cleanup;
         asyncJob = VIR_ASYNC_JOB_MIGRATION_OUT;
     } else {
@@ -4903,8 +4894,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
             goto error;
     }
 
-    if (qemuDomainObjEnterMonitorAsync(vm,
-                                       VIR_ASYNC_JOB_MIGRATION_OUT) < 0)
+    if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_MIGRATION_OUT) < 0)
         goto error;
 
     if (priv->job.abortJob) {
@@ -4945,8 +4935,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
     if (flags & VIR_MIGRATE_POSTCOPY)
         waitFlags |= QEMU_MIGRATION_COMPLETED_POSTCOPY;
 
-    rc = qemuMigrationSrcWaitForCompletion(vm,
-                                           VIR_ASYNC_JOB_MIGRATION_OUT,
+    rc = qemuMigrationSrcWaitForCompletion(vm, VIR_ASYNC_JOB_MIGRATION_OUT,
                                            dconn, waitFlags);
     if (rc == -2)
         goto error;
@@ -5047,8 +5036,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver,
 
         if (cancel &&
             priv->job.current->status != VIR_DOMAIN_JOB_STATUS_HYPERVISOR_COMPLETED &&
-            qemuDomainObjEnterMonitorAsync(vm,
-                                           VIR_ASYNC_JOB_MIGRATION_OUT) == 0) {
+            qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_MIGRATION_OUT) == 0) {
             qemuMonitorMigrateCancel(priv->mon);
             qemuDomainObjExitMonitor(vm);
         }
@@ -6186,8 +6174,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver,
 
     /* If we didn't start the job in the begin phase, start it now. */
     if (!(flags & VIR_MIGRATE_CHANGE_PROTECTION)) {
-        if (qemuMigrationJobStart(vm, VIR_ASYNC_JOB_MIGRATION_OUT,
-                                  flags) < 0)
+        if (qemuMigrationJobStart(vm, VIR_ASYNC_JOB_MIGRATION_OUT, flags) < 0)
             return ret;
     } else if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_OUT)) {
         return ret;
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 4a3f4fa5e3..0b4d9b089f 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -311,8 +311,7 @@ qemuSnapshotCreateActiveInternal(virQEMUDriver *driver,
         }
     }
 
-    if (qemuDomainObjEnterMonitorAsync(vm,
-                                       VIR_ASYNC_JOB_SNAPSHOT) < 0) {
+    if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPSHOT) < 0) {
         resume = false;
         goto cleanup;
     }
-- 
2.37.1




[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