]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virDomainGetBlockJobInfo: Fix corner case when qemu reports no info
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 2 Sep 2016 07:45:44 +0000 (09:45 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 14 Sep 2016 10:44:42 +0000 (12:44 +0200)
commit988218ca3f0de571d97d02365db9ffa0845c18da
tree6c5d194d46b7878ec2fe7134dbf1968608747ec6
parent5d213b34de442490c66ee54b17d15e68cfeb2174
virDomainGetBlockJobInfo: Fix corner case when qemu reports no info

https://bugzilla.redhat.com/show_bug.cgi?id=1372613

Apparently, some management applications use the following code
pattern when waiting for a block job to finish:

  while (1) {
    virDomainGetBlockJobInfo(dom, disk, info, flags);

    if (info.cur == info.end)
        break;

    sleep(1);
  }

Problem with this approach is in its corner cases. In case of
QEMU, libvirt merely pass what has been reported on the monitor.
However, if the block job hasn't started yet, qemu reports cur ==
end == 0 which tricks mgmt apps into thinking job is complete.

The solution is to mangle cur/end values as described here [1].

1: https://www.redhat.com/archives/libvir-list/2016-September/msg00017.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/libvirt-domain.c
src/qemu/qemu_driver.c