Commit f5e8715a8b4 added logic which adds some fake job info when qemu
didn't return anything but in such case the job type would not be set.
Since we already have the proper job type recorded in qemuBlockJobDataPtr
which the caller fetched, we can use this it and also remove the lookup
from the disk which was necessary prior to the conversion to
qemuBlockJobDataPtr.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
I've wanted to fix it before pushing what would become commit f5e8715a8b4
but Michal accidentally pushed it with one of his patches.
src/qemu/qemu_driver.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d8478945d6..5d4697103d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14638,9 +14638,11 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
static int
qemuBlockJobInfoTranslate(qemuMonitorBlockJobInfoPtr rawInfo,
virDomainBlockJobInfoPtr info,
- virDomainDiskDefPtr disk,
+ qemuBlockJobDataPtr job,
bool reportBytes)
{
+ info->type = job->type;
+
/* If the job data is no longer present this means that the job already
* disappeared in qemu (pre-blockdev) but libvirt didn't process the
* finishing yet. Fake a incomplete job. */
@@ -14674,11 +14676,6 @@ qemuBlockJobInfoTranslate(qemuMonitorBlockJobInfoPtr rawInfo,
info->cur > 0)
info->cur -= 1;
- info->type = rawInfo->type;
- if (info->type == VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT &&
- disk->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT)
- info->type = disk->mirrorJob;
-
if (rawInfo->bandwidth && !reportBytes)
rawInfo->bandwidth = VIR_DIV_UP(rawInfo->bandwidth, 1024 * 1024);
info->bandwidth = rawInfo->bandwidth;
@@ -14737,7 +14734,7 @@ qemuDomainGetBlockJobInfo(virDomainPtr dom,
rawInfo = g_hash_table_lookup(blockjobstats, job->name);
- if (qemuBlockJobInfoTranslate(rawInfo, info, disk,
+ if (qemuBlockJobInfoTranslate(rawInfo, info, job,
flags & VIR_DOMAIN_BLOCK_JOB_INFO_BANDWIDTH_BYTES)
< 0)
goto endjob;
--
2.28.0