From patchwork Fri Oct 19 13:32:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 192699 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 171422C008E for ; Sat, 20 Oct 2012 00:42:31 +1100 (EST) Received: from localhost ([::1]:40224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPCii-0007es-EJ for incoming@patchwork.ozlabs.org; Fri, 19 Oct 2012 09:34:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPCiM-0007BG-RF for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:34:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TPCiG-0006ha-Dh for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:34:14 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:36749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TPCiG-0006Qo-74 for qemu-devel@nongnu.org; Fri, 19 Oct 2012 09:34:08 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so437208pbb.4 for ; Fri, 19 Oct 2012 06:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=cZTBCmAVbYzgr8fqc3ahvMMNqbEA/0zVuoA79DWL58k=; b=J+wykjKwRQJlR+3o34gLxiQe57bXYcpPDdbZAPCMsxs9vtzN3ZMTyC4H6A64UrXQL2 nOTFssMbxCl3buNMpjbC2O3ybUIYxVf/dBNY2qKR8SKvjY4q2jkHxNOyzfz62pAcDPWo xk3J5BCgyfyCkBbUmY+sRan/UHeQaNHErmBqIja3+HhyBYvuO22jtqlSD10tC+ldFxEV C1/hj1JWVFqWkJsyBrhfLg4qvWBKoLfGZQcS6/NzY1Meq7MOvTOY4mCdYDfX9hmKW1Xp 4o0SHRXSW0T6w8ReazG9YBVJ4BZNxlQFQPJb/SKFj2zuVJ2xPIFizcEBe/WZguY7Bj4K y8BQ== Received: by 10.68.136.98 with SMTP id pz2mr6020485pbb.2.1350653647878; Fri, 19 Oct 2012 06:34:07 -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 kr4sm1240726pbc.76.2012.10.19.06.34.01 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Oct 2012 06:34:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 19 Oct 2012 15:32:00 +0200 Message-Id: <1350653528-5834-22-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1350653528-5834-1-git-send-email-pbonzini@redhat.com> References: <1350653528-5834-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 Subject: [Qemu-devel] [PATCH 21/29] qemu-sockets: add error propagation to Unix socket functions 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 unix:/vvv,server=off connect(unix:/vvv): No such file or directory chardev: opening backend "socket" failed After: $ x86_64-softmmu/qemu-system-x86_64 -monitor unix:/vvv,server=off qemu-system-x86_64: -monitor unix:/vvv,server=off: Failed to connect to socket: No such file or directory chardev: opening backend "socket" failed Reviewed-by: Paolo Bonzini Signed-off-by: Paolo Bonzini --- qemu-sockets.c | 16 ++++++++-------- 1 file modificato, 8 inserzioni(+), 8 rimozioni(-) diff --git a/qemu-sockets.c b/qemu-sockets.c index fb9c4c9..daff8e6 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -632,7 +632,7 @@ int unix_listen_opts(QemuOpts *opts, Error **errp) sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { - perror("socket(unix)"); + error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); return -1; } @@ -657,11 +657,11 @@ int unix_listen_opts(QemuOpts *opts, Error **errp) unlink(un.sun_path); if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) { - fprintf(stderr, "bind(unix:%s): %s\n", un.sun_path, strerror(errno)); + error_set_errno(errp, errno, QERR_SOCKET_BIND_FAILED); goto err; } if (listen(sock, 1) < 0) { - fprintf(stderr, "listen(unix:%s): %s\n", un.sun_path, strerror(errno)); + error_set_errno(errp, errno, QERR_SOCKET_LISTEN_FAILED); goto err; } @@ -681,13 +681,13 @@ int unix_connect_opts(QemuOpts *opts, Error **errp, int sock, rc; if (NULL == path) { - fprintf(stderr, "unix connect: no path specified\n"); + error_setg(errp, "unix connect: no path specified\n"); return -1; } sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { - perror("socket(unix)"); + error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); return -1; } if (callback != NULL) { @@ -722,7 +722,7 @@ int unix_connect_opts(QemuOpts *opts, Error **errp, } if (rc < 0) { - fprintf(stderr, "connect(unix:%s): %s\n", path, strerror(errno)); + error_set_errno(errp, -rc, QERR_SOCKET_CONNECT_FAILED); close(sock); sock = -1; } @@ -735,7 +735,7 @@ int unix_connect_opts(QemuOpts *opts, Error **errp, int unix_listen_opts(QemuOpts *opts, Error **errp) { - fprintf(stderr, "unix sockets are not available on windows\n"); + error_setg(errp, "unix sockets are not available on windows"); errno = ENOTSUP; return -1; } @@ -743,7 +743,7 @@ int unix_listen_opts(QemuOpts *opts, Error **errp) int unix_connect_opts(QemuOpts *opts, Error **errp, NonBlockingConnectHandler *callback, void *opaque) { - fprintf(stderr, "unix sockets are not available on windows\n"); + error_setg(errp, "unix sockets are not available on windows"); errno = ENOTSUP; return -1; }