[libvirt] [PATCH 5/8] qemu: driver: Report error if pivoting fails in qemuDomainBlockJobAbort

Peter Krempa posted 8 patches 6 years, 6 months ago
[libvirt] [PATCH 5/8] qemu: driver: Report error if pivoting fails in qemuDomainBlockJobAbort
Posted by Peter Krempa 6 years, 6 months ago
As the error message is now available and we know whether the job failed
we can report an error straight away rather than having the user check
the event.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_driver.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 39b5ea5e7e..7a69a0e084 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17230,6 +17230,21 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
             }
             qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE);
         }
+
+        if (pivot &&
+            job->state == QEMU_BLOCKJOB_STATE_FAILED) {
+            if (job->errmsg)
+                virReportError(VIR_ERR_OPERATION_FAILED,
+                               _("block job '%s' failed while pivoting"),
+                               job->name);
+            else
+                virReportError(VIR_ERR_OPERATION_FAILED,
+                               _("block job '%s' failed while pivoting: %s"),
+                               job->name, NULLSTR(job->errmsg));
+
+            ret = -1;
+            goto endjob;
+        }
     }

  endjob:
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/8] qemu: driver: Report error if pivoting fails in qemuDomainBlockJobAbort
Posted by Ján Tomko 6 years, 6 months ago
On Thu, Jul 18, 2019 at 06:31:40PM +0200, Peter Krempa wrote:
>As the error message is now available and we know whether the job failed
>we can report an error straight away rather than having the user check
>the event.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_driver.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
>diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>index 39b5ea5e7e..7a69a0e084 100644
>--- a/src/qemu/qemu_driver.c
>+++ b/src/qemu/qemu_driver.c
>@@ -17230,6 +17230,21 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
>             }
>             qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE);
>         }
>+
>+        if (pivot &&
>+            job->state == QEMU_BLOCKJOB_STATE_FAILED) {
>+            if (job->errmsg)
>+                virReportError(VIR_ERR_OPERATION_FAILED,
>+                               _("block job '%s' failed while pivoting"),
>+                               job->name);
>+            else

Please, put some braces around these multi-line bodies.

>+                virReportError(VIR_ERR_OPERATION_FAILED,
>+                               _("block job '%s' failed while pivoting: %s"),
>+                               job->name, NULLSTR(job->errmsg));

It is self-evident that job->errormsg cannot be NULL here.

Jano

>+
>+            ret = -1;

I'm not a fan of the numerous alterations of the 'ret' value throughout
the function.

>+            goto endjob;
>+        }
>     }

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list