mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
qemu: blockjob: Pass job into qemuBlockJobUpdateDisk and rename it
Instead of passing in the disk information, pass in the job and name the function accordingly. Few callers needed to be modified to have the job pointer handy. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c257352797
commit
103a4245ae
@ -334,10 +334,10 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qemuBlockJobUpdateDisk:
|
* qemuBlockJobUpdate:
|
||||||
* @vm: domain
|
* @vm: domain
|
||||||
* @disk: domain disk
|
* @job: job data
|
||||||
* @error: error (output parameter)
|
* @asyncJob: current qemu asynchronous job type
|
||||||
*
|
*
|
||||||
* Update disk's mirror state in response to a block job event stored in
|
* Update disk's mirror state in response to a block job event stored in
|
||||||
* blockJobStatus by qemuProcessHandleBlockJob event handler.
|
* blockJobStatus by qemuProcessHandleBlockJob event handler.
|
||||||
@ -345,11 +345,10 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver,
|
|||||||
* Returns the block job event processed or -1 if there was no pending event.
|
* Returns the block job event processed or -1 if there was no pending event.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
qemuBlockJobUpdateDisk(virDomainObjPtr vm,
|
qemuBlockJobUpdate(virDomainObjPtr vm,
|
||||||
int asyncJob,
|
qemuBlockJobDataPtr job,
|
||||||
virDomainDiskDefPtr disk)
|
int asyncJob)
|
||||||
{
|
{
|
||||||
qemuBlockJobDataPtr job = QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob;
|
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
|
||||||
if (job->newstate == -1)
|
if (job->newstate == -1)
|
||||||
@ -372,7 +371,7 @@ qemuBlockJobUpdateDisk(virDomainObjPtr vm,
|
|||||||
*
|
*
|
||||||
* During a synchronous block job, a block job event for @disk
|
* During a synchronous block job, a block job event for @disk
|
||||||
* will not be processed asynchronously. Instead, it will be
|
* will not be processed asynchronously. Instead, it will be
|
||||||
* processed only when qemuBlockJobUpdateDisk or qemuBlockJobSyncEndDisk
|
* processed only when qemuBlockJobUpdate or qemuBlockJobSyncEndDisk
|
||||||
* is called.
|
* is called.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -404,7 +403,12 @@ qemuBlockJobSyncEndDisk(virDomainObjPtr vm,
|
|||||||
int asyncJob,
|
int asyncJob,
|
||||||
virDomainDiskDefPtr disk)
|
virDomainDiskDefPtr disk)
|
||||||
{
|
{
|
||||||
|
qemuBlockJobDataPtr job = QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob;
|
||||||
|
|
||||||
|
if (!job)
|
||||||
|
return;
|
||||||
|
|
||||||
VIR_DEBUG("disk=%s", disk->dst);
|
VIR_DEBUG("disk=%s", disk->dst);
|
||||||
qemuBlockJobUpdateDisk(vm, asyncJob, disk);
|
qemuBlockJobUpdate(vm, job, asyncJob);
|
||||||
QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob->synchronous = false;
|
job->synchronous = false;
|
||||||
}
|
}
|
||||||
|
@ -96,9 +96,9 @@ qemuBlockJobIsRunning(qemuBlockJobDataPtr job)
|
|||||||
void
|
void
|
||||||
qemuBlockJobStartupFinalize(qemuBlockJobDataPtr job);
|
qemuBlockJobStartupFinalize(qemuBlockJobDataPtr job);
|
||||||
|
|
||||||
int qemuBlockJobUpdateDisk(virDomainObjPtr vm,
|
int qemuBlockJobUpdate(virDomainObjPtr vm,
|
||||||
int asyncJob,
|
qemuBlockJobDataPtr job,
|
||||||
virDomainDiskDefPtr disk);
|
int asyncJob);
|
||||||
|
|
||||||
void qemuBlockJobSyncBegin(qemuBlockJobDataPtr job);
|
void qemuBlockJobSyncBegin(qemuBlockJobDataPtr job);
|
||||||
void qemuBlockJobSyncEndDisk(virDomainObjPtr vm,
|
void qemuBlockJobSyncEndDisk(virDomainObjPtr vm,
|
||||||
|
@ -4740,7 +4740,7 @@ processBlockJobEvent(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
job->newstate = status;
|
job->newstate = status;
|
||||||
|
|
||||||
qemuBlockJobUpdateDisk(vm, QEMU_ASYNC_JOB_NONE, disk);
|
qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE);
|
||||||
|
|
||||||
endjob:
|
endjob:
|
||||||
qemuBlockJobStartupFinalize(job);
|
qemuBlockJobStartupFinalize(job);
|
||||||
@ -17445,13 +17445,13 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
|
|||||||
* do the waiting while still holding the VM job, to prevent newly
|
* do the waiting while still holding the VM job, to prevent newly
|
||||||
* scheduled block jobs from confusing us. */
|
* scheduled block jobs from confusing us. */
|
||||||
if (!async) {
|
if (!async) {
|
||||||
qemuBlockJobUpdateDisk(vm, QEMU_ASYNC_JOB_NONE, disk);
|
qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE);
|
||||||
while (qemuBlockJobIsRunning(job)) {
|
while (qemuBlockJobIsRunning(job)) {
|
||||||
if (virDomainObjWait(vm) < 0) {
|
if (virDomainObjWait(vm) < 0) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
qemuBlockJobUpdateDisk(vm, QEMU_ASYNC_JOB_NONE, disk);
|
qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,17 +464,16 @@ qemuMigrationDstStopNBDServer(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qemuMigrationNBDReportMirrorError(virDomainDiskDefPtr disk)
|
qemuMigrationNBDReportMirrorError(qemuBlockJobDataPtr job,
|
||||||
|
const char *diskdst)
|
||||||
{
|
{
|
||||||
qemuBlockJobDataPtr job = QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob;
|
|
||||||
|
|
||||||
if (job->errmsg) {
|
if (job->errmsg) {
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("migration of disk %s failed: %s"),
|
_("migration of disk %s failed: %s"),
|
||||||
disk->dst, job->errmsg);
|
diskdst, job->errmsg);
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("migration of disk %s failed"), disk->dst);
|
_("migration of disk %s failed"), diskdst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,16 +500,26 @@ qemuMigrationSrcNBDStorageCopyReady(virDomainObjPtr vm,
|
|||||||
for (i = 0; i < vm->def->ndisks; i++) {
|
for (i = 0; i < vm->def->ndisks; i++) {
|
||||||
virDomainDiskDefPtr disk = vm->def->disks[i];
|
virDomainDiskDefPtr disk = vm->def->disks[i];
|
||||||
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||||
|
qemuBlockJobDataPtr job;
|
||||||
|
|
||||||
if (!diskPriv->migrating)
|
if (!diskPriv->migrating)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
status = qemuBlockJobUpdateDisk(vm, asyncJob, disk);
|
if (!(job = qemuBlockJobDiskGetJob(disk))) {
|
||||||
if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) {
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
qemuMigrationNBDReportMirrorError(disk);
|
_("missing block job data for disk '%s'"), disk->dst);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status = qemuBlockJobUpdate(vm, job, asyncJob);
|
||||||
|
if (status == VIR_DOMAIN_BLOCK_JOB_FAILED) {
|
||||||
|
qemuMigrationNBDReportMirrorError(job, disk->dst);
|
||||||
|
virObjectUnref(job);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
virObjectUnref(job);
|
||||||
|
|
||||||
if (disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_READY)
|
if (disk->mirrorState != VIR_DOMAIN_DISK_MIRROR_STATE_READY)
|
||||||
notReady++;
|
notReady++;
|
||||||
}
|
}
|
||||||
@ -550,15 +559,19 @@ qemuMigrationSrcNBDCopyCancelled(virDomainObjPtr vm,
|
|||||||
for (i = 0; i < vm->def->ndisks; i++) {
|
for (i = 0; i < vm->def->ndisks; i++) {
|
||||||
virDomainDiskDefPtr disk = vm->def->disks[i];
|
virDomainDiskDefPtr disk = vm->def->disks[i];
|
||||||
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||||
|
qemuBlockJobDataPtr job;
|
||||||
|
|
||||||
if (!diskPriv->migrating)
|
if (!diskPriv->migrating)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
status = qemuBlockJobUpdateDisk(vm, asyncJob, disk);
|
if (!(job = qemuBlockJobDiskGetJob(disk)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
status = qemuBlockJobUpdate(vm, job, asyncJob);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case VIR_DOMAIN_BLOCK_JOB_FAILED:
|
case VIR_DOMAIN_BLOCK_JOB_FAILED:
|
||||||
if (check) {
|
if (check) {
|
||||||
qemuMigrationNBDReportMirrorError(disk);
|
qemuMigrationNBDReportMirrorError(job, disk->dst);
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
ATTRIBUTE_FALLTHROUGH;
|
ATTRIBUTE_FALLTHROUGH;
|
||||||
@ -574,6 +587,8 @@ qemuMigrationSrcNBDCopyCancelled(virDomainObjPtr vm,
|
|||||||
|
|
||||||
if (status == VIR_DOMAIN_BLOCK_JOB_COMPLETED)
|
if (status == VIR_DOMAIN_BLOCK_JOB_COMPLETED)
|
||||||
completed++;
|
completed++;
|
||||||
|
|
||||||
|
virObjectUnref(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Updating completed block job drops the lock thus we have to recheck
|
/* Updating completed block job drops the lock thus we have to recheck
|
||||||
@ -616,6 +631,7 @@ static int
|
|||||||
qemuMigrationSrcNBDCopyCancelOne(virQEMUDriverPtr driver,
|
qemuMigrationSrcNBDCopyCancelOne(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
virDomainDiskDefPtr disk,
|
virDomainDiskDefPtr disk,
|
||||||
|
qemuBlockJobDataPtr job,
|
||||||
bool failNoJob,
|
bool failNoJob,
|
||||||
qemuDomainAsyncJob asyncJob)
|
qemuDomainAsyncJob asyncJob)
|
||||||
{
|
{
|
||||||
@ -625,12 +641,12 @@ qemuMigrationSrcNBDCopyCancelOne(virQEMUDriverPtr driver,
|
|||||||
int status;
|
int status;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
status = qemuBlockJobUpdateDisk(vm, asyncJob, disk);
|
status = qemuBlockJobUpdate(vm, job, asyncJob);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case VIR_DOMAIN_BLOCK_JOB_FAILED:
|
case VIR_DOMAIN_BLOCK_JOB_FAILED:
|
||||||
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
|
case VIR_DOMAIN_BLOCK_JOB_CANCELED:
|
||||||
if (failNoJob) {
|
if (failNoJob) {
|
||||||
qemuMigrationNBDReportMirrorError(disk);
|
qemuMigrationNBDReportMirrorError(job, disk->dst);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
ATTRIBUTE_FALLTHROUGH;
|
ATTRIBUTE_FALLTHROUGH;
|
||||||
@ -700,7 +716,7 @@ qemuMigrationSrcNBDCopyCancel(virQEMUDriverPtr driver,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = qemuMigrationSrcNBDCopyCancelOne(driver, vm, disk,
|
rv = qemuMigrationSrcNBDCopyCancelOne(driver, vm, disk, job,
|
||||||
check, asyncJob);
|
check, asyncJob);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user