The pointer to the qemu driver is already included in domain object's
private data, so does not need to be passed as yet another parameter
when the domain object is already passed.
Also removes parameter 'driver' from functions which had it just because of
qemuBlockJobUpdate.
Signed-off-by: Roland Schulz <schullzroll(a)gmail.com>
---
Follow up on BiteSizeTask
https://wiki.libvirt.org/page/BiteSizedTasks#Clean_up_virQEMUDriverPtr_pa...
src/qemu/qemu_blockjob.c | 13 +++++--------
src/qemu/qemu_blockjob.h | 6 ++----
src/qemu/qemu_driver.c | 6 +++---
src/qemu/qemu_migration.c | 29 +++++++++++++----------------
4 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 617e4ee56..e0dfb88c1 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -44,7 +44,6 @@ VIR_LOG_INIT("qemu.qemu_blockjob");
/**
* qemuBlockJobUpdate:
- * @driver: qemu driver
* @vm: domain
* @disk: domain disk
* @error: error (output parameter)
@@ -55,20 +54,20 @@ VIR_LOG_INIT("qemu.qemu_blockjob");
* Returns the block job event processed or -1 if there was no pending event.
*/
int
-qemuBlockJobUpdate(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+qemuBlockJobUpdate(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk,
char **error)
{
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+ qemuDomainObjPrivatePtr priv = vm->privateData;
int status = diskPriv->blockJobStatus;
if (error)
*error = NULL;
if (status != -1) {
- qemuBlockJobEventProcess(driver, vm, disk, asyncJob,
+ qemuBlockJobEventProcess(priv->driver, vm, disk, asyncJob,
diskPriv->blockJobType,
diskPriv->blockJobStatus);
diskPriv->blockJobStatus = -1;
@@ -244,7 +243,6 @@ qemuBlockJobSyncBegin(virDomainDiskDefPtr disk)
/**
* qemuBlockJobSyncEnd:
- * @driver: qemu driver
* @vm: domain
* @disk: domain disk
*
@@ -252,12 +250,11 @@ qemuBlockJobSyncBegin(virDomainDiskDefPtr disk)
* for the disk is processed.
*/
void
-qemuBlockJobSyncEnd(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+qemuBlockJobSyncEnd(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk)
{
VIR_DEBUG("disk=%s", disk->dst);
- qemuBlockJobUpdate(driver, vm, asyncJob, disk, NULL);
+ qemuBlockJobUpdate(vm, asyncJob, disk, NULL);
QEMU_DOMAIN_DISK_PRIVATE(disk)->blockJobSync = false;
}
diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h
index e71d691c9..cee3ee21c 100644
--- a/src/qemu/qemu_blockjob.h
+++ b/src/qemu/qemu_blockjob.h
@@ -26,8 +26,7 @@
# include "qemu_conf.h"
# include "qemu_domain.h"
-int qemuBlockJobUpdate(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+int qemuBlockJobUpdate(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk,
char **error);
@@ -39,8 +38,7 @@ void qemuBlockJobEventProcess(virQEMUDriverPtr driver,
int status);
void qemuBlockJobSyncBegin(virDomainDiskDefPtr disk);
-void qemuBlockJobSyncEnd(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+void qemuBlockJobSyncEnd(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
virDomainDiskDefPtr disk);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c129321a5..b03eb3042 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16934,19 +16934,19 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
* block jobs from confusing us. */
if (!async) {
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
- qemuBlockJobUpdate(driver, vm, QEMU_ASYNC_JOB_NONE, disk, NULL);
+ qemuBlockJobUpdate(vm, QEMU_ASYNC_JOB_NONE, disk, NULL);
while (diskPriv->blockjob) {
if (virDomainObjWait(vm) < 0) {
ret = -1;
goto endjob;
}
- qemuBlockJobUpdate(driver, vm, QEMU_ASYNC_JOB_NONE, disk, NULL);
+ qemuBlockJobUpdate(vm, QEMU_ASYNC_JOB_NONE, disk, NULL);
}
}
endjob:
if (disk)
- qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
+ qemuBlockJobSyncEnd(vm, QEMU_ASYNC_JOB_NONE, disk);
qemuDomainObjEndJob(driver, vm);
cleanup:
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 7602a304c..f01bb64f6 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -464,7 +464,6 @@ qemuMigrationDstStopNBDServer(virQEMUDriverPtr driver,
/**
* qemuMigrationSrcDriveMirrorReady:
- * @driver: qemu driver
* @vm: domain
*
* Check the status of all drive-mirrors started by
@@ -476,8 +475,7 @@ qemuMigrationDstStopNBDServer(virQEMUDriverPtr driver,
* -1 on error.
*/
static int
-qemuMigrationSrcDriveMirrorReady(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+qemuMigrationSrcDriveMirrorReady(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob)
{
size_t i;
@@ -492,7 +490,7 @@ qemuMigrationSrcDriveMirrorReady(virQEMUDriverPtr driver,
if (!diskPriv->migrating)
continue;
- status = qemuBlockJobUpdate(driver, vm, asyncJob, disk, &error);
+ status = qemuBlockJobUpdate(vm, asyncJob, disk, &error);
if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) {
if (error) {
virReportError(VIR_ERR_OPERATION_FAILED,
@@ -532,8 +530,7 @@ qemuMigrationSrcDriveMirrorReady(virQEMUDriverPtr driver,
* -2 all mirrors are gone but some of them failed.
*/
static int
-qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
+qemuMigrationDriveMirrorCancelled(virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob,
bool check)
{
@@ -552,7 +549,7 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
if (!diskPriv->migrating)
continue;
- status = qemuBlockJobUpdate(driver, vm, asyncJob, disk, &error);
+ status = qemuBlockJobUpdate(vm, asyncJob, disk, &error);
switch (status) {
case VIR_DOMAIN_BLOCK_JOB_FAILED:
if (check) {
@@ -569,7 +566,7 @@ qemuMigrationDriveMirrorCancelled(virQEMUDriverPtr driver,
ATTRIBUTE_FALLTHROUGH;
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
- qemuBlockJobSyncEnd(driver, vm, asyncJob, disk);
+ qemuBlockJobSyncEnd(vm, asyncJob, disk);
diskPriv->migrating = false;
break;
@@ -633,7 +630,7 @@ qemuMigrationSrcCancelOneDriveMirror(virQEMUDriverPtr driver,
int status;
int rv;
- status = qemuBlockJobUpdate(driver, vm, asyncJob, disk, &error);
+ status = qemuBlockJobUpdate(vm, asyncJob, disk, &error);
switch (status) {
case VIR_DOMAIN_BLOCK_JOB_FAILED:
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
@@ -716,12 +713,12 @@ qemuMigrationSrcCancelDriveMirror(virQEMUDriverPtr driver,
err = virSaveLastError();
failed = true;
}
- qemuBlockJobSyncEnd(driver, vm, asyncJob, disk);
+ qemuBlockJobSyncEnd(vm, asyncJob, disk);
diskPriv->migrating = false;
}
}
- while ((rv = qemuMigrationDriveMirrorCancelled(driver, vm, asyncJob,
+ while ((rv = qemuMigrationDriveMirrorCancelled(vm, asyncJob,
check)) != 1) {
if (check && !failed &&
dconn && virConnectIsAlive(dconn) <= 0) {
@@ -848,7 +845,7 @@ qemuMigrationSrcDriveMirror(virQEMUDriverPtr driver,
VIR_FREE(nbd_dest);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || mon_ret < 0) {
- qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, disk);
+ qemuBlockJobSyncEnd(vm, QEMU_ASYNC_JOB_MIGRATION_OUT, disk);
goto cleanup;
}
diskPriv->migrating = true;
@@ -859,7 +856,7 @@ qemuMigrationSrcDriveMirror(virQEMUDriverPtr driver,
}
}
- while ((rv = qemuMigrationSrcDriveMirrorReady(driver, vm,
+ while ((rv = qemuMigrationSrcDriveMirrorReady(vm,
QEMU_ASYNC_JOB_MIGRATION_OUT)) != 1) {
if (rv < 0)
goto cleanup;
@@ -1366,7 +1363,7 @@ qemuMigrationAnyCompleted(virQEMUDriverPtr driver,
/* This flag should only be set when run on src host */
if (flags & QEMU_MIGRATION_COMPLETED_CHECK_STORAGE &&
- qemuMigrationSrcDriveMirrorReady(driver, vm, asyncJob) < 0)
+ qemuMigrationSrcDriveMirrorReady(vm, asyncJob) < 0)
goto error;
if (flags & QEMU_MIGRATION_COMPLETED_ABORT_ON_ERROR &&
@@ -5273,7 +5270,7 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
VIR_DEBUG("Drive mirror on disk %s is still running",
disk->dst);
} else {
VIR_DEBUG("Drive mirror on disk %s is gone", disk->dst);
- qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
+ qemuBlockJobSyncEnd(vm, QEMU_ASYNC_JOB_NONE, disk);
diskPriv->migrating = false;
}
}
@@ -5295,7 +5292,7 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
if (diskPriv->migrating) {
- qemuBlockJobSyncEnd(driver, vm, QEMU_ASYNC_JOB_NONE, disk);
+ qemuBlockJobSyncEnd(vm, QEMU_ASYNC_JOB_NONE, disk);
diskPriv->migrating = false;
}
}
--
2.14.3