qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Amos Kong <akong@redhat.com>
Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] iscsi: add error handling for qmp_query_uuid
Date: Tue, 05 Nov 2013 08:52:36 +0100	[thread overview]
Message-ID: <5278A3C4.2070305@redhat.com> (raw)
In-Reply-To: <1383611594-19632-1-git-send-email-akong@redhat.com>

On 11/05/13 01:33, Amos Kong wrote:
> We can't assume that qmp_query_uuid() always returns available value.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
> v2: free errp if it's set
> ---
>  block/iscsi.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index a2a961e..4051bdd 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -1059,6 +1059,7 @@ static char *parse_initiator_name(const char *target)
>      const char *name;
>      char *iscsi_name;
>      UuidInfo *uuid_info;
> +    Error *errp = NULL;

I think we usually call this "local_err" or something similar.

>  
>      list = qemu_find_opts("iscsi");
>      if (list) {
> @@ -1074,8 +1075,11 @@ static char *parse_initiator_name(const char *target)
>          }
>      }
>  
> -    uuid_info = qmp_query_uuid(NULL);
> -    if (strcmp(uuid_info->UUID, UUID_NONE) == 0) {
> +    uuid_info = qmp_query_uuid(&errp);
> +    if (error_is_set(&errp)) {
> +        name = qemu_get_vm_name();

I wonder if such an error should make parse_initiator_name() fail (which
is currently not possible), or maybe succeed with qemu_get_vm_name() but
print the UUID error message as a "warning" (could be pointless though).

> +        error_free(errp);
> +    } else if (strcmp(uuid_info->UUID, UUID_NONE) == 0) {
>          name = qemu_get_vm_name();
>      } else {
>          name = uuid_info->UUID;
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

  reply	other threads:[~2013-11-05  7:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05  0:08 [Qemu-devel] [PATCH] iscsi: add error handling for qmp_query_uuid Amos Kong
2013-11-05  0:33 ` [Qemu-devel] [PATCH v2] " Amos Kong
2013-11-05  7:52   ` Laszlo Ersek [this message]
2013-11-05 13:17   ` Stefan Hajnoczi
2013-11-05 13:44     ` Paolo Bonzini
2013-11-05  9:03 ` [Qemu-devel] [PATCH] " Paolo Bonzini
2013-11-05 15:05   ` Amos Kong

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=5278A3C4.2070305@redhat.com \
    --to=lersek@redhat.com \
    --cc=akong@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).