From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdbOk-0008ME-1s for qemu-devel@nongnu.org; Tue, 05 Nov 2013 02:50:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdbOb-00024K-2r for qemu-devel@nongnu.org; Tue, 05 Nov 2013 02:50:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdbOa-000248-RH for qemu-devel@nongnu.org; Tue, 05 Nov 2013 02:49:53 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA57npth007565 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 5 Nov 2013 02:49:51 -0500 Message-ID: <5278A3C4.2070305@redhat.com> Date: Tue, 05 Nov 2013 08:52:36 +0100 From: Laszlo Ersek MIME-Version: 1.0 References: <1383610089-12168-1-git-send-email-akong@redhat.com> <1383611594-19632-1-git-send-email-akong@redhat.com> In-Reply-To: <1383611594-19632-1-git-send-email-akong@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] iscsi: add error handling for qmp_query_uuid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org 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 > --- > 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