* [Qemu-devel] [PATCH v2] block: mirror - use local_err to avoid NULL errp
@ 2014-02-13 14:23 Jeff Cody
2014-02-13 14:31 ` Kevin Wolf
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jeff Cody @ 2014-02-13 14:23 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, famz, armbru, stefanha
When starting a block job, commit_active_start() relies on whether *errp
is set by mirror_start_job. This allows it to determine if the mirror
job start failed, so that it can clean up any changes to open flags from
the bdrv_reopen(). If errp is NULL, then it will not be able to
determine if mirror_start_job failed or not.
To avoid this, use a local Error variable, and then propagate the error
(if any) to errp.
Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
block/mirror.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index 2a43334..ddb5765 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -633,6 +633,8 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
{
int64_t length, base_length;
int orig_base_flags;
+ Error *local_err = NULL;
+
orig_base_flags = bdrv_get_flags(base);
@@ -663,9 +665,10 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
bdrv_ref(base);
mirror_start_job(bs, base, speed, 0, 0,
- on_error, on_error, cb, opaque, errp,
+ on_error, on_error, cb, opaque, &local_err,
&commit_active_job_driver, false, base);
- if (error_is_set(errp)) {
+ if (error_is_set(&local_err)) {
+ error_propagate(errp, local_err);
goto error_restore_flags;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] block: mirror - use local_err to avoid NULL errp
2014-02-13 14:23 [Qemu-devel] [PATCH v2] block: mirror - use local_err to avoid NULL errp Jeff Cody
@ 2014-02-13 14:31 ` Kevin Wolf
2014-02-13 15:05 ` Eric Blake
2014-02-14 15:28 ` Stefan Hajnoczi
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2014-02-13 14:31 UTC (permalink / raw)
To: Jeff Cody; +Cc: famz, qemu-devel, stefanha, armbru
Am 13.02.2014 um 15:23 hat Jeff Cody geschrieben:
> When starting a block job, commit_active_start() relies on whether *errp
> is set by mirror_start_job. This allows it to determine if the mirror
> job start failed, so that it can clean up any changes to open flags from
> the bdrv_reopen(). If errp is NULL, then it will not be able to
> determine if mirror_start_job failed or not.
>
> To avoid this, use a local Error variable, and then propagate the error
> (if any) to errp.
>
> Reported-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] block: mirror - use local_err to avoid NULL errp
2014-02-13 14:23 [Qemu-devel] [PATCH v2] block: mirror - use local_err to avoid NULL errp Jeff Cody
2014-02-13 14:31 ` Kevin Wolf
@ 2014-02-13 15:05 ` Eric Blake
2014-02-14 15:28 ` Stefan Hajnoczi
2 siblings, 0 replies; 4+ messages in thread
From: Eric Blake @ 2014-02-13 15:05 UTC (permalink / raw)
To: Jeff Cody, qemu-devel; +Cc: kwolf, famz, armbru, stefanha
[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]
On 02/13/2014 07:23 AM, Jeff Cody wrote:
> When starting a block job, commit_active_start() relies on whether *errp
> is set by mirror_start_job. This allows it to determine if the mirror
> job start failed, so that it can clean up any changes to open flags from
> the bdrv_reopen(). If errp is NULL, then it will not be able to
> determine if mirror_start_job failed or not.
>
> To avoid this, use a local Error variable, and then propagate the error
> (if any) to errp.
>
> Reported-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> block/mirror.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/block/mirror.c b/block/mirror.c
> index 2a43334..ddb5765 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -633,6 +633,8 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
> {
> int64_t length, base_length;
> int orig_base_flags;
> + Error *local_err = NULL;
> +
>
> orig_base_flags = bdrv_get_flags(base);
Why the double blank line?
Besides that,
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] block: mirror - use local_err to avoid NULL errp
2014-02-13 14:23 [Qemu-devel] [PATCH v2] block: mirror - use local_err to avoid NULL errp Jeff Cody
2014-02-13 14:31 ` Kevin Wolf
2014-02-13 15:05 ` Eric Blake
@ 2014-02-14 15:28 ` Stefan Hajnoczi
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-02-14 15:28 UTC (permalink / raw)
To: Jeff Cody; +Cc: kwolf, famz, qemu-devel, stefanha, armbru
On Thu, Feb 13, 2014 at 09:23:38AM -0500, Jeff Cody wrote:
> When starting a block job, commit_active_start() relies on whether *errp
> is set by mirror_start_job. This allows it to determine if the mirror
> job start failed, so that it can clean up any changes to open flags from
> the bdrv_reopen(). If errp is NULL, then it will not be able to
> determine if mirror_start_job failed or not.
>
> To avoid this, use a local Error variable, and then propagate the error
> (if any) to errp.
>
> Reported-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> block/mirror.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-02-14 15:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-13 14:23 [Qemu-devel] [PATCH v2] block: mirror - use local_err to avoid NULL errp Jeff Cody
2014-02-13 14:31 ` Kevin Wolf
2014-02-13 15:05 ` Eric Blake
2014-02-14 15:28 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).