[libvirt] [PATCH] blockjob: Fix a error checking of blockjob status in some case

Jie Wang posted 1 patch 6 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1516370585-81510-1-git-send-email-wangjie88@huawei.com
src/qemu/qemu_monitor_json.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] blockjob: Fix a error checking of blockjob status in some case
Posted by Jie Wang 6 years, 2 months ago
offset and len can also be equal to 0 on failed if blockjob return
status:"BLOCK_JOB_COMPLETED" with error:"File descriptor in bad
state", this bug can be reproduced easily if you perform a async
block job on read only filesystem, so it's very worthwhile for us to
check 'error' in this case.
---
 src/qemu/qemu_monitor_json.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 5ddd855..442b218 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -889,7 +889,7 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon,
     case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
         error = virJSONValueObjectGetString(data, "error");
         /* Make sure the whole device has been processed */
-        if (offset != len)
+        if (offset != len || error)
             event = VIR_DOMAIN_BLOCK_JOB_FAILED;
         break;
     case VIR_DOMAIN_BLOCK_JOB_CANCELED:
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] blockjob: Fix a error checking of blockjob status in some case
Posted by John Ferlan 6 years, 2 months ago

On 01/19/2018 09:03 AM, Jie Wang wrote:
> offset and len can also be equal to 0 on failed if blockjob return
> status:"BLOCK_JOB_COMPLETED" with error:"File descriptor in bad
> state", this bug can be reproduced easily if you perform a async
> block job on read only filesystem, so it's very worthwhile for us to
> check 'error' in this case.

Perhaps better said:


Commit id 'bc444666f' added a check if the returned data buffer had an
error, but failed to adjust the event from
VIR_DOMAIN_BLOCK_JOB_COMPLETED to VIR_DOMAIN_BLOCK_JOB_FAILED in order
to propagate an error such as "File descriptor in bad state" that may be
returned from QEMU when both @offset and @len are set to 0 such as is
the case when performing an async block job read on a read only filesystem.

If that adjustment is fine with you and anyone else that cares to read
this response, then I'll make the adjustment and push...

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

> ---
>  src/qemu/qemu_monitor_json.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 5ddd855..442b218 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -889,7 +889,7 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon,
>      case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
>          error = virJSONValueObjectGetString(data, "error");
>          /* Make sure the whole device has been processed */
> -        if (offset != len)
> +        if (offset != len || error)
>              event = VIR_DOMAIN_BLOCK_JOB_FAILED;
>          break;
>      case VIR_DOMAIN_BLOCK_JOB_CANCELED:
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] blockjob: Fix a error checking of blockjob status in some case
Posted by Eric Blake 6 years, 2 months ago
On 01/31/2018 08:56 AM, John Ferlan wrote:
> 
> 
> On 01/19/2018 09:03 AM, Jie Wang wrote:
>> offset and len can also be equal to 0 on failed if blockjob return
>> status:"BLOCK_JOB_COMPLETED" with error:"File descriptor in bad
>> state", this bug can be reproduced easily if you perform a async
>> block job on read only filesystem, so it's very worthwhile for us to
>> check 'error' in this case.
> 
> Perhaps better said:
> 
> 
> Commit id 'bc444666f' added a check if the returned data buffer had an
> error, but failed to adjust the event from
> VIR_DOMAIN_BLOCK_JOB_COMPLETED to VIR_DOMAIN_BLOCK_JOB_FAILED in order
> to propagate an error such as "File descriptor in bad state" that may be
> returned from QEMU when both @offset and @len are set to 0 such as is
> the case when performing an async block job read on a read only filesystem.
> 
> If that adjustment is fine with you and anyone else that cares to read
> this response, then I'll make the adjustment and push...
> 
> Reviewed-by: John Ferlan <jferlan@redhat.com>

Works for me as well.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

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