Description of problem: The event types in block-job and block-job-2 events are incorrect when --active is used for blockcommit. This is a regression. It is correct with libvirt-4.5.0-23.module+el8.1.0+2947+d70a8de0.x86_64 and libvirt-5.0.0-10.module+el8.0.1+3363+49e420ce.x86_64 Version-Release number of selected component (if applicable): libvirt-5.3.0-1.module+el8.1.0+3164+94495c71.x86_64 How reproducible: 100% Steps to Reproduce: 1. Set selinux to Permissive before doing blockcommit, due to bug 1717768 2. Run libvirt-tck script for testing perl-Sys-Virt package. # vim scripts/event/150-domain-blockjob.t ... sub check_event { my $job_type = shift; my $job_status = shift; my $type_name = shift; my $status_name = shift; $event_type = ''; $event_type2 = ''; ... is($event_type, $job_type, "Get block job type: $type_name"); is($event_status, $job_status, "Get block job status: $status_name"); is($event_type2, $job_type, "Get block job 2 type: $type_name"); is($event_status2, $job_status, "Get block job 2 status: $status_name"); } sub blockjob_cb { my $con = shift; my $dom = shift; my $path = shift; $event_type = shift; $event_status = shift; print "Block job callback: $path $event_type $event_status\n"; } sub commit_active { diag "basepath=$basepath, toppath=$toppath"; return $dom->block_commit("vda", $basepath, $toppath, 1000, Sys::Virt::Domain::BLOCK_COMMIT_ACTIVE); } sub commit_relative { diag "basepath=$basepath, toppath=$toppath"; return $dom->block_commit("vda", $basepath, $toppath, 1000, Sys::Virt::Domain::BLOCK_COMMIT_RELATIVE| Sys::Virt::Domain::BLOCK_COMMIT_ACTIVE); } my @tests = ( { job => "block_commit_active", event => Sys::Virt::Domain::BLOCK_JOB_TYPE_ACTIVE_COMMIT, result => Sys::Virt::Domain::BLOCK_JOB_READY, func => \&commit_active, result_msg => "ready", }, { job => "block_commit_relative", event => Sys::Virt::Domain::BLOCK_JOB_TYPE_ACTIVE_COMMIT, result => Sys::Virt::Domain::BLOCK_JOB_READY, func => \&commit_relative, result_msg => "completed", }, ); # libvirt-tck --testdir scripts/event/150-domain-blockjob.t -v --force Block job callback: /var/cache/libvirt-tck/storage-fs/tck/tck.snapshot3 3 3 Block job 2 callback: vda 3 3 not ok 27 - Get block job type: block_commit_active <=== Fail # Failed test 'Get block job type: block_commit_active' # at scripts/event/150-domain-blockjob.t line 61. # got: '3' # expected: '4' ok 28 - Get block job status: ready not ok 29 - Get block job 2 type: block_commit_active <=== Fail # Failed test 'Get block job 2 type: block_commit_active' # at scripts/event/150-domain-blockjob.t line 63. # got: '3' # expected: '4' ... Block job callback: /var/cache/libvirt-tck/storage-fs/tck/tck.snapshot3 3 3 Block job 2 callback: vda 3 3 not ok 35 - Get block job type: block_commit_relative <=== Fail # Failed test 'Get block job type: block_commit_relative' # at scripts/event/150-domain-blockjob.t line 61. # got: '3' # expected: '4' ok 36 - Get block job status: completed not ok 37 - Get block job 2 type: block_commit_relative <=== Fail # Failed test 'Get block job 2 type: block_commit_relative' # at scripts/event/150-domain-blockjob.t line 63. # got: '3' # expected: '4' ok 38 - Get block job 2 status: completed 2. At same time, run virsh event to get the event list ... event 'lifecycle' for domain tck: Started Booted event 'block-job' for domain tck: Block Commit for /var/cache/libvirt-tck/storage-fs/tck/tck.snapshot3 ready event 'block-job-2' for domain tck: Block Commit for vda ready event 'lifecycle' for domain tck: Stopped Destroyed event 'lifecycle' for domain tck: Undefined Removed event 'lifecycle' for domain tck: Defined Added event 'lifecycle' for domain tck: Resumed Unpaused event 'lifecycle' for domain tck: Started Booted event 'block-job' for domain tck: Block Commit for /var/cache/libvirt-tck/storage-fs/tck/tck.snapshot3 ready event 'block-job-2' for domain tck: Block Commit for vda ready event 'lifecycle' for domain tck: Stopped Destroyed event 'lifecycle' for domain tck: Undefined Removed 3. Actual results: See above. Expected results: Below output is for libvirt-4.5.0-23.module+el8.1.0+2947+d70a8de0.x86_64: Block job callback: /var/cache/libvirt-tck/storage-fs/tck/tck.snapshot3 4 3 Block job 2 callback: vda 4 3 ok 27 - Get block job type: block_commit_active <=== expected ok 28 - Get block job status: ready ok 29 - Get block job 2 type: block_commit_active <=== expected ok 30 - Get block job 2 status: ready # Destroying the running domain # Undefining the inactive domain config ok 31 - succeed to create external snapshot ok 32 - succeed to create external snapshot ok 33 - succeed to create external snapshot ok 34 - block pulled Block job callback: /var/cache/libvirt-tck/storage-fs/tck/tck.snapshot3 4 3 Block job 2 callback: vda 4 3 ok 35 - Get block job type: block_commit_relative <=== expected ok 36 - Get block job status: completed ok 37 - Get block job 2 type: block_commit_relative <=== expected ok 38 - Get block job 2 status: completed Additional info:
Fixed upstream: commit 00c4c971fd4eac00ce80f7ffe415a4f5a3c45b03 Author: Peter Krempa <pkrempa> Date: Thu Jul 18 18:08:11 2019 +0200 qemu: process: Don't use qemuBlockJobStartupFinalize in qemuProcessHandleBlockJob The block job event handler qemuProcessHandleBlockJob looks at the block job data to see whether the job requires synchronous handling. Since the block job event may arrive before we continue the job handling (if the job has no data to copy) we could hit the state when the job is still set as QEMU_BLOCKJOB_STATE_NEW (as we move it to the QEMU_BLOCKJOB_STATE_RUNNING state only after returning from monitor). If the event handler uses qemuBlockJobStartupFinalize it would unregister and free the job. Thankfully this is not a big problem for legacy blockjobs as we don't need much data for them but since we'd re-instantiate the job data structure we'd report wrong job type for active commit as qemu reports it as a regular commit job. Fix it by not using qemuBlockJobStartupFinalize function in qemuProcessHandleBlockJob as it is not starting the job anyways. https://bugzilla.redhat.com/show_bug.cgi?id=1721375 Signed-off-by: Peter Krempa <pkrempa> Reviewed-by: Ján Tomko <jtomko> v5.5.0-260-g00c4c971fd
# rpm -q perl-Sys-Virt libvirt perl-Sys-Virt-5.6.0-1.module+el8.1.0+3908+8a8c5ed4.x86_64 libvirt-5.6.0-1.module+el8.1.0+3890+4d3d259c.x86_64 Rerun # libvirt-tck --testdir scripts/event/150-domain-blockjob.t -v --force Block job callback: /var/cache/libvirt-tck/storage-fs/tck/tck.snapshot3 4 3 Block job 2 callback: vda 4 3 ok 29 - Get block job type: block_commit_active ok 30 - Get block job status: ready ok 31 - Get block job 2 type: block_commit_active ok 32 - Get block job 2 status: ready # Destroying the running domain # Undefining the inactive domain config # Delete qcow2 backend volume ok 33 - create qcow2 backing file volume Ignore to download vmlinuz and initrd ok 34 - succeed to create external snapshot ok 35 - succeed to create external snapshot ok 36 - succeed to create external snapshot ok 37 - block pulled Block job callback: /var/cache/libvirt-tck/storage-fs/tck/tck.snapshot3 4 3 Block job 2 callback: vda 4 3 ok 38 - Get block job type: block_commit_relative ok 39 - Get block job status: completed ok 40 - Get block job 2 type: block_commit_relative ok 41 - Get block job 2 status: completed # Destroying the running domain # Undefining the inactive domain config # Delete qcow2 backend volume ok All tests successful. Files=1, Tests=41, 16 wallclock secs ( 0.03 usr 0.01 sys + 0.26 cusr 0.05 csys = 0.35 CPU) Result: PASS
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2019:3723