mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
qemu: blockjob: Split out handling of completed jobs
qemuBlockJobEventProcessLegacy was getting too big. Remove handling of completed jobs in a separate function. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
246303dc5b
commit
232ab2f200
@ -81,46 +81,15 @@ qemuBlockJobEmitEvents(virQEMUDriverPtr driver,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuBlockJobEventProcessLegacy:
|
||||
* @driver: qemu driver
|
||||
* @vm: domain
|
||||
* @disk: domain disk
|
||||
* @type: block job type
|
||||
* @status: block job status
|
||||
*
|
||||
* Update disk's mirror state in response to a block job event
|
||||
* from QEMU. For mirror state's that must survive libvirt
|
||||
* restart, also update the domain's status XML.
|
||||
*/
|
||||
static void
|
||||
qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver,
|
||||
qemuBlockJobEventProcessLegacyCompleted(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainDiskDefPtr disk,
|
||||
int asyncJob,
|
||||
int type,
|
||||
int status)
|
||||
int asyncJob)
|
||||
{
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virDomainDiskDefPtr persistDisk = NULL;
|
||||
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||
virDomainDiskDefPtr persistDisk = NULL;
|
||||
|
||||
VIR_DEBUG("disk=%s, mirrorState=%s, type=%d, status=%d",
|
||||
disk->dst,
|
||||
NULLSTR(virDomainDiskMirrorStateTypeToString(disk->mirrorState)),
|
||||
type,
|
||||
status);
|
||||
|
||||
if (type == VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT &&
|
||||
disk->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT)
|
||||
type = disk->mirrorJob;
|
||||
|
||||
qemuBlockJobEmitEvents(driver, vm, disk, type, status);
|
||||
|
||||
/* If we completed a block pull or commit, then update the XML
|
||||
* to match. */
|
||||
switch ((virConnectDomainEventBlockJobStatus) status) {
|
||||
case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
|
||||
if (disk->mirrorState == VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT) {
|
||||
if (vm->newDef) {
|
||||
virStorageSourcePtr copy = NULL;
|
||||
@ -173,6 +142,49 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver,
|
||||
ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk, true));
|
||||
ignore_value(qemuBlockNodeNamesDetect(driver, vm, asyncJob));
|
||||
diskPriv->blockjob->started = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuBlockJobEventProcessLegacy:
|
||||
* @driver: qemu driver
|
||||
* @vm: domain
|
||||
* @disk: domain disk
|
||||
* @type: block job type
|
||||
* @status: block job status
|
||||
*
|
||||
* Update disk's mirror state in response to a block job event
|
||||
* from QEMU. For mirror state's that must survive libvirt
|
||||
* restart, also update the domain's status XML.
|
||||
*/
|
||||
static void
|
||||
qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainDiskDefPtr disk,
|
||||
int asyncJob,
|
||||
int type,
|
||||
int status)
|
||||
{
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||
|
||||
VIR_DEBUG("disk=%s, mirrorState=%s, type=%d, status=%d",
|
||||
disk->dst,
|
||||
NULLSTR(virDomainDiskMirrorStateTypeToString(disk->mirrorState)),
|
||||
type,
|
||||
status);
|
||||
|
||||
if (type == VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT &&
|
||||
disk->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT)
|
||||
type = disk->mirrorJob;
|
||||
|
||||
qemuBlockJobEmitEvents(driver, vm, disk, type, status);
|
||||
|
||||
/* If we completed a block pull or commit, then update the XML
|
||||
* to match. */
|
||||
switch ((virConnectDomainEventBlockJobStatus) status) {
|
||||
case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
|
||||
qemuBlockJobEventProcessLegacyCompleted(driver, vm, disk, asyncJob);
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_BLOCK_JOB_READY:
|
||||
|
Loading…
Reference in New Issue
Block a user