From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdcXi-0004Ge-5J for qemu-devel@nongnu.org; Tue, 05 Nov 2013 04:03:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdcXZ-000287-Om for qemu-devel@nongnu.org; Tue, 05 Nov 2013 04:03:22 -0500 Received: from mail-ea0-x22b.google.com ([2a00:1450:4013:c01::22b]:58517) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdcXZ-00027T-HM for qemu-devel@nongnu.org; Tue, 05 Nov 2013 04:03:13 -0500 Received: by mail-ea0-f171.google.com with SMTP id h15so686914eak.30 for ; Tue, 05 Nov 2013 01:03:12 -0800 (PST) Sender: Paolo Bonzini Message-ID: <5278B44E.9000102@redhat.com> Date: Tue, 05 Nov 2013 10:03:10 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1383610089-12168-1-git-send-email-akong@redhat.com> In-Reply-To: <1383610089-12168-1-git-send-email-akong@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] 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, lersek@redhat.com, qemu-devel@nongnu.org Il 05/11/2013 01:08, Amos Kong ha scritto: > We can't assume that qmp_query_uuid() always returns available value. > > Signed-off-by: Amos Kong > --- > block/iscsi.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/block/iscsi.c b/block/iscsi.c > index a2a961e..1fc1da4 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; > > list = qemu_find_opts("iscsi"); > if (list) { > @@ -1074,8 +1075,10 @@ 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(); > + } else if (strcmp(uuid_info->UUID, UUID_NONE) == 0) { > name = qemu_get_vm_name(); > } else { > name = uuid_info->UUID; > Does this fix an actual bug? qmp_query_uuid will never fail, it just has an Error* argument to comply with the requirements of the code generator. Paolo