From patchwork Wed Oct 10 14:02:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 190665 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 C9D492C0087 for ; Thu, 11 Oct 2012 01:57:35 +1100 (EST) Received: from localhost ([::1]:39990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLwuF-00046d-1p for incoming@patchwork.ozlabs.org; Wed, 10 Oct 2012 10:05:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLwt2-0002D9-CF for qemu-devel@nongnu.org; Wed, 10 Oct 2012 10:03:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLwsu-0002Cg-H0 for qemu-devel@nongnu.org; Wed, 10 Oct 2012 10:03:48 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:48668) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLwsu-00028a-Bg for qemu-devel@nongnu.org; Wed, 10 Oct 2012 10:03:40 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so726564pbb.4 for ; Wed, 10 Oct 2012 07:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=mNAy9M+S21KP9/1xrdlKVgSZhFbX5o78SKVjV17FPbg=; b=C2wkHAhYD1OBSyjAGB0n2q34KwgZqTZpihRzv25bdtb9v3QHItb6kfgdLy77oRY5wO pS9HkJ/kABPKMk8eW86xPVEu2wtTZxPILGTLWFAYpgMtXXJKGVh0Kes/VHrem6Uqnnnh BWVMGpSPIRrSKdFYQkP2GHWZki1JWbzkSWyNvmTuOGeAcJEvT7I0Y4EbvWcTCgJKXosi 7PX6wrTRvFNE/0NHvRu0jwJSNanfjf6Nm5C0S5AU65aBqTyA8EkbmC50dyd3WmNXgo6n 4rBy6M6ac1MMGq4pvu1Mji8cXEUSoge1L5lM0D7tTcr+7bl/Cj8WmIU1SkhTrCBIj1cT 2tLQ== Received: by 10.68.234.7 with SMTP id ua7mr75142169pbc.91.1349877819836; Wed, 10 Oct 2012 07:03:39 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id n7sm905723pav.26.2012.10.10.07.03.38 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Oct 2012 07:03:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 10 Oct 2012 16:02:51 +0200 Message-Id: <1349877786-23514-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1349877786-23514-1-git-send-email-pbonzini@redhat.com> References: <1349877786-23514-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 10/25] qemu-char: ask and print error information from qemu-sockets 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 Before: $ qemu-system-x86_64 -monitor tcp:localhost:6000 (starts despite error) $ qemu-system-x86_64 -monitor tcp:foo.bar:12345 getaddrinfo(foo.bar,12345): Name or service not known chardev: opening backend "socket" failed $ qemu-system-x86_64 -monitor tcp:localhost:443,server=on inet_listen_opts: bind(ipv4,127.0.0.1,443): Permission denied inet_listen_opts: FAILED chardev: opening backend "socket" failed After: $ x86_64-softmmu/qemu-system-x86_64 -monitor tcp:localhost:6000 x86_64-softmmu/qemu-system-x86_64: -monitor tcp:localhost:6000: Failed to connect to socket: Connection refused chardev: opening backend "socket" failed $ x86_64-softmmu/qemu-system-x86_64 -monitor tcp:foo.bar:12345 qemu-system-x86_64: -monitor tcp:foo.bar:12345: address resolution failed for foo.bar:12345: Name or service not known chardev: opening backend "socket" failed $ x86_64-softmmu/qemu-system-x86_64 -monitor tcp:localhost:443,server=on qemu-system-x86_64: -monitor tcp:localhost:443,server=on: Failed to bind socket: Permission denied chardev: opening backend "socket" failed Reviewed-by: Luiz Capitulino Signed-off-by: Paolo Bonzini --- qemu-char.c | 23 +++++++++++++++++------ 1 file modificato, 17 inserzioni(+), 6 rimozioni(-) diff --git a/qemu-char.c b/qemu-char.c index 8ebd582..04b5c23 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2097,12 +2097,13 @@ static CharDriverState *qemu_chr_open_udp(QemuOpts *opts) { CharDriverState *chr = NULL; NetCharDriver *s = NULL; + Error *local_err = NULL; int fd = -1; chr = g_malloc0(sizeof(CharDriverState)); s = g_malloc0(sizeof(NetCharDriver)); - fd = inet_dgram_opts(opts, NULL); + fd = inet_dgram_opts(opts, &local_err); if (fd < 0) { fprintf(stderr, "inet_dgram_opts failed\n"); goto return_err; @@ -2118,6 +2119,10 @@ static CharDriverState *qemu_chr_open_udp(QemuOpts *opts) return chr; return_err: + if (local_err) { + qerror_report_err(local_err); + error_free(local_err); + } g_free(chr); g_free(s); if (fd >= 0) { @@ -2428,6 +2433,7 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) { CharDriverState *chr = NULL; TCPCharDriver *s = NULL; + Error *local_err = NULL; int fd = -1; int is_listen; int is_waitconnect; @@ -2448,15 +2454,15 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) if (is_unix) { if (is_listen) { - fd = unix_listen_opts(opts, NULL); + fd = unix_listen_opts(opts, &local_err); } else { - fd = unix_connect_opts(opts, NULL, NULL, NULL); + fd = unix_connect_opts(opts, &local_err, NULL, NULL); } } else { if (is_listen) { - fd = inet_listen_opts(opts, 0, NULL); + fd = inet_listen_opts(opts, 0, &local_err); } else { - fd = inet_connect_opts(opts, NULL, NULL, NULL); + fd = inet_connect_opts(opts, &local_err, NULL, NULL); } } if (fd < 0) { @@ -2517,8 +2523,13 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) return chr; fail: - if (fd >= 0) + if (local_err) { + qerror_report_err(local_err); + error_free(local_err); + } + if (fd >= 0) { closesocket(fd); + } g_free(s); g_free(chr); return NULL;