qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: stefanha@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block: Fix NULL dereference on empty drive error
Date: Mon, 5 Mar 2018 10:10:29 -0600	[thread overview]
Message-ID: <0bf2b0c9-93ae-d816-b1ca-6a042340dcee@redhat.com> (raw)
In-Reply-To: <20180305150529.11203-1-kwolf@redhat.com>

On 03/05/2018 09:05 AM, Kevin Wolf wrote:
> blk_error_action() sends a BLOCK_IO_ERROR QMP event which includes the
> node name of its root node. If the BlockBackend represents an empty
> drive, there is no root node, so we should not try to access its node
> name. Make the field optional in the event and include it only when
> the BlockBackend isn't empty.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> 
> Stefan, this is needed for your patch that reverts the workaround in the
> IDE flush code. Without it, make check seems to succeed, but if you look
> closer, qemu actually segfaults.
> 
> qapi/block-core.json  | 6 ++++--
>   block/block-backend.c | 5 +++--
>   2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index 5c5921bfb7..00475f08d4 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -3676,7 +3676,8 @@
>   #
>   # @node-name: node name. Note that errors may be reported for the root node
>   #             that is directly attached to a guest device rather than for the
> -#             node where the error occurred. (Since: 2.8)
> +#             node where the error occurred. The node name is not present if
> +#             the drive is empty. (Since: 2.8)

Making an output field change from always present to sometimes absent 
might break older clients that expected to be able to parse the field 
unconditionally.  Would it be better to keep the 'node-name' field 
mandatory in the output but make it an empty string?

Then again, since the field was not present prior to 2.8, but the event 
itself is older, we can argue that clients of older qemu have to be 
prepared for the field to not be present.  So I think I can live with 
this change as-is.

>   #
>   # @operation: I/O operation
>   #
> @@ -3707,7 +3708,8 @@
>   #
>   ##
>   { 'event': 'BLOCK_IO_ERROR',
> -  'data': { 'device': 'str', 'node-name': 'str', 'operation': 'IoOperationType',
> +  'data': { 'device': 'str', '*node-name': 'str',
> +            'operation': 'IoOperationType',
>               'action': 'BlockErrorAction', '*nospace': 'bool',
>               'reason': 'str' } }
>   

Reviewed-by: Eric Blake <eblake@redhat.com>

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

  reply	other threads:[~2018-03-05 16:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05 15:05 [Qemu-devel] [PATCH] block: Fix NULL dereference on empty drive error Kevin Wolf
2018-03-05 16:10 ` Eric Blake [this message]
2018-03-05 16:22   ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0bf2b0c9-93ae-d816-b1ca-6a042340dcee@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).