From patchwork Wed Mar 6 10:48:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 225474 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9B6D22C03B0 for ; Wed, 6 Mar 2013 21:48:51 +1100 (EST) Received: from localhost ([::1]:39363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDBtx-0001oJ-Sy for incoming@patchwork.ozlabs.org; Wed, 06 Mar 2013 05:48:49 -0500 Received: from eggs.gnu.org ([208.118.235.92]:44474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDBti-0001oC-5W for qemu-devel@nongnu.org; Wed, 06 Mar 2013 05:48:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDBte-0000RO-3T for qemu-devel@nongnu.org; Wed, 06 Mar 2013 05:48:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDBtd-0000RE-SE for qemu-devel@nongnu.org; Wed, 06 Mar 2013 05:48:30 -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 r26AmSv9030840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Mar 2013 05:48:28 -0500 Received: from dhcp-200-207.str.redhat.com (dhcp-192-246.str.redhat.com [10.33.192.246]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r26AmR7A010519; Wed, 6 Mar 2013 05:48:28 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 6 Mar 2013 11:48:06 +0100 Message-Id: <1362566886-14073-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH] qemu-sockets: Fix assertion failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org inet_connect_opts() tries all possible addrinfos returned by getaddrinfo(). If one fails with an error, the next one is tried. In this case, the Error should be discarded because the whole operation is successful if another addrinfo from the list succeeds; and if it doesn't, setting an already set Error will trigger an assertion failure. Signed-off-by: Kevin Wolf --- util/qemu-sockets.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 1350ccc..32e609a 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -373,6 +373,14 @@ int inet_connect_opts(QemuOpts *opts, Error **errp, } for (e = res; e != NULL; e = e->ai_next) { + + /* Overwriting errors isn't allowed, so clear any error that may have + * occured in the previous iteration */ + if (error_is_set(errp)) { + error_free(*errp); + *errp = NULL; + } + if (connect_state != NULL) { connect_state->current_addr = e; }