public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Yang Bai <hamo.by@gmail.com>
To: penberg@kernel.org
Cc: kvm@vger.kernel.org, Yang Bai <hamo.by@gmail.com>
Subject: [PATCH 4/4] kvm tool: ensure kvm_ipc__register_handler success
Date: Fri, 10 Feb 2012 17:55:36 +0800	[thread overview]
Message-ID: <1328867736-4394-4-git-send-email-hamo.by@gmail.com> (raw)
In-Reply-To: <1328867736-4394-1-git-send-email-hamo.by@gmail.com>

By checking the return value from kvm_ipc__register_handler,
we can ensure that it succeeds.

Signed-off-by: Yang Bai <hamo.by@gmail.com>
---
 tools/kvm/kvm.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index f02d5df..99bcef4 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -396,10 +396,16 @@ struct kvm *kvm__init(const char *kvm_dev, const char *hugetlbfs_path, u64 ram_s
 		goto err_vm_fd;
 	}
 
-	kvm_ipc__register_handler(KVM_IPC_PID, kvm__pid);
+	ret = kvm_ipc__register_handler(KVM_IPC_PID, kvm__pid);
+	if (ret < 0) {
+		pr_err("Register ipc handler failed.");
+		goto err_ipc;
+	}
 
 	return kvm;
 
+err_ipc:
+	kvm_ipc__stop();
 err_vm_fd:
 	close(kvm->vm_fd);
 err_sys_fd:
-- 
1.7.8.3


  parent reply	other threads:[~2012-02-10  9:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-10  9:55 [PATCH 1/4] kvm tool: Stop init if check_extensions failed Yang Bai
2012-02-10  9:55 ` [PATCH 2/4] kvm tool: unite the error handle in kvm__init Yang Bai
2012-02-10  9:55 ` [PATCH 3/4] kvm tool: if kvm_ipc__start failed, return negative Yang Bai
2012-02-10  9:55 ` Yang Bai [this message]
2012-02-10 11:38 ` [PATCH 1/4] kvm tool: Stop init if check_extensions failed 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=1328867736-4394-4-git-send-email-hamo.by@gmail.com \
    --to=hamo.by@gmail.com \
    --cc=kvm@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