mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: <penberg@kernel.org>
Cc: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/6] kvm tools: More error handling in the ipc code
Date: Wed,  6 Feb 2013 19:19:12 +1100	[thread overview]
Message-ID: <1360138756-1991-2-git-send-email-michael@ellerman.id.au> (raw)
In-Reply-To: <1360138756-1991-1-git-send-email-michael@ellerman.id.au>

Add perror() calls to a couple of exit paths, to ease debugging.

There are also two places where we print "Failed starting IPC thread",
but one is really an epoll failure, so make that obvious.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 tools/kvm/kvm-ipc.c |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tools/kvm/kvm-ipc.c b/tools/kvm/kvm-ipc.c
index bdcc0d1..7897519 100644
--- a/tools/kvm/kvm-ipc.c
+++ b/tools/kvm/kvm-ipc.c
@@ -49,18 +49,25 @@ static int kvm__create_socket(struct kvm *kvm)
 	}
 
 	s = socket(AF_UNIX, SOCK_STREAM, 0);
-	if (s < 0)
+	if (s < 0) {
+		perror("socket");
 		return s;
+	}
+
 	local.sun_family = AF_UNIX;
 	strlcpy(local.sun_path, full_name, sizeof(local.sun_path));
 	len = strlen(local.sun_path) + sizeof(local.sun_family);
 	r = bind(s, (struct sockaddr *)&local, len);
-	if (r < 0)
+	if (r < 0) {
+		perror("bind");
 		goto fail;
+	}
 
 	r = listen(s, 5);
-	if (r < 0)
+	if (r < 0) {
+		perror("listen");
 		goto fail;
+	}
 
 	return s;
 
@@ -430,6 +437,7 @@ int kvm_ipc__init(struct kvm *kvm)
 
 	epoll_fd = epoll_create(KVM_IPC_MAX_MSGS);
 	if (epoll_fd < 0) {
+		perror("epoll_create");
 		ret = epoll_fd;
 		goto err;
 	}
@@ -437,13 +445,14 @@ int kvm_ipc__init(struct kvm *kvm)
 	ev.events = EPOLLIN | EPOLLET;
 	ev.data.fd = sock;
 	if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, sock, &ev) < 0) {
-		pr_err("Failed starting IPC thread");
+		pr_err("Failed adding socket to epoll");
 		ret = -EFAULT;
 		goto err_epoll;
 	}
 
 	stop_fd = eventfd(0, 0);
 	if (stop_fd < 0) {
+		perror("eventfd");
 		ret = stop_fd;
 		goto err_epoll;
 	}
-- 
1.7.10.4


  reply	other threads:[~2013-02-06  8:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-06  8:19 [PATCH 1/6] kvm tools: Return error status in lkvm list Michael Ellerman
2013-02-06  8:19 ` Michael Ellerman [this message]
2013-02-06  8:19 ` [PATCH 3/6] kvm tools: Rework stdio/stdout handling to support redirection Michael Ellerman
2013-02-06  8:19 ` [PATCH 4/6] kvm tools: powerpc: Fix buglet in xics_init() handling of nrcpus Michael Ellerman
2013-02-06  8:19 ` [PATCH 5/6] kvm tools: powerpc: Add cpu info entry for POWER8 Michael Ellerman
2013-02-06  8:19 ` [PATCH 6/6] kvm tools: powerpc: Only emit TB freq if it's non-zero Michael Ellerman
2013-02-06 11:16 ` [PATCH 1/6] kvm tools: Return error status in lkvm list Pekka Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360138756-1991-2-git-send-email-michael@ellerman.id.au \
    --to=michael@ellerman.id.au \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®