[PATCH] qemuBlockJobInfoTranslate: Take job type from qemuBlockJobDataPtr

Peter Krempa posted 1 patch 3 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/b03dfdd52baeaa16543e39420259dc0b1cd05fce.1607360209.git.pkrempa@redhat.com
src/qemu/qemu_driver.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
[PATCH] qemuBlockJobInfoTranslate: Take job type from qemuBlockJobDataPtr
Posted by Peter Krempa 3 years, 4 months ago
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@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

Re: [PATCH] qemuBlockJobInfoTranslate: Take job type from qemuBlockJobDataPtr
Posted by Michal Privoznik 3 years, 4 months ago
On 12/7/20 5:57 PM, Peter Krempa wrote:
> 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@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(-)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal