Bug 1336333

Summary: libvirt-1.2.21 virDomainBlockJobInfoPtr should add ready flag in the structure
Product: [Community] Virtualization Tools Reporter: Michael Liu <ztehypervisor>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED NOTABUG QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: pkrempa, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-16 08:44:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Michael Liu 2016-05-16 08:17:21 UTC
Description of problem:

The function of virDomainGetBlockJobInfo is to get the block job status.But the virDomainBlockJobInfoPtr structure which is geted by virDomainGetBlockJobInfo only has cur and end member.Users can only be based on these two values are equal to judge whether the block job is completed.But in fact, the block job maybe don't finish yet although cur and end are equal.For example,the job is doing flush operation.
The structure of qemuMonitorBlockJobInfo which is used by qemu and libvirt has ready flag.This flag is signed when the block job is complete finished.I don't know why virDomainBlockJobInfoPtr does't has this member.
Version-Release number of selected component (if applicable):
libvirt-1.2.21 

How reproducible:
Migrate virtual disk from disk array to lvm with virDomainBlockRebase.Then get block job status with virDomainGetBlockJobInfo.

Actual results:
The cur and end which are the members of virDomainBlockJobInfoPtr are equal.But the block job does not complete.

Comment 1 Peter Krempa 2016-05-16 08:44:44 UTC
(In reply to Michael Liu from comment #0)
> Description of problem:
> 
> The function of virDomainGetBlockJobInfo is to get the block job status.But
> the virDomainBlockJobInfoPtr structure which is geted by
> virDomainGetBlockJobInfo only has cur and end member.Users can only be based
> on these two values are equal to judge whether the block job is

Public API structures can't be changed since it would break ABI.

> completed.But in fact, the block job maybe don't finish yet although cur and
> end are equal.For example,the job is doing flush operation.

That's true. This was the reason why libvirt added  VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2 event which fires after the block job completes. The event contains field called 'status' which returns the following data:

enum virConnectDomainEventBlockJobStatus {
VIR_DOMAIN_BLOCK_JOB_COMPLETED	=	0
VIR_DOMAIN_BLOCK_JOB_FAILED	=	1
VIR_DOMAIN_BLOCK_JOB_CANCELED	=	2
VIR_DOMAIN_BLOCK_JOB_READY	=	3
VIR_DOMAIN_BLOCK_JOB_LAST	=	4
}

VIR_DOMAIN_BLOCK_JOB_READY is the appropriate event you want to wait for.

> The structure of qemuMonitorBlockJobInfo which is used by qemu and libvirt
> has ready flag.This flag is signed when the block job is complete finished.I
> don't know why virDomainBlockJobInfoPtr does't has this member.
> Version-Release number of selected component (if applicable):
> libvirt-1.2.21 
> 
> How reproducible:
> Migrate virtual disk from disk array to lvm with virDomainBlockRebase.Then
> get block job status with virDomainGetBlockJobInfo.

This is incorrect approach as described above.

> 
> Actual results:
> The cur and end which are the members of virDomainBlockJobInfoPtr are
> equal.But the block job does not complete.